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