Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: src/ic/ic-compiler.cc

Issue 755513003: Hydrogen: fix keyed loads with string keys (Closed) Base URL: gh:v8/v8@master
Patch Set: fixes Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ic/ic-compiler.h ('k') | src/type-info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ic/handler-compiler.h" 7 #include "src/ic/handler-compiler.h"
8 #include "src/ic/ic-inl.h" 8 #include "src/ic/ic-inl.h"
9 #include "src/ic/ic-compiler.h" 9 #include "src/ic/ic-compiler.h"
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 CacheHolderFlag flag; 58 CacheHolderFlag flag;
59 Handle<Map> stub_holder = IC::GetICCacheHolder(*type, isolate, &flag); 59 Handle<Map> stub_holder = IC::GetICCacheHolder(*type, isolate, &flag);
60 if (kind == Code::KEYED_STORE_IC) { 60 if (kind == Code::KEYED_STORE_IC) {
61 // Always set the "property" bit. 61 // Always set the "property" bit.
62 extra_ic_state = 62 extra_ic_state =
63 KeyedStoreIC::IcCheckTypeField::update(extra_ic_state, PROPERTY); 63 KeyedStoreIC::IcCheckTypeField::update(extra_ic_state, PROPERTY);
64 DCHECK(STANDARD_STORE == 64 DCHECK(STANDARD_STORE ==
65 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state)); 65 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state));
66 } else if (kind == Code::KEYED_LOAD_IC) {
67 extra_ic_state = KeyedLoadIC::IcCheckTypeField::update(extra_ic_state,
68 PROPERTY);
66 } 69 }
67 70
68 Handle<Code> ic; 71 Handle<Code> ic;
69 // There are multiple string maps that all use the same prototype. That 72 // There are multiple string maps that all use the same prototype. That
70 // prototype cannot hold multiple handlers, one for each of the string maps, 73 // prototype cannot hold multiple handlers, one for each of the string maps,
71 // for a single name. Hence, turn off caching of the IC. 74 // for a single name. Hence, turn off caching of the IC.
72 bool can_be_cached = !type->Is(HeapType::String()); 75 bool can_be_cached = !type->Is(HeapType::String());
73 if (can_be_cached) { 76 if (can_be_cached) {
74 ic = Find(name, stub_holder, kind, extra_ic_state, flag); 77 ic = Find(name, stub_holder, kind, extra_ic_state, flag);
75 if (!ic.is_null()) return ic; 78 if (!ic.is_null()) return ic;
76 } 79 }
77 80
78 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); 81 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag);
79 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY); 82 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY);
80 83
81 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); 84 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic);
82 return ic; 85 return ic;
83 } 86 }
84 87
85 88
86 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic( 89 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic(
87 Handle<Map> receiver_map) { 90 Handle<Map> receiver_map,
91 ExtraICState extra_ic_state) {
Jakob Kummerow 2014/12/12 10:14:27 If you insist on keeping this additional argument,
indutny 2014/12/12 13:05:37 I'd either need to pass this, or StrictMode to be
Jakob Kummerow 2014/12/12 13:34:16 Why do you need StrictMode? Loads don't depend on
88 Isolate* isolate = receiver_map->GetIsolate(); 92 Isolate* isolate = receiver_map->GetIsolate();
89 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); 93 extra_ic_state = KeyedLoadIC::IcCheckTypeField::update(extra_ic_state,
94 ELEMENT);
95 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC,
96 extra_ic_state);
90 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string(); 97 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string();
91 98
92 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); 99 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
93 if (probe->IsCode()) return Handle<Code>::cast(probe); 100 if (probe->IsCode()) return Handle<Code>::cast(probe);
94 101
95 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map); 102 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map);
96 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC); 103 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC, extra_ic_state);
97 Handle<Code> code = 104 Handle<Code> code =
98 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub, 105 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub,
99 isolate->factory()->empty_string(), ELEMENT); 106 isolate->factory()->empty_string(), ELEMENT);
100 107
101 Map::UpdateCodeCache(receiver_map, name, code); 108 Map::UpdateCodeCache(receiver_map, name, code);
102 return code; 109 return code;
103 } 110 }
104 111
105 112
106 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( 113 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!receiver_map->is_dictionary_map()) { 253 if (!receiver_map->is_dictionary_map()) {
247 Map::UpdateCodeCache(receiver_map, name, ic); 254 Map::UpdateCodeCache(receiver_map, name, ic);
248 } 255 }
249 256
250 return ic; 257 return ic;
251 } 258 }
252 259
253 260
254 // TODO(verwaest): Change this method so it takes in a TypeHandleList. 261 // TODO(verwaest): Change this method so it takes in a TypeHandleList.
255 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic( 262 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic(
256 MapHandleList* receiver_maps) { 263 MapHandleList* receiver_maps,
264 ExtraICState extra_ic_state) {
257 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); 265 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
258 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); 266 extra_ic_state = KeyedLoadIC::IcCheckTypeField::update(extra_ic_state,
267 ELEMENT);
268 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC,
269 POLYMORPHIC,
270 extra_ic_state);
259 Handle<PolymorphicCodeCache> cache = 271 Handle<PolymorphicCodeCache> cache =
260 isolate->factory()->polymorphic_code_cache(); 272 isolate->factory()->polymorphic_code_cache();
261 Handle<Object> probe = cache->Lookup(receiver_maps, flags); 273 Handle<Object> probe = cache->Lookup(receiver_maps, flags);
262 if (probe->IsCode()) return Handle<Code>::cast(probe); 274 if (probe->IsCode()) return Handle<Code>::cast(probe);
263 275
264 TypeHandleList types(receiver_maps->length()); 276 TypeHandleList types(receiver_maps->length());
265 for (int i = 0; i < receiver_maps->length(); i++) { 277 for (int i = 0; i < receiver_maps->length(); i++) {
266 types.Add(HeapType::Class(receiver_maps->at(i), isolate)); 278 types.Add(HeapType::Class(receiver_maps->at(i), isolate));
267 } 279 }
268 CodeHandleList handlers(receiver_maps->length()); 280 CodeHandleList handlers(receiver_maps->length());
269 ElementHandlerCompiler compiler(isolate); 281 ElementHandlerCompiler compiler(isolate);
270 compiler.CompileElementHandlers(receiver_maps, &handlers); 282 compiler.CompileElementHandlers(receiver_maps, &handlers);
271 PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC); 283 PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC, extra_ic_state);
272 Handle<Code> code = ic_compiler.CompilePolymorphic( 284 Handle<Code> code = ic_compiler.CompilePolymorphic(
273 &types, &handlers, isolate->factory()->empty_string(), Code::NORMAL, 285 &types, &handlers, isolate->factory()->empty_string(), Code::NORMAL,
274 ELEMENT); 286 ELEMENT);
275 287
276 isolate->counters()->keyed_load_polymorphic_stubs()->Increment(); 288 isolate->counters()->keyed_load_polymorphic_stubs()->Increment();
277 289
278 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); 290 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
279 return code; 291 return code;
280 } 292 }
281 293
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 461
450 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); 462 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss);
451 463
452 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); 464 return GetCode(kind(), Code::NORMAL, factory()->empty_string());
453 } 465 }
454 466
455 467
456 #undef __ 468 #undef __
457 } 469 }
458 } // namespace v8::internal 470 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic-compiler.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698