Commit 9129547b authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[ic] Optimize CallOptimization

Instead of calling LookupHolderOfExpectedType twice, call it once
and pass the result to IsCompatibleReceiverMap.

Removes unnecessary IsCompatibleReceiver function.

Bug: v8:9805
Change-Id: I1333449d10702e824dddbdbca5c87e639a7d7118
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692187
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72695}
parent eed0d27c
...@@ -60,19 +60,10 @@ Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( ...@@ -60,19 +60,10 @@ Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
return Handle<JSObject>::null(); return Handle<JSObject>::null();
} }
bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver, bool CallOptimization::IsCompatibleReceiverMap(
Handle<JSObject> holder) const { Handle<JSObject> api_holder, Handle<JSObject> holder,
HolderLookup holder_lookup) const {
DCHECK(is_simple_api_call()); DCHECK(is_simple_api_call());
if (!receiver->IsHeapObject()) return false;
Handle<Map> map(HeapObject::cast(*receiver).map(), holder->GetIsolate());
return IsCompatibleReceiverMap(map, holder);
}
bool CallOptimization::IsCompatibleReceiverMap(Handle<Map> map,
Handle<JSObject> holder) const {
HolderLookup holder_lookup;
Handle<JSObject> api_holder = LookupHolderOfExpectedType(map, &holder_lookup);
switch (holder_lookup) { switch (holder_lookup) {
case kHolderNotFound: case kHolderNotFound:
return false; return false;
......
...@@ -42,13 +42,8 @@ class CallOptimization { ...@@ -42,13 +42,8 @@ class CallOptimization {
Handle<JSObject> LookupHolderOfExpectedType( Handle<JSObject> LookupHolderOfExpectedType(
Handle<Map> receiver_map, HolderLookup* holder_lookup) const; Handle<Map> receiver_map, HolderLookup* holder_lookup) const;
// Check if the api holder is between the receiver and the holder. bool IsCompatibleReceiverMap(Handle<JSObject> api_holder,
bool IsCompatibleReceiver(Handle<Object> receiver, Handle<JSObject> holder, HolderLookup) const;
Handle<JSObject> holder) const;
// Check if the api holder is between the receiver and the holder.
bool IsCompatibleReceiverMap(Handle<Map> receiver_map,
Handle<JSObject> holder) const;
private: private:
void Initialize(Isolate* isolate, Handle<JSFunction> function); void Initialize(Isolate* isolate, Handle<JSFunction> function);
......
...@@ -888,15 +888,17 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) { ...@@ -888,15 +888,17 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
CallOptimization call_optimization(isolate(), getter); CallOptimization call_optimization(isolate(), getter);
if (call_optimization.is_simple_api_call()) { if (call_optimization.is_simple_api_call()) {
if (!call_optimization.IsCompatibleReceiverMap(map, holder) || CallOptimization::HolderLookup holder_lookup;
Handle<JSObject> api_holder =
call_optimization.LookupHolderOfExpectedType(map, &holder_lookup);
if (!call_optimization.IsCompatibleReceiverMap(api_holder, holder,
holder_lookup) ||
!holder->HasFastProperties()) { !holder->HasFastProperties()) {
TRACE_HANDLER_STATS(isolate(), LoadIC_SlowStub); TRACE_HANDLER_STATS(isolate(), LoadIC_SlowStub);
return LoadHandler::LoadSlow(isolate()); return LoadHandler::LoadSlow(isolate());
} }
CallOptimization::HolderLookup holder_lookup;
call_optimization.LookupHolderOfExpectedType(map, &holder_lookup);
smi_handler = LoadHandler::LoadApiGetter( smi_handler = LoadHandler::LoadApiGetter(
isolate(), holder_lookup == CallOptimization::kHolderIsReceiver); isolate(), holder_lookup == CallOptimization::kHolderIsReceiver);
...@@ -1747,11 +1749,12 @@ MaybeObjectHandle StoreIC::ComputeHandler(LookupIterator* lookup) { ...@@ -1747,11 +1749,12 @@ MaybeObjectHandle StoreIC::ComputeHandler(LookupIterator* lookup) {
CallOptimization call_optimization(isolate(), setter); CallOptimization call_optimization(isolate(), setter);
if (call_optimization.is_simple_api_call()) { if (call_optimization.is_simple_api_call()) {
if (call_optimization.IsCompatibleReceiver(receiver, holder)) {
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
Handle<JSObject> api_holder =
call_optimization.LookupHolderOfExpectedType( call_optimization.LookupHolderOfExpectedType(
lookup_start_object_map(), &holder_lookup); lookup_start_object_map(), &holder_lookup);
if (call_optimization.IsCompatibleReceiverMap(api_holder, holder,
holder_lookup)) {
Handle<Smi> smi_handler = StoreHandler::StoreApiSetter( Handle<Smi> smi_handler = StoreHandler::StoreApiSetter(
isolate(), isolate(),
holder_lookup == CallOptimization::kHolderIsReceiver); holder_lookup == CallOptimization::kHolderIsReceiver);
......
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