| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 OperandStackDepthDecrement(arg_count + 1); | 2443 OperandStackDepthDecrement(arg_count + 1); |
| 2444 | 2444 |
| 2445 RecordJSReturnSite(expr); | 2445 RecordJSReturnSite(expr); |
| 2446 | 2446 |
| 2447 // Restore context register. | 2447 // Restore context register. |
| 2448 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2448 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2449 // Discard the function left on TOS. | 2449 // Discard the function left on TOS. |
| 2450 context()->DropAndPlug(1, rax); | 2450 context()->DropAndPlug(1, rax); |
| 2451 } | 2451 } |
| 2452 | 2452 |
| 2453 | 2453 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { |
| 2454 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2454 int arg_count = expr->arguments()->length(); |
| 2455 // Push copy of the first argument or undefined if it doesn't exist. | 2455 // Push copy of the first argument or undefined if it doesn't exist. |
| 2456 if (arg_count > 0) { | 2456 if (arg_count > 0) { |
| 2457 __ Push(Operand(rsp, arg_count * kPointerSize)); | 2457 __ Push(Operand(rsp, arg_count * kPointerSize)); |
| 2458 } else { | 2458 } else { |
| 2459 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2459 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 2460 } | 2460 } |
| 2461 | 2461 |
| 2462 // Push the enclosing function. | 2462 // Push the enclosing function. |
| 2463 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 2463 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2464 | 2464 |
| 2465 // Push the language mode. | 2465 // Push the language mode. |
| 2466 __ Push(Smi::FromInt(language_mode())); | 2466 __ Push(Smi::FromInt(language_mode())); |
| 2467 | 2467 |
| 2468 // Push the start position of the scope the calls resides in. | 2468 // Push the start position of the scope the calls resides in. |
| 2469 __ Push(Smi::FromInt(scope()->start_position())); | 2469 __ Push(Smi::FromInt(scope()->start_position())); |
| 2470 | 2470 |
| 2471 // Push the source position of the eval call. |
| 2472 __ Push(Smi::FromInt(expr->position())); |
| 2473 |
| 2471 // Do the runtime call. | 2474 // Do the runtime call. |
| 2472 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); | 2475 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); |
| 2473 } | 2476 } |
| 2474 | 2477 |
| 2475 | 2478 |
| 2476 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 2479 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
| 2477 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 2480 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
| 2478 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 2481 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
| 2479 if (callee->var()->IsLookupSlot()) { | 2482 if (callee->var()->IsLookupSlot()) { |
| 2480 Label slow, done; | 2483 Label slow, done; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2508 } else { | 2511 } else { |
| 2509 VisitForStackValue(callee); | 2512 VisitForStackValue(callee); |
| 2510 // refEnv.WithBaseObject() | 2513 // refEnv.WithBaseObject() |
| 2511 OperandStackDepthIncrement(1); | 2514 OperandStackDepthIncrement(1); |
| 2512 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2515 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 2513 } | 2516 } |
| 2514 } | 2517 } |
| 2515 | 2518 |
| 2516 | 2519 |
| 2517 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { | 2520 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
| 2518 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 2521 // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval |
| 2519 // to resolve the function we need to call. Then we call the resolved | 2522 // to resolve the function we need to call. Then we call the resolved |
| 2520 // function using the given arguments. | 2523 // function using the given arguments. |
| 2521 ZoneList<Expression*>* args = expr->arguments(); | 2524 ZoneList<Expression*>* args = expr->arguments(); |
| 2522 int arg_count = args->length(); | 2525 int arg_count = args->length(); |
| 2523 PushCalleeAndWithBaseObject(expr); | 2526 PushCalleeAndWithBaseObject(expr); |
| 2524 | 2527 |
| 2525 // Push the arguments. | 2528 // Push the arguments. |
| 2526 for (int i = 0; i < arg_count; i++) { | 2529 for (int i = 0; i < arg_count; i++) { |
| 2527 VisitForStackValue(args->at(i)); | 2530 VisitForStackValue(args->at(i)); |
| 2528 } | 2531 } |
| 2529 | 2532 |
| 2530 // Push a copy of the function (found below the arguments) and resolve | 2533 // Push a copy of the function (found below the arguments) and resolve |
| 2531 // eval. | 2534 // eval. |
| 2532 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 2535 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2533 EmitResolvePossiblyDirectEval(arg_count); | 2536 EmitResolvePossiblyDirectEval(expr); |
| 2534 | 2537 |
| 2535 // Touch up the callee. | 2538 // Touch up the callee. |
| 2536 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 2539 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
| 2537 | 2540 |
| 2538 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2541 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 2539 | 2542 |
| 2540 SetCallPosition(expr); | 2543 SetCallPosition(expr); |
| 2541 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2544 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2542 __ Set(rax, arg_count); | 2545 __ Set(rax, arg_count); |
| 2543 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2546 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 DCHECK_EQ( | 3883 DCHECK_EQ( |
| 3881 isolate->builtins()->OnStackReplacement()->entry(), | 3884 isolate->builtins()->OnStackReplacement()->entry(), |
| 3882 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3885 Assembler::target_address_at(call_target_address, unoptimized_code)); |
| 3883 return ON_STACK_REPLACEMENT; | 3886 return ON_STACK_REPLACEMENT; |
| 3884 } | 3887 } |
| 3885 | 3888 |
| 3886 } // namespace internal | 3889 } // namespace internal |
| 3887 } // namespace v8 | 3890 } // namespace v8 |
| 3888 | 3891 |
| 3889 #endif // V8_TARGET_ARCH_X64 | 3892 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |