OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/serializer-common.h" | 5 #include "src/snapshot/serializer-common.h" |
6 | 6 |
7 #include "src/external-reference-table.h" | 7 #include "src/external-reference-table.h" |
8 #include "src/ic/stub-cache.h" | 8 #include "src/ic/stub-cache.h" |
9 #include "src/list-inl.h" | 9 #include "src/list-inl.h" |
10 | 10 |
| 11 #if defined(DEBUG) && defined(V8_OS_LINUX) |
| 12 #include <execinfo.h> |
| 13 #endif // DEBUG && V8_OS_LINUX |
| 14 |
11 namespace v8 { | 15 namespace v8 { |
12 namespace internal { | 16 namespace internal { |
13 | 17 |
14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { | 18 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { |
15 map_ = isolate->external_reference_map(); | 19 map_ = isolate->external_reference_map(); |
16 if (map_ != NULL) return; | 20 if (map_ != NULL) return; |
17 map_ = new base::HashMap(); | 21 map_ = new base::HashMap(); |
18 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); | 22 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); |
19 for (int i = 0; i < table->size(); ++i) { | 23 for (int i = 0; i < table->size(); ++i) { |
20 Address addr = table->address(i); | 24 Address addr = table->address(i); |
21 if (addr == ExternalReferenceTable::NotAvailable()) continue; | 25 if (addr == ExternalReferenceTable::NotAvailable()) continue; |
22 // We expect no duplicate external references entries in the table. | 26 // We expect no duplicate external references entries in the table. |
23 // AccessorRefTable getter may have duplicates, indicated by an empty string | 27 // AccessorRefTable getter may have duplicates, indicated by an empty string |
24 // as name. | 28 // as name. |
25 DCHECK(table->name(i)[0] == '\0' || | 29 DCHECK(table->name(i)[0] == '\0' || |
26 map_->Lookup(addr, Hash(addr)) == nullptr); | 30 map_->Lookup(addr, Hash(addr)) == nullptr); |
27 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i); | 31 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i); |
28 } | 32 } |
29 isolate->set_external_reference_map(map_); | 33 isolate->set_external_reference_map(map_); |
30 } | 34 } |
31 | 35 |
32 uint32_t ExternalReferenceEncoder::Encode(Address address) const { | 36 uint32_t ExternalReferenceEncoder::Encode(Address address) const { |
33 DCHECK_NOT_NULL(address); | 37 DCHECK_NOT_NULL(address); |
34 base::HashMap::Entry* entry = | 38 base::HashMap::Entry* entry = |
35 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address)); | 39 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address)); |
36 DCHECK_NOT_NULL(entry); | 40 if (entry == nullptr) { |
| 41 void* function_addr = address; |
| 42 v8::base::OS::PrintError("Unknown external reference %p.\n", function_addr); |
| 43 #if defined(DEBUG) && defined(V8_OS_LINUX) |
| 44 v8::base::OS::PrintError("%s\n", backtrace_symbols(&function_addr, 1)[0]); |
| 45 #endif // DEBUG && V8_OS_LINUX |
| 46 v8::base::OS::Abort(); |
| 47 } |
37 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); | 48 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
38 } | 49 } |
39 | 50 |
40 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, | 51 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, |
41 Address address) const { | 52 Address address) const { |
42 base::HashMap::Entry* entry = | 53 base::HashMap::Entry* entry = |
43 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address)); | 54 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address)); |
44 if (entry == NULL) return "<unknown>"; | 55 if (entry == NULL) return "<unknown>"; |
45 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); | 56 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
46 return ExternalReferenceTable::instance(isolate)->name(i); | 57 return ExternalReferenceTable::instance(isolate)->name(i); |
(...skipping 24 matching lines...) Expand all Loading... |
71 if (cache->at(i)->IsUndefined(isolate)) break; | 82 if (cache->at(i)->IsUndefined(isolate)) break; |
72 } | 83 } |
73 } | 84 } |
74 | 85 |
75 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { | 86 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { |
76 return !o->IsString() && !o->IsScript(); | 87 return !o->IsString() && !o->IsScript(); |
77 } | 88 } |
78 | 89 |
79 } // namespace internal | 90 } // namespace internal |
80 } // namespace v8 | 91 } // namespace v8 |
OLD | NEW |