Commit 5728ac61 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[api] Only support direct hidden prototypes for API call optimizations

There are only two users of hidden prototypes left and they both only have 1 level. This slightly simplifies the handcrafted code.

Bug: v8:5561
Change-Id: I674e72f1465ccbe75c0bb63f7eea3525830145cb
Reviewed-on: https://chromium-review.googlesource.com/512745Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45503}
parent ee3729d2
...@@ -199,9 +199,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -199,9 +199,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -209,10 +207,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -209,10 +207,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ ldr(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -134,9 +134,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -134,9 +134,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Mov(holder, receiver); __ Mov(holder, receiver);
...@@ -144,10 +142,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -144,10 +142,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ Ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ Ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ Ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ Ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ Ldr(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ Ldr(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -20,10 +20,8 @@ CallOptimization::CallOptimization(Handle<Object> function) { ...@@ -20,10 +20,8 @@ CallOptimization::CallOptimization(Handle<Object> function) {
} }
} }
Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
Handle<Map> object_map, HolderLookup* holder_lookup, Handle<Map> object_map, HolderLookup* holder_lookup) const {
int* holder_depth_in_prototype_chain) const {
DCHECK(is_simple_api_call()); DCHECK(is_simple_api_call());
if (!object_map->IsJSObjectMap()) { if (!object_map->IsJSObjectMap()) {
*holder_lookup = kHolderNotFound; *holder_lookup = kHolderNotFound;
...@@ -34,15 +32,11 @@ Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( ...@@ -34,15 +32,11 @@ Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
*holder_lookup = kHolderIsReceiver; *holder_lookup = kHolderIsReceiver;
return Handle<JSObject>::null(); return Handle<JSObject>::null();
} }
for (int depth = 1; true; depth++) { if (object_map->has_hidden_prototype()) {
if (!object_map->has_hidden_prototype()) break;
Handle<JSObject> prototype(JSObject::cast(object_map->prototype())); Handle<JSObject> prototype(JSObject::cast(object_map->prototype()));
object_map = handle(prototype->map()); object_map = handle(prototype->map());
if (expected_receiver_type_->IsTemplateFor(*object_map)) { if (expected_receiver_type_->IsTemplateFor(*object_map)) {
*holder_lookup = kHolderFound; *holder_lookup = kHolderFound;
if (holder_depth_in_prototype_chain != NULL) {
*holder_depth_in_prototype_chain = depth;
}
return prototype; return prototype;
} }
} }
......
...@@ -38,8 +38,7 @@ class CallOptimization BASE_EMBEDDED { ...@@ -38,8 +38,7 @@ class CallOptimization BASE_EMBEDDED {
enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound }; enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound };
Handle<JSObject> LookupHolderOfExpectedType( Handle<JSObject> LookupHolderOfExpectedType(
Handle<Map> receiver_map, HolderLookup* holder_lookup, Handle<Map> receiver_map, HolderLookup* holder_lookup) const;
int* holder_depth_in_prototype_chain = NULL) const;
// Check if the api holder is between the receiver and the holder. // Check if the api holder is between the receiver and the holder.
bool IsCompatibleReceiver(Handle<Object> receiver, bool IsCompatibleReceiver(Handle<Object> receiver,
......
...@@ -139,9 +139,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -139,9 +139,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -149,10 +147,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -149,10 +147,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset)); __ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ mov(holder, FieldOperand(holder, Map::kPrototypeOffset)); __ mov(holder, FieldOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ mov(holder, FieldOperand(holder, HeapObject::kMapOffset));
__ mov(holder, FieldOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -189,9 +189,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -189,9 +189,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -199,10 +197,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -199,10 +197,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ lw(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ lw(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ lw(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ lw(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ lw(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ lw(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -188,9 +188,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -188,9 +188,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -198,10 +196,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -198,10 +196,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ Ld(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ Ld(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ Ld(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ Ld(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ Ld(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ Ld(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -194,9 +194,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -194,9 +194,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -204,10 +202,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -204,10 +202,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ LoadP(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -186,9 +186,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -186,9 +186,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -196,10 +194,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -196,10 +194,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset)); __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ LoadP(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
__ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -117,9 +117,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -117,9 +117,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -127,10 +125,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -127,10 +125,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ movp(holder, FieldOperand(receiver, HeapObject::kMapOffset)); __ movp(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ movp(holder, FieldOperand(holder, Map::kPrototypeOffset)); __ movp(holder, FieldOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ movp(holder, FieldOperand(holder, HeapObject::kMapOffset));
__ movp(holder, FieldOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
...@@ -138,9 +138,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -138,9 +138,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place. // Put holder in place.
CallOptimization::HolderLookup holder_lookup; CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0; optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
switch (holder_lookup) { switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver: case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver); __ Move(holder, receiver);
...@@ -148,10 +146,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( ...@@ -148,10 +146,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound: case CallOptimization::kHolderFound:
__ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset)); __ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ mov(holder, FieldOperand(holder, Map::kPrototypeOffset)); __ mov(holder, FieldOperand(holder, Map::kPrototypeOffset));
for (int i = 1; i < holder_depth; i++) {
__ mov(holder, FieldOperand(holder, HeapObject::kMapOffset));
__ mov(holder, FieldOperand(holder, Map::kPrototypeOffset));
}
break; break;
case CallOptimization::kHolderNotFound: case CallOptimization::kHolderNotFound:
UNREACHABLE(); UNREACHABLE();
......
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