Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Only treat lookup-slot-calls going through 'with' special
Browse files Browse the repository at this point in the history
This replaces LOOKUP_SLOT_CALL with WITH_CALL, and relies on regular lookup-slot handling in variable load to support other lookup slots (variables resolved in the context of sloppy eval). This allows optimizations for such variable loads to kick in for calls as well. We only need special handling for function calls in the context of with, since it changes the receiver of the call from undefined/global to the with-object.

This currently doesn't yet make it work for the direct eval call itself, since the POSSIBLY_EVAL_CALL flag is also used to deal with direct eval later.

BUG=

Review-Url: https://codereview.chromium.org/2480253006
Cr-Commit-Position: refs/heads/master@{#40962}
  • Loading branch information
verwaest authored and Commit bot committed Nov 14, 2016
1 parent 1c9528c commit 733af7e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/ast/ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,9 @@ Call::CallType Call::GetCallType() const {
} else if (proxy->var()->IsUnallocated()) {
return GLOBAL_CALL;
} else if (proxy->var()->IsLookupSlot()) {
return LOOKUP_SLOT_CALL;
// Calls going through 'with' always use DYNAMIC rather than DYNAMIC_LOCAL
// or DYNAMIC_GLOBAL.
return proxy->var()->mode() == DYNAMIC ? WITH_CALL : OTHER_CALL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ class Call final : public Expression {
enum CallType {
POSSIBLY_EVAL_CALL,
GLOBAL_CALL,
LOOKUP_SLOT_CALL,
WITH_CALL,
NAMED_PROPERTY_CALL,
KEYED_PROPERTY_CALL,
NAMED_SUPER_PROPERTY_CALL,
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ast-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ void AstGraphBuilder::VisitCall(Call* expr) {
receiver_value = jsgraph()->UndefinedConstant();
break;
}
case Call::LOOKUP_SLOT_CALL: {
case Call::WITH_CALL: {
Variable* variable = callee->AsVariableProxy()->var();
DCHECK(variable->location() == VariableLocation::LOOKUP);
Node* name = jsgraph()->Constant(variable->name());
Expand Down
4 changes: 2 additions & 2 deletions src/full-codegen/full-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,8 @@ void FullCodeGenerator::VisitCall(Call* expr) {
case Call::GLOBAL_CALL:
EmitCallWithLoadIC(expr);
break;
case Call::LOOKUP_SLOT_CALL:
// Call to a lookup slot (dynamically introduced variable).
case Call::WITH_CALL:
// Call to a lookup slot looked up through a with scope.
PushCalleeAndWithBaseObject(expr);
EmitCall(expr);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/bytecode-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ void BytecodeGenerator::VisitCall(Call* expr) {
builder()->StoreAccumulatorInRegister(callee);
break;
}
case Call::LOOKUP_SLOT_CALL:
case Call::WITH_CALL:
case Call::POSSIBLY_EVAL_CALL: {
if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) {
RegisterAllocationScope inner_register_scope(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 83
bytecode array length: 82
bytecodes: [
B(CreateFunctionContext), U8(3),
B(PushContext), R(0),
Expand Down Expand Up @@ -41,9 +41,10 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), U8(6),
B(Star), R(1),
/* 52 E> */ B(Call), R(1), R(2), U8(2), U8(2),
/* 62 S> */ B(LdaConstant), U8(1),
B(Star), R(3),
B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), R(3), U8(1), R(1),
/* 62 S> */ B(LdaUndefined),
B(Star), R(2),
/* 69 E> */ B(LdaLookupGlobalSlot), U8(1), U8(8), U8(1),
B(Star), R(1),
/* 69 E> */ B(Call), R(1), R(2), U8(1), U8(6),
/* 74 S> */ B(Return),
]
Expand Down

0 comments on commit 733af7e

Please sign in to comment.