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 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 OperandStackDepthDecrement(arg_count + 1); | 2533 OperandStackDepthDecrement(arg_count + 1); |
2534 | 2534 |
2535 RecordJSReturnSite(expr); | 2535 RecordJSReturnSite(expr); |
2536 | 2536 |
2537 // Restore context register. | 2537 // Restore context register. |
2538 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2538 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2539 // Discard the function left on TOS. | 2539 // Discard the function left on TOS. |
2540 context()->DropAndPlug(1, rax); | 2540 context()->DropAndPlug(1, rax); |
2541 } | 2541 } |
2542 | 2542 |
2543 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { | 2543 |
2544 int arg_count = expr->arguments()->length(); | 2544 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2545 // Push copy of the first argument or undefined if it doesn't exist. | 2545 // Push copy of the first argument or undefined if it doesn't exist. |
2546 if (arg_count > 0) { | 2546 if (arg_count > 0) { |
2547 __ Push(Operand(rsp, arg_count * kPointerSize)); | 2547 __ Push(Operand(rsp, arg_count * kPointerSize)); |
2548 } else { | 2548 } else { |
2549 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2549 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2550 } | 2550 } |
2551 | 2551 |
2552 // Push the enclosing function. | 2552 // Push the enclosing function. |
2553 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 2553 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
2554 | 2554 |
2555 // Push the language mode. | 2555 // Push the language mode. |
2556 __ Push(Smi::FromInt(language_mode())); | 2556 __ Push(Smi::FromInt(language_mode())); |
2557 | 2557 |
2558 // Push the source position of the eval call. | 2558 // Push the start position of the scope the calls resides in. |
2559 __ Push(Smi::FromInt(expr->position())); | 2559 __ Push(Smi::FromInt(scope()->start_position())); |
2560 | 2560 |
2561 // Do the runtime call. | 2561 // Do the runtime call. |
2562 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); | 2562 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); |
2563 } | 2563 } |
2564 | 2564 |
2565 | 2565 |
2566 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 2566 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
2567 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 2567 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
2568 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 2568 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
2569 if (callee->var()->IsLookupSlot()) { | 2569 if (callee->var()->IsLookupSlot()) { |
(...skipping 28 matching lines...) Expand all Loading... |
2598 } else { | 2598 } else { |
2599 VisitForStackValue(callee); | 2599 VisitForStackValue(callee); |
2600 // refEnv.WithBaseObject() | 2600 // refEnv.WithBaseObject() |
2601 OperandStackDepthIncrement(1); | 2601 OperandStackDepthIncrement(1); |
2602 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2602 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2603 } | 2603 } |
2604 } | 2604 } |
2605 | 2605 |
2606 | 2606 |
2607 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { | 2607 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
2608 // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval | 2608 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
2609 // to resolve the function we need to call. Then we call the resolved | 2609 // to resolve the function we need to call. Then we call the resolved |
2610 // function using the given arguments. | 2610 // function using the given arguments. |
2611 ZoneList<Expression*>* args = expr->arguments(); | 2611 ZoneList<Expression*>* args = expr->arguments(); |
2612 int arg_count = args->length(); | 2612 int arg_count = args->length(); |
2613 PushCalleeAndWithBaseObject(expr); | 2613 PushCalleeAndWithBaseObject(expr); |
2614 | 2614 |
2615 // Push the arguments. | 2615 // Push the arguments. |
2616 for (int i = 0; i < arg_count; i++) { | 2616 for (int i = 0; i < arg_count; i++) { |
2617 VisitForStackValue(args->at(i)); | 2617 VisitForStackValue(args->at(i)); |
2618 } | 2618 } |
2619 | 2619 |
2620 // Push a copy of the function (found below the arguments) and resolve | 2620 // Push a copy of the function (found below the arguments) and resolve |
2621 // eval. | 2621 // eval. |
2622 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); | 2622 __ Push(Operand(rsp, (arg_count + 1) * kPointerSize)); |
2623 EmitResolvePossiblyDirectEval(expr); | 2623 EmitResolvePossiblyDirectEval(arg_count); |
2624 | 2624 |
2625 // Touch up the callee. | 2625 // Touch up the callee. |
2626 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); | 2626 __ movp(Operand(rsp, (arg_count + 1) * kPointerSize), rax); |
2627 | 2627 |
2628 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2628 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
2629 | 2629 |
2630 SetCallPosition(expr); | 2630 SetCallPosition(expr); |
2631 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2631 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
2632 __ Set(rax, arg_count); | 2632 __ Set(rax, arg_count); |
2633 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2633 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3970 DCHECK_EQ( | 3970 DCHECK_EQ( |
3971 isolate->builtins()->OnStackReplacement()->entry(), | 3971 isolate->builtins()->OnStackReplacement()->entry(), |
3972 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3972 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3973 return ON_STACK_REPLACEMENT; | 3973 return ON_STACK_REPLACEMENT; |
3974 } | 3974 } |
3975 | 3975 |
3976 } // namespace internal | 3976 } // namespace internal |
3977 } // namespace v8 | 3977 } // namespace v8 |
3978 | 3978 |
3979 #endif // V8_TARGET_ARCH_X64 | 3979 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |