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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 // This simulates the initial call to bytecode handlers in interpreter entry | 1141 // This simulates the initial call to bytecode handlers in interpreter entry |
1142 // trampoline. The return will never actually be taken, but our stack walker | 1142 // trampoline. The return will never actually be taken, but our stack walker |
1143 // uses this address to determine whether a frame is interpreted. | 1143 // uses this address to determine whether a frame is interpreted. |
1144 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1144 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1145 | 1145 |
1146 Generate_EnterBytecodeDispatch(masm); | 1146 Generate_EnterBytecodeDispatch(masm); |
1147 } | 1147 } |
1148 | 1148 |
1149 | 1149 |
1150 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1150 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1151 // ----------- S t a t e ------------- |
| 1152 // -- a3 : new target (preserved for callee) |
| 1153 // -- a1 : target function (preserved for callee) |
| 1154 // ----------------------------------- |
| 1155 // First lookup code, maybe we don't need to compile! |
| 1156 Label gotta_call_runtime, gotta_call_runtime_no_stack; |
| 1157 Label maybe_call_runtime; |
| 1158 Label try_shared; |
| 1159 Label loop_top, loop_bottom; |
| 1160 |
| 1161 Register closure = a1; |
| 1162 Register new_target = a3; |
| 1163 __ push(new_target); |
| 1164 __ push(closure); |
| 1165 |
| 1166 Register map = a0; |
| 1167 Register index = a2; |
| 1168 __ lw(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1169 __ lw(map, FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1170 __ lw(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1171 __ Branch(&gotta_call_runtime, lt, index, Operand(Smi::FromInt(2))); |
| 1172 |
| 1173 // Find literals. |
| 1174 // a3 : native context |
| 1175 // a2 : length / index |
| 1176 // a0 : optimized code map |
| 1177 // stack[0] : new target |
| 1178 // stack[4] : closure |
| 1179 Register native_context = a3; |
| 1180 __ lw(native_context, NativeContextMemOperand()); |
| 1181 |
| 1182 __ bind(&loop_top); |
| 1183 Register temp = a1; |
| 1184 Register array_pointer = t1; |
| 1185 |
| 1186 // Does the native context match? |
| 1187 __ sll(at, index, kPointerSizeLog2 - kSmiTagSize); |
| 1188 __ Addu(array_pointer, map, Operand(at)); |
| 1189 __ lw(temp, FieldMemOperand(array_pointer, |
| 1190 SharedFunctionInfo::OffsetToPreviousContext())); |
| 1191 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1192 __ Branch(&loop_bottom, ne, temp, Operand(native_context)); |
| 1193 // OSR id set to none? |
| 1194 __ lw(temp, FieldMemOperand(array_pointer, |
| 1195 SharedFunctionInfo::OffsetToPreviousOsrAstId())); |
| 1196 const int bailout_id = BailoutId::None().ToInt(); |
| 1197 __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id))); |
| 1198 // Literals available? |
| 1199 __ lw(temp, FieldMemOperand(array_pointer, |
| 1200 SharedFunctionInfo::OffsetToPreviousLiterals())); |
| 1201 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1202 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1203 |
| 1204 // Save the literals in the closure. |
| 1205 __ lw(t0, MemOperand(sp, 0)); |
| 1206 __ sw(temp, FieldMemOperand(t0, JSFunction::kLiteralsOffset)); |
| 1207 __ push(index); |
| 1208 __ RecordWriteField(t0, JSFunction::kLiteralsOffset, temp, index, |
| 1209 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1210 OMIT_SMI_CHECK); |
| 1211 __ pop(index); |
| 1212 |
| 1213 // Code available? |
| 1214 Register entry = t0; |
| 1215 __ lw(entry, |
| 1216 FieldMemOperand(array_pointer, |
| 1217 SharedFunctionInfo::OffsetToPreviousCachedCode())); |
| 1218 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1219 __ JumpIfSmi(entry, &maybe_call_runtime); |
| 1220 |
| 1221 // Found literals and code. Get them into the closure and return. |
| 1222 __ pop(closure); |
| 1223 // Store code entry in the closure. |
| 1224 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1225 |
| 1226 Label install_optimized_code_and_tailcall; |
| 1227 __ bind(&install_optimized_code_and_tailcall); |
| 1228 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1229 |
| 1230 // Link the closure into the optimized function list. |
| 1231 // t0 : code entry |
| 1232 // a3 : native context |
| 1233 // a1 : closure |
| 1234 __ lw(t1, |
| 1235 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1236 __ sw(t1, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
| 1237 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, t1, a0, |
| 1238 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1239 OMIT_SMI_CHECK); |
| 1240 const int function_list_offset = |
| 1241 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1242 __ sw(closure, |
| 1243 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1244 // Save closure before the write barrier. |
| 1245 __ mov(t1, closure); |
| 1246 __ RecordWriteContextSlot(native_context, function_list_offset, closure, a0, |
| 1247 kRAHasNotBeenSaved, kDontSaveFPRegs); |
| 1248 __ mov(closure, t1); |
| 1249 __ pop(new_target); |
| 1250 __ Jump(entry); |
| 1251 |
| 1252 __ bind(&loop_bottom); |
| 1253 __ Subu(index, index, |
| 1254 Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); |
| 1255 __ Branch(&loop_top, gt, index, Operand(Smi::FromInt(1))); |
| 1256 |
| 1257 // We found neither literals nor code. |
| 1258 __ jmp(&gotta_call_runtime); |
| 1259 |
| 1260 __ bind(&maybe_call_runtime); |
| 1261 __ pop(closure); |
| 1262 |
| 1263 // Last possibility. Check the context free optimized code map entry. |
| 1264 __ lw(entry, FieldMemOperand(map, FixedArray::kHeaderSize + |
| 1265 SharedFunctionInfo::kSharedCodeIndex)); |
| 1266 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1267 __ JumpIfSmi(entry, &try_shared); |
| 1268 |
| 1269 // Store code entry in the closure. |
| 1270 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1271 __ jmp(&install_optimized_code_and_tailcall); |
| 1272 |
| 1273 __ bind(&try_shared); |
| 1274 __ pop(new_target); |
| 1275 // Is the full code valid? |
| 1276 __ lw(entry, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1277 __ lw(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); |
| 1278 __ lw(t1, FieldMemOperand(entry, Code::kFlagsOffset)); |
| 1279 __ And(t1, t1, Operand(Code::KindField::kMask)); |
| 1280 __ srl(t1, t1, Code::KindField::kShift); |
| 1281 __ Branch(&gotta_call_runtime_no_stack, eq, t1, Operand(Code::BUILTIN)); |
| 1282 // Yes, install the full code. |
| 1283 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1284 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1285 __ Jump(entry); |
| 1286 |
| 1287 __ bind(&gotta_call_runtime); |
| 1288 __ pop(closure); |
| 1289 __ pop(new_target); |
| 1290 __ bind(&gotta_call_runtime_no_stack); |
1151 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1291 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
1152 GenerateTailCallToReturnedCode(masm); | 1292 GenerateTailCallToReturnedCode(masm); |
1153 } | 1293 } |
1154 | 1294 |
1155 | 1295 |
1156 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1296 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1157 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1297 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
1158 GenerateTailCallToReturnedCode(masm); | 1298 GenerateTailCallToReturnedCode(masm); |
1159 } | 1299 } |
1160 | 1300 |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 } | 2815 } |
2676 } | 2816 } |
2677 | 2817 |
2678 | 2818 |
2679 #undef __ | 2819 #undef __ |
2680 | 2820 |
2681 } // namespace internal | 2821 } // namespace internal |
2682 } // namespace v8 | 2822 } // namespace v8 |
2683 | 2823 |
2684 #endif // V8_TARGET_ARCH_MIPS | 2824 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |