| 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 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
| 8 | 8 |
| 9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
| 10 // | 10 // |
| (...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 | 2617 |
| 2618 | 2618 |
| 2619 void FullCodeGenerator::CallIC(Handle<Code> code, | 2619 void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2620 TypeFeedbackId id) { | 2620 TypeFeedbackId id) { |
| 2621 ic_total_count_++; | 2621 ic_total_count_++; |
| 2622 __ Call(code, RelocInfo::CODE_TARGET, id); | 2622 __ Call(code, RelocInfo::CODE_TARGET, id); |
| 2623 } | 2623 } |
| 2624 | 2624 |
| 2625 | 2625 |
| 2626 // Code common for calls using the IC. | 2626 // Code common for calls using the IC. |
| 2627 void FullCodeGenerator::EmitCallWithIC(Call* expr) { | 2627 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
| 2628 Expression* callee = expr->expression(); | 2628 Expression* callee = expr->expression(); |
| 2629 ZoneList<Expression*>* args = expr->arguments(); | |
| 2630 int arg_count = args->length(); | |
| 2631 | 2629 |
| 2632 CallFunctionFlags flags; | 2630 CallIC::CallType call_type = callee->IsVariableProxy() |
| 2631 ? CallIC::FUNCTION |
| 2632 : CallIC::METHOD; |
| 2633 |
| 2633 // Get the target function. | 2634 // Get the target function. |
| 2634 if (callee->IsVariableProxy()) { | 2635 if (call_type == CallIC::FUNCTION) { |
| 2635 { StackValueContext context(this); | 2636 { StackValueContext context(this); |
| 2636 EmitVariableLoad(callee->AsVariableProxy()); | 2637 EmitVariableLoad(callee->AsVariableProxy()); |
| 2637 PrepareForBailout(callee, NO_REGISTERS); | 2638 PrepareForBailout(callee, NO_REGISTERS); |
| 2638 } | 2639 } |
| 2639 // Push undefined as receiver. This is patched in the method prologue if it | 2640 // Push undefined as receiver. This is patched in the method prologue if it |
| 2640 // is a sloppy mode method. | 2641 // is a sloppy mode method. |
| 2641 __ Push(isolate()->factory()->undefined_value()); | 2642 __ Push(isolate()->factory()->undefined_value()); |
| 2642 flags = NO_CALL_FUNCTION_FLAGS; | |
| 2643 } else { | 2643 } else { |
| 2644 // Load the function from the receiver. | 2644 // Load the function from the receiver. |
| 2645 ASSERT(callee->IsProperty()); | 2645 ASSERT(callee->IsProperty()); |
| 2646 __ lw(v0, MemOperand(sp, 0)); | 2646 __ lw(v0, MemOperand(sp, 0)); |
| 2647 EmitNamedPropertyLoad(callee->AsProperty()); | 2647 EmitNamedPropertyLoad(callee->AsProperty()); |
| 2648 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2648 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2649 // Push the target function under the receiver. | 2649 // Push the target function under the receiver. |
| 2650 __ lw(at, MemOperand(sp, 0)); | 2650 __ lw(at, MemOperand(sp, 0)); |
| 2651 __ push(at); | 2651 __ push(at); |
| 2652 __ sw(v0, MemOperand(sp, kPointerSize)); | 2652 __ sw(v0, MemOperand(sp, kPointerSize)); |
| 2653 flags = CALL_AS_METHOD; | |
| 2654 } | 2653 } |
| 2655 | 2654 |
| 2656 // Load the arguments. | 2655 EmitCall(expr, call_type); |
| 2657 { PreservePositionScope scope(masm()->positions_recorder()); | |
| 2658 for (int i = 0; i < arg_count; i++) { | |
| 2659 VisitForStackValue(args->at(i)); | |
| 2660 } | |
| 2661 } | |
| 2662 // Record source position for debugger. | |
| 2663 SetSourcePosition(expr->position()); | |
| 2664 CallFunctionStub stub(isolate(), arg_count, flags); | |
| 2665 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
| 2666 __ CallStub(&stub); | |
| 2667 | |
| 2668 RecordJSReturnSite(expr); | |
| 2669 | |
| 2670 // Restore context register. | |
| 2671 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
| 2672 | |
| 2673 context()->DropAndPlug(1, v0); | |
| 2674 } | 2656 } |
| 2675 | 2657 |
| 2676 | 2658 |
| 2677 // Code common for calls using the IC. | 2659 // Code common for calls using the IC. |
| 2678 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, | 2660 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
| 2679 Expression* key) { | 2661 Expression* key) { |
| 2680 // Load the key. | 2662 // Load the key. |
| 2681 VisitForAccumulatorValue(key); | 2663 VisitForAccumulatorValue(key); |
| 2682 | 2664 |
| 2683 Expression* callee = expr->expression(); | 2665 Expression* callee = expr->expression(); |
| 2684 ZoneList<Expression*>* args = expr->arguments(); | |
| 2685 int arg_count = args->length(); | |
| 2686 | 2666 |
| 2687 // Load the function from the receiver. | 2667 // Load the function from the receiver. |
| 2688 ASSERT(callee->IsProperty()); | 2668 ASSERT(callee->IsProperty()); |
| 2689 __ lw(a1, MemOperand(sp, 0)); | 2669 __ lw(a1, MemOperand(sp, 0)); |
| 2690 EmitKeyedPropertyLoad(callee->AsProperty()); | 2670 EmitKeyedPropertyLoad(callee->AsProperty()); |
| 2691 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); | 2671 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
| 2692 | 2672 |
| 2693 // Push the target function under the receiver. | 2673 // Push the target function under the receiver. |
| 2694 __ lw(at, MemOperand(sp, 0)); | 2674 __ lw(at, MemOperand(sp, 0)); |
| 2695 __ push(at); | 2675 __ push(at); |
| 2696 __ sw(v0, MemOperand(sp, kPointerSize)); | 2676 __ sw(v0, MemOperand(sp, kPointerSize)); |
| 2697 | 2677 |
| 2698 { PreservePositionScope scope(masm()->positions_recorder()); | 2678 EmitCall(expr, CallIC::METHOD); |
| 2699 for (int i = 0; i < arg_count; i++) { | |
| 2700 VisitForStackValue(args->at(i)); | |
| 2701 } | |
| 2702 } | |
| 2703 | |
| 2704 // Record source position for debugger. | |
| 2705 SetSourcePosition(expr->position()); | |
| 2706 CallFunctionStub stub(isolate(), arg_count, CALL_AS_METHOD); | |
| 2707 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
| 2708 __ CallStub(&stub); | |
| 2709 | |
| 2710 RecordJSReturnSite(expr); | |
| 2711 // Restore context register. | |
| 2712 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
| 2713 | |
| 2714 context()->DropAndPlug(1, v0); | |
| 2715 } | 2679 } |
| 2716 | 2680 |
| 2717 | 2681 |
| 2718 void FullCodeGenerator::EmitCallWithStub(Call* expr) { | 2682 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
| 2719 // Code common for calls using the call stub. | 2683 // Load the arguments. |
| 2720 ZoneList<Expression*>* args = expr->arguments(); | 2684 ZoneList<Expression*>* args = expr->arguments(); |
| 2721 int arg_count = args->length(); | 2685 int arg_count = args->length(); |
| 2722 { PreservePositionScope scope(masm()->positions_recorder()); | 2686 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2723 for (int i = 0; i < arg_count; i++) { | 2687 for (int i = 0; i < arg_count; i++) { |
| 2724 VisitForStackValue(args->at(i)); | 2688 VisitForStackValue(args->at(i)); |
| 2725 } | 2689 } |
| 2726 } | 2690 } |
| 2727 // Record source position for debugger. | 2691 |
| 2692 // Record source position of the IC call. |
| 2728 SetSourcePosition(expr->position()); | 2693 SetSourcePosition(expr->position()); |
| 2694 Handle<Code> ic = CallIC::initialize_stub( |
| 2695 isolate(), arg_count, call_type); |
| 2696 __ li(a3, Operand(Smi::FromInt(expr->CallFeedbackSlot()))); |
| 2697 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2698 // Don't assign a type feedback id to the IC, since type feedback is provided |
| 2699 // by the vector above. |
| 2700 CallIC(ic); |
| 2729 | 2701 |
| 2730 __ li(a2, FeedbackVector()); | |
| 2731 __ li(a3, Operand(Smi::FromInt(expr->CallFeedbackSlot()))); | |
| 2732 | |
| 2733 // Record call targets in unoptimized code. | |
| 2734 CallFunctionStub stub(isolate(), arg_count, RECORD_CALL_TARGET); | |
| 2735 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
| 2736 __ CallStub(&stub); | |
| 2737 RecordJSReturnSite(expr); | 2702 RecordJSReturnSite(expr); |
| 2738 // Restore context register. | 2703 // Restore context register. |
| 2739 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2704 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2740 context()->DropAndPlug(1, v0); | 2705 context()->DropAndPlug(1, v0); |
| 2741 } | 2706 } |
| 2742 | 2707 |
| 2743 | 2708 |
| 2744 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2709 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
| 2745 // t2: copy of the first argument or undefined if it doesn't exist. | 2710 // t2: copy of the first argument or undefined if it doesn't exist. |
| 2746 if (arg_count > 0) { | 2711 if (arg_count > 0) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 // Record source position for debugger. | 2773 // Record source position for debugger. |
| 2809 SetSourcePosition(expr->position()); | 2774 SetSourcePosition(expr->position()); |
| 2810 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 2775 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2811 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2776 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2812 __ CallStub(&stub); | 2777 __ CallStub(&stub); |
| 2813 RecordJSReturnSite(expr); | 2778 RecordJSReturnSite(expr); |
| 2814 // Restore context register. | 2779 // Restore context register. |
| 2815 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2780 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2816 context()->DropAndPlug(1, v0); | 2781 context()->DropAndPlug(1, v0); |
| 2817 } else if (call_type == Call::GLOBAL_CALL) { | 2782 } else if (call_type == Call::GLOBAL_CALL) { |
| 2818 EmitCallWithIC(expr); | 2783 EmitCallWithLoadIC(expr); |
| 2819 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 2784 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 2820 // Call to a lookup slot (dynamically introduced variable). | 2785 // Call to a lookup slot (dynamically introduced variable). |
| 2821 VariableProxy* proxy = callee->AsVariableProxy(); | 2786 VariableProxy* proxy = callee->AsVariableProxy(); |
| 2822 Label slow, done; | 2787 Label slow, done; |
| 2823 | 2788 |
| 2824 { PreservePositionScope scope(masm()->positions_recorder()); | 2789 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2825 // Generate code for loading from variables potentially shadowed | 2790 // Generate code for loading from variables potentially shadowed |
| 2826 // by eval-introduced variables. | 2791 // by eval-introduced variables. |
| 2827 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); | 2792 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |
| 2828 } | 2793 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2847 __ push(v0); | 2812 __ push(v0); |
| 2848 // The receiver is implicitly the global receiver. Indicate this | 2813 // The receiver is implicitly the global receiver. Indicate this |
| 2849 // by passing the hole to the call function stub. | 2814 // by passing the hole to the call function stub. |
| 2850 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); | 2815 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
| 2851 __ push(a1); | 2816 __ push(a1); |
| 2852 __ bind(&call); | 2817 __ bind(&call); |
| 2853 } | 2818 } |
| 2854 | 2819 |
| 2855 // The receiver is either the global receiver or an object found | 2820 // The receiver is either the global receiver or an object found |
| 2856 // by LoadContextSlot. | 2821 // by LoadContextSlot. |
| 2857 EmitCallWithStub(expr); | 2822 EmitCall(expr); |
| 2858 } else if (call_type == Call::PROPERTY_CALL) { | 2823 } else if (call_type == Call::PROPERTY_CALL) { |
| 2859 Property* property = callee->AsProperty(); | 2824 Property* property = callee->AsProperty(); |
| 2860 { PreservePositionScope scope(masm()->positions_recorder()); | 2825 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2861 VisitForStackValue(property->obj()); | 2826 VisitForStackValue(property->obj()); |
| 2862 } | 2827 } |
| 2863 if (property->key()->IsPropertyName()) { | 2828 if (property->key()->IsPropertyName()) { |
| 2864 EmitCallWithIC(expr); | 2829 EmitCallWithLoadIC(expr); |
| 2865 } else { | 2830 } else { |
| 2866 EmitKeyedCallWithIC(expr, property->key()); | 2831 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 2867 } | 2832 } |
| 2868 } else { | 2833 } else { |
| 2869 ASSERT(call_type == Call::OTHER_CALL); | 2834 ASSERT(call_type == Call::OTHER_CALL); |
| 2870 // Call to an arbitrary expression not handled specially above. | 2835 // Call to an arbitrary expression not handled specially above. |
| 2871 { PreservePositionScope scope(masm()->positions_recorder()); | 2836 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2872 VisitForStackValue(callee); | 2837 VisitForStackValue(callee); |
| 2873 } | 2838 } |
| 2874 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); | 2839 __ LoadRoot(a1, Heap::kUndefinedValueRootIndex); |
| 2875 __ push(a1); | 2840 __ push(a1); |
| 2876 // Emit function call. | 2841 // Emit function call. |
| 2877 EmitCallWithStub(expr); | 2842 EmitCall(expr); |
| 2878 } | 2843 } |
| 2879 | 2844 |
| 2880 #ifdef DEBUG | 2845 #ifdef DEBUG |
| 2881 // RecordJSReturnSite should have been called. | 2846 // RecordJSReturnSite should have been called. |
| 2882 ASSERT(expr->return_is_recorded_); | 2847 ASSERT(expr->return_is_recorded_); |
| 2883 #endif | 2848 #endif |
| 2884 } | 2849 } |
| 2885 | 2850 |
| 2886 | 2851 |
| 2887 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2852 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2913 // Record call targets in unoptimized code. | 2878 // Record call targets in unoptimized code. |
| 2914 if (FLAG_pretenuring_call_new) { | 2879 if (FLAG_pretenuring_call_new) { |
| 2915 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); | 2880 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 2916 ASSERT(expr->AllocationSiteFeedbackSlot() == | 2881 ASSERT(expr->AllocationSiteFeedbackSlot() == |
| 2917 expr->CallNewFeedbackSlot() + 1); | 2882 expr->CallNewFeedbackSlot() + 1); |
| 2918 } | 2883 } |
| 2919 | 2884 |
| 2920 __ li(a2, FeedbackVector()); | 2885 __ li(a2, FeedbackVector()); |
| 2921 __ li(a3, Operand(Smi::FromInt(expr->CallNewFeedbackSlot()))); | 2886 __ li(a3, Operand(Smi::FromInt(expr->CallNewFeedbackSlot()))); |
| 2922 | 2887 |
| 2923 CallConstructStub stub(isolate(), RECORD_CALL_TARGET); | 2888 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 2924 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 2889 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 2925 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2890 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 2926 context()->Plug(v0); | 2891 context()->Plug(v0); |
| 2927 } | 2892 } |
| 2928 | 2893 |
| 2929 | 2894 |
| 2930 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2895 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 2931 ZoneList<Expression*>* args = expr->arguments(); | 2896 ZoneList<Expression*>* args = expr->arguments(); |
| 2932 ASSERT(args->length() == 1); | 2897 ASSERT(args->length() == 1); |
| 2933 | 2898 |
| (...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4930 Assembler::target_address_at(pc_immediate_load_address)) == | 4895 Assembler::target_address_at(pc_immediate_load_address)) == |
| 4931 reinterpret_cast<uint32_t>( | 4896 reinterpret_cast<uint32_t>( |
| 4932 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4897 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4933 return OSR_AFTER_STACK_CHECK; | 4898 return OSR_AFTER_STACK_CHECK; |
| 4934 } | 4899 } |
| 4935 | 4900 |
| 4936 | 4901 |
| 4937 } } // namespace v8::internal | 4902 } } // namespace v8::internal |
| 4938 | 4903 |
| 4939 #endif // V8_TARGET_ARCH_MIPS | 4904 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |