| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 HashMap encodings_; | 72 HashMap encodings_; |
| 73 static uint32_t Hash(Address key) { | 73 static uint32_t Hash(Address key) { |
| 74 return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2); | 74 return static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key) >> 2); |
| 75 } | 75 } |
| 76 | 76 |
| 77 int IndexOf(Address key) const; | 77 int IndexOf(Address key) const; |
| 78 | 78 |
| 79 static bool Match(void* key1, void* key2) { return key1 == key2; } | 79 static bool Match(void* key1, void* key2) { return key1 == key2; } |
| 80 | 80 |
| 81 void Put(Address key, int index); | 81 void Put(Address key, int index); |
| 82 |
| 83 Isolate* isolate_; |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 | 86 |
| 85 class ExternalReferenceDecoder { | 87 class ExternalReferenceDecoder { |
| 86 public: | 88 public: |
| 87 ExternalReferenceDecoder(); | 89 ExternalReferenceDecoder(); |
| 88 ~ExternalReferenceDecoder(); | 90 ~ExternalReferenceDecoder(); |
| 89 | 91 |
| 90 Address Decode(uint32_t key) const { | 92 Address Decode(uint32_t key) const { |
| 91 if (key == 0) return NULL; | 93 if (key == 0) return NULL; |
| 92 return *Lookup(key); | 94 return *Lookup(key); |
| 93 } | 95 } |
| 94 | 96 |
| 95 private: | 97 private: |
| 96 Address** encodings_; | 98 Address** encodings_; |
| 97 | 99 |
| 98 Address* Lookup(uint32_t key) const { | 100 Address* Lookup(uint32_t key) const { |
| 99 int type = key >> kReferenceTypeShift; | 101 int type = key >> kReferenceTypeShift; |
| 100 ASSERT(kFirstTypeCode <= type && type < kTypeCodeCount); | 102 ASSERT(kFirstTypeCode <= type && type < kTypeCodeCount); |
| 101 int id = key & kReferenceIdMask; | 103 int id = key & kReferenceIdMask; |
| 102 return &encodings_[type][id]; | 104 return &encodings_[type][id]; |
| 103 } | 105 } |
| 104 | 106 |
| 105 void Put(uint32_t key, Address value) { | 107 void Put(uint32_t key, Address value) { |
| 106 *Lookup(key) = value; | 108 *Lookup(key) = value; |
| 107 } | 109 } |
| 110 |
| 111 Isolate* isolate_; |
| 108 }; | 112 }; |
| 109 | 113 |
| 110 | 114 |
| 111 class SnapshotByteSource { | 115 class SnapshotByteSource { |
| 112 public: | 116 public: |
| 113 SnapshotByteSource(const byte* array, int length) | 117 SnapshotByteSource(const byte* array, int length) |
| 114 : data_(array), length_(length), position_(0) { } | 118 : data_(array), length_(length), position_(0) { } |
| 115 | 119 |
| 116 bool HasMore() { return position_ < length_; } | 120 bool HasMore() { return position_ < length_; } |
| 117 | 121 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; } | 574 virtual int RootIndex(HeapObject* o) { return kInvalidRootIndex; } |
| 571 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 575 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
| 572 return false; | 576 return false; |
| 573 } | 577 } |
| 574 }; | 578 }; |
| 575 | 579 |
| 576 | 580 |
| 577 } } // namespace v8::internal | 581 } } // namespace v8::internal |
| 578 | 582 |
| 579 #endif // V8_SERIALIZE_H_ | 583 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |