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/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // Leave the frame (also dropping the register file). | 1058 // Leave the frame (also dropping the register file). |
1059 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 1059 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
1060 | 1060 |
1061 // Drop receiver + arguments and return. | 1061 // Drop receiver + arguments and return. |
1062 __ lw(at, FieldMemOperand(kInterpreterBytecodeArrayRegister, | 1062 __ lw(at, FieldMemOperand(kInterpreterBytecodeArrayRegister, |
1063 BytecodeArray::kParameterSizeOffset)); | 1063 BytecodeArray::kParameterSizeOffset)); |
1064 __ Daddu(sp, sp, at); | 1064 __ Daddu(sp, sp, at); |
1065 __ Jump(ra); | 1065 __ Jump(ra); |
1066 } | 1066 } |
1067 | 1067 |
| 1068 static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index, |
| 1069 Register limit, Register scratch) { |
| 1070 Label loop_header, loop_check; |
| 1071 __ Branch(&loop_check); |
| 1072 __ bind(&loop_header); |
| 1073 __ ld(scratch, MemOperand(index)); |
| 1074 __ Daddu(index, index, Operand(-kPointerSize)); |
| 1075 __ push(scratch); |
| 1076 __ bind(&loop_check); |
| 1077 __ Branch(&loop_header, gt, index, Operand(limit)); |
| 1078 } |
| 1079 |
| 1080 static void Generate_InterpreterComputeLastArgumentAddress( |
| 1081 MacroAssembler* masm, Register num_args, Register start_address, |
| 1082 Register output_reg) { |
| 1083 __ Daddu(output_reg, num_args, Operand(1)); // Add one for receiver. |
| 1084 __ dsll(output_reg, output_reg, kPointerSizeLog2); |
| 1085 __ Dsubu(output_reg, start_address, output_reg); |
| 1086 } |
| 1087 |
| 1088 // static |
| 1089 void Builtins::Generate_InterpreterPushArgsAndCallICImpl( |
| 1090 MacroAssembler* masm, TailCallMode tail_call_mode) { |
| 1091 // ----------- S t a t e ------------- |
| 1092 // -- a0 : the number of arguments (not including the receiver) |
| 1093 // -- a4 : the address of the first argument to be pushed. Subsequent |
| 1094 // arguments should be consecutive above this, in the same order as |
| 1095 // they are to be pushed onto the stack. |
| 1096 // -- a1 : the target to call (can be any Object). |
| 1097 // -- a3 : feedback vector slot id |
| 1098 // -- a2 : type feedback vector |
| 1099 // ----------------------------------- |
| 1100 |
| 1101 { |
| 1102 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1103 |
| 1104 // Computes the address of last argument in a5. |
| 1105 Generate_InterpreterComputeLastArgumentAddress(masm, a0, a4, a5); |
| 1106 |
| 1107 // Push the arguments. |
| 1108 Generate_InterpreterPushArgs(masm, a4, a5, at); |
| 1109 |
| 1110 // Call via the CallIC stub. |
| 1111 CallICState call_ic_state(0, ConvertReceiverMode::kAny, tail_call_mode, |
| 1112 true); |
| 1113 CallICStub stub(masm->isolate(), call_ic_state); |
| 1114 // TODO(mythria): This should be replaced by a TailCallStub, when we |
| 1115 // update the code to find the target IC from jump instructions. |
| 1116 __ CallStub(&stub); |
| 1117 } |
| 1118 __ Ret(); |
| 1119 } |
1068 | 1120 |
1069 // static | 1121 // static |
1070 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1122 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1071 MacroAssembler* masm, TailCallMode tail_call_mode) { | 1123 MacroAssembler* masm, TailCallMode tail_call_mode) { |
1072 // ----------- S t a t e ------------- | 1124 // ----------- S t a t e ------------- |
1073 // -- a0 : the number of arguments (not including the receiver) | 1125 // -- a0 : the number of arguments (not including the receiver) |
1074 // -- a2 : the address of the first argument to be pushed. Subsequent | 1126 // -- a2 : the address of the first argument to be pushed. Subsequent |
1075 // arguments should be consecutive above this, in the same order as | 1127 // arguments should be consecutive above this, in the same order as |
1076 // they are to be pushed onto the stack. | 1128 // they are to be pushed onto the stack. |
1077 // -- a1 : the target to call (can be any Object). | 1129 // -- a1 : the target to call (can be any Object). |
1078 // ----------------------------------- | 1130 // ----------------------------------- |
1079 | 1131 |
1080 // Find the address of the last argument. | 1132 // Computes the address of last argument in a3. |
1081 __ Daddu(a3, a0, Operand(1)); // Add one for receiver. | 1133 Generate_InterpreterComputeLastArgumentAddress(masm, a0, a2, a3); |
1082 __ dsll(a3, a3, kPointerSizeLog2); | |
1083 __ Dsubu(a3, a2, Operand(a3)); | |
1084 | 1134 |
1085 // Push the arguments. | 1135 // Push the arguments. |
1086 Label loop_header, loop_check; | 1136 Generate_InterpreterPushArgs(masm, a2, a3, at); |
1087 __ Branch(&loop_check); | |
1088 __ bind(&loop_header); | |
1089 __ ld(t0, MemOperand(a2)); | |
1090 __ Daddu(a2, a2, Operand(-kPointerSize)); | |
1091 __ push(t0); | |
1092 __ bind(&loop_check); | |
1093 __ Branch(&loop_header, gt, a2, Operand(a3)); | |
1094 | 1137 |
1095 // Call the target. | 1138 // Call the target. |
1096 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1139 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1097 tail_call_mode), | 1140 tail_call_mode), |
1098 RelocInfo::CODE_TARGET); | 1141 RelocInfo::CODE_TARGET); |
1099 } | 1142 } |
1100 | 1143 |
1101 | 1144 |
1102 // static | 1145 // static |
1103 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 1146 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 Comment cmnt(masm, "[ PrepareForTailCall"); | 2112 Comment cmnt(masm, "[ PrepareForTailCall"); |
2070 | 2113 |
2071 // Prepare for tail call only if the debugger is not active. | 2114 // Prepare for tail call only if the debugger is not active. |
2072 Label done; | 2115 Label done; |
2073 ExternalReference debug_is_active = | 2116 ExternalReference debug_is_active = |
2074 ExternalReference::debug_is_active_address(masm->isolate()); | 2117 ExternalReference::debug_is_active_address(masm->isolate()); |
2075 __ li(at, Operand(debug_is_active)); | 2118 __ li(at, Operand(debug_is_active)); |
2076 __ lb(scratch1, MemOperand(at)); | 2119 __ lb(scratch1, MemOperand(at)); |
2077 __ Branch(&done, ne, scratch1, Operand(zero_reg)); | 2120 __ Branch(&done, ne, scratch1, Operand(zero_reg)); |
2078 | 2121 |
| 2122 // Drop possible internal frame pushed for calling CallICStub. |
| 2123 // TODO(mythria): when we tail call the CallICStub, remove this. |
| 2124 { |
| 2125 Label no_internal_callic_frame; |
| 2126 __ ld(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
| 2127 __ Branch(&no_internal_callic_frame, ne, scratch3, |
| 2128 Operand(Smi::FromInt(StackFrame::INTERNAL))); |
| 2129 __ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2130 __ bind(&no_internal_callic_frame); |
| 2131 } |
| 2132 |
2079 // Drop possible interpreter handler/stub frame. | 2133 // Drop possible interpreter handler/stub frame. |
2080 { | 2134 { |
2081 Label no_interpreter_frame; | 2135 Label no_interpreter_frame; |
2082 __ ld(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); | 2136 __ ld(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
2083 __ Branch(&no_interpreter_frame, ne, scratch3, | 2137 __ Branch(&no_interpreter_frame, ne, scratch3, |
2084 Operand(Smi::FromInt(StackFrame::STUB))); | 2138 Operand(Smi::FromInt(StackFrame::STUB))); |
2085 __ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 2139 __ ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
2086 __ bind(&no_interpreter_frame); | 2140 __ bind(&no_interpreter_frame); |
2087 } | 2141 } |
2088 | 2142 |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 } | 2813 } |
2760 } | 2814 } |
2761 | 2815 |
2762 | 2816 |
2763 #undef __ | 2817 #undef __ |
2764 | 2818 |
2765 } // namespace internal | 2819 } // namespace internal |
2766 } // namespace v8 | 2820 } // namespace v8 |
2767 | 2821 |
2768 #endif // V8_TARGET_ARCH_MIPS64 | 2822 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |