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

Side by Side 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 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 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 size_t first_argument_register) { 2349 size_t first_argument_register) {
2350 // Visit arguments. 2350 // Visit arguments.
2351 for (int i = 0; i < static_cast<int>(args->length()); i++) { 2351 for (int i = 0; i < static_cast<int>(args->length()); i++) {
2352 VisitForRegisterValue(args->at(i), arg_regs[first_argument_register + i]); 2352 VisitForRegisterValue(args->at(i), arg_regs[first_argument_register + i]);
2353 } 2353 }
2354 } 2354 }
2355 2355
2356 void BytecodeGenerator::VisitCall(Call* expr) { 2356 void BytecodeGenerator::VisitCall(Call* expr) {
2357 Expression* callee_expr = expr->expression(); 2357 Expression* callee_expr = expr->expression();
2358 Call::CallType call_type = expr->GetCallType(); 2358 Call::CallType call_type = expr->GetCallType();
2359 bool possibly_eval = call_type == Call::POSSIBLY_EVAL_THROUGH_WITH_CALL ||
2360 call_type == Call::POSSIBLY_EVAL_CALL;
2359 2361
2360 if (call_type == Call::SUPER_CALL) { 2362 if (call_type == Call::SUPER_CALL) {
2361 return VisitCallSuper(expr); 2363 return VisitCallSuper(expr);
2362 } 2364 }
2363 2365
2364 Register callee = register_allocator()->NewRegister(); 2366 Register callee = register_allocator()->NewRegister();
2365 2367
2366 // Add an argument register for the receiver. 2368 // Add an argument register for the receiver.
2367 RegisterList args = 2369 RegisterList args =
2368 register_allocator()->NewRegisterList(expr->arguments()->length() + 1); 2370 register_allocator()->NewRegisterList(expr->arguments()->length() + 1);
(...skipping 16 matching lines...) Expand all
2385 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 2387 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
2386 // Load callee as a global variable. 2388 // Load callee as a global variable.
2387 VariableProxy* proxy = callee_expr->AsVariableProxy(); 2389 VariableProxy* proxy = callee_expr->AsVariableProxy();
2388 BuildVariableLoadForAccumulatorValue(proxy->var(), 2390 BuildVariableLoadForAccumulatorValue(proxy->var(),
2389 proxy->VariableFeedbackSlot(), 2391 proxy->VariableFeedbackSlot(),
2390 proxy->hole_check_mode()); 2392 proxy->hole_check_mode());
2391 builder()->StoreAccumulatorInRegister(callee); 2393 builder()->StoreAccumulatorInRegister(callee);
2392 break; 2394 break;
2393 } 2395 }
2394 case Call::WITH_CALL: 2396 case Call::WITH_CALL:
2395 case Call::POSSIBLY_EVAL_CALL: { 2397 case Call::POSSIBLY_EVAL_THROUGH_WITH_CALL: {
2396 if (callee_expr->AsVariableProxy()->var()->IsLookupSlot()) { 2398 DCHECK(callee_expr->AsVariableProxy()->var()->IsLookupSlot());
2397 RegisterAllocationScope inner_register_scope(this); 2399 RegisterAllocationScope inner_register_scope(this);
2398 Register name = register_allocator()->NewRegister(); 2400 Register name = register_allocator()->NewRegister();
2399 2401
2400 // Call %LoadLookupSlotForCall to get the callee and receiver. 2402 // Call %LoadLookupSlotForCall to get the callee and receiver.
2401 DCHECK(Register::AreContiguous(callee, receiver)); 2403 DCHECK(Register::AreContiguous(callee, receiver));
2402 RegisterList result_pair(callee.index(), 2); 2404 RegisterList result_pair(callee.index(), 2);
2403 Variable* variable = callee_expr->AsVariableProxy()->var(); 2405 Variable* variable = callee_expr->AsVariableProxy()->var();
2404 builder() 2406 builder()
2405 ->LoadLiteral(variable->name()) 2407 ->LoadLiteral(variable->name())
2406 .StoreAccumulatorInRegister(name) 2408 .StoreAccumulatorInRegister(name)
2407 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name, 2409 .CallRuntimeForPair(Runtime::kLoadLookupSlotForCall, name,
2408 result_pair); 2410 result_pair);
2409 break; 2411 break;
2410 }
2411 // Fall through.
2412 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL);
2413 } 2412 }
2413 case Call::POSSIBLY_EVAL_CALL:
2414 case Call::OTHER_CALL: { 2414 case Call::OTHER_CALL: {
2415 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); 2415 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver);
2416 VisitForRegisterValue(callee_expr, callee); 2416 VisitForRegisterValue(callee_expr, callee);
2417 break; 2417 break;
2418 } 2418 }
2419 case Call::NAMED_SUPER_PROPERTY_CALL: { 2419 case Call::NAMED_SUPER_PROPERTY_CALL: {
2420 Property* property = callee_expr->AsProperty(); 2420 Property* property = callee_expr->AsProperty();
2421 VisitNamedSuperPropertyLoad(property, receiver); 2421 VisitNamedSuperPropertyLoad(property, receiver);
2422 builder()->StoreAccumulatorInRegister(callee); 2422 builder()->StoreAccumulatorInRegister(callee);
2423 break; 2423 break;
2424 } 2424 }
2425 case Call::KEYED_SUPER_PROPERTY_CALL: { 2425 case Call::KEYED_SUPER_PROPERTY_CALL: {
2426 Property* property = callee_expr->AsProperty(); 2426 Property* property = callee_expr->AsProperty();
2427 VisitKeyedSuperPropertyLoad(property, receiver); 2427 VisitKeyedSuperPropertyLoad(property, receiver);
2428 builder()->StoreAccumulatorInRegister(callee); 2428 builder()->StoreAccumulatorInRegister(callee);
2429 break; 2429 break;
2430 } 2430 }
2431 case Call::SUPER_CALL: 2431 case Call::SUPER_CALL:
2432 UNREACHABLE(); 2432 UNREACHABLE();
2433 break; 2433 break;
2434 } 2434 }
2435 2435
2436 // Evaluate all arguments to the function call and store in sequential args 2436 // Evaluate all arguments to the function call and store in sequential args
2437 // registers. 2437 // registers.
2438 VisitArguments(expr->arguments(), args, 1); 2438 VisitArguments(expr->arguments(), args, 1);
2439 2439
2440 // Resolve callee for a potential direct eval call. This block will mutate the 2440 // Resolve callee for a potential direct eval call. This block will mutate the
2441 // callee value. 2441 // callee value.
2442 if (call_type == Call::POSSIBLY_EVAL_CALL && 2442 if (possibly_eval && expr->arguments()->length() > 0) {
2443 expr->arguments()->length() > 0) {
2444 RegisterAllocationScope inner_register_scope(this); 2443 RegisterAllocationScope inner_register_scope(this);
2445 // Set up arguments for ResolvePossiblyDirectEval by copying callee, source 2444 // Set up arguments for ResolvePossiblyDirectEval by copying callee, source
2446 // strings and function closure, and loading language and 2445 // strings and function closure, and loading language and
2447 // position. 2446 // position.
2448 RegisterList runtime_call_args = register_allocator()->NewRegisterList(6); 2447 RegisterList runtime_call_args = register_allocator()->NewRegisterList(6);
2449 builder() 2448 builder()
2450 ->MoveRegister(callee, runtime_call_args[0]) 2449 ->MoveRegister(callee, runtime_call_args[0])
2451 .MoveRegister(args[1], runtime_call_args[1]) 2450 .MoveRegister(args[1], runtime_call_args[1])
2452 .MoveRegister(Register::function_closure(), runtime_call_args[2]) 2451 .MoveRegister(Register::function_closure(), runtime_call_args[2])
2453 .LoadLiteral(Smi::FromInt(language_mode())) 2452 .LoadLiteral(Smi::FromInt(language_mode()))
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 } 3191 }
3193 3192
3194 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3193 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3195 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3194 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3196 : Runtime::kStoreKeyedToSuper_Sloppy; 3195 : Runtime::kStoreKeyedToSuper_Sloppy;
3197 } 3196 }
3198 3197
3199 } // namespace interpreter 3198 } // namespace interpreter
3200 } // namespace internal 3199 } // namespace internal
3201 } // namespace v8 3200 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698