| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 // This simulates the initial call to bytecode handlers in interpreter entry | 1170 // This simulates the initial call to bytecode handlers in interpreter entry |
| 1171 // trampoline. The return will never actually be taken, but our stack walker | 1171 // trampoline. The return will never actually be taken, but our stack walker |
| 1172 // uses this address to determine whether a frame is interpreted. | 1172 // uses this address to determine whether a frame is interpreted. |
| 1173 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1173 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 1174 | 1174 |
| 1175 Generate_EnterBytecodeDispatch(masm); | 1175 Generate_EnterBytecodeDispatch(masm); |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 | 1178 |
| 1179 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1179 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1180 // ----------- S t a t e ------------- | |
| 1181 // -- x0 : argument count (preserved for callee) | |
| 1182 // -- x3 : new target (preserved for callee) | |
| 1183 // -- x1 : target function (preserved for callee) | |
| 1184 // ----------------------------------- | |
| 1185 // First lookup code, maybe we don't need to compile! | |
| 1186 Label gotta_call_runtime; | |
| 1187 Label maybe_call_runtime; | |
| 1188 Label try_shared; | |
| 1189 Label loop_top, loop_bottom; | |
| 1190 | |
| 1191 Register closure = x1; | |
| 1192 Register new_target = x3; | |
| 1193 Register map = x13; | |
| 1194 Register index = x2; | |
| 1195 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
| 1196 __ Ldr(map, | |
| 1197 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | |
| 1198 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); | |
| 1199 __ Cmp(index, Operand(2)); | |
| 1200 __ B(lt, &gotta_call_runtime); | |
| 1201 | |
| 1202 // Find literals. | |
| 1203 // x3 : native context | |
| 1204 // x2 : length / index | |
| 1205 // x13 : optimized code map | |
| 1206 // stack[0] : new target | |
| 1207 // stack[4] : closure | |
| 1208 Register native_context = x4; | |
| 1209 __ Ldr(native_context, NativeContextMemOperand()); | |
| 1210 | |
| 1211 __ Bind(&loop_top); | |
| 1212 Register temp = x5; | |
| 1213 Register array_pointer = x6; | |
| 1214 | |
| 1215 // Does the native context match? | |
| 1216 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); | |
| 1217 __ Ldr(temp, FieldMemOperand(array_pointer, | |
| 1218 SharedFunctionInfo::kOffsetToPreviousContext)); | |
| 1219 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
| 1220 __ Cmp(temp, native_context); | |
| 1221 __ B(ne, &loop_bottom); | |
| 1222 // OSR id set to none? | |
| 1223 __ Ldr(temp, FieldMemOperand(array_pointer, | |
| 1224 SharedFunctionInfo::kOffsetToPreviousOsrAstId)); | |
| 1225 const int bailout_id = BailoutId::None().ToInt(); | |
| 1226 __ Cmp(temp, Operand(Smi::FromInt(bailout_id))); | |
| 1227 __ B(ne, &loop_bottom); | |
| 1228 // Literals available? | |
| 1229 __ Ldr(temp, FieldMemOperand(array_pointer, | |
| 1230 SharedFunctionInfo::kOffsetToPreviousLiterals)); | |
| 1231 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
| 1232 __ JumpIfSmi(temp, &gotta_call_runtime); | |
| 1233 | |
| 1234 // Save the literals in the closure. | |
| 1235 __ Str(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset)); | |
| 1236 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, x7, | |
| 1237 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
| 1238 OMIT_SMI_CHECK); | |
| 1239 | |
| 1240 // Code available? | |
| 1241 Register entry = x7; | |
| 1242 __ Ldr(entry, | |
| 1243 FieldMemOperand(array_pointer, | |
| 1244 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | |
| 1245 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
| 1246 __ JumpIfSmi(entry, &maybe_call_runtime); | |
| 1247 | |
| 1248 // Found literals and code. Get them into the closure and return. | |
| 1249 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1250 | |
| 1251 Label install_optimized_code_and_tailcall; | |
| 1252 __ Bind(&install_optimized_code_and_tailcall); | |
| 1253 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
| 1254 __ RecordWriteCodeEntryField(closure, entry, x5); | |
| 1255 | |
| 1256 // Link the closure into the optimized function list. | |
| 1257 // x7 : code entry | |
| 1258 // x4 : native context | |
| 1259 // x1 : closure | |
| 1260 __ Ldr(x8, | |
| 1261 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
| 1262 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | |
| 1263 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13, | |
| 1264 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
| 1265 OMIT_SMI_CHECK); | |
| 1266 const int function_list_offset = | |
| 1267 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | |
| 1268 __ Str(closure, | |
| 1269 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
| 1270 __ Mov(x5, closure); | |
| 1271 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13, | |
| 1272 kLRHasNotBeenSaved, kDontSaveFPRegs); | |
| 1273 __ Jump(entry); | |
| 1274 | |
| 1275 __ Bind(&loop_bottom); | |
| 1276 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); | |
| 1277 __ Cmp(index, Operand(1)); | |
| 1278 __ B(gt, &loop_top); | |
| 1279 | |
| 1280 // We found neither literals nor code. | |
| 1281 __ B(&gotta_call_runtime); | |
| 1282 | |
| 1283 __ Bind(&maybe_call_runtime); | |
| 1284 | |
| 1285 // Last possibility. Check the context free optimized code map entry. | |
| 1286 __ Ldr(entry, FieldMemOperand(map, FixedArray::kHeaderSize + | |
| 1287 SharedFunctionInfo::kSharedCodeIndex)); | |
| 1288 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
| 1289 __ JumpIfSmi(entry, &try_shared); | |
| 1290 | |
| 1291 // Store code entry in the closure. | |
| 1292 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1293 __ B(&install_optimized_code_and_tailcall); | |
| 1294 | |
| 1295 __ Bind(&try_shared); | |
| 1296 // Is the full code valid? | |
| 1297 __ Ldr(entry, | |
| 1298 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
| 1299 __ Ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); | |
| 1300 __ Ldr(x5, FieldMemOperand(entry, Code::kFlagsOffset)); | |
| 1301 __ and_(x5, x5, Operand(Code::KindField::kMask)); | |
| 1302 __ Mov(x5, Operand(x5, LSR, Code::KindField::kShift)); | |
| 1303 __ Cmp(x5, Operand(Code::BUILTIN)); | |
| 1304 __ B(eq, &gotta_call_runtime); | |
| 1305 // Yes, install the full code. | |
| 1306 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 1307 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
| 1308 __ RecordWriteCodeEntryField(closure, entry, x5); | |
| 1309 __ Jump(entry); | |
| 1310 | |
| 1311 __ Bind(&gotta_call_runtime); | |
| 1312 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); | 1180 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
| 1313 } | 1181 } |
| 1314 | 1182 |
| 1315 | 1183 |
| 1316 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1184 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| 1317 GenerateTailCallToReturnedCode(masm, | 1185 GenerateTailCallToReturnedCode(masm, |
| 1318 Runtime::kCompileOptimized_NotConcurrent); | 1186 Runtime::kCompileOptimized_NotConcurrent); |
| 1319 } | 1187 } |
| 1320 | 1188 |
| 1321 | 1189 |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 } | 2758 } |
| 2891 } | 2759 } |
| 2892 | 2760 |
| 2893 | 2761 |
| 2894 #undef __ | 2762 #undef __ |
| 2895 | 2763 |
| 2896 } // namespace internal | 2764 } // namespace internal |
| 2897 } // namespace v8 | 2765 } // namespace v8 |
| 2898 | 2766 |
| 2899 #endif // V8_TARGET_ARCH_ARM | 2767 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |