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/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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 // Leave the frame (also dropping the register file). | 1066 // Leave the frame (also dropping the register file). |
1067 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 1067 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
1068 | 1068 |
1069 // Drop receiver + arguments and return. | 1069 // Drop receiver + arguments and return. |
1070 __ lw(at, FieldMemOperand(kInterpreterBytecodeArrayRegister, | 1070 __ lw(at, FieldMemOperand(kInterpreterBytecodeArrayRegister, |
1071 BytecodeArray::kParameterSizeOffset)); | 1071 BytecodeArray::kParameterSizeOffset)); |
1072 __ Addu(sp, sp, at); | 1072 __ Addu(sp, sp, at); |
1073 __ Jump(ra); | 1073 __ Jump(ra); |
1074 } | 1074 } |
1075 | 1075 |
| 1076 static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index, |
| 1077 Register limit, Register scratch) { |
| 1078 Label loop_header, loop_check; |
| 1079 __ Branch(&loop_check); |
| 1080 __ bind(&loop_header); |
| 1081 __ lw(scratch, MemOperand(index)); |
| 1082 __ Addu(index, index, Operand(-kPointerSize)); |
| 1083 __ push(scratch); |
| 1084 __ bind(&loop_check); |
| 1085 __ Branch(&loop_header, gt, index, Operand(limit)); |
| 1086 } |
| 1087 |
| 1088 static void Generate_InterpreterComputeLastArgumentAddress( |
| 1089 MacroAssembler* masm, Register num_args, Register start_address, |
| 1090 Register output_reg) { |
| 1091 __ Addu(output_reg, num_args, Operand(1)); // Add one for receiver. |
| 1092 __ sll(output_reg, output_reg, kPointerSizeLog2); |
| 1093 __ Subu(output_reg, start_address, output_reg); |
| 1094 } |
| 1095 |
| 1096 // static |
| 1097 void Builtins::Generate_InterpreterPushArgsAndCallICImpl( |
| 1098 MacroAssembler* masm, TailCallMode tail_call_mode) { |
| 1099 // ----------- S t a t e ------------- |
| 1100 // -- a0 : the number of arguments (not including the receiver) |
| 1101 // -- t0 : the address of the first argument to be pushed. Subsequent |
| 1102 // arguments should be consecutive above this, in the same order as |
| 1103 // they are to be pushed onto the stack. |
| 1104 // -- a1 : the target to call (can be any Object). |
| 1105 // -- a3 : feedback vector slot id |
| 1106 // -- a2 : type feedback vector |
| 1107 // ----------------------------------- |
| 1108 |
| 1109 { |
| 1110 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1111 |
| 1112 // Computes the address of last argument in t1. |
| 1113 Generate_InterpreterComputeLastArgumentAddress(masm, a0, t0, t1); |
| 1114 |
| 1115 // Push the arguments. |
| 1116 Generate_InterpreterPushArgs(masm, t0, t1, at); |
| 1117 |
| 1118 // Call via the CallIC stub. |
| 1119 CallICState call_ic_state(0, ConvertReceiverMode::kAny, tail_call_mode, |
| 1120 true); |
| 1121 CallICStub stub(masm->isolate(), call_ic_state); |
| 1122 // TODO(mythria): This should be replaced by a TailCallStub, when we |
| 1123 // update the code to find the target IC from jump instructions. |
| 1124 __ CallStub(&stub); |
| 1125 } |
| 1126 __ Ret(); |
| 1127 } |
1076 | 1128 |
1077 // static | 1129 // static |
1078 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1130 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1079 MacroAssembler* masm, TailCallMode tail_call_mode) { | 1131 MacroAssembler* masm, TailCallMode tail_call_mode) { |
1080 // ----------- S t a t e ------------- | 1132 // ----------- S t a t e ------------- |
1081 // -- a0 : the number of arguments (not including the receiver) | 1133 // -- a0 : the number of arguments (not including the receiver) |
1082 // -- a2 : the address of the first argument to be pushed. Subsequent | 1134 // -- a2 : the address of the first argument to be pushed. Subsequent |
1083 // arguments should be consecutive above this, in the same order as | 1135 // arguments should be consecutive above this, in the same order as |
1084 // they are to be pushed onto the stack. | 1136 // they are to be pushed onto the stack. |
1085 // -- a1 : the target to call (can be any Object). | 1137 // -- a1 : the target to call (can be any Object). |
1086 // ----------------------------------- | 1138 // ----------------------------------- |
1087 | 1139 |
1088 // Find the address of the last argument. | 1140 // Computes the address of last argument in a3. |
1089 __ Addu(a3, a0, Operand(1)); // Add one for receiver. | 1141 Generate_InterpreterComputeLastArgumentAddress(masm, a0, a2, a3); |
1090 __ sll(a3, a3, kPointerSizeLog2); | |
1091 __ Subu(a3, a2, Operand(a3)); | |
1092 | 1142 |
1093 // Push the arguments. | 1143 // Push the arguments. |
1094 Label loop_header, loop_check; | 1144 Generate_InterpreterPushArgs(masm, a2, a3, at); |
1095 __ Branch(&loop_check); | |
1096 __ bind(&loop_header); | |
1097 __ lw(t0, MemOperand(a2)); | |
1098 __ Addu(a2, a2, Operand(-kPointerSize)); | |
1099 __ push(t0); | |
1100 __ bind(&loop_check); | |
1101 __ Branch(&loop_header, gt, a2, Operand(a3)); | |
1102 | 1145 |
1103 // Call the target. | 1146 // Call the target. |
1104 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1147 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1105 tail_call_mode), | 1148 tail_call_mode), |
1106 RelocInfo::CODE_TARGET); | 1149 RelocInfo::CODE_TARGET); |
1107 } | 1150 } |
1108 | 1151 |
1109 | |
1110 // static | 1152 // static |
1111 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 1153 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
1112 // ----------- S t a t e ------------- | 1154 // ----------- S t a t e ------------- |
1113 // -- a0 : argument count (not including receiver) | 1155 // -- a0 : argument count (not including receiver) |
1114 // -- a3 : new target | 1156 // -- a3 : new target |
1115 // -- a1 : constructor to call | 1157 // -- a1 : constructor to call |
1116 // -- a2 : address of the first argument | 1158 // -- a2 : address of the first argument |
1117 // ----------------------------------- | 1159 // ----------------------------------- |
1118 | 1160 |
1119 // Find the address of the last argument. | 1161 // Find the address of the last argument. |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 Comment cmnt(masm, "[ PrepareForTailCall"); | 2116 Comment cmnt(masm, "[ PrepareForTailCall"); |
2075 | 2117 |
2076 // Prepare for tail call only if the debugger is not active. | 2118 // Prepare for tail call only if the debugger is not active. |
2077 Label done; | 2119 Label done; |
2078 ExternalReference debug_is_active = | 2120 ExternalReference debug_is_active = |
2079 ExternalReference::debug_is_active_address(masm->isolate()); | 2121 ExternalReference::debug_is_active_address(masm->isolate()); |
2080 __ li(at, Operand(debug_is_active)); | 2122 __ li(at, Operand(debug_is_active)); |
2081 __ lb(scratch1, MemOperand(at)); | 2123 __ lb(scratch1, MemOperand(at)); |
2082 __ Branch(&done, ne, scratch1, Operand(zero_reg)); | 2124 __ Branch(&done, ne, scratch1, Operand(zero_reg)); |
2083 | 2125 |
| 2126 // Drop possible internal frame pushed for calling CallICStub. |
| 2127 // TODO(mythria): when we tail call the CallICStub, remove this. |
| 2128 { |
| 2129 Label no_internal_callic_frame; |
| 2130 __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
| 2131 __ Branch(&no_internal_callic_frame, ne, scratch3, |
| 2132 Operand(Smi::FromInt(StackFrame::INTERNAL))); |
| 2133 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2134 __ bind(&no_internal_callic_frame); |
| 2135 } |
| 2136 |
2084 // Drop possible interpreter handler/stub frame. | 2137 // Drop possible interpreter handler/stub frame. |
2085 { | 2138 { |
2086 Label no_interpreter_frame; | 2139 Label no_interpreter_frame; |
2087 __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); | 2140 __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
2088 __ Branch(&no_interpreter_frame, ne, scratch3, | 2141 __ Branch(&no_interpreter_frame, ne, scratch3, |
2089 Operand(Smi::FromInt(StackFrame::STUB))); | 2142 Operand(Smi::FromInt(StackFrame::STUB))); |
2090 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 2143 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
2091 __ bind(&no_interpreter_frame); | 2144 __ bind(&no_interpreter_frame); |
2092 } | 2145 } |
2093 | 2146 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2765 } | 2818 } |
2766 } | 2819 } |
2767 | 2820 |
2768 | 2821 |
2769 #undef __ | 2822 #undef __ |
2770 | 2823 |
2771 } // namespace internal | 2824 } // namespace internal |
2772 } // namespace v8 | 2825 } // namespace v8 |
2773 | 2826 |
2774 #endif // V8_TARGET_ARCH_MIPS | 2827 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |