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

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: better fix 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
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 // Update key type
Jakob Kummerow 2014/12/10 15:21:18 nit: punctuation (but see comment on next line).
68 IcCheckType key_type = name->IsString() ? PROPERTY : ELEMENT;
Jakob Kummerow 2014/12/10 15:21:18 This distinction doesn't make sense, we only ever
69
70 extra_ic_state = KeyedLoadIC::ComputeExtraICState(key_type);
66 } 71 }
67 72
68 Handle<Code> ic; 73 Handle<Code> ic;
69 // There are multiple string maps that all use the same prototype. That 74 // 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, 75 // prototype cannot hold multiple handlers, one for each of the string maps,
71 // for a single name. Hence, turn off caching of the IC. 76 // for a single name. Hence, turn off caching of the IC.
72 bool can_be_cached = !type->Is(HeapType::String()); 77 bool can_be_cached = !type->Is(HeapType::String());
73 if (can_be_cached) { 78 if (can_be_cached) {
74 ic = Find(name, stub_holder, kind, extra_ic_state, flag); 79 ic = Find(name, stub_holder, kind, extra_ic_state, flag);
75 if (!ic.is_null()) return ic; 80 if (!ic.is_null()) return ic;
76 } 81 }
77 82
78 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); 83 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag);
79 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY); 84 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY);
80 85
81 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); 86 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic);
82 return ic; 87 return ic;
83 } 88 }
84 89
85 90
86 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic( 91 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic(
87 Handle<Map> receiver_map) { 92 Handle<Map> receiver_map, IcCheckType key_type) {
88 Isolate* isolate = receiver_map->GetIsolate(); 93 Isolate* isolate = receiver_map->GetIsolate();
89 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); 94 ExtraICState extra_state =
95 KeyedLoadIC::ComputeExtraICState(key_type);
96 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC,
97 extra_state);
90 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string(); 98 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string();
91 99
92 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); 100 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
93 if (probe->IsCode()) return Handle<Code>::cast(probe); 101 if (probe->IsCode()) return Handle<Code>::cast(probe);
94 102
95 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map); 103 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map);
96 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC); 104 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC, extra_state);
97 Handle<Code> code = 105 Handle<Code> code =
98 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub, 106 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub,
99 isolate->factory()->empty_string(), ELEMENT); 107 isolate->factory()->empty_string(), ELEMENT);
100 108
101 Map::UpdateCodeCache(receiver_map, name, code); 109 Map::UpdateCodeCache(receiver_map, name, code);
102 return code; 110 return code;
103 } 111 }
104 112
105 113
106 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( 114 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!receiver_map->is_dictionary_map()) { 254 if (!receiver_map->is_dictionary_map()) {
247 Map::UpdateCodeCache(receiver_map, name, ic); 255 Map::UpdateCodeCache(receiver_map, name, ic);
248 } 256 }
249 257
250 return ic; 258 return ic;
251 } 259 }
252 260
253 261
254 // TODO(verwaest): Change this method so it takes in a TypeHandleList. 262 // TODO(verwaest): Change this method so it takes in a TypeHandleList.
255 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic( 263 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic(
256 MapHandleList* receiver_maps) { 264 MapHandleList* receiver_maps, IcCheckType key_type) {
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 ExtraICState extra_state =
267 KeyedLoadIC::ComputeExtraICState(key_type);
268 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC,
269 POLYMORPHIC,
270 extra_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_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 key_type);
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
282 294
283 Handle<Code> PropertyICCompiler::ComputePolymorphic( 295 Handle<Code> PropertyICCompiler::ComputePolymorphic(
284 Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers, 296 Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers,
(...skipping 164 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

Powered by Google App Engine
This is Rietveld 408576698