OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
7 | 7 |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
10 #include "src/heap-profiler.h" | 10 #include "src/heap-profiler.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // both. | 141 // both. |
142 class SerializerDeserializer: public ObjectVisitor { | 142 class SerializerDeserializer: public ObjectVisitor { |
143 public: | 143 public: |
144 static void Iterate(Isolate* isolate, ObjectVisitor* visitor); | 144 static void Iterate(Isolate* isolate, ObjectVisitor* visitor); |
145 | 145 |
146 static int nop() { return kNop; } | 146 static int nop() { return kNop; } |
147 | 147 |
148 protected: | 148 protected: |
149 // Where the pointed-to object can be found: | 149 // Where the pointed-to object can be found: |
150 enum Where { | 150 enum Where { |
151 kNewObject = 0, // Object is next in snapshot. | 151 kNewObject = 0, // Object is next in snapshot. |
152 // 1-6 One per space. | 152 // 1-6 One per space. |
153 kRootArray = 0x9, // Object is found in root array. | 153 kRootArray = 0x9, // Object is found in root array. |
154 kPartialSnapshotCache = 0xa, // Object is in the cache. | 154 kPartialSnapshotCache = 0xa, // Object is in the cache. |
155 kExternalReference = 0xb, // Pointer to an external reference. | 155 kExternalReference = 0xb, // Pointer to an external reference. |
156 kSkip = 0xc, // Skip n bytes. | 156 kSkip = 0xc, // Skip n bytes. |
157 kNop = 0xd, // Does nothing, used to pad. | 157 kBuiltin = 0xd, // Builtin code object. |
158 // 0xe-0xf Free. | 158 // 0xe Free. |
159 kBackref = 0x10, // Object is described relative to end. | 159 kNop = 0xf, // Does nothing, used to pad. |
| 160 kBackref = 0x10, // Object is described relative to end. |
160 // 0x11-0x16 One per space. | 161 // 0x11-0x16 One per space. |
161 kBackrefWithSkip = 0x18, // Object is described relative to end. | 162 kBackrefWithSkip = 0x18, // Object is described relative to end. |
162 // 0x19-0x1e One per space. | 163 // 0x19-0x1e One per space. |
163 // 0x20-0x3f Used by misc. tags below. | 164 // 0x20-0x3f Used by misc. tags below. |
164 kPointedToMask = 0x3f | 165 kPointedToMask = 0x3f |
165 }; | 166 }; |
166 | 167 |
167 // How to code the pointer to the object. | 168 // How to code the pointer to the object. |
168 enum HowToCode { | 169 enum HowToCode { |
169 kPlain = 0, // Straight pointer. | 170 kPlain = 0, // Straight pointer. |
170 // What this means depends on the architecture: | 171 // What this means depends on the architecture: |
171 kFromCode = 0x40, // A pointer inlined in code. | 172 kFromCode = 0x40, // A pointer inlined in code. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 set_root_index_wave_front(Heap::kStrongRootListLength); | 560 set_root_index_wave_front(Heap::kStrongRootListLength); |
560 InitializeCodeAddressMap(); | 561 InitializeCodeAddressMap(); |
561 } | 562 } |
562 | 563 |
563 static ScriptData* Serialize(Handle<SharedFunctionInfo> info); | 564 static ScriptData* Serialize(Handle<SharedFunctionInfo> info); |
564 virtual void SerializeObject(Object* o, HowToCode how_to_code, | 565 virtual void SerializeObject(Object* o, HowToCode how_to_code, |
565 WhereToPoint where_to_point, int skip); | 566 WhereToPoint where_to_point, int skip); |
566 | 567 |
567 static Object* Deserialize(Isolate* isolate, ScriptData* data); | 568 static Object* Deserialize(Isolate* isolate, ScriptData* data); |
568 | 569 |
569 // The data header consists of int-sized entries: | 570 private: |
570 // [0] version hash | 571 void SerializeBuiltin(Code* builtin, HowToCode how_to_code, |
571 // [1] length in bytes | 572 WhereToPoint where_to_point, int skip); |
572 // [2..8] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE. | |
573 static const int kHeaderSize = 9; | |
574 static const int kVersionHashOffset = 0; | |
575 static const int kPayloadLengthOffset = 1; | |
576 static const int kReservationsOffset = 2; | |
577 }; | 573 }; |
578 | 574 |
579 | 575 |
580 // Wrapper around ScriptData to provide code-serializer-specific functionality. | 576 // Wrapper around ScriptData to provide code-serializer-specific functionality. |
581 class SerializedCodeData { | 577 class SerializedCodeData { |
582 public: | 578 public: |
583 // Used by when consuming. | 579 // Used by when consuming. |
584 explicit SerializedCodeData(ScriptData* data) | 580 explicit SerializedCodeData(ScriptData* data) |
585 : script_data_(data), owns_script_data_(false) { | 581 : script_data_(data), owns_script_data_(false) { |
586 CHECK(IsSane()); | 582 CHECK(IsSane()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 static const int kVersionHashOffset = 0; | 628 static const int kVersionHashOffset = 0; |
633 static const int kReservationsOffset = 1; | 629 static const int kReservationsOffset = 1; |
634 static const int kHeaderEntries = 8; | 630 static const int kHeaderEntries = 8; |
635 | 631 |
636 ScriptData* script_data_; | 632 ScriptData* script_data_; |
637 bool owns_script_data_; | 633 bool owns_script_data_; |
638 }; | 634 }; |
639 } } // namespace v8::internal | 635 } } // namespace v8::internal |
640 | 636 |
641 #endif // V8_SERIALIZE_H_ | 637 #endif // V8_SERIALIZE_H_ |
OLD | NEW |