| 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 // Ignore duplicate API references. |
| 25 if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue; |
| 24 DCHECK(map_->Get(addr).IsNothing()); | 26 DCHECK(map_->Get(addr).IsNothing()); |
| 25 map_->Set(addr, i); | 27 map_->Set(addr, i); |
| 26 DCHECK(map_->Get(addr).IsJust()); | 28 DCHECK(map_->Get(addr).IsJust()); |
| 27 } | 29 } |
| 28 isolate->set_external_reference_map(map_); | 30 isolate->set_external_reference_map(map_); |
| 29 } | 31 } |
| 30 | 32 |
| 31 uint32_t ExternalReferenceEncoder::Encode(Address address) const { | 33 uint32_t ExternalReferenceEncoder::Encode(Address address) const { |
| 32 Maybe<uint32_t> maybe_index = map_->Get(address); | 34 Maybe<uint32_t> maybe_index = map_->Get(address); |
| 33 if (maybe_index.IsNothing()) { | 35 if (maybe_index.IsNothing()) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 List<AccessorInfo*>* accessor_infos) { | 86 List<AccessorInfo*>* accessor_infos) { |
| 85 // Restore wiped accessor infos. | 87 // Restore wiped accessor infos. |
| 86 for (AccessorInfo* info : *accessor_infos) { | 88 for (AccessorInfo* info : *accessor_infos) { |
| 87 Foreign::cast(info->js_getter()) | 89 Foreign::cast(info->js_getter()) |
| 88 ->set_foreign_address(info->redirected_getter()); | 90 ->set_foreign_address(info->redirected_getter()); |
| 89 } | 91 } |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace internal | 94 } // namespace internal |
| 93 } // namespace v8 | 95 } // namespace v8 |
| OLD | NEW |