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