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/deoptimizer.h" |
7 #include "src/external-reference-table.h" | 8 #include "src/external-reference-table.h" |
8 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
9 #include "src/list-inl.h" | 10 #include "src/list-inl.h" |
10 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { | 16 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) |
| 17 : isolate_(isolate) { |
16 map_ = isolate->external_reference_map(); | 18 map_ = isolate->external_reference_map(); |
17 #ifdef DEBUG | 19 #ifdef DEBUG |
18 table_ = ExternalReferenceTable::instance(isolate); | 20 table_ = ExternalReferenceTable::instance(isolate); |
19 #endif // DEBUG | 21 #endif // DEBUG |
20 if (map_ != nullptr) return; | 22 if (map_ != nullptr) return; |
21 map_ = new AddressToIndexHashMap(); | 23 map_ = new AddressToIndexHashMap(); |
22 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); | 24 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); |
23 for (uint32_t i = 0; i < table->size(); ++i) { | 25 for (uint32_t i = 0; i < table->size(); ++i) { |
24 Address addr = table->address(i); | 26 Address addr = table->address(i); |
25 // Ignore duplicate API references. | 27 // Ignore duplicate API references. |
26 if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue; | 28 if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue; |
27 DCHECK(map_->Get(addr).IsNothing()); | 29 DCHECK(map_->Get(addr).IsNothing()); |
28 map_->Set(addr, i); | 30 map_->Set(addr, i); |
29 DCHECK(map_->Get(addr).IsJust()); | 31 DCHECK(map_->Get(addr).IsJust()); |
30 } | 32 } |
31 isolate->set_external_reference_map(map_); | 33 isolate->set_external_reference_map(map_); |
32 } | 34 } |
33 | 35 |
34 uint32_t ExternalReferenceEncoder::Encode(Address address) const { | 36 uint32_t ExternalReferenceEncoder::Encode(Address address) const { |
35 Maybe<uint32_t> maybe_index = map_->Get(address); | 37 Maybe<uint32_t> maybe_index = map_->Get(address); |
36 if (maybe_index.IsNothing()) { | 38 if (maybe_index.IsNothing()) { |
| 39 int id = |
| 40 Deoptimizer::GetDeoptimizationId(isolate_, address, Deoptimizer::EAGER); |
| 41 if (id != Deoptimizer::kNotDeoptimizationEntry) |
| 42 return id | ExternalReferenceTable::kEagerDeoptFlag; |
| 43 id = Deoptimizer::GetDeoptimizationId(isolate_, address, Deoptimizer::LAZY); |
| 44 if (id != Deoptimizer::kNotDeoptimizationEntry) |
| 45 return id | ExternalReferenceTable::kLazyDeoptFlag; |
| 46 id = Deoptimizer::GetDeoptimizationId(isolate_, address, Deoptimizer::SOFT); |
| 47 if (id != Deoptimizer::kNotDeoptimizationEntry) |
| 48 return id | ExternalReferenceTable::kSoftDeoptFlag; |
| 49 } |
| 50 if (maybe_index.IsNothing()) { |
37 void* addr = address; | 51 void* addr = address; |
38 v8::base::OS::PrintError("Unknown external reference %p.\n", addr); | 52 v8::base::OS::PrintError("Unknown external reference %p.\n", addr); |
39 v8::base::OS::PrintError("%s", ExternalReferenceTable::ResolveSymbol(addr)); | 53 v8::base::OS::PrintError("%s", ExternalReferenceTable::ResolveSymbol(addr)); |
40 v8::base::OS::Abort(); | 54 v8::base::OS::Abort(); |
41 } | 55 } |
42 #ifdef DEBUG | 56 #ifdef DEBUG |
43 table_->increment_count(maybe_index.FromJust()); | 57 table_->increment_count(maybe_index.FromJust()); |
44 #endif // DEBUG | 58 #endif // DEBUG |
45 return maybe_index.FromJust(); | 59 return maybe_index.FromJust(); |
46 } | 60 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 List<AccessorInfo*>* accessor_infos) { | 101 List<AccessorInfo*>* accessor_infos) { |
88 // Restore wiped accessor infos. | 102 // Restore wiped accessor infos. |
89 for (AccessorInfo* info : *accessor_infos) { | 103 for (AccessorInfo* info : *accessor_infos) { |
90 Foreign::cast(info->js_getter()) | 104 Foreign::cast(info->js_getter()) |
91 ->set_foreign_address(info->redirected_getter()); | 105 ->set_foreign_address(info->redirected_getter()); |
92 } | 106 } |
93 } | 107 } |
94 | 108 |
95 } // namespace internal | 109 } // namespace internal |
96 } // namespace v8 | 110 } // namespace v8 |
OLD | NEW |