Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2487483004: Only treat possible eval calls going through 'with' as special. (Closed)
Patch Set: Fix AstGraphBuilder Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 6f3fcb5cdf625f082c30f0f89b21a643be8601b1..ef94d2cdfb0f6fdc7248edeb6cb8088978d1ac87 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -2356,6 +2356,8 @@ void BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args,
void BytecodeGenerator::VisitCall(Call* expr) {
Expression* callee_expr = expr->expression();
Call::CallType call_type = expr->GetCallType();
+ bool possibly_eval = call_type == Call::POSSIBLY_EVAL_THROUGH_WITH_CALL ||
+ call_type == Call::POSSIBLY_EVAL_CALL;
if (call_type == Call::SUPER_CALL) {
return VisitCallSuper(expr);
@@ -2392,25 +2394,23 @@ void BytecodeGenerator::VisitCall(Call* expr) {
break;
}
case Call::WITH_CALL:
- case Call::POSSIBLY_EVAL_CALL: {
- if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) {
- RegisterAllocationScope inner_register_scope(this);
- Register name = register_allocator()->NewRegister();
-
- // Call %LoadLookupSlotForCall to get the callee and receiver.
- DCHECK(Register::AreContiguous(callee, receiver));
- RegisterList result_pair(callee.index(), 2);
- Variable* variable = callee_expr->AsVariableProxy()->var();
- builder()
- ->LoadLiteral(variable->name())
- .StoreAccumulatorInRegister(name)
- .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name,
- result_pair);
- break;
- }
- // Fall through.
- DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL);
+ case Call::POSSIBLY_EVAL_THROUGH_WITH_CALL: {
+ DCHECK(callee_expr->AsVariableProxy()->var()->IsLookupSlot());
+ RegisterAllocationScope inner_register_scope(this);
+ Register name = register_allocator()->NewRegister();
+
+ // Call %LoadLookupSlotForCall to get the callee and receiver.
+ DCHECK(Register::AreContiguous(callee, receiver));
+ RegisterList result_pair(callee.index(), 2);
+ Variable* variable = callee_expr->AsVariableProxy()->var();
+ builder()
+ ->LoadLiteral(variable->name())
+ .StoreAccumulatorInRegister(name)
+ .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name,
+ result_pair);
+ break;
}
+ case Call::POSSIBLY_EVAL_CALL:
case Call::OTHER_CALL: {
builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
VisitForRegisterValue(callee_expr, callee);
@@ -2439,8 +2439,7 @@ void BytecodeGenerator::VisitCall(Call* expr) {
// Resolve callee for a potential direct eval call. This block will mutate the
// callee value.
- if (call_type == Call::POSSIBLY_EVAL_CALL &&
- expr->arguments()->length() > 0) {
+ if (possibly_eval && expr->arguments()->length() > 0) {
RegisterAllocationScope inner_register_scope(this);
// Set up arguments for ResolvePossiblyDirectEval by copying callee, source
// strings and function closure, and loading language and

Powered by Google App Engine
This is Rietveld 408576698