| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 /// Copyright 2006-2008 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // This is used during building, but not at runtime by V8. | 48 // This is used during building, but not at runtime by V8. |
| 49 class SerializationAddressMapper { | 49 class SerializationAddressMapper { |
| 50 public: | 50 public: |
| 51 static bool IsMapped(HeapObject* obj) { | 51 static bool IsMapped(HeapObject* obj) { |
| 52 EnsureMapExists(); | 52 EnsureMapExists(); |
| 53 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; | 53 return serialization_map_->Lookup(Key(obj), Hash(obj), false) != NULL; |
| 54 } | 54 } |
| 55 | 55 |
| 56 static int MappedTo(HeapObject* obj) { | 56 static int MappedTo(HeapObject* obj) { |
| 57 ASSERT(IsMapped(obj)); | 57 ASSERT(IsMapped(obj)); |
| 58 return reinterpret_cast<intptr_t>(serialization_map_->Lookup(Key(obj), | 58 return static_cast<int>(reinterpret_cast<intptr_t>( |
| 59 Hash(obj), | 59 serialization_map_->Lookup(Key(obj), Hash(obj), false)->value)); |
| 60 false)->value); | |
| 61 } | 60 } |
| 62 | 61 |
| 63 static void Map(HeapObject* obj, int to) { | 62 static void Map(HeapObject* obj, int to) { |
| 64 EnsureMapExists(); | 63 EnsureMapExists(); |
| 65 ASSERT(!IsMapped(obj)); | 64 ASSERT(!IsMapped(obj)); |
| 66 HashMap::Entry* entry = | 65 HashMap::Entry* entry = |
| 67 serialization_map_->Lookup(Key(obj), Hash(obj), true); | 66 serialization_map_->Lookup(Key(obj), Hash(obj), true); |
| 68 entry->value = Value(to); | 67 entry->value = Value(to); |
| 69 } | 68 } |
| 70 | 69 |
| 71 static void Zap() { | 70 static void Zap() { |
| 72 if (serialization_map_ != NULL) { | 71 if (serialization_map_ != NULL) { |
| 73 delete serialization_map_; | 72 delete serialization_map_; |
| 74 } | 73 } |
| 75 serialization_map_ = NULL; | 74 serialization_map_ = NULL; |
| 76 } | 75 } |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 static bool SerializationMatchFun(void* key1, void* key2) { | 78 static bool SerializationMatchFun(void* key1, void* key2) { |
| 80 return key1 == key2; | 79 return key1 == key2; |
| 81 } | 80 } |
| 82 | 81 |
| 83 static uint32_t Hash(HeapObject* obj) { | 82 static uint32_t Hash(HeapObject* obj) { |
| 84 return reinterpret_cast<intptr_t>(obj->address()); | 83 return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); |
| 85 } | 84 } |
| 86 | 85 |
| 87 static void* Key(HeapObject* obj) { | 86 static void* Key(HeapObject* obj) { |
| 88 return reinterpret_cast<void*>(obj->address()); | 87 return reinterpret_cast<void*>(obj->address()); |
| 89 } | 88 } |
| 90 | 89 |
| 91 static void* Value(int v) { | 90 static void* Value(int v) { |
| 92 return reinterpret_cast<void*>(v); | 91 return reinterpret_cast<void*>(v); |
| 93 } | 92 } |
| 94 | 93 |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); | 1212 fullness_[space] = RoundUp(fullness_[space], Page::kPageSize); |
| 1214 } | 1213 } |
| 1215 } | 1214 } |
| 1216 int allocation_address = fullness_[space]; | 1215 int allocation_address = fullness_[space]; |
| 1217 fullness_[space] = allocation_address + size; | 1216 fullness_[space] = allocation_address + size; |
| 1218 return allocation_address; | 1217 return allocation_address; |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 | 1220 |
| 1222 } } // namespace v8::internal | 1221 } } // namespace v8::internal |
| OLD | NEW |