OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
(...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 } | 2737 } |
2738 } else { | 2738 } else { |
2739 VisitForStackValue(callee); | 2739 VisitForStackValue(callee); |
2740 // refEnv.WithBaseObject() | 2740 // refEnv.WithBaseObject() |
2741 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); | 2741 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); |
2742 __ Push(x10); // Reserved receiver slot. | 2742 __ Push(x10); // Reserved receiver slot. |
2743 } | 2743 } |
2744 } | 2744 } |
2745 | 2745 |
2746 | 2746 |
2747 void FullCodeGenerator::VisitCall(Call* expr) { | 2747 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
2748 #ifdef DEBUG | 2748 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
2749 // We want to verify that RecordJSReturnSite gets called on all paths | 2749 // to resolve the function we need to call. Then we call the resolved |
2750 // through this function. Avoid early returns. | 2750 // function using the given arguments. |
2751 expr->return_is_recorded_ = false; | 2751 ZoneList<Expression*>* args = expr->arguments(); |
2752 #endif | 2752 int arg_count = args->length(); |
2753 | 2753 |
2754 Comment cmnt(masm_, "[ Call"); | 2754 PushCalleeAndWithBaseObject(expr); |
2755 Expression* callee = expr->expression(); | |
2756 Call::CallType call_type = expr->GetCallType(isolate()); | |
2757 | 2755 |
2758 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 2756 // Push the arguments. |
2759 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 2757 for (int i = 0; i < arg_count; i++) { |
2760 // to resolve the function we need to call. Then we call the resolved | 2758 VisitForStackValue(args->at(i)); |
2761 // function using the given arguments. | |
2762 ZoneList<Expression*>* args = expr->arguments(); | |
2763 int arg_count = args->length(); | |
2764 | |
2765 PushCalleeAndWithBaseObject(expr); | |
2766 | |
2767 // Push the arguments. | |
2768 for (int i = 0; i < arg_count; i++) { | |
2769 VisitForStackValue(args->at(i)); | |
2770 } | |
2771 | |
2772 // Push a copy of the function (found below the arguments) and | |
2773 // resolve eval. | |
2774 __ Peek(x10, (arg_count + 1) * kPointerSize); | |
2775 __ Push(x10); | |
2776 EmitResolvePossiblyDirectEval(arg_count); | |
2777 | |
2778 // Touch up the stack with the resolved function. | |
2779 __ Poke(x0, (arg_count + 1) * kPointerSize); | |
2780 | |
2781 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | |
2782 | |
2783 // Record source position for debugger. | |
2784 SetCallPosition(expr, arg_count); | |
2785 | |
2786 // Call the evaluated function. | |
2787 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
2788 __ Peek(x1, (arg_count + 1) * kXRegSize); | |
2789 __ CallStub(&stub); | |
2790 RecordJSReturnSite(expr); | |
2791 // Restore context register. | |
2792 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2793 context()->DropAndPlug(1, x0); | |
2794 | |
2795 } else if (call_type == Call::GLOBAL_CALL) { | |
2796 EmitCallWithLoadIC(expr); | |
2797 | |
2798 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | |
2799 // Call to a lookup slot (dynamically introduced variable). | |
2800 PushCalleeAndWithBaseObject(expr); | |
2801 EmitCall(expr); | |
2802 } else if (call_type == Call::NAMED_PROPERTY_CALL) { | |
2803 Property* property = callee->AsProperty(); | |
2804 VisitForStackValue(property->obj()); | |
2805 EmitCallWithLoadIC(expr); | |
2806 } else if (call_type == Call::KEYED_PROPERTY_CALL) { | |
2807 Property* property = callee->AsProperty(); | |
2808 VisitForStackValue(property->obj()); | |
2809 EmitKeyedCallWithLoadIC(expr, property->key()); | |
2810 } else if (call_type == Call::NAMED_SUPER_PROPERTY_CALL) { | |
2811 EmitSuperCallWithLoadIC(expr); | |
2812 } else if (call_type == Call::KEYED_SUPER_PROPERTY_CALL) { | |
2813 EmitKeyedSuperCallWithLoadIC(expr); | |
2814 } else if (call_type == Call::SUPER_CALL) { | |
2815 EmitSuperConstructorCall(expr); | |
2816 } else { | |
2817 DCHECK(call_type == Call::OTHER_CALL); | |
2818 // Call to an arbitrary expression not handled specially above. | |
2819 VisitForStackValue(callee); | |
2820 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); | |
2821 __ Push(x1); | |
2822 // Emit function call. | |
2823 EmitCall(expr); | |
2824 } | 2759 } |
2825 | 2760 |
2826 #ifdef DEBUG | 2761 // Push a copy of the function (found below the arguments) and |
2827 // RecordJSReturnSite should have been called. | 2762 // resolve eval. |
2828 DCHECK(expr->return_is_recorded_); | 2763 __ Peek(x10, (arg_count + 1) * kPointerSize); |
2829 #endif | 2764 __ Push(x10); |
| 2765 EmitResolvePossiblyDirectEval(arg_count); |
| 2766 |
| 2767 // Touch up the stack with the resolved function. |
| 2768 __ Poke(x0, (arg_count + 1) * kPointerSize); |
| 2769 |
| 2770 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
| 2771 |
| 2772 // Record source position for debugger. |
| 2773 SetCallPosition(expr, arg_count); |
| 2774 |
| 2775 // Call the evaluated function. |
| 2776 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2777 __ Peek(x1, (arg_count + 1) * kXRegSize); |
| 2778 __ CallStub(&stub); |
| 2779 RecordJSReturnSite(expr); |
| 2780 // Restore context register. |
| 2781 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2782 context()->DropAndPlug(1, x0); |
2830 } | 2783 } |
2831 | 2784 |
2832 | 2785 |
2833 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2786 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
2834 Comment cmnt(masm_, "[ CallNew"); | 2787 Comment cmnt(masm_, "[ CallNew"); |
2835 // According to ECMA-262, section 11.2.2, page 44, the function | 2788 // According to ECMA-262, section 11.2.2, page 44, the function |
2836 // expression in new calls must be evaluated before the | 2789 // expression in new calls must be evaluated before the |
2837 // arguments. | 2790 // arguments. |
2838 | 2791 |
2839 // Push constructor on the stack. If it's not a function it's used as | 2792 // Push constructor on the stack. If it's not a function it's used as |
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5178 } | 5131 } |
5179 | 5132 |
5180 return INTERRUPT; | 5133 return INTERRUPT; |
5181 } | 5134 } |
5182 | 5135 |
5183 | 5136 |
5184 } // namespace internal | 5137 } // namespace internal |
5185 } // namespace v8 | 5138 } // namespace v8 |
5186 | 5139 |
5187 #endif // V8_TARGET_ARCH_ARM64 | 5140 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |