V8 Project
serialize.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_SERIALIZE_H_
6 #define V8_SERIALIZE_H_
7 
8 #include "src/compiler.h"
9 #include "src/hashmap.h"
10 #include "src/heap-profiler.h"
11 #include "src/isolate.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 // A TypeCode is used to distinguish different kinds of external reference.
18 // It is a single bit to make testing for types easy.
19 enum TypeCode {
20  UNCLASSIFIED, // One-of-a-kind references.
31 };
32 
35 
36 const int kReferenceIdBits = 16;
37 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1;
39 
41 
42 // ExternalReferenceTable is a helper class that defines the relationship
43 // between external references and their encodings. It is used to build
44 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder.
46  public:
47  static ExternalReferenceTable* instance(Isolate* isolate);
48 
50 
51  int size() const { return refs_.length(); }
52 
53  Address address(int i) { return refs_[i].address; }
54 
55  uint32_t code(int i) { return refs_[i].code; }
56 
57  const char* name(int i) { return refs_[i].name; }
58 
59  int max_id(int code) { return max_id_[code]; }
60 
61  private:
62  explicit ExternalReferenceTable(Isolate* isolate) : refs_(64) {
63  PopulateTable(isolate);
64  }
65 
69  const char* name;
70  };
71 
72  void PopulateTable(Isolate* isolate);
73 
74  // For a few types of references, we can get their address from their id.
75  void AddFromId(TypeCode type,
76  uint16_t id,
77  const char* name,
78  Isolate* isolate);
79 
80  // For other types of references, the caller will figure out the address.
81  void Add(Address address, TypeCode type, uint16_t id, const char* name);
82 
83  void Add(Address address, const char* name) {
85  }
86 
89 };
90 
91 
93  public:
94  explicit ExternalReferenceEncoder(Isolate* isolate);
95 
96  uint32_t Encode(Address key) const;
97 
98  const char* NameOfAddress(Address key) const;
99 
100  private:
102  static uint32_t Hash(Address key) {
103  return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2);
104  }
105 
106  int IndexOf(Address key) const;
107 
108  void Put(Address key, int index);
109 
111 };
112 
113 
115  public:
116  explicit ExternalReferenceDecoder(Isolate* isolate);
118 
119  Address Decode(uint32_t key) const {
120  if (key == 0) return NULL;
121  return *Lookup(key);
122  }
123 
124  private:
126 
127  Address* Lookup(uint32_t key) const {
128  int type = key >> kReferenceTypeShift;
129  DCHECK(kFirstTypeCode <= type && type < kTypeCodeCount);
130  int id = key & kReferenceIdMask;
131  return &encodings_[type][id];
132  }
133 
134  void Put(uint32_t key, Address value) {
135  *Lookup(key) = value;
136  }
137 
139 };
140 
141 
142 // The Serializer/Deserializer class is a common superclass for Serializer and
143 // Deserializer which is used to store common constants and methods used by
144 // both.
146  public:
147  static void Iterate(Isolate* isolate, ObjectVisitor* visitor);
148 
149  static int nop() { return kNop; }
150 
151  // No reservation for large object space necessary.
153  static const int kNumberOfSpaces = INVALID_SPACE;
154 
155  protected:
156  // Where the pointed-to object can be found:
157  enum Where {
158  kNewObject = 0, // Object is next in snapshot.
159  // 1-7 One per space.
160  kRootArray = 0x9, // Object is found in root array.
161  kPartialSnapshotCache = 0xa, // Object is in the cache.
162  kExternalReference = 0xb, // Pointer to an external reference.
163  kSkip = 0xc, // Skip n bytes.
164  kBuiltin = 0xd, // Builtin code object.
165  kAttachedReference = 0xe, // Object is described in an attached list.
166  kNop = 0xf, // Does nothing, used to pad.
167  kBackref = 0x10, // Object is described relative to end.
168  // 0x11-0x17 One per space.
169  kBackrefWithSkip = 0x18, // Object is described relative to end.
170  // 0x19-0x1f One per space.
171  // 0x20-0x3f Used by misc. tags below.
172  kPointedToMask = 0x3f
173  };
174 
175  // How to code the pointer to the object.
176  enum HowToCode {
177  kPlain = 0, // Straight pointer.
178  // What this means depends on the architecture:
179  kFromCode = 0x40, // A pointer inlined in code.
180  kHowToCodeMask = 0x40
181  };
182 
183  // For kRootArrayConstants
184  enum WithSkip {
187  kWithSkipMask = 0x40
188  };
189 
190  // Where to point within the object.
193  kInnerPointer = 0x80, // First insn in code object or payload of cell.
194  kWhereToPointMask = 0x80
195  };
196 
197  // Misc.
198  // Raw data to be copied from the snapshot. This byte code does not advance
199  // the current pointer, which is used for code objects, where we write the
200  // entire code in one memcpy, then fix up stuff with kSkip and other byte
201  // codes that overwrite data.
202  static const int kRawData = 0x20;
203  // Some common raw lengths: 0x21-0x3f. These autoadvance the current pointer.
204  // A tag emitted at strategic points in the snapshot to delineate sections.
205  // If the deserializer does not find these at the expected moments then it
206  // is an indication that the snapshot and the VM do not fit together.
207  // Examine the build process for architecture, version or configuration
208  // mismatches.
209  static const int kSynchronize = 0x70;
210  // Used for the source code of the natives, which is in the executable, but
211  // is referred to from external strings in the snapshot.
212  static const int kNativesStringResource = 0x71;
213  static const int kRepeat = 0x72;
214  static const int kConstantRepeat = 0x73;
215  // 0x73-0x7f Repeat last word (subtract 0x72 to get the count).
216  static const int kMaxRepeats = 0x7f - 0x72;
217  static int CodeForRepeats(int repeats) {
218  DCHECK(repeats >= 1 && repeats <= kMaxRepeats);
219  return 0x72 + repeats;
220  }
221  static int RepeatsForCode(int byte_code) {
222  DCHECK(byte_code >= kConstantRepeat && byte_code <= 0x7f);
223  return byte_code - 0x72;
224  }
225  static const int kRootArrayConstants = 0xa0;
226  // 0xa0-0xbf Things from the first 32 elements of the root array.
227  static const int kRootArrayNumberOfConstantEncodings = 0x20;
228  static int RootArrayConstantFromByteCode(int byte_code) {
229  return byte_code & 0x1f;
230  }
231 
232  static const int kAnyOldSpace = -1;
233 
234  // A bitmask for getting the space out of an instruction.
235  static const int kSpaceMask = 7;
237 };
238 
239 
240 // A Deserializer reads a snapshot and reconstructs the Object graph it defines.
242  public:
243  // Create a deserializer from a snapshot byte source.
244  explicit Deserializer(SnapshotByteSource* source);
245 
246  virtual ~Deserializer();
247 
248  // Deserialize the snapshot into an empty heap.
249  void Deserialize(Isolate* isolate);
250 
251  // Deserialize a single object and the objects reachable from it.
252  void DeserializePartial(Isolate* isolate, Object** root);
253 
254  void set_reservation(int space_number, int reservation) {
255  DCHECK(space_number >= 0);
256  DCHECK(space_number < kNumberOfSpaces);
257  reservations_[space_number] = reservation;
258  }
259 
261 
262  // Serialized user code reference certain objects that are provided in a list
263  // By calling this method, we assume that we are deserializing user code.
264  void SetAttachedObjects(Vector<Handle<Object> >* attached_objects) {
265  attached_objects_ = attached_objects;
266  }
267 
269 
270  private:
271  virtual void VisitPointers(Object** start, Object** end);
272 
273  virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
274  UNREACHABLE();
275  }
276 
277  // Allocation sites are present in the snapshot, and must be linked into
278  // a list at deserialization time.
280 
281  // Fills in some heap data in an area from start to end (non-inclusive). The
282  // space id is used for the write barrier. The object_address is the address
283  // of the object we are writing into, or NULL if we are not writing into an
284  // object, i.e. if we are writing a series of tagged values that are not on
285  // the heap.
286  void ReadChunk(
287  Object** start, Object** end, int space, Address object_address);
288  void ReadObject(int space_number, Object** write_back);
289  Address Allocate(int space_index, int size);
290 
291  // Special handling for serialized code like hooking up internalized strings.
294 
295  // This returns the address of an object that has been described in the
296  // snapshot as being offset bytes back in a particular space.
298  int offset = source_->GetInt();
299  if (space == LO_SPACE) return deserialized_large_objects_[offset];
301  offset <<= kObjectAlignmentBits;
302  return HeapObject::FromAddress(high_water_[space] - offset);
303  }
304 
305  // Cached current isolate.
307 
308  // Objects from the attached object descriptions in the serialized user code.
310 
311  SnapshotByteSource* source_;
312  // This is the address of the next object that will be allocated in each
313  // space. It is used to calculate the addresses of back-references.
315 
317  static const intptr_t kUninitializedReservation = -1;
318 
320 
322 
324 };
325 
326 
327 // Mapping objects to their location after deserialization.
328 // This is used during building, but not at runtime by V8.
330  public:
332  : no_allocation_(),
333  serialization_map_(new HashMap(HashMap::PointersMatch)) { }
334 
336  delete serialization_map_;
337  }
338 
339  bool IsMapped(HeapObject* obj) {
340  return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL;
341  }
342 
343  int MappedTo(HeapObject* obj) {
344  DCHECK(IsMapped(obj));
345  return static_cast<int>(reinterpret_cast<intptr_t>(
346  serialization_map_->Lookup(Key(obj), Hash(obj), false)->value));
347  }
348 
349  void AddMapping(HeapObject* obj, int to) {
350  DCHECK(!IsMapped(obj));
351  HashMap::Entry* entry =
352  serialization_map_->Lookup(Key(obj), Hash(obj), true);
353  entry->value = Value(to);
354  }
355 
356  private:
357  static uint32_t Hash(HeapObject* obj) {
358  return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address()));
359  }
360 
361  static void* Key(HeapObject* obj) {
362  return reinterpret_cast<void*>(obj->address());
363  }
364 
365  static void* Value(int v) {
366  return reinterpret_cast<void*>(v);
367  }
368 
372 };
373 
374 
375 class CodeAddressMap;
376 
377 // There can be only one serializer per V8 process.
379  public:
381  ~Serializer();
382  void VisitPointers(Object** start, Object** end);
383  // You can call this after serialization to find out how much space was used
384  // in each space.
387  return fullness_[space];
388  }
389 
390  Isolate* isolate() const { return isolate_; }
391 
393  void PutRoot(int index,
394  HeapObject* object,
395  HowToCode how,
396  WhereToPoint where,
397  int skip);
398 
399  protected:
400  static const int kInvalidRootIndex = -1;
401 
402  int RootIndex(HeapObject* heap_object, HowToCode from);
404  void set_root_index_wave_front(intptr_t value) {
405  DCHECK(value >= root_index_wave_front_);
406  root_index_wave_front_ = value;
407  }
408 
410  public:
412  Object* o,
413  SnapshotByteSink* sink,
414  HowToCode how_to_code,
415  WhereToPoint where_to_point)
416  : serializer_(serializer),
417  object_(HeapObject::cast(o)),
418  sink_(sink),
419  reference_representation_(how_to_code + where_to_point),
421  code_object_(o->IsCode()),
423  void Serialize();
424  void VisitPointers(Object** start, Object** end);
425  void VisitEmbeddedPointer(RelocInfo* target);
427  void VisitExternalReference(RelocInfo* rinfo);
428  void VisitCodeTarget(RelocInfo* target);
429  void VisitCodeEntry(Address entry_address);
430  void VisitCell(RelocInfo* rinfo);
431  void VisitRuntimeEntry(RelocInfo* reloc);
432  // Used for seralizing the external strings that hold the natives source.
435  // We can't serialize a heap with external two byte strings.
438  UNREACHABLE();
439  }
440 
441  private:
443  // This function outputs or skips the raw data between the last pointer and
444  // up to the current position. It optionally can just return the number of
445  // bytes to skip instead of performing a skip instruction, in case the skip
446  // can be merged into the next instruction.
447  int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn);
448 
456  };
457 
458  virtual void SerializeObject(Object* o,
459  HowToCode how_to_code,
460  WhereToPoint where_to_point,
461  int skip) = 0;
463  HowToCode how_to_code,
464  WhereToPoint where_to_point,
465  int skip);
467  // This will return the space for an object.
468  static int SpaceOfObject(HeapObject* object);
469  int AllocateLargeObject(int size);
470  int Allocate(int space, int size);
472  return external_reference_encoder_->Encode(addr);
473  }
474 
475  int SpaceAreaSize(int space);
476 
477  // Some roots should not be serialized, because their actual value depends on
478  // absolute addresses and they are reset after deserialization, anyway.
479  bool ShouldBeSkipped(Object** current);
480 
482  // Keep track of the fullness of each space in order to generate
483  // relative addresses for back references.
487 
490  void Pad();
491 
492  friend class ObjectSerializer;
493  friend class Deserializer;
494 
495  // We may not need the code address map for logging for every instance
496  // of the serializer. Initialize it on demand.
498 
499  private:
501  // We map serialized large objects to indexes for back-referencing.
504 };
505 
506 
508  public:
510  Serializer* startup_snapshot_serializer,
511  SnapshotByteSink* sink)
512  : Serializer(isolate, sink),
513  startup_serializer_(startup_snapshot_serializer) {
516  }
517 
518  // Serialize the objects reachable from a single object pointer.
519  void Serialize(Object** o);
520  virtual void SerializeObject(Object* o,
521  HowToCode how_to_code,
522  WhereToPoint where_to_point,
523  int skip);
524 
525  private:
528  // Scripts should be referred only through shared function infos. We can't
529  // allow them to be part of the partial snapshot because they contain a
530  // unique ID, and deserializing several partial snapshots containing script
531  // would cause dupes.
532  DCHECK(!o->IsScript());
533  return o->IsName() || o->IsSharedFunctionInfo() ||
534  o->IsHeapNumber() || o->IsCode() ||
535  o->IsScopeInfo() ||
536  o->map() ==
537  startup_serializer_->isolate()->heap()->fixed_cow_array_map();
538  }
539 
540 
543 };
544 
545 
547  public:
549  : Serializer(isolate, sink) {
550  // Clear the cache of objects used by the partial snapshot. After the
551  // strong roots have been serialized we can create a partial snapshot
552  // which will repopulate the cache with objects needed by that partial
553  // snapshot.
554  isolate->set_serialize_partial_snapshot_cache_length(0);
556  }
557  // Serialize the current state of the heap. The order is:
558  // 1) Strong references.
559  // 2) Partial snapshot cache.
560  // 3) Weak references (e.g. the string table).
561  virtual void SerializeStrongReferences();
562  virtual void SerializeObject(Object* o,
563  HowToCode how_to_code,
564  WhereToPoint where_to_point,
565  int skip);
567  void Serialize() {
570  Pad();
571  }
572 
573  private:
575 };
576 
577 
578 class CodeSerializer : public Serializer {
579  public:
583 
585  ScriptData* data,
587 
588  static const int kSourceObjectIndex = 0;
589  static const int kCodeStubsBaseIndex = 1;
590 
592  DCHECK(!AllowHeapAllocation::IsAllowed());
593  return source_;
594  }
595 
597 
598  private:
600  Code* main_code)
601  : Serializer(isolate, sink), source_(source), main_code_(main_code) {
604  }
605 
606  virtual void SerializeObject(Object* o, HowToCode how_to_code,
607  WhereToPoint where_to_point, int skip);
608 
609  void SerializeBuiltin(Code* builtin, HowToCode how_to_code,
610  WhereToPoint where_to_point);
611  void SerializeCodeStub(Code* stub, HowToCode how_to_code,
612  WhereToPoint where_to_point);
613  void SerializeSourceObject(HowToCode how_to_code,
614  WhereToPoint where_to_point);
615  void SerializeHeapObject(HeapObject* heap_object, HowToCode how_to_code,
616  WhereToPoint where_to_point);
617  int AddCodeStubKey(uint32_t stub_key);
618 
624 };
625 
626 
627 // Wrapper around ScriptData to provide code-serializer-specific functionality.
629  public:
630  // Used by when consuming.
631  explicit SerializedCodeData(ScriptData* data, String* source)
634  CHECK(IsSane(source));
635  }
636 
637  // Used when producing.
639 
641  if (owns_script_data_) delete script_data_;
642  }
643 
644  // Return ScriptData object and relinquish ownership over it to the caller.
646  ScriptData* result = script_data_;
647  script_data_ = NULL;
649  owns_script_data_ = false;
650  return result;
651  }
652 
654  return Vector<const uint32_t>(
655  reinterpret_cast<const uint32_t*>(script_data_->data() + kHeaderSize),
657  }
658 
659  const byte* Payload() const {
660  int code_stubs_size = GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size;
661  return script_data_->data() + kHeaderSize + code_stubs_size;
662  }
663 
664  int PayloadLength() const {
665  int payload_length = GetHeaderValue(kPayloadLengthOffset);
667  Payload() + payload_length);
668  return payload_length;
669  }
670 
671  int GetReservation(int space) const {
673  }
674 
675  private:
676  void SetHeaderValue(int offset, int value) {
677  reinterpret_cast<int*>(const_cast<byte*>(script_data_->data()))[offset] =
678  value;
679  }
680 
681  int GetHeaderValue(int offset) const {
682  return reinterpret_cast<const int*>(script_data_->data())[offset];
683  }
684 
685  bool IsSane(String* source);
686 
687  int CheckSum(String* source);
688 
689  // The data header consists of int-sized entries:
690  // [0] version hash
691  // [1] number of code stub keys
692  // [2] payload length
693  // [3..9] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE.
694  static const int kCheckSumOffset = 0;
695  static const int kNumCodeStubKeysOffset = 1;
696  static const int kPayloadLengthOffset = 2;
697  static const int kReservationsOffset = 3;
698 
699  static const int kHeaderEntries =
701  static const int kHeaderSize = kHeaderEntries * kIntSize;
702 
703  // Following the header, we store, in sequential order
704  // - code stub keys
705  // - serialization payload
706 
709 };
710 } } // namespace v8::internal
711 
712 #endif // V8_SERIALIZE_H_
An ExternalOneByteStringResource is a wrapper around an one-byte string buffer that resides outside V...
Definition: v8.h:1918
An ExternalStringResource is a wrapper around a two-byte string buffer that resides outside V8's heap...
Definition: v8.h:1885
CodeSerializer(Isolate *isolate, SnapshotByteSink *sink, String *source, Code *main_code)
Definition: serialize.h:599
static const int kCodeStubsBaseIndex
Definition: serialize.h:589
List< uint32_t > * stub_keys()
Definition: serialize.h:596
static ScriptData * Serialize(Isolate *isolate, Handle< SharedFunctionInfo > info, Handle< String > source)
Definition: serialize.cc:1836
void SerializeHeapObject(HeapObject *heap_object, HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.cc:1939
void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.cc:2014
List< uint32_t > stub_keys_
Definition: serialize.h:622
void SerializeBuiltin(Code *builtin, HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.cc:1962
int AddCodeStubKey(uint32_t stub_key)
Definition: serialize.cc:2002
DisallowHeapAllocation no_gc_
Definition: serialize.h:619
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1868
static Handle< SharedFunctionInfo > Deserialize(Isolate *isolate, ScriptData *data, Handle< String > source)
Definition: serialize.cc:2024
void SerializeCodeStub(Code *stub, HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.cc:1981
DISALLOW_COPY_AND_ASSIGN(CodeSerializer)
static const int kSourceObjectIndex
Definition: serialize.h:588
ExternalReferenceDecoder * external_reference_decoder_
Definition: serialize.h:319
int reservations_[kNumberOfSpaces]
Definition: serialize.h:316
void ReadChunk(Object **start, Object **end, int space, Address object_address)
Definition: serialize.cc:837
Address Allocate(int space_index, int size)
Definition: serialize.cc:820
Vector< Handle< Object > > * attached_objects_
Definition: serialize.h:309
List< HeapObject * > deserialized_large_objects_
Definition: serialize.h:321
DISALLOW_COPY_AND_ASSIGN(Deserializer)
HeapObject * GetAddressFromEnd(int space)
Definition: serialize.h:297
void DeserializePartial(Isolate *isolate, Object **root)
Definition: serialize.cc:661
static const intptr_t kUninitializedReservation
Definition: serialize.h:317
SnapshotByteSource * source_
Definition: serialize.h:311
void Deserialize(Isolate *isolate)
Definition: serialize.cc:616
Deserializer(SnapshotByteSource *source)
Definition: serialize.cc:595
Object * ProcessBackRefInSerializedCode(Object *obj)
Definition: serialize.cc:767
virtual void VisitRuntimeEntry(RelocInfo *rinfo)
Definition: serialize.h:273
virtual void VisitPointers(Object **start, Object **end)
Definition: serialize.cc:700
void RelinkAllocationSite(AllocationSite *site)
Definition: serialize.cc:707
HeapObject * ProcessNewObjectFromSerializedCode(HeapObject *obj)
Definition: serialize.cc:749
void SetAttachedObjects(Vector< Handle< Object > > *attached_objects)
Definition: serialize.h:264
Address high_water_[kNumberOfPreallocatedSpaces]
Definition: serialize.h:314
void set_reservation(int space_number, int reservation)
Definition: serialize.h:254
void ReadObject(int space_number, Object **write_back)
Definition: serialize.cc:780
Address Decode(uint32_t key) const
Definition: serialize.h:119
Address * Lookup(uint32_t key) const
Definition: serialize.h:127
ExternalReferenceDecoder(Isolate *isolate)
Definition: serialize.cc:461
void Put(uint32_t key, Address value)
Definition: serialize.h:134
static uint32_t Hash(Address key)
Definition: serialize.h:102
int IndexOf(Address key) const
Definition: serialize.cc:445
void Put(Address key, int index)
Definition: serialize.cc:455
uint32_t Encode(Address key) const
Definition: serialize.cc:430
ExternalReferenceEncoder(Isolate *isolate)
Definition: serialize.cc:419
const char * NameOfAddress(Address key) const
Definition: serialize.cc:438
void Add(Address address, const char *name)
Definition: serialize.h:83
void AddFromId(TypeCode type, uint16_t id, const char *name, Isolate *isolate)
Definition: serialize.cc:59
List< ExternalReferenceEntry > refs_
Definition: serialize.h:87
static ExternalReferenceTable * instance(Isolate *isolate)
Definition: serialize.cc:48
void Add(Address address, TypeCode type, uint16_t id, const char *name)
Definition: serialize.cc:94
ExternalReferenceTable(Isolate *isolate)
Definition: serialize.h:62
uint16_t max_id_[kTypeCodeCount]
Definition: serialize.h:88
void PopulateTable(Isolate *isolate)
Definition: serialize.cc:111
static HeapObject * FromAddress(Address address)
Definition: objects-inl.h:1464
@ kStrongRootListLength
Definition: heap.h:1073
int PartialSnapshotCacheIndex(HeapObject *o)
Definition: serialize.cc:1313
PartialSerializer(Isolate *isolate, Serializer *startup_snapshot_serializer, SnapshotByteSink *sink)
Definition: serialize.h:509
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1456
bool ShouldBeInThePartialSnapshotCache(HeapObject *o)
Definition: serialize.h:527
DISALLOW_COPY_AND_ASSIGN(PartialSerializer)
const byte * data() const
Definition: compiler.h:40
int length() const
Definition: compiler.h:41
static uint32_t Hash(HeapObject *obj)
Definition: serialize.h:357
DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper)
static void * Key(HeapObject *obj)
Definition: serialize.h:361
DisallowHeapAllocation no_allocation_
Definition: serialize.h:369
void AddMapping(HeapObject *obj, int to)
Definition: serialize.h:349
static const int kHeaderEntries
Definition: serialize.h:699
SerializedCodeData(ScriptData *data, String *source)
Definition: serialize.h:631
static const int kPayloadLengthOffset
Definition: serialize.h:696
void SetHeaderValue(int offset, int value)
Definition: serialize.h:676
static const int kReservationsOffset
Definition: serialize.h:697
int GetHeaderValue(int offset) const
Definition: serialize.h:681
static const int kCheckSumOffset
Definition: serialize.h:694
Vector< const uint32_t > CodeStubKeys() const
Definition: serialize.h:653
const byte * Payload() const
Definition: serialize.h:659
int CheckSum(String *source)
Definition: serialize.cc:2109
int GetReservation(int space) const
Definition: serialize.h:671
static const int kNumCodeStubKeysOffset
Definition: serialize.h:695
static const int kHeaderSize
Definition: serialize.h:701
bool IsSane(String *source)
Definition: serialize.cc:2103
STATIC_ASSERT(kNumberOfSpaces<=kSpaceMask+1)
static int RootArrayConstantFromByteCode(int byte_code)
Definition: serialize.h:228
static int RepeatsForCode(int byte_code)
Definition: serialize.h:221
static const int kNativesStringResource
Definition: serialize.h:212
static const int kRootArrayNumberOfConstantEncodings
Definition: serialize.h:227
static void Iterate(Isolate *isolate, ObjectVisitor *visitor)
Definition: serialize.cc:1293
static int CodeForRepeats(int repeats)
Definition: serialize.h:217
static const int kRootArrayConstants
Definition: serialize.h:225
static const int kNumberOfPreallocatedSpaces
Definition: serialize.h:152
int OutputRawData(Address up_to, ReturnSkip return_skip=kIgnoringReturn)
Definition: serialize.cc:1726
ObjectSerializer(Serializer *serializer, Object *o, SnapshotByteSink *sink, HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.h:411
void VisitEmbeddedPointer(RelocInfo *target)
Definition: serialize.cc:1601
void VisitPointers(Object **start, Object **end)
Definition: serialize.cc:1559
void VisitRuntimeEntry(RelocInfo *reloc)
Definition: serialize.cc:1637
void VisitCodeEntry(Address entry_address)
Definition: serialize.cc:1661
void VisitExternalOneByteString(v8::String::ExternalOneByteStringResource **resource)
Definition: serialize.cc:1680
void VisitExternalTwoByteString(v8::String::ExternalStringResource **resource)
Definition: serialize.h:436
void VisitCodeTarget(RelocInfo *target)
Definition: serialize.cc:1649
void SerializeReferenceToPreviousObject(HeapObject *heap_object, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1353
ExternalReferenceEncoder * external_reference_encoder_
Definition: serialize.h:486
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)=0
int fullness_[kNumberOfSpaces]
Definition: serialize.h:484
int RootIndex(HeapObject *heap_object, HowToCode from)
Definition: serialize.cc:1336
SerializationAddressMapper * address_mapper()
Definition: serialize.h:392
intptr_t root_index_wave_front_
Definition: serialize.h:489
int Allocate(int space, int size)
Definition: serialize.cc:1804
SnapshotByteSink * sink_
Definition: serialize.h:485
void VisitPointers(Object **start, Object **end)
Definition: serialize.cc:1262
static const int kInvalidRootIndex
Definition: serialize.h:400
CodeAddressMap * code_address_map_
Definition: serialize.h:500
int AllocateLargeObject(int size)
Definition: serialize.cc:1798
static int SpaceOfObject(HeapObject *object)
Definition: serialize.cc:1785
int CurrentAllocationAddress(int space) const
Definition: serialize.h:385
Serializer(Isolate *isolate, SnapshotByteSink *sink)
Definition: serialize.cc:1214
int EncodeExternalReference(Address addr)
Definition: serialize.h:471
Isolate * isolate() const
Definition: serialize.h:390
DISALLOW_COPY_AND_ASSIGN(Serializer)
void set_root_index_wave_front(intptr_t value)
Definition: serialize.h:404
SerializationAddressMapper address_mapper_
Definition: serialize.h:488
int SpaceAreaSize(int space)
Definition: serialize.cc:1812
bool ShouldBeSkipped(Object **current)
Definition: serialize.cc:1254
intptr_t root_index_wave_front()
Definition: serialize.h:403
void PutRoot(int index, HeapObject *object, HowToCode how, WhereToPoint where, int skip)
Definition: serialize.cc:1428
Sink to write snapshot files to.
DISALLOW_COPY_AND_ASSIGN(StartupSerializer)
virtual void SerializeStrongReferences()
Definition: serialize.cc:1233
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1380
StartupSerializer(Isolate *isolate, SnapshotByteSink *sink)
Definition: serialize.h:548
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:114
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi space(in MBytes)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define UNREACHABLE()
Definition: logging.h:30
#define CHECK(condition)
Definition: logging.h:36
#define DCHECK(condition)
Definition: logging.h:205
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
unsigned short uint16_t
Definition: unicode.cc:23
int int32_t
Definition: unicode.cc:24
const int kReferenceTypeShift
Definition: serialize.h:38
const int kTypeCodeCount
Definition: serialize.h:33
const int kDeoptTableSerializeEntryCount
Definition: serialize.h:40
const int kFirstTypeCode
Definition: serialize.h:34
const int kInt32Size
Definition: globals.h:125
byte * Address
Definition: globals.h:101
const int kReferenceIdMask
Definition: serialize.h:37
const int kIntSize
Definition: globals.h:124
@ INVALID_SPACE
Definition: globals.h:367
const int kReferenceIdBits
Definition: serialize.h:36
const int kObjectAlignmentBits
Definition: globals.h:225
@ RUNTIME_FUNCTION
Definition: serialize.h:23
@ LAZY_DEOPTIMIZATION
Definition: serialize.h:30
@ STUB_CACHE_TABLE
Definition: serialize.h:28
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20