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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2517 // Do not transform the receiver for strict mode functions. | 2517 // Do not transform the receiver for strict mode functions. |
2518 int32_t strict_mode_function_mask = | 2518 int32_t strict_mode_function_mask = |
2519 1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize); | 2519 1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize); |
2520 // Do not transform the receiver for native (Compilerhints already in a3). | 2520 // Do not transform the receiver for native (Compilerhints already in a3). |
2521 int32_t native_mask = 1 << (SharedFunctionInfo::kNative + kSmiTagSize); | 2521 int32_t native_mask = 1 << (SharedFunctionInfo::kNative + kSmiTagSize); |
2522 __ And(at, t0, Operand(strict_mode_function_mask | native_mask)); | 2522 __ And(at, t0, Operand(strict_mode_function_mask | native_mask)); |
2523 __ Branch(cont, ne, at, Operand(zero_reg)); | 2523 __ Branch(cont, ne, at, Operand(zero_reg)); |
2524 } | 2524 } |
2525 | 2525 |
2526 | 2526 |
2527 static void EmitSlowCase(MacroAssembler* masm, | 2527 static void EmitSlowCase(MacroAssembler* masm, int argc) { |
2528 int argc, | 2528 __ li(a0, Operand(argc)); |
2529 Label* non_function) { | 2529 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
2530 // Check for function proxy. | |
2531 __ Branch(non_function, ne, t0, Operand(JS_FUNCTION_PROXY_TYPE)); | |
2532 __ push(a1); // put proxy as additional argument | |
2533 __ li(a0, Operand(argc + 1, RelocInfo::NONE32)); | |
2534 __ mov(a2, zero_reg); | |
2535 __ GetBuiltinFunction(a1, Context::CALL_FUNCTION_PROXY_BUILTIN_INDEX); | |
2536 { | |
2537 Handle<Code> adaptor = | |
2538 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | |
2539 __ Jump(adaptor, RelocInfo::CODE_TARGET); | |
2540 } | |
2541 | |
2542 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | |
2543 // of the original receiver from the call site). | |
2544 __ bind(non_function); | |
2545 __ sw(a1, MemOperand(sp, argc * kPointerSize)); | |
2546 __ li(a0, Operand(argc)); // Set up the number of arguments. | |
2547 __ mov(a2, zero_reg); | |
2548 __ GetBuiltinFunction(a1, Context::CALL_NON_FUNCTION_BUILTIN_INDEX); | |
2549 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | |
2550 RelocInfo::CODE_TARGET); | |
2551 } | 2530 } |
2552 | 2531 |
2553 | 2532 |
2554 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2533 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
2555 // Wrap the receiver and patch it back onto the stack. | 2534 // Wrap the receiver and patch it back onto the stack. |
2556 { FrameScope frame_scope(masm, StackFrame::INTERNAL); | 2535 { FrameScope frame_scope(masm, StackFrame::INTERNAL); |
2557 __ Push(a1); | 2536 __ Push(a1); |
2558 __ mov(a0, a3); | 2537 __ mov(a0, a3); |
2559 ToObjectStub stub(masm->isolate()); | 2538 ToObjectStub stub(masm->isolate()); |
2560 __ CallStub(&stub); | 2539 __ CallStub(&stub); |
2561 __ pop(a1); | 2540 __ pop(a1); |
2562 } | 2541 } |
2563 __ Branch(USE_DELAY_SLOT, cont); | 2542 __ Branch(USE_DELAY_SLOT, cont); |
2564 __ sw(v0, MemOperand(sp, argc * kPointerSize)); | 2543 __ sw(v0, MemOperand(sp, argc * kPointerSize)); |
2565 } | 2544 } |
2566 | 2545 |
2567 | 2546 |
2568 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2547 static void CallFunctionNoFeedback(MacroAssembler* masm, |
2569 int argc, bool needs_checks, | 2548 int argc, bool needs_checks, |
2570 bool call_as_method) { | 2549 bool call_as_method) { |
2571 // a1 : the function to call | 2550 // a1 : the function to call |
2572 Label slow, non_function, wrap, cont; | 2551 Label slow, wrap, cont; |
2573 | 2552 |
2574 if (needs_checks) { | 2553 if (needs_checks) { |
2575 // Check that the function is really a JavaScript function. | 2554 // Check that the function is really a JavaScript function. |
2576 // a1: pushed function (to be verified) | 2555 // a1: pushed function (to be verified) |
2577 __ JumpIfSmi(a1, &non_function); | 2556 __ JumpIfSmi(a1, &slow); |
2578 | 2557 |
2579 // Goto slow case if we do not have a function. | 2558 // Goto slow case if we do not have a function. |
2580 __ GetObjectType(a1, t0, t0); | 2559 __ GetObjectType(a1, t0, t0); |
2581 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); | 2560 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); |
2582 } | 2561 } |
2583 | 2562 |
2584 // Fast-case: Invoke the function now. | 2563 // Fast-case: Invoke the function now. |
2585 // a1: pushed function | 2564 // a1: pushed function |
2586 ParameterCount actual(argc); | 2565 ParameterCount actual(argc); |
2587 | 2566 |
(...skipping 14 matching lines...) Expand all Loading... |
2602 } | 2581 } |
2603 | 2582 |
2604 __ bind(&cont); | 2583 __ bind(&cont); |
2605 } | 2584 } |
2606 | 2585 |
2607 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2586 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); |
2608 | 2587 |
2609 if (needs_checks) { | 2588 if (needs_checks) { |
2610 // Slow-case: Non-function called. | 2589 // Slow-case: Non-function called. |
2611 __ bind(&slow); | 2590 __ bind(&slow); |
2612 EmitSlowCase(masm, argc, &non_function); | 2591 EmitSlowCase(masm, argc); |
2613 } | 2592 } |
2614 | 2593 |
2615 if (call_as_method) { | 2594 if (call_as_method) { |
2616 __ bind(&wrap); | 2595 __ bind(&wrap); |
2617 // Wrap the receiver and patch it back onto the stack. | 2596 // Wrap the receiver and patch it back onto the stack. |
2618 EmitWrapCase(masm, argc, &cont); | 2597 EmitWrapCase(masm, argc, &cont); |
2619 } | 2598 } |
2620 } | 2599 } |
2621 | 2600 |
2622 | 2601 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 | 2715 |
2737 __ mov(a2, t0); | 2716 __ mov(a2, t0); |
2738 __ mov(a3, a1); | 2717 __ mov(a3, a1); |
2739 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2718 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
2740 __ TailCallStub(&stub); | 2719 __ TailCallStub(&stub); |
2741 | 2720 |
2742 __ bind(&miss); | 2721 __ bind(&miss); |
2743 GenerateMiss(masm); | 2722 GenerateMiss(masm); |
2744 | 2723 |
2745 // The slow case, we need this no matter what to complete a call after a miss. | 2724 // The slow case, we need this no matter what to complete a call after a miss. |
2746 CallFunctionNoFeedback(masm, | 2725 __ li(a0, Operand(arg_count())); |
2747 arg_count(), | 2726 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
2748 true, | |
2749 CallAsMethod()); | |
2750 | |
2751 // Unreachable. | |
2752 __ stop("Unexpected code address"); | |
2753 } | 2727 } |
2754 | 2728 |
2755 | 2729 |
2756 void CallICStub::Generate(MacroAssembler* masm) { | 2730 void CallICStub::Generate(MacroAssembler* masm) { |
2757 // a1 - function | 2731 // a1 - function |
2758 // a3 - slot id (Smi) | 2732 // a3 - slot id (Smi) |
2759 // a2 - vector | 2733 // a2 - vector |
2760 const int with_types_offset = | 2734 const int with_types_offset = |
2761 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | 2735 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); |
2762 const int generic_offset = | 2736 const int generic_offset = |
2763 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | 2737 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); |
2764 Label extra_checks_or_miss, slow_start; | 2738 Label extra_checks_or_miss, slow_start; |
2765 Label slow, non_function, wrap, cont; | 2739 Label slow, wrap, cont; |
2766 Label have_js_function; | 2740 Label have_js_function; |
2767 int argc = arg_count(); | 2741 int argc = arg_count(); |
2768 ParameterCount actual(argc); | 2742 ParameterCount actual(argc); |
2769 | 2743 |
2770 // The checks. First, does r1 match the recorded monomorphic target? | 2744 // The checks. First, does r1 match the recorded monomorphic target? |
2771 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); | 2745 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); |
2772 __ Addu(t0, a2, Operand(t0)); | 2746 __ Addu(t0, a2, Operand(t0)); |
2773 __ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize)); | 2747 __ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize)); |
2774 | 2748 |
2775 // We don't know that we have a weak cell. We might have a private symbol | 2749 // 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... |
2809 __ JumpIfSmi(a3, &wrap); | 2783 __ JumpIfSmi(a3, &wrap); |
2810 __ GetObjectType(a3, t0, t0); | 2784 __ GetObjectType(a3, t0, t0); |
2811 __ Branch(&wrap, lt, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); | 2785 __ Branch(&wrap, lt, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); |
2812 | 2786 |
2813 __ bind(&cont); | 2787 __ bind(&cont); |
2814 } | 2788 } |
2815 | 2789 |
2816 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); | 2790 __ InvokeFunction(a1, actual, JUMP_FUNCTION, NullCallWrapper()); |
2817 | 2791 |
2818 __ bind(&slow); | 2792 __ bind(&slow); |
2819 EmitSlowCase(masm, argc, &non_function); | 2793 EmitSlowCase(masm, argc); |
2820 | 2794 |
2821 if (CallAsMethod()) { | 2795 if (CallAsMethod()) { |
2822 __ bind(&wrap); | 2796 __ bind(&wrap); |
2823 EmitWrapCase(masm, argc, &cont); | 2797 EmitWrapCase(masm, argc, &cont); |
2824 } | 2798 } |
2825 | 2799 |
2826 __ bind(&extra_checks_or_miss); | 2800 __ bind(&extra_checks_or_miss); |
2827 Label uninitialized, miss; | 2801 Label uninitialized, miss; |
2828 | 2802 |
2829 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 2803 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 | 2871 |
2898 // We are here because tracing is on or we encountered a MISS case we can't | 2872 // We are here because tracing is on or we encountered a MISS case we can't |
2899 // handle here. | 2873 // handle here. |
2900 __ bind(&miss); | 2874 __ bind(&miss); |
2901 GenerateMiss(masm); | 2875 GenerateMiss(masm); |
2902 | 2876 |
2903 // the slow case | 2877 // the slow case |
2904 __ bind(&slow_start); | 2878 __ bind(&slow_start); |
2905 // Check that the function is really a JavaScript function. | 2879 // Check that the function is really a JavaScript function. |
2906 // r1: pushed function (to be verified) | 2880 // r1: pushed function (to be verified) |
2907 __ JumpIfSmi(a1, &non_function); | 2881 __ JumpIfSmi(a1, &slow); |
2908 | 2882 |
2909 // Goto slow case if we do not have a function. | 2883 // Goto slow case if we do not have a function. |
2910 __ GetObjectType(a1, t0, t0); | 2884 __ GetObjectType(a1, t0, t0); |
2911 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); | 2885 __ Branch(&slow, ne, t0, Operand(JS_FUNCTION_TYPE)); |
2912 __ Branch(&have_js_function); | 2886 __ Branch(&have_js_function); |
2913 } | 2887 } |
2914 | 2888 |
2915 | 2889 |
2916 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 2890 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
2917 FrameScope scope(masm, StackFrame::INTERNAL); | 2891 FrameScope scope(masm, StackFrame::INTERNAL); |
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5790 MemOperand(fp, 6 * kPointerSize), NULL); | 5764 MemOperand(fp, 6 * kPointerSize), NULL); |
5791 } | 5765 } |
5792 | 5766 |
5793 | 5767 |
5794 #undef __ | 5768 #undef __ |
5795 | 5769 |
5796 } // namespace internal | 5770 } // namespace internal |
5797 } // namespace v8 | 5771 } // namespace v8 |
5798 | 5772 |
5799 #endif // V8_TARGET_ARCH_MIPS | 5773 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |