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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2487483004: Only treat possible eval calls going through 'with' as special. (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-info.h" 10 #include "src/compilation-info.h"
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 // Receiver is undefined for global calls. 2384 // Receiver is undefined for global calls.
2385 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 2385 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
2386 // Load callee as a global variable. 2386 // Load callee as a global variable.
2387 VariableProxy* proxy = callee_expr->AsVariableProxy(); 2387 VariableProxy* proxy = callee_expr->AsVariableProxy();
2388 BuildVariableLoadForAccumulatorValue(proxy->var(), 2388 BuildVariableLoadForAccumulatorValue(proxy->var(),
2389 proxy->VariableFeedbackSlot(), 2389 proxy->VariableFeedbackSlot(),
2390 proxy->hole_check_mode()); 2390 proxy->hole_check_mode());
2391 builder()->StoreAccumulatorInRegister(callee); 2391 builder()->StoreAccumulatorInRegister(callee);
2392 break; 2392 break;
2393 } 2393 }
2394 case Call::WITH_CALL: 2394 case Call::WITH_CALL: {
2395 case Call::POSSIBLY_EVAL_CALL: { 2395 DCHECK(callee_expr->AsVariableProxy()->var()->IsLookupSlot());
2396 if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) { 2396 RegisterAllocationScope inner_register_scope(this);
2397 RegisterAllocationScope inner_register_scope(this); 2397 Register name = register_allocator()->NewRegister();
2398 Register name = register_allocator()->NewRegister();
2399 2398
2400 // Call %LoadLookupSlotForCall to get the callee and receiver. 2399 // Call %LoadLookupSlotForCall to get the callee and receiver.
2401 DCHECK(Register::AreContiguous(callee, receiver)); 2400 DCHECK(Register::AreContiguous(callee, receiver));
2402 RegisterList result_pair(callee.index(), 2); 2401 RegisterList result_pair(callee.index(), 2);
2403 Variable* variable = callee_expr->AsVariableProxy()->var(); 2402 Variable* variable = callee_expr->AsVariableProxy()->var();
2404 builder() 2403 builder()
2405 ->LoadLiteral(variable->name()) 2404 ->LoadLiteral(variable->name())
2406 .StoreAccumulatorInRegister(name) 2405 .StoreAccumulatorInRegister(name)
2407 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name, 2406 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name,
2408 result_pair); 2407 result_pair);
2409 break; 2408 break;
2410 }
2411 // Fall through.
2412 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL);
2413 } 2409 }
2414 case Call::OTHER_CALL: { 2410 case Call::OTHER_CALL:
2415 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 2411 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
2416 VisitForRegisterValue(callee_expr, callee); 2412 VisitForRegisterValue(callee_expr, callee);
2417 break; 2413 break;
2418 }
2419 case Call::NAMED_SUPER_PROPERTY_CALL: { 2414 case Call::NAMED_SUPER_PROPERTY_CALL: {
2420 Property* property = callee_expr->AsProperty(); 2415 Property* property = callee_expr->AsProperty();
2421 VisitNamedSuperPropertyLoad(property, receiver); 2416 VisitNamedSuperPropertyLoad(property, receiver);
2422 builder()->StoreAccumulatorInRegister(callee); 2417 builder()->StoreAccumulatorInRegister(callee);
2423 break; 2418 break;
2424 } 2419 }
2425 case Call::KEYED_SUPER_PROPERTY_CALL: { 2420 case Call::KEYED_SUPER_PROPERTY_CALL: {
2426 Property* property = callee_expr->AsProperty(); 2421 Property* property = callee_expr->AsProperty();
2427 VisitKeyedSuperPropertyLoad(property, receiver); 2422 VisitKeyedSuperPropertyLoad(property, receiver);
2428 builder()->StoreAccumulatorInRegister(callee); 2423 builder()->StoreAccumulatorInRegister(callee);
2429 break; 2424 break;
2430 } 2425 }
2431 case Call::SUPER_CALL: 2426 case Call::SUPER_CALL:
2432 UNREACHABLE(); 2427 UNREACHABLE();
2433 break; 2428 break;
2434 } 2429 }
2435 2430
2436 // Evaluate all arguments to the function call and store in sequential args 2431 // Evaluate all arguments to the function call and store in sequential args
2437 // registers. 2432 // registers.
2438 VisitArguments(expr->arguments(), args, 1); 2433 VisitArguments(expr->arguments(), args, 1);
2439 2434
2440 // Resolve callee for a potential direct eval call. This block will mutate the 2435 // Resolve callee for a potential direct eval call. This block will mutate the
2441 // callee value. 2436 // callee value.
2442 if (call_type == Call::POSSIBLY_EVAL_CALL && 2437 if (expr->is_possibly_eval() && expr->arguments()->length() > 0) {
2443 expr->arguments()->length() > 0) {
2444 RegisterAllocationScope inner_register_scope(this); 2438 RegisterAllocationScope inner_register_scope(this);
2445 // Set up arguments for ResolvePossiblyDirectEval by copying callee, source 2439 // Set up arguments for ResolvePossiblyDirectEval by copying callee, source
2446 // strings and function closure, and loading language and 2440 // strings and function closure, and loading language and
2447 // position. 2441 // position.
2448 RegisterList runtime_call_args = register_allocator()->NewRegisterList(6); 2442 RegisterList runtime_call_args = register_allocator()->NewRegisterList(6);
2449 builder() 2443 builder()
2450 ->MoveRegister(callee, runtime_call_args[0]) 2444 ->MoveRegister(callee, runtime_call_args[0])
2451 .MoveRegister(args[1], runtime_call_args[1]) 2445 .MoveRegister(args[1], runtime_call_args[1])
2452 .MoveRegister(Register::function_closure(), runtime_call_args[2]) 2446 .MoveRegister(Register::function_closure(), runtime_call_args[2])
2453 .LoadLiteral(Smi::FromInt(language_mode())) 2447 .LoadLiteral(Smi::FromInt(language_mode()))
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 } 3186 }
3193 3187
3194 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3188 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3195 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3189 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3196 : Runtime::kStoreKeyedToSuper_Sloppy; 3190 : Runtime::kStoreKeyedToSuper_Sloppy;
3197 } 3191 }
3198 3192
3199 } // namespace interpreter 3193 } // namespace interpreter
3200 } // namespace internal 3194 } // namespace internal
3201 } // namespace v8 3195 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698