| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const char* NameOfAddress(Address key) const; | 117 const char* NameOfAddress(Address key) const; |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 HashMap encodings_; | 120 HashMap encodings_; |
| 121 static uint32_t Hash(Address key) { | 121 static uint32_t Hash(Address key) { |
| 122 return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2); | 122 return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2); |
| 123 } | 123 } |
| 124 | 124 |
| 125 int IndexOf(Address key) const; | 125 int IndexOf(Address key) const; |
| 126 | 126 |
| 127 static bool Match(void* key1, void* key2) { return key1 == key2; } | |
| 128 | |
| 129 void Put(Address key, int index); | 127 void Put(Address key, int index); |
| 130 | 128 |
| 131 Isolate* isolate_; | 129 Isolate* isolate_; |
| 132 }; | 130 }; |
| 133 | 131 |
| 134 | 132 |
| 135 class ExternalReferenceDecoder { | 133 class ExternalReferenceDecoder { |
| 136 public: | 134 public: |
| 137 explicit ExternalReferenceDecoder(Isolate* isolate); | 135 explicit ExternalReferenceDecoder(Isolate* isolate); |
| 138 ~ExternalReferenceDecoder(); | 136 ~ExternalReferenceDecoder(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 virtual int Position() = 0; | 405 virtual int Position() = 0; |
| 408 }; | 406 }; |
| 409 | 407 |
| 410 | 408 |
| 411 // Mapping objects to their location after deserialization. | 409 // Mapping objects to their location after deserialization. |
| 412 // This is used during building, but not at runtime by V8. | 410 // This is used during building, but not at runtime by V8. |
| 413 class SerializationAddressMapper { | 411 class SerializationAddressMapper { |
| 414 public: | 412 public: |
| 415 SerializationAddressMapper() | 413 SerializationAddressMapper() |
| 416 : no_allocation_(), | 414 : no_allocation_(), |
| 417 serialization_map_(new HashMap(&SerializationMatchFun)) { } | 415 serialization_map_(new HashMap(HashMap::PointersMatch)) { } |
| 418 | 416 |
| 419 ~SerializationAddressMapper() { | 417 ~SerializationAddressMapper() { |
| 420 delete serialization_map_; | 418 delete serialization_map_; |
| 421 } | 419 } |
| 422 | 420 |
| 423 bool IsMapped(HeapObject* obj) { | 421 bool IsMapped(HeapObject* obj) { |
| 424 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; | 422 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; |
| 425 } | 423 } |
| 426 | 424 |
| 427 int MappedTo(HeapObject* obj) { | 425 int MappedTo(HeapObject* obj) { |
| 428 ASSERT(IsMapped(obj)); | 426 ASSERT(IsMapped(obj)); |
| 429 return static_cast<int>(reinterpret_cast<intptr_t>( | 427 return static_cast<int>(reinterpret_cast<intptr_t>( |
| 430 serialization_map_->Lookup(Key(obj), Hash(obj), false)->value)); | 428 serialization_map_->Lookup(Key(obj), Hash(obj), false)->value)); |
| 431 } | 429 } |
| 432 | 430 |
| 433 void AddMapping(HeapObject* obj, int to) { | 431 void AddMapping(HeapObject* obj, int to) { |
| 434 ASSERT(!IsMapped(obj)); | 432 ASSERT(!IsMapped(obj)); |
| 435 HashMap::Entry* entry = | 433 HashMap::Entry* entry = |
| 436 serialization_map_->Lookup(Key(obj), Hash(obj), true); | 434 serialization_map_->Lookup(Key(obj), Hash(obj), true); |
| 437 entry->value = Value(to); | 435 entry->value = Value(to); |
| 438 } | 436 } |
| 439 | 437 |
| 440 private: | 438 private: |
| 441 static bool SerializationMatchFun(void* key1, void* key2) { | |
| 442 return key1 == key2; | |
| 443 } | |
| 444 | |
| 445 static uint32_t Hash(HeapObject* obj) { | 439 static uint32_t Hash(HeapObject* obj) { |
| 446 return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); | 440 return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); |
| 447 } | 441 } |
| 448 | 442 |
| 449 static void* Key(HeapObject* obj) { | 443 static void* Key(HeapObject* obj) { |
| 450 return reinterpret_cast<void*>(obj->address()); | 444 return reinterpret_cast<void*>(obj->address()); |
| 451 } | 445 } |
| 452 | 446 |
| 453 static void* Value(int v) { | 447 static void* Value(int v) { |
| 454 return reinterpret_cast<void*>(v); | 448 return reinterpret_cast<void*>(v); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 private: | 657 private: |
| 664 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 658 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
| 665 return false; | 659 return false; |
| 666 } | 660 } |
| 667 }; | 661 }; |
| 668 | 662 |
| 669 | 663 |
| 670 } } // namespace v8::internal | 664 } } // namespace v8::internal |
| 671 | 665 |
| 672 #endif // V8_SERIALIZE_H_ | 666 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |