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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.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/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2555 | 2555 |
2556 __ lbu(a4, FieldMemOperand(a3, SharedFunctionInfo::kStrictModeByteOffset)); | 2556 __ lbu(a4, FieldMemOperand(a3, SharedFunctionInfo::kStrictModeByteOffset)); |
2557 __ And(at, a4, Operand(strict_mode_function_mask)); | 2557 __ And(at, a4, Operand(strict_mode_function_mask)); |
2558 __ Branch(cont, ne, at, Operand(zero_reg)); | 2558 __ Branch(cont, ne, at, Operand(zero_reg)); |
2559 __ lbu(a4, FieldMemOperand(a3, SharedFunctionInfo::kNativeByteOffset)); | 2559 __ lbu(a4, FieldMemOperand(a3, SharedFunctionInfo::kNativeByteOffset)); |
2560 __ And(at, a4, Operand(native_mask)); | 2560 __ And(at, a4, Operand(native_mask)); |
2561 __ Branch(cont, ne, at, Operand(zero_reg)); | 2561 __ Branch(cont, ne, at, Operand(zero_reg)); |
2562 } | 2562 } |
2563 | 2563 |
2564 | 2564 |
2565 static void EmitSlowCase(MacroAssembler* masm, int argc) { | 2565 static void EmitSlowCase(MacroAssembler* masm, |
2566 __ li(a0, Operand(argc)); | 2566 int argc, |
2567 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2567 Label* non_function) { |
| 2568 // Check for function proxy. |
| 2569 __ Branch(non_function, ne, a4, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 2570 __ push(a1); // put proxy as additional argument |
| 2571 __ li(a0, Operand(argc + 1, RelocInfo::NONE32)); |
| 2572 __ mov(a2, zero_reg); |
| 2573 __ GetBuiltinFunction(a1, Context::CALL_FUNCTION_PROXY_BUILTIN_INDEX); |
| 2574 { |
| 2575 Handle<Code> adaptor = |
| 2576 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
| 2577 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
| 2578 } |
| 2579 |
| 2580 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2581 // of the original receiver from the call site). |
| 2582 __ bind(non_function); |
| 2583 __ sd(a1, MemOperand(sp, argc * kPointerSize)); |
| 2584 __ li(a0, Operand(argc)); // Set up the number of arguments. |
| 2585 __ mov(a2, zero_reg); |
| 2586 __ GetBuiltinFunction(a1, Context::CALL_NON_FUNCTION_BUILTIN_INDEX); |
| 2587 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 2588 RelocInfo::CODE_TARGET); |
2568 } | 2589 } |
2569 | 2590 |
2570 | 2591 |
2571 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2592 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
2572 // Wrap the receiver and patch it back onto the stack. | 2593 // Wrap the receiver and patch it back onto the stack. |
2573 { FrameScope frame_scope(masm, StackFrame::INTERNAL); | 2594 { FrameScope frame_scope(masm, StackFrame::INTERNAL); |
2574 __ Push(a1); | 2595 __ Push(a1); |
2575 __ mov(a0, a3); | 2596 __ mov(a0, a3); |
2576 ToObjectStub stub(masm->isolate()); | 2597 ToObjectStub stub(masm->isolate()); |
2577 __ CallStub(&stub); | 2598 __ CallStub(&stub); |
2578 __ pop(a1); | 2599 __ pop(a1); |
2579 } | 2600 } |
2580 __ Branch(USE_DELAY_SLOT, cont); | 2601 __ Branch(USE_DELAY_SLOT, cont); |
2581 __ sd(v0, MemOperand(sp, argc * kPointerSize)); | 2602 __ sd(v0, MemOperand(sp, argc * kPointerSize)); |
2582 } | 2603 } |
2583 | 2604 |
2584 | 2605 |
2585 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2606 static void CallFunctionNoFeedback(MacroAssembler* masm, |
2586 int argc, bool needs_checks, | 2607 int argc, bool needs_checks, |
2587 bool call_as_method) { | 2608 bool call_as_method) { |
2588 // a1 : the function to call | 2609 // a1 : the function to call |
2589 Label slow, wrap, cont; | 2610 Label slow, non_function, wrap, cont; |
2590 | 2611 |
2591 if (needs_checks) { | 2612 if (needs_checks) { |
2592 // Check that the function is really a JavaScript function. | 2613 // Check that the function is really a JavaScript function. |
2593 // a1: pushed function (to be verified) | 2614 // a1: pushed function (to be verified) |
2594 __ JumpIfSmi(a1, &slow); | 2615 __ JumpIfSmi(a1, &non_function); |
2595 | 2616 |
2596 // Goto slow case if we do not have a function. | 2617 // Goto slow case if we do not have a function. |
2597 __ GetObjectType(a1, a4, a4); | 2618 __ GetObjectType(a1, a4, a4); |
2598 __ Branch(&slow, ne, a4, Operand(JS_FUNCTION_TYPE)); | 2619 __ Branch(&slow, ne, a4, Operand(JS_FUNCTION_TYPE)); |
2599 } | 2620 } |
2600 | 2621 |
2601 // Fast-case: Invoke the function now. | 2622 // Fast-case: Invoke the function now. |
2602 // a1: pushed function | 2623 // a1: pushed function |
2603 ParameterCount actual(argc); | 2624 ParameterCount actual(argc); |
2604 | 2625 |
(...skipping 13 matching lines...) Expand all Loading... |
2618 __ jmp(&wrap); | 2639 __ jmp(&wrap); |
2619 } | 2640 } |
2620 | 2641 |
2621 __ bind(&cont); | 2642 __ bind(&cont); |
2622 } | 2643 } |
2623 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2644 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); |
2624 | 2645 |
2625 if (needs_checks) { | 2646 if (needs_checks) { |
2626 // Slow-case: Non-function called. | 2647 // Slow-case: Non-function called. |
2627 __ bind(&slow); | 2648 __ bind(&slow); |
2628 EmitSlowCase(masm, argc); | 2649 EmitSlowCase(masm, argc, &non_function); |
2629 } | 2650 } |
2630 | 2651 |
2631 if (call_as_method) { | 2652 if (call_as_method) { |
2632 __ bind(&wrap); | 2653 __ bind(&wrap); |
2633 // Wrap the receiver and patch it back onto the stack. | 2654 // Wrap the receiver and patch it back onto the stack. |
2634 EmitWrapCase(masm, argc, &cont); | 2655 EmitWrapCase(masm, argc, &cont); |
2635 } | 2656 } |
2636 } | 2657 } |
2637 | 2658 |
2638 | 2659 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2791 | 2812 |
2792 __ mov(a2, a4); | 2813 __ mov(a2, a4); |
2793 __ mov(a3, a1); | 2814 __ mov(a3, a1); |
2794 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2815 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
2795 __ TailCallStub(&stub); | 2816 __ TailCallStub(&stub); |
2796 | 2817 |
2797 __ bind(&miss); | 2818 __ bind(&miss); |
2798 GenerateMiss(masm); | 2819 GenerateMiss(masm); |
2799 | 2820 |
2800 // The slow case, we need this no matter what to complete a call after a miss. | 2821 // The slow case, we need this no matter what to complete a call after a miss. |
2801 __ li(a0, Operand(arg_count())); | 2822 CallFunctionNoFeedback(masm, |
2802 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2823 arg_count(), |
| 2824 true, |
| 2825 CallAsMethod()); |
| 2826 |
| 2827 // Unreachable. |
| 2828 __ stop("Unexpected code address"); |
2803 } | 2829 } |
2804 | 2830 |
2805 | 2831 |
2806 void CallICStub::Generate(MacroAssembler* masm) { | 2832 void CallICStub::Generate(MacroAssembler* masm) { |
2807 // a1 - function | 2833 // a1 - function |
2808 // a3 - slot id (Smi) | 2834 // a3 - slot id (Smi) |
2809 // a2 - vector | 2835 // a2 - vector |
2810 const int with_types_offset = | 2836 const int with_types_offset = |
2811 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | 2837 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); |
2812 const int generic_offset = | 2838 const int generic_offset = |
2813 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | 2839 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); |
2814 Label extra_checks_or_miss, slow_start; | 2840 Label extra_checks_or_miss, slow_start; |
2815 Label slow, wrap, cont; | 2841 Label slow, non_function, wrap, cont; |
2816 Label have_js_function; | 2842 Label have_js_function; |
2817 int argc = arg_count(); | 2843 int argc = arg_count(); |
2818 ParameterCount actual(argc); | 2844 ParameterCount actual(argc); |
2819 | 2845 |
2820 // The checks. First, does r1 match the recorded monomorphic target? | 2846 // The checks. First, does r1 match the recorded monomorphic target? |
2821 __ dsrl(a4, a3, 32 - kPointerSizeLog2); | 2847 __ dsrl(a4, a3, 32 - kPointerSizeLog2); |
2822 __ Daddu(a4, a2, Operand(a4)); | 2848 __ Daddu(a4, a2, Operand(a4)); |
2823 __ ld(a4, FieldMemOperand(a4, FixedArray::kHeaderSize)); | 2849 __ ld(a4, FieldMemOperand(a4, FixedArray::kHeaderSize)); |
2824 | 2850 |
2825 // We don't know that we have a weak cell. We might have a private symbol | 2851 // We don't know that we have a weak cell. We might have a private symbol |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 __ JumpIfSmi(a3, &wrap); | 2885 __ JumpIfSmi(a3, &wrap); |
2860 __ GetObjectType(a3, a4, a4); | 2886 __ GetObjectType(a3, a4, a4); |
2861 __ Branch(&wrap, lt, a4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 2887 __ Branch(&wrap, lt, a4, Operand(FIRST_SPEC_OBJECT_TYPE)); |
2862 | 2888 |
2863 __ bind(&cont); | 2889 __ bind(&cont); |
2864 } | 2890 } |
2865 | 2891 |
2866 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2892 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); |
2867 | 2893 |
2868 __ bind(&slow); | 2894 __ bind(&slow); |
2869 EmitSlowCase(masm, argc); | 2895 EmitSlowCase(masm, argc, &non_function); |
2870 | 2896 |
2871 if (CallAsMethod()) { | 2897 if (CallAsMethod()) { |
2872 __ bind(&wrap); | 2898 __ bind(&wrap); |
2873 EmitWrapCase(masm, argc, &cont); | 2899 EmitWrapCase(masm, argc, &cont); |
2874 } | 2900 } |
2875 | 2901 |
2876 __ bind(&extra_checks_or_miss); | 2902 __ bind(&extra_checks_or_miss); |
2877 Label uninitialized, miss; | 2903 Label uninitialized, miss; |
2878 | 2904 |
2879 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 2905 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2946 __ Branch(&have_js_function); | 2972 __ Branch(&have_js_function); |
2947 | 2973 |
2948 // We are here because tracing is on or we encountered a MISS case we can't | 2974 // We are here because tracing is on or we encountered a MISS case we can't |
2949 // handle here. | 2975 // handle here. |
2950 __ bind(&miss); | 2976 __ bind(&miss); |
2951 GenerateMiss(masm); | 2977 GenerateMiss(masm); |
2952 | 2978 |
2953 // the slow case | 2979 // the slow case |
2954 __ bind(&slow_start); | 2980 __ bind(&slow_start); |
2955 // Check that the function is really a JavaScript function. | 2981 // Check that the function is really a JavaScript function. |
2956 // a1: pushed function (to be verified) | 2982 // r1: pushed function (to be verified) |
2957 __ JumpIfSmi(a1, &slow); | 2983 __ JumpIfSmi(a1, &non_function); |
2958 | 2984 |
2959 // Goto slow case if we do not have a function. | 2985 // Goto slow case if we do not have a function. |
2960 __ GetObjectType(a1, a4, a4); | 2986 __ GetObjectType(a1, a4, a4); |
2961 __ Branch(&slow, ne, a4, Operand(JS_FUNCTION_TYPE)); | 2987 __ Branch(&slow, ne, a4, Operand(JS_FUNCTION_TYPE)); |
2962 __ Branch(&have_js_function); | 2988 __ Branch(&have_js_function); |
2963 } | 2989 } |
2964 | 2990 |
2965 | 2991 |
2966 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 2992 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
2967 FrameScope scope(masm, StackFrame::INTERNAL); | 2993 FrameScope scope(masm, StackFrame::INTERNAL); |
(...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5790 MemOperand(fp, 6 * kPointerSize), NULL); | 5816 MemOperand(fp, 6 * kPointerSize), NULL); |
5791 } | 5817 } |
5792 | 5818 |
5793 | 5819 |
5794 #undef __ | 5820 #undef __ |
5795 | 5821 |
5796 } // namespace internal | 5822 } // namespace internal |
5797 } // namespace v8 | 5823 } // namespace v8 |
5798 | 5824 |
5799 #endif // V8_TARGET_ARCH_MIPS64 | 5825 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |