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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 OperandStackDepthDecrement(arg_count + 1); | 2535 OperandStackDepthDecrement(arg_count + 1); |
2536 | 2536 |
2537 RecordJSReturnSite(expr); | 2537 RecordJSReturnSite(expr); |
2538 | 2538 |
2539 // Restore context register. | 2539 // Restore context register. |
2540 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2540 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2541 | 2541 |
2542 context()->DropAndPlug(1, eax); | 2542 context()->DropAndPlug(1, eax); |
2543 } | 2543 } |
2544 | 2544 |
2545 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { | 2545 |
2546 int arg_count = expr->arguments()->length(); | 2546 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2547 // Push copy of the first argument or undefined if it doesn't exist. | 2547 // Push copy of the first argument or undefined if it doesn't exist. |
2548 if (arg_count > 0) { | 2548 if (arg_count > 0) { |
2549 __ push(Operand(esp, arg_count * kPointerSize)); | 2549 __ push(Operand(esp, arg_count * kPointerSize)); |
2550 } else { | 2550 } else { |
2551 __ push(Immediate(isolate()->factory()->undefined_value())); | 2551 __ push(Immediate(isolate()->factory()->undefined_value())); |
2552 } | 2552 } |
2553 | 2553 |
2554 // Push the enclosing function. | 2554 // Push the enclosing function. |
2555 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2555 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
2556 | 2556 |
2557 // Push the language mode. | 2557 // Push the language mode. |
2558 __ push(Immediate(Smi::FromInt(language_mode()))); | 2558 __ push(Immediate(Smi::FromInt(language_mode()))); |
2559 | 2559 |
2560 // Push the source position of the eval call. | 2560 // Push the start position of the scope the calls resides in. |
2561 __ push(Immediate(Smi::FromInt(expr->position()))); | 2561 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
2562 | 2562 |
2563 // Do the runtime call. | 2563 // Do the runtime call. |
2564 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); | 2564 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); |
2565 } | 2565 } |
2566 | 2566 |
2567 | 2567 |
2568 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 2568 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
2569 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 2569 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
2570 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 2570 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
2571 if (callee->var()->IsLookupSlot()) { | 2571 if (callee->var()->IsLookupSlot()) { |
(...skipping 27 matching lines...) Expand all Loading... |
2599 } | 2599 } |
2600 } else { | 2600 } else { |
2601 VisitForStackValue(callee); | 2601 VisitForStackValue(callee); |
2602 // refEnv.WithBaseObject() | 2602 // refEnv.WithBaseObject() |
2603 PushOperand(isolate()->factory()->undefined_value()); | 2603 PushOperand(isolate()->factory()->undefined_value()); |
2604 } | 2604 } |
2605 } | 2605 } |
2606 | 2606 |
2607 | 2607 |
2608 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { | 2608 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
2609 // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval | 2609 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
2610 // to resolve the function we need to call. Then we call the resolved | 2610 // to resolve the function we need to call. Then we call the resolved |
2611 // function using the given arguments. | 2611 // function using the given arguments. |
2612 ZoneList<Expression*>* args = expr->arguments(); | 2612 ZoneList<Expression*>* args = expr->arguments(); |
2613 int arg_count = args->length(); | 2613 int arg_count = args->length(); |
2614 | 2614 |
2615 PushCalleeAndWithBaseObject(expr); | 2615 PushCalleeAndWithBaseObject(expr); |
2616 | 2616 |
2617 // Push the arguments. | 2617 // Push the arguments. |
2618 for (int i = 0; i < arg_count; i++) { | 2618 for (int i = 0; i < arg_count; i++) { |
2619 VisitForStackValue(args->at(i)); | 2619 VisitForStackValue(args->at(i)); |
2620 } | 2620 } |
2621 | 2621 |
2622 // Push a copy of the function (found below the arguments) and | 2622 // Push a copy of the function (found below the arguments) and |
2623 // resolve eval. | 2623 // resolve eval. |
2624 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 2624 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
2625 EmitResolvePossiblyDirectEval(expr); | 2625 EmitResolvePossiblyDirectEval(arg_count); |
2626 | 2626 |
2627 // Touch up the stack with the resolved function. | 2627 // Touch up the stack with the resolved function. |
2628 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 2628 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
2629 | 2629 |
2630 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2630 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
2631 | 2631 |
2632 SetCallPosition(expr); | 2632 SetCallPosition(expr); |
2633 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2633 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2634 __ Set(eax, arg_count); | 2634 __ Set(eax, arg_count); |
2635 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2635 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3977 isolate->builtins()->OnStackReplacement()->entry(), | 3977 isolate->builtins()->OnStackReplacement()->entry(), |
3978 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3978 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3979 return ON_STACK_REPLACEMENT; | 3979 return ON_STACK_REPLACEMENT; |
3980 } | 3980 } |
3981 | 3981 |
3982 | 3982 |
3983 } // namespace internal | 3983 } // namespace internal |
3984 } // namespace v8 | 3984 } // namespace v8 |
3985 | 3985 |
3986 #endif // V8_TARGET_ARCH_X87 | 3986 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |