Commit a6882e82 authored by verwaest's avatar verwaest Committed by Commit bot

Keyed IC cleanup: we always return Handle<Code>(), so just return void instead.

BUG=

Review URL: https://codereview.chromium.org/1853373004

Cr-Commit-Position: refs/heads/master@{#35299}
parent cf8de862
...@@ -592,8 +592,8 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { ...@@ -592,8 +592,8 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
if (FLAG_use_ic) { if (FLAG_use_ic) {
DCHECK(UseVector()); DCHECK(UseVector());
ConfigureVectorState(MEGAMORPHIC); ConfigureVectorState(MEGAMORPHIC);
TRACE_IC("LoadIC", name);
TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index"); TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index");
TRACE_IC("LoadIC", name);
} }
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, ASSIGN_RETURN_ON_EXCEPTION(isolate(), result,
...@@ -1188,8 +1188,7 @@ static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { ...@@ -1188,8 +1188,7 @@ static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) {
return key; return key;
} }
void KeyedLoadIC::UpdateLoadElement(Handle<HeapObject> receiver) {
Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
Handle<Map> receiver_map(receiver->map(), isolate()); Handle<Map> receiver_map(receiver->map(), isolate());
DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE); // Checked by caller. DCHECK(receiver_map->instance_type() != JS_VALUE_TYPE); // Checked by caller.
MapHandleList target_receiver_maps; MapHandleList target_receiver_maps;
...@@ -1199,15 +1198,14 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { ...@@ -1199,15 +1198,14 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
Handle<Code> handler = Handle<Code> handler =
PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
receiver_map, extra_ic_state()); receiver_map, extra_ic_state());
ConfigureVectorState(Handle<Name>::null(), receiver_map, handler); return ConfigureVectorState(Handle<Name>(), receiver_map, handler);
return Handle<Code>();
} }
for (int i = 0; i < target_receiver_maps.length(); i++) { for (int i = 0; i < target_receiver_maps.length(); i++) {
if (!target_receiver_maps.at(i).is_null() && if (!target_receiver_maps.at(i).is_null() &&
target_receiver_maps.at(i)->instance_type() == JS_VALUE_TYPE) { target_receiver_maps.at(i)->instance_type() == JS_VALUE_TYPE) {
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue"); TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "JSValue");
return Handle<Code>(); return;
} }
} }
...@@ -1225,8 +1223,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { ...@@ -1225,8 +1223,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
Handle<Code> handler = Handle<Code> handler =
PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
receiver_map, extra_ic_state()); receiver_map, extra_ic_state());
ConfigureVectorState(Handle<Name>::null(), receiver_map, handler); return ConfigureVectorState(Handle<Name>(), receiver_map, handler);
return Handle<Code>();
} }
DCHECK(state() != GENERIC); DCHECK(state() != GENERIC);
...@@ -1237,21 +1234,20 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) { ...@@ -1237,21 +1234,20 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<HeapObject> receiver) {
// If the miss wasn't due to an unseen map, a polymorphic stub // If the miss wasn't due to an unseen map, a polymorphic stub
// won't help, use the generic stub. // won't help, use the generic stub.
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice"); TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "same map added twice");
return Handle<Code>(); return;
} }
// If the maximum number of receiver maps has been exceeded, use the generic // If the maximum number of receiver maps has been exceeded, use the generic
// version of the IC. // version of the IC.
if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { if (target_receiver_maps.length() > kMaxKeyedPolymorphism) {
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded"); TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "max polymorph exceeded");
return Handle<Code>(); return;
} }
CodeHandleList handlers(target_receiver_maps.length()); CodeHandleList handlers(target_receiver_maps.length());
ElementHandlerCompiler compiler(isolate()); ElementHandlerCompiler compiler(isolate());
compiler.CompileElementHandlers(&target_receiver_maps, &handlers); compiler.CompileElementHandlers(&target_receiver_maps, &handlers);
ConfigureVectorState(Handle<Name>::null(), &target_receiver_maps, &handlers); ConfigureVectorState(Handle<Name>(), &target_receiver_maps, &handlers);
return Handle<Code>();
} }
...@@ -1266,7 +1262,6 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, ...@@ -1266,7 +1262,6 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
} }
Handle<Object> load_handle; Handle<Object> load_handle;
Handle<Code> stub;
// Check for non-string values that can be converted into an // Check for non-string values that can be converted into an
// internalized string directly or is representable as a smi. // internalized string directly or is representable as a smi.
...@@ -1280,19 +1275,15 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object, ...@@ -1280,19 +1275,15 @@ MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
!object->IsJSValue()) { !object->IsJSValue()) {
if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { if (object->IsJSObject() || (object->IsString() && key->IsNumber())) {
Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); Handle<HeapObject> receiver = Handle<HeapObject>::cast(object);
if (object->IsString() || key->IsSmi()) stub = LoadElementStub(receiver); if (object->IsString() || key->IsSmi()) UpdateLoadElement(receiver);
} }
} }
DCHECK(UseVector());
if (!is_vector_set()) { if (!is_vector_set()) {
if (stub.is_null()) { ConfigureVectorState(MEGAMORPHIC);
ConfigureVectorState(MEGAMORPHIC); TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic");
TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic");
}
TRACE_IC("LoadIC", key);
} }
TRACE_IC("LoadIC", key);
if (!load_handle.is_null()) return load_handle; if (!load_handle.is_null()) return load_handle;
...@@ -1692,9 +1683,8 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1692,9 +1683,8 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
return slow_stub(); return slow_stub();
} }
void KeyedStoreIC::UpdateStoreElement(Handle<Map> receiver_map,
Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
KeyedAccessStoreMode store_mode) {
MapHandleList target_receiver_maps; MapHandleList target_receiver_maps;
TargetMaps(&target_receiver_maps); TargetMaps(&target_receiver_maps);
if (target_receiver_maps.length() == 0) { if (target_receiver_maps.length() == 0) {
...@@ -1704,8 +1694,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1704,8 +1694,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
Handle<Code> handler = Handle<Code> handler =
PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
monomorphic_map, language_mode(), store_mode); monomorphic_map, language_mode(), store_mode);
ConfigureVectorState(Handle<Name>::null(), monomorphic_map, handler); return ConfigureVectorState(Handle<Name>(), monomorphic_map, handler);
return Handle<Code>();
} }
// There are several special cases where an IC that is MONOMORPHIC can still // There are several special cases where an IC that is MONOMORPHIC can still
...@@ -1731,22 +1720,21 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1731,22 +1720,21 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
Handle<Code> handler = Handle<Code> handler =
PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
transitioned_receiver_map, language_mode(), store_mode); transitioned_receiver_map, language_mode(), store_mode);
ConfigureVectorState(Handle<Name>::null(), transitioned_receiver_map, ConfigureVectorState(Handle<Name>(), transitioned_receiver_map, handler);
handler); return;
return Handle<Code>(); }
} else if (receiver_map.is_identical_to(previous_receiver_map) && if (receiver_map.is_identical_to(previous_receiver_map) &&
old_store_mode == STANDARD_STORE && old_store_mode == STANDARD_STORE &&
(store_mode == STORE_AND_GROW_NO_TRANSITION || (store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
store_mode == STORE_NO_TRANSITION_HANDLE_COW)) { store_mode == STORE_NO_TRANSITION_HANDLE_COW)) {
// A "normal" IC that handles stores can switch to a version that can // A "normal" IC that handles stores can switch to a version that can
// grow at the end of the array, handle OOB accesses or copy COW arrays // grow at the end of the array, handle OOB accesses or copy COW arrays
// and still stay MONOMORPHIC. // and still stay MONOMORPHIC.
Handle<Code> handler = Handle<Code> handler =
PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
receiver_map, language_mode(), store_mode); receiver_map, language_mode(), store_mode);
ConfigureVectorState(Handle<Name>::null(), receiver_map, handler); return ConfigureVectorState(Handle<Name>(), receiver_map, handler);
return Handle<Code>();
} }
} }
...@@ -1766,14 +1754,12 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1766,14 +1754,12 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
// If the miss wasn't due to an unseen map, a polymorphic stub // If the miss wasn't due to an unseen map, a polymorphic stub
// won't help, use the megamorphic stub which can handle everything. // won't help, use the megamorphic stub which can handle everything.
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "same map added twice"); TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "same map added twice");
return Handle<Code>(); return;
} }
// If the maximum number of receiver maps has been exceeded, use the // If the maximum number of receiver maps has been exceeded, use the
// megamorphic version of the IC. // megamorphic version of the IC.
if (target_receiver_maps.length() > kMaxKeyedPolymorphism) { if (target_receiver_maps.length() > kMaxKeyedPolymorphism) return;
return Handle<Code>();
}
// Make sure all polymorphic handlers have the same store mode, otherwise the // Make sure all polymorphic handlers have the same store mode, otherwise the
// megamorphic stub must be used. // megamorphic stub must be used.
...@@ -1783,7 +1769,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1783,7 +1769,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
store_mode = old_store_mode; store_mode = old_store_mode;
} else if (store_mode != old_store_mode) { } else if (store_mode != old_store_mode) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "store mode mismatch"); TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "store mode mismatch");
return Handle<Code>(); return;
} }
} }
...@@ -1801,7 +1787,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1801,7 +1787,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
external_arrays != target_receiver_maps.length()) { external_arrays != target_receiver_maps.length()) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
"unsupported combination of external and normal arrays"); "unsupported combination of external and normal arrays");
return Handle<Code>(); return;
} }
} }
...@@ -1811,7 +1797,6 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map, ...@@ -1811,7 +1797,6 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<Map> receiver_map,
&target_receiver_maps, &transitioned_maps, &handlers, store_mode, &target_receiver_maps, &transitioned_maps, &handlers, store_mode,
language_mode()); language_mode());
ConfigureVectorState(&target_receiver_maps, &transitioned_maps, &handlers); ConfigureVectorState(&target_receiver_maps, &transitioned_maps, &handlers);
return Handle<Code>();
} }
...@@ -1984,7 +1969,6 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1984,7 +1969,6 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
value, language_mode()), value, language_mode()),
Object); Object);
Handle<Code> stub;
if (use_ic) { if (use_ic) {
if (!old_receiver_map.is_null()) { if (!old_receiver_map.is_null()) {
if (sloppy_arguments_elements) { if (sloppy_arguments_elements) {
...@@ -1995,7 +1979,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1995,7 +1979,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
// other non-dictionary receivers in the polymorphic case benefit // other non-dictionary receivers in the polymorphic case benefit
// from fast path keyed stores. // from fast path keyed stores.
if (!old_receiver_map->DictionaryElementsInPrototypeChainOnly()) { if (!old_receiver_map->DictionaryElementsInPrototypeChainOnly()) {
stub = StoreElementStub(old_receiver_map, store_mode); UpdateStoreElement(old_receiver_map, store_mode);
} else { } else {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
"dictionary or proxy prototype"); "dictionary or proxy prototype");
...@@ -2009,11 +1993,8 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -2009,11 +1993,8 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
} }
if (!is_vector_set()) { if (!is_vector_set()) {
if (stub.is_null() || *stub == *slow_stub()) { ConfigureVectorState(MEGAMORPHIC);
ConfigureVectorState(MEGAMORPHIC); TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic");
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC",
stub.is_null() ? "set generic" : "slow stub");
}
} }
TRACE_IC("StoreIC", key); TRACE_IC("StoreIC", key);
......
...@@ -376,7 +376,7 @@ class KeyedLoadIC : public LoadIC { ...@@ -376,7 +376,7 @@ class KeyedLoadIC : public LoadIC {
protected: protected:
// receiver is HeapObject because it could be a String or a JSObject // receiver is HeapObject because it could be a String or a JSObject
Handle<Code> LoadElementStub(Handle<HeapObject> receiver); void UpdateLoadElement(Handle<HeapObject> receiver);
private: private:
friend class IC; friend class IC;
...@@ -492,8 +492,8 @@ class KeyedStoreIC : public StoreIC { ...@@ -492,8 +492,8 @@ class KeyedStoreIC : public StoreIC {
static void Clear(Isolate* isolate, Code* host, KeyedStoreICNexus* nexus); static void Clear(Isolate* isolate, Code* host, KeyedStoreICNexus* nexus);
protected: protected:
Handle<Code> StoreElementStub(Handle<Map> receiver_map, void UpdateStoreElement(Handle<Map> receiver_map,
KeyedAccessStoreMode store_mode); KeyedAccessStoreMode store_mode);
private: private:
Handle<Map> ComputeTransitionedMap(Handle<Map> map, Handle<Map> ComputeTransitionedMap(Handle<Map> map,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment