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

Side by Side Diff: src/ic/ic.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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 return key; 1226 return key;
1227 } 1227 }
1228 1228
1229 1229
1230 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { 1230 Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
1231 Handle<Map> receiver_map(receiver->map(), isolate()); 1231 Handle<Map> receiver_map(receiver->map(), isolate());
1232 MapHandleList target_receiver_maps; 1232 MapHandleList target_receiver_maps;
1233 TargetMaps(&target_receiver_maps); 1233 TargetMaps(&target_receiver_maps);
1234 1234
1235 if (target_receiver_maps.length() == 0) { 1235 if (target_receiver_maps.length() == 0) {
1236 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); 1236 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map,
1237 extra_ic_state(),
1238 ELEMENT);
1237 } 1239 }
1238 1240
1239 // The first time a receiver is seen that is a transitioned version of the 1241 // The first time a receiver is seen that is a transitioned version of the
1240 // previous monomorphic receiver type, assume the new ElementsKind is the 1242 // previous monomorphic receiver type, assume the new ElementsKind is the
1241 // monomorphic type. This benefits global arrays that only transition 1243 // monomorphic type. This benefits global arrays that only transition
1242 // once, and all call sites accessing them are faster if they remain 1244 // once, and all call sites accessing them are faster if they remain
1243 // monomorphic. If this optimistic assumption is not true, the IC will 1245 // monomorphic. If this optimistic assumption is not true, the IC will
1244 // miss again and it will become polymorphic and support both the 1246 // miss again and it will become polymorphic and support both the
1245 // untransitioned and transitioned maps. 1247 // untransitioned and transitioned maps.
1246 if (state() == MONOMORPHIC && !receiver->IsString() && 1248 if (state() == MONOMORPHIC && !receiver->IsString() &&
1247 IsMoreGeneralElementsKindTransition( 1249 IsMoreGeneralElementsKindTransition(
1248 target_receiver_maps.at(0)->elements_kind(), 1250 target_receiver_maps.at(0)->elements_kind(),
1249 Handle<JSObject>::cast(receiver)->GetElementsKind())) { 1251 Handle<JSObject>::cast(receiver)->GetElementsKind())) {
1250 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map); 1252 return PropertyICCompiler::ComputeKeyedLoadMonomorphic(receiver_map,
1253 extra_ic_state(),
1254 ELEMENT);
1251 } 1255 }
1252 1256
1253 DCHECK(state() != GENERIC); 1257 DCHECK(state() != GENERIC);
1254 1258
1255 // Determine the list of receiver maps that this call site has seen, 1259 // Determine the list of receiver maps that this call site has seen,
1256 // adding the map that was just encountered. 1260 // adding the map that was just encountered.
1257 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) { 1261 if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map)) {
1258 // If the miss wasn't due to an unseen map, a polymorphic stub 1262 // If the miss wasn't due to an unseen map, a polymorphic stub
1259 // won't help, use the generic stub. 1263 // won't help, use the generic stub.
1260 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); 1264 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice");
1261 return generic_stub(); 1265 return generic_stub();
1262 } 1266 }
1263 1267
1264 // If the maximum number of receiver maps has been exceeded, use the generic 1268 // If the maximum number of receiver maps has been exceeded, use the generic
1265 // version of the IC. 1269 // version of the IC.
1266 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { 1270 if (target_receiver_maps.length() > kMaxKeyedPolymorphism) {
1267 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); 1271 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded");
1268 return generic_stub(); 1272 return generic_stub();
1269 } 1273 }
1270 1274
1271 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps); 1275 return PropertyICCompiler::ComputeKeyedLoadPolymorphic(&target_receiver_maps,
1276 extra_ic_state(),
1277 ELEMENT);
1272 } 1278 }
1273 1279
1274 1280
1275 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, 1281 MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
1276 Handle<Object> key) { 1282 Handle<Object> key) {
1277 if (MigrateDeprecated(object)) { 1283 if (MigrateDeprecated(object)) {
1278 Handle<Object> result; 1284 Handle<Object> result;
1279 ASSIGN_RETURN_ON_EXCEPTION( 1285 ASSIGN_RETURN_ON_EXCEPTION(
1280 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key), 1286 isolate(), result, Runtime::GetObjectProperty(isolate(), object, key),
1281 Object); 1287 Object);
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 static const Address IC_utilities[] = { 2787 static const Address IC_utilities[] = {
2782 #define ADDR(name) FUNCTION_ADDR(name), 2788 #define ADDR(name) FUNCTION_ADDR(name),
2783 IC_UTIL_LIST(ADDR) NULL 2789 IC_UTIL_LIST(ADDR) NULL
2784 #undef ADDR 2790 #undef ADDR
2785 }; 2791 };
2786 2792
2787 2793
2788 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 2794 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
2789 } 2795 }
2790 } // namespace v8::internal 2796 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698