| 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 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, | 347 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, |
| 348 Address address) const { | 348 Address address) const { |
| 349 HashMap::Entry* entry = | 349 HashMap::Entry* entry = |
| 350 const_cast<HashMap*>(map_)->Lookup(address, Hash(address)); | 350 const_cast<HashMap*>(map_)->Lookup(address, Hash(address)); |
| 351 if (entry == NULL) return "<unknown>"; | 351 if (entry == NULL) return "<unknown>"; |
| 352 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); | 352 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
| 353 return ExternalReferenceTable::instance(isolate)->name(i); | 353 return ExternalReferenceTable::instance(isolate)->name(i); |
| 354 } | 354 } |
| 355 | 355 |
| 356 | 356 |
| 357 RootIndexMap::RootIndexMap(Isolate* isolate) { | |
| 358 map_ = isolate->root_index_map(); | |
| 359 if (map_ != NULL) return; | |
| 360 map_ = new HashMap(HashMap::PointersMatch); | |
| 361 for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) { | |
| 362 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); | |
| 363 Object* root = isolate->heap()->root(root_index); | |
| 364 // Omit root entries that can be written after initialization. They must | |
| 365 // not be referenced through the root list in the snapshot. | |
| 366 if (root->IsHeapObject() && | |
| 367 isolate->heap()->RootCanBeTreatedAsConstant(root_index)) { | |
| 368 HeapObject* heap_object = HeapObject::cast(root); | |
| 369 HashMap::Entry* entry = LookupEntry(map_, heap_object, false); | |
| 370 if (entry != NULL) { | |
| 371 // Some are initialized to a previous value in the root list. | |
| 372 DCHECK_LT(GetValue(entry), i); | |
| 373 } else { | |
| 374 SetValue(LookupEntry(map_, heap_object, true), i); | |
| 375 } | |
| 376 } | |
| 377 } | |
| 378 isolate->set_root_index_map(map_); | |
| 379 } | |
| 380 | |
| 381 | |
| 382 class CodeAddressMap: public CodeEventLogger { | 357 class CodeAddressMap: public CodeEventLogger { |
| 383 public: | 358 public: |
| 384 explicit CodeAddressMap(Isolate* isolate) | 359 explicit CodeAddressMap(Isolate* isolate) |
| 385 : isolate_(isolate) { | 360 : isolate_(isolate) { |
| 386 isolate->logger()->addCodeEventListener(this); | 361 isolate->logger()->addCodeEventListener(this); |
| 387 } | 362 } |
| 388 | 363 |
| 389 virtual ~CodeAddressMap() { | 364 virtual ~CodeAddressMap() { |
| 390 isolate_->logger()->removeCodeEventListener(this); | 365 isolate_->logger()->removeCodeEventListener(this); |
| 391 } | 366 } |
| (...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2853 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2879 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2854 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2880 if (r == CHECK_SUCCESS) return scd; | 2855 if (r == CHECK_SUCCESS) return scd; |
| 2881 cached_data->Reject(); | 2856 cached_data->Reject(); |
| 2882 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2857 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2883 delete scd; | 2858 delete scd; |
| 2884 return NULL; | 2859 return NULL; |
| 2885 } | 2860 } |
| 2886 } // namespace internal | 2861 } // namespace internal |
| 2887 } // namespace v8 | 2862 } // namespace v8 |
| OLD | NEW |