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 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { | 14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { |
15 map_ = isolate->external_reference_map(); | 15 map_ = isolate->external_reference_map(); |
16 #ifdef DEBUG | 16 #ifdef DEBUG |
17 table_ = ExternalReferenceTable::instance(isolate); | 17 table_ = ExternalReferenceTable::instance(isolate); |
18 #endif // DEBUG | 18 #endif // DEBUG |
19 if (map_ != nullptr) return; | 19 if (map_ != nullptr) return; |
20 map_ = new AddressToIndexHashMap(); | 20 map_ = new AddressToIndexHashMap(); |
21 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); | 21 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); |
22 for (uint32_t i = 0; i < table->size(); ++i) { | 22 for (uint32_t i = 0; i < table->size(); ++i) { |
23 Address addr = table->address(i); | 23 Address addr = table->address(i); |
24 DCHECK(map_->Get(addr).IsNothing() || | 24 DCHECK(map_->Get(addr).IsNothing()); |
25 strncmp(table->name(i), "Redirect to ", 12) == 0); | |
26 map_->Set(addr, i); | 25 map_->Set(addr, i); |
27 DCHECK(map_->Get(addr).IsJust()); | 26 DCHECK(map_->Get(addr).IsJust()); |
28 } | 27 } |
29 isolate->set_external_reference_map(map_); | 28 isolate->set_external_reference_map(map_); |
30 } | 29 } |
31 | 30 |
32 uint32_t ExternalReferenceEncoder::Encode(Address address) const { | 31 uint32_t ExternalReferenceEncoder::Encode(Address address) const { |
33 Maybe<uint32_t> maybe_index = map_->Get(address); | 32 Maybe<uint32_t> maybe_index = map_->Get(address); |
34 if (maybe_index.IsNothing()) { | 33 if (maybe_index.IsNothing()) { |
35 void* addr = address; | 34 void* addr = address; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // and eventually terminates the cache with undefined. | 73 // and eventually terminates the cache with undefined. |
75 visitor->VisitPointer(&cache->at(i)); | 74 visitor->VisitPointer(&cache->at(i)); |
76 if (cache->at(i)->IsUndefined(isolate)) break; | 75 if (cache->at(i)->IsUndefined(isolate)) break; |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { | 79 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { |
81 return !o->IsString() && !o->IsScript(); | 80 return !o->IsString() && !o->IsScript(); |
82 } | 81 } |
83 | 82 |
| 83 void SerializerDeserializer::RestoreExternalReferenceRedirectors( |
| 84 List<AccessorInfo*>* accessor_infos) { |
| 85 // Restore wiped accessor infos. |
| 86 for (AccessorInfo* info : *accessor_infos) { |
| 87 Foreign::cast(info->js_getter()) |
| 88 ->set_foreign_address(info->redirected_getter()); |
| 89 } |
| 90 } |
| 91 |
84 } // namespace internal | 92 } // namespace internal |
85 } // namespace v8 | 93 } // namespace v8 |
OLD | NEW |