OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 void PutInt(uintptr_t integer, const char* description); | 401 void PutInt(uintptr_t integer, const char* description); |
402 virtual int Position() = 0; | 402 virtual int Position() = 0; |
403 }; | 403 }; |
404 | 404 |
405 | 405 |
406 // Mapping objects to their location after deserialization. | 406 // Mapping objects to their location after deserialization. |
407 // This is used during building, but not at runtime by V8. | 407 // This is used during building, but not at runtime by V8. |
408 class SerializationAddressMapper { | 408 class SerializationAddressMapper { |
409 public: | 409 public: |
410 SerializationAddressMapper() | 410 SerializationAddressMapper() |
411 : serialization_map_(new HashMap(&SerializationMatchFun)), | 411 : no_allocation_(), |
412 no_allocation_(new AssertNoAllocation()) { } | 412 serialization_map_(new HashMap(&SerializationMatchFun)) { } |
413 | 413 |
414 ~SerializationAddressMapper() { | 414 ~SerializationAddressMapper() { |
415 delete serialization_map_; | 415 delete serialization_map_; |
416 delete no_allocation_; | |
417 } | 416 } |
418 | 417 |
419 bool IsMapped(HeapObject* obj) { | 418 bool IsMapped(HeapObject* obj) { |
420 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; | 419 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; |
421 } | 420 } |
422 | 421 |
423 int MappedTo(HeapObject* obj) { | 422 int MappedTo(HeapObject* obj) { |
424 ASSERT(IsMapped(obj)); | 423 ASSERT(IsMapped(obj)); |
425 return static_cast<int>(reinterpret_cast<intptr_t>( | 424 return static_cast<int>(reinterpret_cast<intptr_t>( |
426 serialization_map_->Lookup(Key(obj), Hash(obj), false)->value)); | 425 serialization_map_->Lookup(Key(obj), Hash(obj), false)->value)); |
(...skipping 16 matching lines...) Expand all Loading... |
443 } | 442 } |
444 | 443 |
445 static void* Key(HeapObject* obj) { | 444 static void* Key(HeapObject* obj) { |
446 return reinterpret_cast<void*>(obj->address()); | 445 return reinterpret_cast<void*>(obj->address()); |
447 } | 446 } |
448 | 447 |
449 static void* Value(int v) { | 448 static void* Value(int v) { |
450 return reinterpret_cast<void*>(v); | 449 return reinterpret_cast<void*>(v); |
451 } | 450 } |
452 | 451 |
| 452 DisallowHeapAllocation no_allocation_; |
453 HashMap* serialization_map_; | 453 HashMap* serialization_map_; |
454 AssertNoAllocation* no_allocation_; | |
455 DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper); | 454 DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper); |
456 }; | 455 }; |
457 | 456 |
458 | 457 |
459 // There can be only one serializer per V8 process. | 458 // There can be only one serializer per V8 process. |
460 class Serializer : public SerializerDeserializer { | 459 class Serializer : public SerializerDeserializer { |
461 public: | 460 public: |
462 explicit Serializer(SnapshotByteSink* sink); | 461 explicit Serializer(SnapshotByteSink* sink); |
463 ~Serializer(); | 462 ~Serializer(); |
464 void VisitPointers(Object** start, Object** end); | 463 void VisitPointers(Object** start, Object** end); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 private: | 653 private: |
655 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 654 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
656 return false; | 655 return false; |
657 } | 656 } |
658 }; | 657 }; |
659 | 658 |
660 | 659 |
661 } } // namespace v8::internal | 660 } } // namespace v8::internal |
662 | 661 |
663 #endif // V8_SERIALIZE_H_ | 662 #endif // V8_SERIALIZE_H_ |
OLD | NEW |