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 #include "src/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 if (entry == NULL) return "<unknown>"; | 347 if (entry == NULL) return "<unknown>"; |
348 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); | 348 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
349 return ExternalReferenceTable::instance(isolate)->name(i); | 349 return ExternalReferenceTable::instance(isolate)->name(i); |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 RootIndexMap::RootIndexMap(Isolate* isolate) { | 353 RootIndexMap::RootIndexMap(Isolate* isolate) { |
354 map_ = isolate->root_index_map(); | 354 map_ = isolate->root_index_map(); |
355 if (map_ != NULL) return; | 355 if (map_ != NULL) return; |
356 map_ = new HashMap(HashMap::PointersMatch); | 356 map_ = new HashMap(HashMap::PointersMatch); |
357 Object** root_array = isolate->heap()->roots_array_start(); | |
358 for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) { | 357 for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) { |
359 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); | 358 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); |
360 Object* root = root_array[root_index]; | 359 Object* root = isolate->heap()->root(root_index); |
361 // Omit root entries that can be written after initialization. They must | 360 // Omit root entries that can be written after initialization. They must |
362 // not be referenced through the root list in the snapshot. | 361 // not be referenced through the root list in the snapshot. |
363 if (root->IsHeapObject() && | 362 if (root->IsHeapObject() && |
364 isolate->heap()->RootCanBeTreatedAsConstant(root_index)) { | 363 isolate->heap()->RootCanBeTreatedAsConstant(root_index)) { |
365 HeapObject* heap_object = HeapObject::cast(root); | 364 HeapObject* heap_object = HeapObject::cast(root); |
366 HashMap::Entry* entry = LookupEntry(map_, heap_object, false); | 365 HashMap::Entry* entry = LookupEntry(map_, heap_object, false); |
367 if (entry != NULL) { | 366 if (entry != NULL) { |
368 // Some are initialized to a previous value in the root list. | 367 // Some are initialized to a previous value in the root list. |
369 DCHECK_LT(GetValue(entry), i); | 368 DCHECK_LT(GetValue(entry), i); |
370 } else { | 369 } else { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 } else if (where == kBackref) { \ | 946 } else if (where == kBackref) { \ |
948 emit_write_barrier = (space_number == NEW_SPACE); \ | 947 emit_write_barrier = (space_number == NEW_SPACE); \ |
949 new_object = GetBackReferencedObject(data & kSpaceMask); \ | 948 new_object = GetBackReferencedObject(data & kSpaceMask); \ |
950 } else if (where == kBackrefWithSkip) { \ | 949 } else if (where == kBackrefWithSkip) { \ |
951 int skip = source_.GetInt(); \ | 950 int skip = source_.GetInt(); \ |
952 current = reinterpret_cast<Object**>( \ | 951 current = reinterpret_cast<Object**>( \ |
953 reinterpret_cast<Address>(current) + skip); \ | 952 reinterpret_cast<Address>(current) + skip); \ |
954 emit_write_barrier = (space_number == NEW_SPACE); \ | 953 emit_write_barrier = (space_number == NEW_SPACE); \ |
955 new_object = GetBackReferencedObject(data & kSpaceMask); \ | 954 new_object = GetBackReferencedObject(data & kSpaceMask); \ |
956 } else if (where == kRootArray) { \ | 955 } else if (where == kRootArray) { \ |
957 int root_id = source_.GetInt(); \ | 956 int id = source_.GetInt(); \ |
Michael Lippautz
2015/08/25 15:13:25
I would say use const here but since all the other
Michael Starzinger
2015/08/25 15:19:39
Acknowledged. I'll leave the decision up to Yang,
Yang
2015/08/26 10:21:48
I'm fine with either.
| |
958 new_object = isolate->heap()->roots_array_start()[root_id]; \ | 957 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(id); \ |
958 new_object = isolate->heap()->root(root_index); \ | |
959 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ | 959 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ |
960 } else if (where == kPartialSnapshotCache) { \ | 960 } else if (where == kPartialSnapshotCache) { \ |
961 int cache_index = source_.GetInt(); \ | 961 int cache_index = source_.GetInt(); \ |
962 new_object = isolate->partial_snapshot_cache()->at(cache_index); \ | 962 new_object = isolate->partial_snapshot_cache()->at(cache_index); \ |
963 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ | 963 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ |
964 } else if (where == kExternalReference) { \ | 964 } else if (where == kExternalReference) { \ |
965 int skip = source_.GetInt(); \ | 965 int skip = source_.GetInt(); \ |
966 current = reinterpret_cast<Object**>( \ | 966 current = reinterpret_cast<Object**>( \ |
967 reinterpret_cast<Address>(current) + skip); \ | 967 reinterpret_cast<Address>(current) + skip); \ |
968 int reference_id = source_.GetInt(); \ | 968 int reference_id = source_.GetInt(); \ |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 SIXTEEN_CASES(kRootArrayConstantsWithSkip) | 1222 SIXTEEN_CASES(kRootArrayConstantsWithSkip) |
1223 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { | 1223 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { |
1224 int skip = source_.GetInt(); | 1224 int skip = source_.GetInt(); |
1225 current = reinterpret_cast<Object**>( | 1225 current = reinterpret_cast<Object**>( |
1226 reinterpret_cast<intptr_t>(current) + skip); | 1226 reinterpret_cast<intptr_t>(current) + skip); |
1227 // Fall through. | 1227 // Fall through. |
1228 } | 1228 } |
1229 | 1229 |
1230 SIXTEEN_CASES(kRootArrayConstants) | 1230 SIXTEEN_CASES(kRootArrayConstants) |
1231 SIXTEEN_CASES(kRootArrayConstants + 16) { | 1231 SIXTEEN_CASES(kRootArrayConstants + 16) { |
1232 int root_id = data & kRootArrayConstantsMask; | 1232 int id = data & kRootArrayConstantsMask; |
1233 Object* object = isolate->heap()->roots_array_start()[root_id]; | 1233 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(id); |
1234 Object* object = isolate->heap()->root(root_index); | |
1234 DCHECK(!isolate->heap()->InNewSpace(object)); | 1235 DCHECK(!isolate->heap()->InNewSpace(object)); |
1235 UnalignedCopy(current++, &object); | 1236 UnalignedCopy(current++, &object); |
1236 break; | 1237 break; |
1237 } | 1238 } |
1238 | 1239 |
1239 STATIC_ASSERT(kNumberOfHotObjects == 8); | 1240 STATIC_ASSERT(kNumberOfHotObjects == 8); |
1240 FOUR_CASES(kHotObjectWithSkip) | 1241 FOUR_CASES(kHotObjectWithSkip) |
1241 FOUR_CASES(kHotObjectWithSkip + 4) { | 1242 FOUR_CASES(kHotObjectWithSkip + 4) { |
1242 int skip = source_.GetInt(); | 1243 int skip = source_.GetInt(); |
1243 current = reinterpret_cast<Object**>( | 1244 current = reinterpret_cast<Object**>( |
(...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2876 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2877 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2877 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2878 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2878 if (r == CHECK_SUCCESS) return scd; | 2879 if (r == CHECK_SUCCESS) return scd; |
2879 cached_data->Reject(); | 2880 cached_data->Reject(); |
2880 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2881 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2881 delete scd; | 2882 delete scd; |
2882 return NULL; | 2883 return NULL; |
2883 } | 2884 } |
2884 } // namespace internal | 2885 } // namespace internal |
2885 } // namespace v8 | 2886 } // namespace v8 |
OLD | NEW |