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 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { | 15 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { |
16 map_ = isolate->external_reference_map(); | 16 map_ = isolate->external_reference_map(); |
17 #ifdef DEBUG | 17 #ifdef DEBUG |
18 table_ = ExternalReferenceTable::instance(isolate); | 18 table_ = ExternalReferenceTable::instance(isolate); |
19 #endif // DEBUG | 19 #endif // DEBUG |
20 if (map_ != nullptr) return; | 20 if (map_ != nullptr) return; |
21 map_ = new AddressToIndexHashMap(); | 21 map_ = new AddressToIndexHashMap(); |
22 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); | 22 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); |
23 for (uint32_t i = 0; i < table->size(); ++i) { | 23 for (uint32_t i = 0; i < table->size(); ++i) { |
24 Address addr = table->address(i); | 24 Address addr = table->address(i); |
25 // Ignore duplicate API references. | 25 // Ignore duplicate API references. |
26 if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue; | 26 if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue; |
| 27 #ifndef V8_OS_WIN |
| 28 // TODO(yangguo): On Windows memcpy and memmove can end up at the same |
| 29 // address due to ICF. See http://crbug.com/726896. |
27 DCHECK(map_->Get(addr).IsNothing()); | 30 DCHECK(map_->Get(addr).IsNothing()); |
| 31 #endif |
28 map_->Set(addr, i); | 32 map_->Set(addr, i); |
29 DCHECK(map_->Get(addr).IsJust()); | 33 DCHECK(map_->Get(addr).IsJust()); |
30 } | 34 } |
31 isolate->set_external_reference_map(map_); | 35 isolate->set_external_reference_map(map_); |
32 } | 36 } |
33 | 37 |
34 uint32_t ExternalReferenceEncoder::Encode(Address address) const { | 38 uint32_t ExternalReferenceEncoder::Encode(Address address) const { |
35 Maybe<uint32_t> maybe_index = map_->Get(address); | 39 Maybe<uint32_t> maybe_index = map_->Get(address); |
36 if (maybe_index.IsNothing()) { | 40 if (maybe_index.IsNothing()) { |
37 void* addr = address; | 41 void* addr = address; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 List<AccessorInfo*>* accessor_infos) { | 91 List<AccessorInfo*>* accessor_infos) { |
88 // Restore wiped accessor infos. | 92 // Restore wiped accessor infos. |
89 for (AccessorInfo* info : *accessor_infos) { | 93 for (AccessorInfo* info : *accessor_infos) { |
90 Foreign::cast(info->js_getter()) | 94 Foreign::cast(info->js_getter()) |
91 ->set_foreign_address(info->redirected_getter()); | 95 ->set_foreign_address(info->redirected_getter()); |
92 } | 96 } |
93 } | 97 } |
94 | 98 |
95 } // namespace internal | 99 } // namespace internal |
96 } // namespace v8 | 100 } // namespace v8 |
OLD | NEW |