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(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -209,10 +207,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -134,9 +134,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Mov(holder, receiver);
......@@ -144,10 +142,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ Ldr(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -20,10 +20,8 @@ CallOptimization::CallOptimization(Handle<Object> function) {
}
}
Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
Handle<Map> object_map, HolderLookup* holder_lookup,
int* holder_depth_in_prototype_chain) const {
Handle<Map> object_map, HolderLookup* holder_lookup) const {
DCHECK(is_simple_api_call());
if (!object_map->IsJSObjectMap()) {
*holder_lookup = kHolderNotFound;
......@@ -34,15 +32,11 @@ Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
*holder_lookup = kHolderIsReceiver;
return Handle<JSObject>::null();
}
for (int depth = 1; true; depth++) {
if (!object_map->has_hidden_prototype()) break;
if (object_map->has_hidden_prototype()) {
Handle<JSObject> prototype(JSObject::cast(object_map->prototype()));
object_map = handle(prototype->map());
if (expected_receiver_type_->IsTemplateFor(*object_map)) {
*holder_lookup = kHolderFound;
if (holder_depth_in_prototype_chain != NULL) {
*holder_depth_in_prototype_chain = depth;
}
return prototype;
}
}
......
......@@ -38,8 +38,7 @@ class CallOptimization BASE_EMBEDDED {
enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound };
Handle<JSObject> LookupHolderOfExpectedType(
Handle<Map> receiver_map, HolderLookup* holder_lookup,
int* holder_depth_in_prototype_chain = NULL) const;
Handle<Map> receiver_map, HolderLookup* holder_lookup) const;
// Check if the api holder is between the receiver and the holder.
bool IsCompatibleReceiver(Handle<Object> receiver,
......
......@@ -139,9 +139,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -149,10 +147,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -189,9 +189,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -199,10 +197,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ lw(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -188,9 +188,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -198,10 +196,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ Ld(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -194,9 +194,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -204,10 +202,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -186,9 +186,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -196,10 +194,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -117,9 +117,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -127,10 +125,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ movp(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
UNREACHABLE();
......
......@@ -138,9 +138,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
// Put holder in place.
CallOptimization::HolderLookup holder_lookup;
int holder_depth = 0;
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
&holder_depth);
optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
switch (holder_lookup) {
case CallOptimization::kHolderIsReceiver:
__ Move(holder, receiver);
......@@ -148,10 +146,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall(
case CallOptimization::kHolderFound:
__ mov(holder, FieldOperand(receiver, HeapObject::kMapOffset));
__ 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;
case CallOptimization::kHolderNotFound:
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