OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/cpu-profiler.h" | 7 #include "src/cpu-profiler.h" |
8 #include "src/ic/handler-compiler.h" | 8 #include "src/ic/handler-compiler.h" |
9 #include "src/ic/ic-inl.h" | 9 #include "src/ic/ic-inl.h" |
10 #include "src/ic/ic-compiler.h" | 10 #include "src/ic/ic-compiler.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 Code::StubType stub_type = handler->type(); | 45 Code::StubType stub_type = handler->type(); |
46 return CompilePolymorphic(&maps, &handlers, name, stub_type, check); | 46 return CompilePolymorphic(&maps, &handlers, name, stub_type, check); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 Handle<Code> PropertyICCompiler::ComputeMonomorphic( | 50 Handle<Code> PropertyICCompiler::ComputeMonomorphic( |
51 Code::Kind kind, Handle<Name> name, Handle<Map> map, Handle<Code> handler, | 51 Code::Kind kind, Handle<Name> name, Handle<Map> map, Handle<Code> handler, |
52 ExtraICState extra_ic_state) { | 52 ExtraICState extra_ic_state) { |
53 Isolate* isolate = name->GetIsolate(); | 53 Isolate* isolate = name->GetIsolate(); |
54 if (handler.is_identical_to(isolate->builtins()->LoadIC_Normal()) || | 54 if (handler.is_identical_to(isolate->builtins()->LoadIC_Normal()) || |
| 55 handler.is_identical_to(isolate->builtins()->LoadIC_Normal_Strong()) || |
55 handler.is_identical_to(isolate->builtins()->StoreIC_Normal())) { | 56 handler.is_identical_to(isolate->builtins()->StoreIC_Normal())) { |
56 name = isolate->factory()->normal_ic_symbol(); | 57 name = isolate->factory()->normal_ic_symbol(); |
57 } | 58 } |
58 | 59 |
59 CacheHolderFlag flag; | 60 CacheHolderFlag flag; |
60 Handle<Map> stub_holder = IC::GetICCacheHolder(map, isolate, &flag); | 61 Handle<Map> stub_holder = IC::GetICCacheHolder(map, isolate, &flag); |
61 if (kind == Code::KEYED_STORE_IC) { | 62 if (kind == Code::KEYED_STORE_IC) { |
62 // Always set the "property" bit. | 63 // Always set the "property" bit. |
63 extra_ic_state = | 64 extra_ic_state = |
64 KeyedStoreIC::IcCheckTypeField::update(extra_ic_state, PROPERTY); | 65 KeyedStoreIC::IcCheckTypeField::update(extra_ic_state, PROPERTY); |
(...skipping 16 matching lines...) Expand all Loading... |
81 | 82 |
82 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); | 83 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); |
83 ic = ic_compiler.CompileMonomorphic(map, handler, name, PROPERTY); | 84 ic = ic_compiler.CompileMonomorphic(map, handler, name, PROPERTY); |
84 | 85 |
85 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); | 86 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); |
86 return ic; | 87 return ic; |
87 } | 88 } |
88 | 89 |
89 | 90 |
90 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( | 91 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( |
91 Handle<Map> receiver_map) { | 92 Handle<Map> receiver_map, ExtraICState extra_ic_state) { |
92 Isolate* isolate = receiver_map->GetIsolate(); | 93 Isolate* isolate = receiver_map->GetIsolate(); |
93 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 94 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
94 ElementsKind elements_kind = receiver_map->elements_kind(); | 95 ElementsKind elements_kind = receiver_map->elements_kind(); |
95 | 96 |
96 // No need to check for an elements-free prototype chain here, the generated | 97 // No need to check for an elements-free prototype chain here, the generated |
97 // stub code needs to check that dynamically anyway. | 98 // stub code needs to check that dynamically anyway. |
98 bool convert_hole_to_undefined = | 99 bool convert_hole_to_undefined = |
99 is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && | 100 is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && |
100 *receiver_map == isolate->get_initial_js_array_map(elements_kind); | 101 *receiver_map == isolate->get_initial_js_array_map(elements_kind) && |
101 | 102 !(is_strong(LoadICState::GetLanguageMode(extra_ic_state))); |
102 Handle<Code> stub; | 103 Handle<Code> stub; |
103 if (receiver_map->has_indexed_interceptor()) { | 104 if (receiver_map->has_indexed_interceptor()) { |
104 stub = LoadIndexedInterceptorStub(isolate).GetCode(); | 105 stub = LoadIndexedInterceptorStub(isolate).GetCode(); |
105 } else if (receiver_map->IsStringMap()) { | 106 } else if (receiver_map->IsStringMap()) { |
106 // We have a string. | 107 // We have a string. |
107 stub = LoadIndexedStringStub(isolate).GetCode(); | 108 stub = LoadIndexedStringStub(isolate).GetCode(); |
108 } else if (receiver_map->has_sloppy_arguments_elements()) { | 109 } else if (receiver_map->has_sloppy_arguments_elements()) { |
109 stub = KeyedLoadSloppyArgumentsStub(isolate).GetCode(); | 110 stub = KeyedLoadSloppyArgumentsStub(isolate).GetCode(); |
110 } else if (receiver_map->has_fast_elements() || | 111 } else if (receiver_map->has_fast_elements() || |
111 receiver_map->has_external_array_elements() || | 112 receiver_map->has_external_array_elements() || |
112 receiver_map->has_fixed_typed_array_elements()) { | 113 receiver_map->has_fixed_typed_array_elements()) { |
113 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, | 114 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, |
114 convert_hole_to_undefined).GetCode(); | 115 convert_hole_to_undefined).GetCode(); |
115 } else { | 116 } else { |
116 stub = LoadDictionaryElementStub(isolate).GetCode(); | 117 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) |
| 118 .GetCode(); |
117 } | 119 } |
118 return stub; | 120 return stub; |
119 } | 121 } |
120 | 122 |
121 | 123 |
122 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( | 124 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( |
123 Handle<Map> receiver_map, LanguageMode language_mode, | 125 Handle<Map> receiver_map, LanguageMode language_mode, |
124 KeyedAccessStoreMode store_mode) { | 126 KeyedAccessStoreMode store_mode) { |
125 Isolate* isolate = receiver_map->GetIsolate(); | 127 Isolate* isolate = receiver_map->GetIsolate(); |
126 ExtraICState extra_state = | 128 ExtraICState extra_state = |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 216 |
215 if (!receiver_map->is_dictionary_map()) { | 217 if (!receiver_map->is_dictionary_map()) { |
216 Map::UpdateCodeCache(receiver_map, name, ic); | 218 Map::UpdateCodeCache(receiver_map, name, ic); |
217 } | 219 } |
218 | 220 |
219 return ic; | 221 return ic; |
220 } | 222 } |
221 | 223 |
222 | 224 |
223 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic( | 225 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic( |
224 MapHandleList* receiver_maps) { | 226 MapHandleList* receiver_maps, LanguageMode language_mode) { |
225 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); | 227 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); |
226 DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT); | 228 DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT); |
227 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); | 229 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); |
228 Handle<PolymorphicCodeCache> cache = | 230 Handle<PolymorphicCodeCache> cache = |
229 isolate->factory()->polymorphic_code_cache(); | 231 isolate->factory()->polymorphic_code_cache(); |
230 Handle<Object> probe = cache->Lookup(receiver_maps, flags); | 232 Handle<Object> probe = cache->Lookup(receiver_maps, flags); |
231 if (probe->IsCode()) return Handle<Code>::cast(probe); | 233 if (probe->IsCode()) return Handle<Code>::cast(probe); |
232 | 234 |
233 CodeHandleList handlers(receiver_maps->length()); | 235 CodeHandleList handlers(receiver_maps->length()); |
234 ElementHandlerCompiler compiler(isolate); | 236 ElementHandlerCompiler compiler(isolate); |
235 compiler.CompileElementHandlers(receiver_maps, &handlers); | 237 compiler.CompileElementHandlers(receiver_maps, &handlers, language_mode); |
236 PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC); | 238 PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC); |
237 Handle<Code> code = ic_compiler.CompilePolymorphic( | 239 Handle<Code> code = ic_compiler.CompilePolymorphic( |
238 receiver_maps, &handlers, isolate->factory()->empty_string(), | 240 receiver_maps, &handlers, isolate->factory()->empty_string(), |
239 Code::NORMAL, ELEMENT); | 241 Code::NORMAL, ELEMENT); |
240 | 242 |
241 isolate->counters()->keyed_load_polymorphic_stubs()->Increment(); | 243 isolate->counters()->keyed_load_polymorphic_stubs()->Increment(); |
242 | 244 |
243 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); | 245 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); |
244 return code; | 246 return code; |
245 } | 247 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 416 |
415 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); | 417 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); |
416 | 418 |
417 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); | 419 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); |
418 } | 420 } |
419 | 421 |
420 | 422 |
421 #undef __ | 423 #undef __ |
422 } // namespace internal | 424 } // namespace internal |
423 } // namespace v8 | 425 } // namespace v8 |
OLD | NEW |