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

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: rebase again 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.h ('k') | src/type-info.h » ('j') | src/typing.cc » ('J')
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) {
88 Isolate* isolate = receiver_map->GetIsolate(); 91 Isolate* isolate = receiver_map->GetIsolate();
92 DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT);
89 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); 93 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC);
90 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string(); 94 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string();
91 95
92 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); 96 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
93 if (probe->IsCode()) return Handle<Code>::cast(probe); 97 if (probe->IsCode()) return Handle<Code>::cast(probe);
94 98
95 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map); 99 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map);
96 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC); 100 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC);
97 Handle<Code> code = 101 Handle<Code> code =
98 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub, 102 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 252 }
249 253
250 return ic; 254 return ic;
251 } 255 }
252 256
253 257
254 // TODO(verwaest): Change this method so it takes in a TypeHandleList. 258 // TODO(verwaest): Change this method so it takes in a TypeHandleList.
255 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic( 259 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic(
256 MapHandleList* receiver_maps) { 260 MapHandleList* receiver_maps) {
257 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); 261 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
262 DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT);
258 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); 263 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
259 Handle<PolymorphicCodeCache> cache = 264 Handle<PolymorphicCodeCache> cache =
260 isolate->factory()->polymorphic_code_cache(); 265 isolate->factory()->polymorphic_code_cache();
261 Handle<Object> probe = cache->Lookup(receiver_maps, flags); 266 Handle<Object> probe = cache->Lookup(receiver_maps, flags);
262 if (probe->IsCode()) return Handle<Code>::cast(probe); 267 if (probe->IsCode()) return Handle<Code>::cast(probe);
263 268
264 TypeHandleList types(receiver_maps->length()); 269 TypeHandleList types(receiver_maps->length());
265 for (int i = 0; i < receiver_maps->length(); i++) { 270 for (int i = 0; i < receiver_maps->length(); i++) {
266 types.Add(HeapType::Class(receiver_maps->at(i), isolate)); 271 types.Add(HeapType::Class(receiver_maps->at(i), isolate));
267 } 272 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 454
450 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); 455 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss);
451 456
452 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); 457 return GetCode(kind(), Code::NORMAL, factory()->empty_string());
453 } 458 }
454 459
455 460
456 #undef __ 461 #undef __
457 } 462 }
458 } // namespace v8::internal 463 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic.h ('k') | src/type-info.h » ('j') | src/typing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698