| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 static int nop() { return kNop; } | 295 static int nop() { return kNop; } |
| 296 | 296 |
| 297 // No reservation for large object space necessary. | 297 // No reservation for large object space necessary. |
| 298 static const int kNumberOfPreallocatedSpaces = LO_SPACE; | 298 static const int kNumberOfPreallocatedSpaces = LO_SPACE; |
| 299 static const int kNumberOfSpaces = LAST_SPACE + 1; | 299 static const int kNumberOfSpaces = LAST_SPACE + 1; |
| 300 | 300 |
| 301 protected: | 301 protected: |
| 302 // Where the pointed-to object can be found: | 302 // Where the pointed-to object can be found: |
| 303 enum Where { | 303 enum Where { |
| 304 kNewObject = 0, // Object is next in snapshot. | 304 kNewObject = 0, // Object is next in snapshot. |
| 305 // 1-7 One per space. | 305 // 1-7 One per space. |
| 306 kRootArray = 0x9, // Object is found in root array. | 306 kRootArray = 0x9, // Object is found in root array. |
| 307 kPartialSnapshotCache = 0xa, // Object is in the cache. | 307 kPartialSnapshotCache = 0xa, // Object is in the cache. |
| 308 kExternalReference = 0xb, // Pointer to an external reference. | 308 kExternalReference = 0xb, // Pointer to an external reference. |
| 309 kSkip = 0xc, // Skip n bytes. | 309 kSkip = 0xc, // Skip n bytes. |
| 310 kBuiltin = 0xd, // Builtin code object. | 310 kBuiltin = 0xd, // Builtin code object. |
| 311 kAttachedReference = 0xe, // Object is described in an attached list. | 311 kAttachedReference = 0xe, // Object is described in an attached list. |
| 312 kNop = 0xf, // Does nothing, used to pad. | 312 // 0xf Used by misc. See below. |
| 313 kBackref = 0x10, // Object is described relative to end. | 313 kBackref = 0x10, // Object is described relative to end. |
| 314 // 0x11-0x17 One per space. | 314 // 0x11-0x17 One per space. |
| 315 kBackrefWithSkip = 0x18, // Object is described relative to end. | 315 kBackrefWithSkip = 0x18, // Object is described relative to end. |
| 316 // 0x19-0x1f One per space. | 316 // 0x19-0x1f One per space. |
| 317 // 0x20-0x3f Used by misc. tags below. | 317 // 0x20-0x3f Used by misc. See below. |
| 318 kPointedToMask = 0x3f | 318 kPointedToMask = 0x3f |
| 319 }; | 319 }; |
| 320 | 320 |
| 321 // How to code the pointer to the object. | 321 // How to code the pointer to the object. |
| 322 enum HowToCode { | 322 enum HowToCode { |
| 323 kPlain = 0, // Straight pointer. | 323 kPlain = 0, // Straight pointer. |
| 324 // What this means depends on the architecture: | 324 // What this means depends on the architecture: |
| 325 kFromCode = 0x40, // A pointer inlined in code. | 325 kFromCode = 0x40, // A pointer inlined in code. |
| 326 kHowToCodeMask = 0x40 | 326 kHowToCodeMask = 0x40 |
| 327 }; | 327 }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 DCHECK(byte_code >= kConstantRepeat && byte_code <= 0x7f); | 368 DCHECK(byte_code >= kConstantRepeat && byte_code <= 0x7f); |
| 369 return byte_code - 0x72; | 369 return byte_code - 0x72; |
| 370 } | 370 } |
| 371 static const int kRootArrayConstants = 0xa0; | 371 static const int kRootArrayConstants = 0xa0; |
| 372 // 0xa0-0xbf Things from the first 32 elements of the root array. | 372 // 0xa0-0xbf Things from the first 32 elements of the root array. |
| 373 static const int kRootArrayNumberOfConstantEncodings = 0x20; | 373 static const int kRootArrayNumberOfConstantEncodings = 0x20; |
| 374 static int RootArrayConstantFromByteCode(int byte_code) { | 374 static int RootArrayConstantFromByteCode(int byte_code) { |
| 375 return byte_code & 0x1f; | 375 return byte_code & 0x1f; |
| 376 } | 376 } |
| 377 | 377 |
| 378 static const int kNop = 0xf; // Do nothing, used for padding. |
| 379 static const int kDoubleAlignPrefix = 0x4f; // Double align next object. |
| 380 |
| 378 static const int kAnyOldSpace = -1; | 381 static const int kAnyOldSpace = -1; |
| 379 | 382 |
| 380 // A bitmask for getting the space out of an instruction. | 383 // A bitmask for getting the space out of an instruction. |
| 381 static const int kSpaceMask = 7; | 384 static const int kSpaceMask = 7; |
| 382 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1); | 385 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1); |
| 383 }; | 386 }; |
| 384 | 387 |
| 385 | 388 |
| 386 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. | 389 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. |
| 387 class Deserializer: public SerializerDeserializer { | 390 class Deserializer: public SerializerDeserializer { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 // a list at deserialization time. | 433 // a list at deserialization time. |
| 431 void RelinkAllocationSite(AllocationSite* site); | 434 void RelinkAllocationSite(AllocationSite* site); |
| 432 | 435 |
| 433 // Fills in some heap data in an area from start to end (non-inclusive). The | 436 // Fills in some heap data in an area from start to end (non-inclusive). The |
| 434 // space id is used for the write barrier. The object_address is the address | 437 // space id is used for the write barrier. The object_address is the address |
| 435 // of the object we are writing into, or NULL if we are not writing into an | 438 // of the object we are writing into, or NULL if we are not writing into an |
| 436 // object, i.e. if we are writing a series of tagged values that are not on | 439 // object, i.e. if we are writing a series of tagged values that are not on |
| 437 // the heap. | 440 // the heap. |
| 438 void ReadData(Object** start, Object** end, int space, | 441 void ReadData(Object** start, Object** end, int space, |
| 439 Address object_address); | 442 Address object_address); |
| 440 void ReadObject(int space_number, Object** write_back); | 443 void ReadObject(int space_number, Object** write_back, bool double_align); |
| 441 Address Allocate(int space_index, int size); | 444 Address Allocate(int space_index, int size); |
| 442 | 445 |
| 443 // Special handling for serialized code like hooking up internalized strings. | 446 // Special handling for serialized code like hooking up internalized strings. |
| 444 HeapObject* ProcessNewObjectFromSerializedCode(HeapObject* obj); | 447 HeapObject* ProcessNewObjectFromSerializedCode(HeapObject* obj); |
| 445 Object* ProcessBackRefInSerializedCode(Object* obj); | 448 Object* ProcessBackRefInSerializedCode(Object* obj); |
| 446 | 449 |
| 447 // This returns the address of an object that has been described in the | 450 // This returns the address of an object that has been described in the |
| 448 // snapshot by chunk index and offset. | 451 // snapshot by chunk index and offset. |
| 449 HeapObject* GetBackReferencedObject(int space) { | 452 HeapObject* GetBackReferencedObject(int space) { |
| 450 if (space == LO_SPACE) { | 453 if (space == LO_SPACE) { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // Following the header, we store, in sequential order | 864 // Following the header, we store, in sequential order |
| 862 // - code stub keys | 865 // - code stub keys |
| 863 // - serialization payload | 866 // - serialization payload |
| 864 | 867 |
| 865 ScriptData* script_data_; | 868 ScriptData* script_data_; |
| 866 bool owns_script_data_; | 869 bool owns_script_data_; |
| 867 }; | 870 }; |
| 868 } } // namespace v8::internal | 871 } } // namespace v8::internal |
| 869 | 872 |
| 870 #endif // V8_SERIALIZE_H_ | 873 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |