v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
serialize.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_SERIALIZE_H_
29 #define V8_SERIALIZE_H_
30 
31 #include "hashmap.h"
32 
33 namespace v8 {
34 namespace internal {
35 
36 // A TypeCode is used to distinguish different kinds of external reference.
37 // It is a single bit to make testing for types easy.
38 enum TypeCode {
39  UNCLASSIFIED, // One-of-a-kind references.
52 };
53 
56 
57 const int kReferenceIdBits = 16;
58 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1;
60 const int kDebugRegisterBits = 4;
62 
64 
65 // ExternalReferenceTable is a helper class that defines the relationship
66 // between external references and their encodings. It is used to build
67 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder.
69  public:
70  static ExternalReferenceTable* instance(Isolate* isolate);
71 
73 
74  int size() const { return refs_.length(); }
75 
76  Address address(int i) { return refs_[i].address; }
77 
78  uint32_t code(int i) { return refs_[i].code; }
79 
80  const char* name(int i) { return refs_[i].name; }
81 
82  int max_id(int code) { return max_id_[code]; }
83 
84  private:
85  explicit ExternalReferenceTable(Isolate* isolate) : refs_(64) {
86  PopulateTable(isolate);
87  }
88 
89  struct ExternalReferenceEntry {
91  uint32_t code;
92  const char* name;
93  };
94 
95  void PopulateTable(Isolate* isolate);
96 
97  // For a few types of references, we can get their address from their id.
98  void AddFromId(TypeCode type,
99  uint16_t id,
100  const char* name,
101  Isolate* isolate);
102 
103  // For other types of references, the caller will figure out the address.
104  void Add(Address address, TypeCode type, uint16_t id, const char* name);
105 
106  List<ExternalReferenceEntry> refs_;
107  int max_id_[kTypeCodeCount];
108 };
109 
110 
112  public:
113  explicit ExternalReferenceEncoder(Isolate* isolate);
114 
115  uint32_t Encode(Address key) const;
116 
117  const char* NameOfAddress(Address key) const;
118 
119  private:
120  HashMap encodings_;
121  static uint32_t Hash(Address key) {
122  return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2);
123  }
124 
125  int IndexOf(Address key) const;
126 
127  static bool Match(void* key1, void* key2) { return key1 == key2; }
128 
129  void Put(Address key, int index);
130 
131  Isolate* isolate_;
132 };
133 
134 
136  public:
137  explicit ExternalReferenceDecoder(Isolate* isolate);
139 
140  Address Decode(uint32_t key) const {
141  if (key == 0) return NULL;
142  return *Lookup(key);
143  }
144 
145  private:
146  Address** encodings_;
147 
148  Address* Lookup(uint32_t key) const {
149  int type = key >> kReferenceTypeShift;
150  ASSERT(kFirstTypeCode <= type && type < kTypeCodeCount);
151  int id = key & kReferenceIdMask;
152  return &encodings_[type][id];
153  }
154 
155  void Put(uint32_t key, Address value) {
156  *Lookup(key) = value;
157  }
158 
159  Isolate* isolate_;
160 };
161 
162 
164  public:
165  SnapshotByteSource(const byte* array, int length)
166  : data_(array), length_(length), position_(0) { }
167 
168  bool HasMore() { return position_ < length_; }
169 
170  int Get() {
171  ASSERT(position_ < length_);
172  return data_[position_++];
173  }
174 
176 #if defined(V8_HOST_CAN_READ_UNALIGNED) && __BYTE_ORDER == __LITTLE_ENDIAN
177  int32_t answer;
178  ASSERT(position_ + sizeof(answer) <= length_ + 0u);
179  answer = *reinterpret_cast<const int32_t*>(data_ + position_);
180 #else
181  int32_t answer = data_[position_];
182  answer |= data_[position_ + 1] << 8;
183  answer |= data_[position_ + 2] << 16;
184  answer |= data_[position_ + 3] << 24;
185 #endif
186  return answer;
187  }
188 
189  void Advance(int by) { position_ += by; }
190 
191  inline void CopyRaw(byte* to, int number_of_bytes);
192 
193  inline int GetInt();
194 
195  bool AtEOF();
196 
197  int position() { return position_; }
198 
199  private:
200  const byte* data_;
201  int length_;
202  int position_;
203 };
204 
205 
206 // The Serializer/Deserializer class is a common superclass for Serializer and
207 // Deserializer which is used to store common constants and methods used by
208 // both.
209 class SerializerDeserializer: public ObjectVisitor {
210  public:
211  static void Iterate(Isolate* isolate, ObjectVisitor* visitor);
212 
213  static int nop() { return kNop; }
214 
215  protected:
216  // Where the pointed-to object can be found:
217  enum Where {
218  kNewObject = 0, // Object is next in snapshot.
219  // 1-6 One per space.
220  kRootArray = 0x9, // Object is found in root array.
221  kPartialSnapshotCache = 0xa, // Object is in the cache.
222  kExternalReference = 0xb, // Pointer to an external reference.
223  kSkip = 0xc, // Skip n bytes.
224  kNop = 0xd, // Does nothing, used to pad.
225  // 0xe-0xf Free.
226  kBackref = 0x10, // Object is described relative to end.
227  // 0x11-0x16 One per space.
228  kBackrefWithSkip = 0x18, // Object is described relative to end.
229  // 0x19-0x1e One per space.
230  // 0x20-0x3f Used by misc. tags below.
232  };
233 
234  // How to code the pointer to the object.
235  enum HowToCode {
236  kPlain = 0, // Straight pointer.
237  // What this means depends on the architecture:
238  kFromCode = 0x40, // A pointer inlined in code.
240  };
241 
242  // For kRootArrayConstants
243  enum WithSkip {
247  };
248 
249  // Where to point within the object.
252  kInnerPointer = 0x80, // First insn in code object or payload of cell.
254  };
255 
256  // Misc.
257  // Raw data to be copied from the snapshot. This byte code does not advance
258  // the current pointer, which is used for code objects, where we write the
259  // entire code in one memcpy, then fix up stuff with kSkip and other byte
260  // codes that overwrite data.
261  static const int kRawData = 0x20;
262  // Some common raw lengths: 0x21-0x3f. These autoadvance the current pointer.
263  // A tag emitted at strategic points in the snapshot to delineate sections.
264  // If the deserializer does not find these at the expected moments then it
265  // is an indication that the snapshot and the VM do not fit together.
266  // Examine the build process for architecture, version or configuration
267  // mismatches.
268  static const int kSynchronize = 0x70;
269  // Used for the source code of the natives, which is in the executable, but
270  // is referred to from external strings in the snapshot.
271  static const int kNativesStringResource = 0x71;
272  static const int kRepeat = 0x72;
273  static const int kConstantRepeat = 0x73;
274  // 0x73-0x7f Repeat last word (subtract 0x72 to get the count).
275  static const int kMaxRepeats = 0x7f - 0x72;
276  static int CodeForRepeats(int repeats) {
277  ASSERT(repeats >= 1 && repeats <= kMaxRepeats);
278  return 0x72 + repeats;
279  }
280  static int RepeatsForCode(int byte_code) {
281  ASSERT(byte_code >= kConstantRepeat && byte_code <= 0x7f);
282  return byte_code - 0x72;
283  }
284  static const int kRootArrayConstants = 0xa0;
285  // 0xa0-0xbf Things from the first 32 elements of the root array.
286  static const int kRootArrayNumberOfConstantEncodings = 0x20;
287  static int RootArrayConstantFromByteCode(int byte_code) {
288  return byte_code & 0x1f;
289  }
290 
291  static const int kNumberOfSpaces = LO_SPACE;
292  static const int kAnyOldSpace = -1;
293 
294  // A bitmask for getting the space out of an instruction.
295  static const int kSpaceMask = 7;
296 };
297 
298 
300  // This way of variable-length encoding integers does not suffer from branch
301  // mispredictions.
302  uint32_t answer = GetUnalignedInt();
303  int bytes = answer & 3;
304  Advance(bytes);
305  uint32_t mask = 0xffffffffu;
306  mask >>= 32 - (bytes << 3);
307  answer &= mask;
308  answer >>= 2;
309  return answer;
310 }
311 
312 
313 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
314  OS::MemCopy(to, data_ + position_, number_of_bytes);
315  position_ += number_of_bytes;
316 }
317 
318 
319 // A Deserializer reads a snapshot and reconstructs the Object graph it defines.
321  public:
322  // Create a deserializer from a snapshot byte source.
323  explicit Deserializer(SnapshotByteSource* source);
324 
325  virtual ~Deserializer();
326 
327  // Deserialize the snapshot into an empty heap.
328  void Deserialize(Isolate* isolate);
329 
330  // Deserialize a single object and the objects reachable from it.
331  void DeserializePartial(Isolate* isolate, Object** root);
332 
333  void set_reservation(int space_number, int reservation) {
334  ASSERT(space_number >= 0);
335  ASSERT(space_number <= LAST_SPACE);
336  reservations_[space_number] = reservation;
337  }
338 
339  private:
340  virtual void VisitPointers(Object** start, Object** end);
341 
342  virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
343  UNREACHABLE();
344  }
345 
346  // Allocation sites are present in the snapshot, and must be linked into
347  // a list at deserialization time.
348  void RelinkAllocationSite(AllocationSite* site);
349 
350  // Fills in some heap data in an area from start to end (non-inclusive). The
351  // space id is used for the write barrier. The object_address is the address
352  // of the object we are writing into, or NULL if we are not writing into an
353  // object, i.e. if we are writing a series of tagged values that are not on
354  // the heap.
355  void ReadChunk(
356  Object** start, Object** end, int space, Address object_address);
357  void ReadObject(int space_number, Object** write_back);
358 
359  // This routine both allocates a new object, and also keeps
360  // track of where objects have been allocated so that we can
361  // fix back references when deserializing.
362  Address Allocate(int space_index, int size) {
363  Address address = high_water_[space_index];
364  high_water_[space_index] = address + size;
365  HeapProfiler* profiler = isolate_->heap_profiler();
366  if (profiler->is_tracking_allocations()) {
367  profiler->AllocationEvent(address, size);
368  }
369  return address;
370  }
371 
372  // This returns the address of an object that has been described in the
373  // snapshot as being offset bytes back in a particular space.
374  HeapObject* GetAddressFromEnd(int space) {
375  int offset = source_->GetInt();
376  offset <<= kObjectAlignmentBits;
377  return HeapObject::FromAddress(high_water_[space] - offset);
378  }
379 
380  void FlushICacheForNewCodeObjects();
381 
382  // Cached current isolate.
383  Isolate* isolate_;
384 
385  SnapshotByteSource* source_;
386  // This is the address of the next object that will be allocated in each
387  // space. It is used to calculate the addresses of back-references.
388  Address high_water_[LAST_SPACE + 1];
389 
390  int reservations_[LAST_SPACE + 1];
391  static const intptr_t kUninitializedReservation = -1;
392 
393  ExternalReferenceDecoder* external_reference_decoder_;
394 
395  DISALLOW_COPY_AND_ASSIGN(Deserializer);
396 };
397 
398 
400  public:
401  virtual ~SnapshotByteSink() { }
402  virtual void Put(int byte, const char* description) = 0;
403  virtual void PutSection(int byte, const char* description) {
404  Put(byte, description);
405  }
406  void PutInt(uintptr_t integer, const char* description);
407  virtual int Position() = 0;
408 };
409 
410 
411 // Mapping objects to their location after deserialization.
412 // This is used during building, but not at runtime by V8.
414  public:
416  : no_allocation_(),
417  serialization_map_(new HashMap(&SerializationMatchFun)) { }
418 
420  delete serialization_map_;
421  }
422 
424  return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL;
425  }
426 
428  ASSERT(IsMapped(obj));
429  return static_cast<int>(reinterpret_cast<intptr_t>(
430  serialization_map_->Lookup(Key(obj), Hash(obj), false)->value));
431  }
432 
433  void AddMapping(HeapObject* obj, int to) {
434  ASSERT(!IsMapped(obj));
435  HashMap::Entry* entry =
436  serialization_map_->Lookup(Key(obj), Hash(obj), true);
437  entry->value = Value(to);
438  }
439 
440  private:
441  static bool SerializationMatchFun(void* key1, void* key2) {
442  return key1 == key2;
443  }
444 
445  static uint32_t Hash(HeapObject* obj) {
446  return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address()));
447  }
448 
449  static void* Key(HeapObject* obj) {
450  return reinterpret_cast<void*>(obj->address());
451  }
452 
453  static void* Value(int v) {
454  return reinterpret_cast<void*>(v);
455  }
456 
457  DisallowHeapAllocation no_allocation_;
458  HashMap* serialization_map_;
459  DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper);
460 };
461 
462 
463 class CodeAddressMap;
464 
465 // There can be only one serializer per V8 process.
467  public:
468  Serializer(Isolate* isolate, SnapshotByteSink* sink);
469  ~Serializer();
470  void VisitPointers(Object** start, Object** end);
471  // You can call this after serialization to find out how much space was used
472  // in each space.
473  int CurrentAllocationAddress(int space) {
474  ASSERT(space < kNumberOfSpaces);
475  return fullness_[space];
476  }
477 
478  Isolate* isolate() const { return isolate_; }
479  static void Enable(Isolate* isolate);
480  static void Disable();
481 
482  // Call this when you have made use of the fact that there is no serialization
483  // going on.
484  static void TooLateToEnableNow() { too_late_to_enable_now_ = true; }
485  static bool enabled() { return serialization_enabled_; }
487  void PutRoot(int index,
488  HeapObject* object,
489  HowToCode how,
490  WhereToPoint where,
491  int skip);
492 
493  protected:
494  static const int kInvalidRootIndex = -1;
495 
496  int RootIndex(HeapObject* heap_object, HowToCode from);
497  virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) = 0;
499  void set_root_index_wave_front(intptr_t value) {
500  ASSERT(value >= root_index_wave_front_);
501  root_index_wave_front_ = value;
502  }
503 
504  class ObjectSerializer : public ObjectVisitor {
505  public:
507  Object* o,
508  SnapshotByteSink* sink,
509  HowToCode how_to_code,
510  WhereToPoint where_to_point)
511  : serializer_(serializer),
512  object_(HeapObject::cast(o)),
513  sink_(sink),
514  reference_representation_(how_to_code + where_to_point),
515  bytes_processed_so_far_(0),
516  code_object_(o->IsCode()),
517  code_has_been_output_(false) { }
518  void Serialize();
519  void VisitPointers(Object** start, Object** end);
520  void VisitEmbeddedPointer(RelocInfo* target);
522  void VisitExternalReference(RelocInfo* rinfo);
523  void VisitCodeTarget(RelocInfo* target);
524  void VisitCodeEntry(Address entry_address);
525  void VisitCell(RelocInfo* rinfo);
526  void VisitRuntimeEntry(RelocInfo* reloc);
527  // Used for seralizing the external strings that hold the natives source.
530  // We can't serialize a heap with external two byte strings.
533  UNREACHABLE();
534  }
535 
536  private:
537  enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn };
538  // This function outputs or skips the raw data between the last pointer and
539  // up to the current position. It optionally can just return the number of
540  // bytes to skip instead of performing a skip instruction, in case the skip
541  // can be merged into the next instruction.
542  int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn);
543 
544  Serializer* serializer_;
545  HeapObject* object_;
546  SnapshotByteSink* sink_;
547  int reference_representation_;
548  int bytes_processed_so_far_;
549  bool code_object_;
550  bool code_has_been_output_;
551  };
552 
553  virtual void SerializeObject(Object* o,
554  HowToCode how_to_code,
555  WhereToPoint where_to_point,
556  int skip) = 0;
558  int space,
559  int address,
560  HowToCode how_to_code,
561  WhereToPoint where_to_point,
562  int skip);
563  void InitializeAllocators();
564  // This will return the space for an object.
565  static int SpaceOfObject(HeapObject* object);
566  int Allocate(int space, int size);
568  return external_reference_encoder_->Encode(addr);
569  }
570 
571  int SpaceAreaSize(int space);
572 
573  // Some roots should not be serialized, because their actual value depends on
574  // absolute addresses and they are reset after deserialization, anyway.
575  bool ShouldBeSkipped(Object** current);
576 
578  // Keep track of the fullness of each space in order to generate
579  // relative addresses for back references.
584  // Did we already make use of the fact that serialization was not enabled?
588  void Pad();
589 
590  friend class ObjectSerializer;
591  friend class Deserializer;
592 
593  private:
594  static CodeAddressMap* code_address_map_;
596 };
597 
598 
600  public:
602  Serializer* startup_snapshot_serializer,
603  SnapshotByteSink* sink)
604  : Serializer(isolate, sink),
605  startup_serializer_(startup_snapshot_serializer) {
607  }
608 
609  // Serialize the objects reachable from a single object pointer.
610  virtual void Serialize(Object** o);
611  virtual void SerializeObject(Object* o,
612  HowToCode how_to_code,
613  WhereToPoint where_to_point,
614  int skip);
615 
616  protected:
617  virtual int PartialSnapshotCacheIndex(HeapObject* o);
619  // Scripts should be referred only through shared function infos. We can't
620  // allow them to be part of the partial snapshot because they contain a
621  // unique ID, and deserializing several partial snapshots containing script
622  // would cause dupes.
623  ASSERT(!o->IsScript());
624  return o->IsName() || o->IsSharedFunctionInfo() ||
625  o->IsHeapNumber() || o->IsCode() ||
626  o->IsScopeInfo() ||
627  o->map() ==
628  startup_serializer_->isolate()->heap()->fixed_cow_array_map();
629  }
630 
631  private:
632  Serializer* startup_serializer_;
633  DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
634 };
635 
636 
638  public:
640  : Serializer(isolate, sink) {
641  // Clear the cache of objects used by the partial snapshot. After the
642  // strong roots have been serialized we can create a partial snapshot
643  // which will repopulate the cache with objects needed by that partial
644  // snapshot.
645  isolate->set_serialize_partial_snapshot_cache_length(0);
646  }
647  // Serialize the current state of the heap. The order is:
648  // 1) Strong references.
649  // 2) Partial snapshot cache.
650  // 3) Weak references (e.g. the string table).
651  virtual void SerializeStrongReferences();
652  virtual void SerializeObject(Object* o,
653  HowToCode how_to_code,
654  WhereToPoint where_to_point,
655  int skip);
657  void Serialize() {
660  Pad();
661  }
662 
663  private:
664  virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) {
665  return false;
666  }
667 };
668 
669 
670 } } // namespace v8::internal
671 
672 #endif // V8_SERIALIZE_H_
byte * Address
Definition: globals.h:186
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)=0
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
Definition: flags.cc:269
static const int kInvalidRootIndex
Definition: serialize.h:494
void VisitCodeTarget(RelocInfo *target)
Definition: serialize.cc:1703
int CurrentAllocationAddress(int space)
Definition: serialize.h:473
ExternalReferenceEncoder(Isolate *isolate)
Definition: serialize.cc:577
SerializationAddressMapper address_mapper_
Definition: serialize.h:586
void CopyRaw(byte *to, int number_of_bytes)
Definition: serialize.h:313
ObjectSerializer(Serializer *serializer, Object *o, SnapshotByteSink *sink, HowToCode how_to_code, WhereToPoint where_to_point)
Definition: serialize.h:506
const int kReferenceTypeShift
Definition: serialize.h:59
void AddMapping(HeapObject *obj, int to)
Definition: serialize.h:433
virtual void Serialize(Object **o)
Definition: serialize.cc:1305
static bool too_late_to_enable_now_
Definition: serialize.h:585
Definition: v8.h:1407
const int kTypeCodeCount
Definition: serialize.h:54
static int RootArrayConstantFromByteCode(int byte_code)
Definition: serialize.h:287
static void Disable()
Definition: serialize.cc:772
const int kDeoptTableSerializeEntryCount
Definition: serialize.h:63
intptr_t root_index_wave_front()
Definition: serialize.h:498
virtual void SerializeStrongReferences()
Definition: serialize.cc:1290
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 Specify the name of the log file Enable low level linux profiler Enable perf linux profiler(experimental annotate support).") DEFINE_string(gc_fake_mmap
int int32_t
Definition: unicode.cc:47
int SpaceAreaSize(int space)
Definition: serialize.cc:1859
Serializer(Isolate *isolate, SnapshotByteSink *sink)
Definition: serialize.cc:1272
static bool enabled()
Definition: serialize.h:485
void VisitRuntimeEntry(RelocInfo *reloc)
Definition: serialize.cc:1691
#define ASSERT(condition)
Definition: checks.h:329
int EncodeExternalReference(Address addr)
Definition: serialize.h:567
unsigned short uint16_t
Definition: unicode.cc:46
void VisitPointers(Object **start, Object **end)
Definition: serialize.cc:1319
static int CodeForRepeats(int repeats)
Definition: serialize.h:276
const int kReferenceIdMask
Definition: serialize.h:58
void PutInt(uintptr_t integer, const char *description)
Definition: serialize.cc:1259
Address Decode(uint32_t key) const
Definition: serialize.h:140
intptr_t root_index_wave_front_
Definition: serialize.h:587
SnapshotByteSink * sink_
Definition: serialize.h:581
void PutRoot(int index, HeapObject *object, HowToCode how, WhereToPoint where, int skip)
Definition: serialize.cc:1490
void VisitCodeEntry(Address entry_address)
Definition: serialize.cc:1715
void set_reservation(int space_number, int reservation)
Definition: serialize.h:333
void VisitPointers(Object **start, Object **end)
Definition: serialize.cc:1614
uint8_t byte
Definition: globals.h:185
bool ShouldBeSkipped(Object **current)
Definition: serialize.cc:1311
void VisitExternalTwoByteString(v8::String::ExternalStringResource **resource)
Definition: serialize.h:531
#define UNREACHABLE()
Definition: checks.h:52
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
Definition: flags.cc:211
int fullness_[LAST_SPACE+1]
Definition: serialize.h:580
static void MemCopy(void *dest, const void *src, size_t size)
Definition: platform.h:399
Deserializer(SnapshotByteSource *source)
Definition: serialize.cc:780
virtual int PartialSnapshotCacheIndex(HeapObject *o)
Definition: serialize.cc:1370
static const int kRootArrayConstants
Definition: serialize.h:284
static int SpaceOfObject(HeapObject *object)
Definition: serialize.cc:1838
SerializationAddressMapper * address_mapper()
Definition: serialize.h:486
static void TooLateToEnableNow()
Definition: serialize.h:484
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1518
ExternalReferenceEncoder * external_reference_encoder_
Definition: serialize.h:582
void Deserialize(Isolate *isolate)
Definition: serialize.cc:799
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:131
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:359
const int kDebugIdShift
Definition: serialize.h:61
int Allocate(int space, int size)
Definition: serialize.cc:1851
static const int kRootArrayNumberOfConstantEncodings
Definition: serialize.h:286
uint32_t Encode(Address key) const
Definition: serialize.cc:588
static bool serialization_enabled_
Definition: serialize.h:583
static void Iterate(Isolate *isolate, ObjectVisitor *visitor)
Definition: serialize.cc:1350
void DeserializePartial(Isolate *isolate, Object **root)
Definition: serialize.cc:844
static int RepeatsForCode(int byte_code)
Definition: serialize.h:280
void SerializeReferenceToPreviousObject(int space, int address, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1418
static void Enable(Isolate *isolate)
Definition: serialize.cc:761
const int kDebugRegisterBits
Definition: serialize.h:60
HeapProfiler * heap_profiler() const
Definition: isolate.h:985
const int kObjectAlignmentBits
Definition: v8globals.h:43
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
Definition: hashmap.h:113
void VisitExternalAsciiString(v8::String::ExternalAsciiStringResource **resource)
Definition: serialize.cc:1733
Isolate * isolate() const
Definition: serialize.h:478
virtual void SerializeObject(Object *o, HowToCode how_to_code, WhereToPoint where_to_point, int skip)
Definition: serialize.cc:1438
StartupSerializer(Isolate *isolate, SnapshotByteSink *sink)
Definition: serialize.h:639
void set_root_index_wave_front(intptr_t value)
Definition: serialize.h:499
static HeapObject * FromAddress(Address address)
Definition: objects-inl.h:1369
const int kFirstTypeCode
Definition: serialize.h:55
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:214
const int kReferenceIdBits
Definition: serialize.h:57
HeapObject * obj
static const int kNativesStringResource
Definition: serialize.h:271
int RootIndex(HeapObject *heap_object, HowToCode from)
Definition: serialize.cc:1393
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)=0
virtual void Put(int byte, const char *description)=0
static ExternalReferenceTable * instance(Isolate *isolate)
Definition: serialize.cc:67
virtual bool ShouldBeInThePartialSnapshotCache(HeapObject *o)
Definition: serialize.h:618
PartialSerializer(Isolate *isolate, Serializer *startup_snapshot_serializer, SnapshotByteSink *sink)
Definition: serialize.h:601
SnapshotByteSource(const byte *array, int length)
Definition: serialize.h:165
virtual void PutSection(int byte, const char *description)
Definition: serialize.h:403
ExternalReferenceDecoder(Isolate *isolate)
Definition: serialize.cc:619
void VisitEmbeddedPointer(RelocInfo *target)
Definition: serialize.cc:1655
const char * NameOfAddress(Address key) const
Definition: serialize.cc:596