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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 // This simulates the initial call to bytecode handlers in interpreter entry | 1150 // This simulates the initial call to bytecode handlers in interpreter entry |
1151 // trampoline. The return will never actually be taken, but our stack walker | 1151 // trampoline. The return will never actually be taken, but our stack walker |
1152 // uses this address to determine whether a frame is interpreted. | 1152 // uses this address to determine whether a frame is interpreted. |
1153 __ Move(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1153 __ Move(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1154 | 1154 |
1155 Generate_EnterBytecodeDispatch(masm); | 1155 Generate_EnterBytecodeDispatch(masm); |
1156 } | 1156 } |
1157 | 1157 |
1158 | 1158 |
1159 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1159 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
1160 // ----------- S t a t e ------------- | |
1161 // -- r3 : new target (preserved for callee) | |
1162 // -- r1 : target function (preserved for callee) | |
1163 // ----------------------------------- | |
1164 // First lookup code, maybe we don't need to compile! | |
1165 Label gotta_call_runtime, gotta_call_runtime_no_stack; | |
1166 Label maybe_call_runtime; | |
1167 Label try_shared; | |
1168 Label loop_top, loop_bottom; | |
1169 | |
1170 Register closure = r1; | |
1171 Register new_target = r3; | |
1172 __ push(new_target); | |
1173 __ push(closure); | |
1174 | |
1175 Register map = r0; | |
1176 Register index = r2; | |
1177 __ ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
1178 __ ldr(map, | |
1179 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | |
1180 __ ldr(index, FieldMemOperand(map, FixedArray::kLengthOffset)); | |
1181 __ cmp(index, Operand(Smi::FromInt(2))); | |
1182 __ b(lt, &gotta_call_runtime); | |
1183 | |
1184 // Find literals. | |
1185 // r3 : native context | |
1186 // r2 : length / index | |
1187 // r0 : optimized code map | |
1188 // stack[0] : new target | |
1189 // stack[4] : closure | |
1190 Register native_context = r3; | |
1191 __ ldr(native_context, NativeContextMemOperand()); | |
1192 | |
1193 __ bind(&loop_top); | |
1194 Register temp = r1; | |
1195 Register array_pointer = r5; | |
1196 | |
1197 // Does the native context match? | |
1198 __ add(array_pointer, map, Operand::PointerOffsetFromSmiKey(index)); | |
1199 __ ldr(temp, FieldMemOperand(array_pointer, | |
1200 SharedFunctionInfo::OffsetToPreviousContext())); | |
1201 __ ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
1202 __ cmp(temp, native_context); | |
1203 __ b(ne, &loop_bottom); | |
1204 // OSR id set to none? | |
1205 __ ldr(temp, FieldMemOperand(array_pointer, | |
1206 SharedFunctionInfo::OffsetToPreviousOsrAstId())); | |
1207 const int bailout_id = BailoutId::None().ToInt(); | |
1208 __ cmp(temp, Operand(Smi::FromInt(bailout_id))); | |
1209 __ b(ne, &loop_bottom); | |
1210 // Literals available? | |
1211 __ ldr(temp, FieldMemOperand(array_pointer, | |
1212 SharedFunctionInfo::OffsetToPreviousLiterals())); | |
1213 __ ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
1214 __ JumpIfSmi(temp, &gotta_call_runtime); | |
1215 | |
1216 // Save the literals in the closure. | |
1217 __ ldr(r4, MemOperand(sp, 0)); | |
1218 __ str(temp, FieldMemOperand(r4, JSFunction::kLiteralsOffset)); | |
1219 __ push(index); | |
1220 __ RecordWriteField(r4, JSFunction::kLiteralsOffset, temp, index, | |
1221 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
1222 OMIT_SMI_CHECK); | |
1223 __ pop(index); | |
1224 | |
1225 // Code available? | |
1226 Register entry = r4; | |
1227 __ ldr(entry, | |
1228 FieldMemOperand(array_pointer, | |
1229 SharedFunctionInfo::OffsetToPreviousCachedCode())); | |
1230 __ ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
1231 __ JumpIfSmi(entry, &maybe_call_runtime); | |
1232 | |
1233 // Found literals and code. Get them into the closure and return. | |
1234 __ pop(closure); | |
1235 // Store code entry in the closure. | |
1236 __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1237 | |
1238 Label install_optimized_code_and_tailcall; | |
1239 __ bind(&install_optimized_code_and_tailcall); | |
1240 __ str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
1241 | |
1242 // Link the closure into the optimized function list. | |
1243 // r4 : code entry | |
1244 // r3 : native context | |
1245 // r1 : closure | |
1246 __ ldr(r5, | |
1247 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
1248 __ str(r5, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | |
1249 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r5, r0, | |
1250 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
1251 OMIT_SMI_CHECK); | |
1252 const int function_list_offset = | |
1253 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | |
1254 __ str(closure, | |
1255 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
1256 // Save closure before the write barrier. | |
1257 __ mov(r5, closure); | |
1258 __ RecordWriteContextSlot(native_context, function_list_offset, closure, r0, | |
1259 kLRHasNotBeenSaved, kDontSaveFPRegs); | |
1260 __ mov(closure, r5); | |
1261 __ pop(new_target); | |
1262 __ Jump(entry); | |
1263 | |
1264 __ bind(&loop_bottom); | |
1265 __ sub(index, index, Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); | |
1266 __ cmp(index, Operand(Smi::FromInt(1))); | |
1267 __ b(gt, &loop_top); | |
1268 | |
1269 // We found neither literals nor code. | |
1270 __ jmp(&gotta_call_runtime); | |
1271 | |
1272 __ bind(&maybe_call_runtime); | |
1273 __ pop(closure); | |
1274 | |
1275 // Last possibility. Check the context free optimized code map entry. | |
1276 __ ldr(entry, FieldMemOperand(map, FixedArray::kHeaderSize + | |
1277 SharedFunctionInfo::kSharedCodeIndex)); | |
1278 __ ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
1279 __ JumpIfSmi(entry, &try_shared); | |
1280 | |
1281 // Store code entry in the closure. | |
1282 __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1283 __ jmp(&install_optimized_code_and_tailcall); | |
1284 | |
1285 __ bind(&try_shared); | |
1286 __ pop(new_target); | |
1287 // Is the full code valid? | |
1288 __ ldr(entry, | |
1289 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
1290 __ ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); | |
1291 __ ldr(r5, FieldMemOperand(entry, Code::kFlagsOffset)); | |
1292 __ and_(r5, r5, Operand(Code::KindField::kMask)); | |
1293 __ mov(r5, Operand(r5, LSR, Code::KindField::kShift)); | |
1294 __ cmp(r5, Operand(Code::BUILTIN)); | |
1295 __ b(eq, &gotta_call_runtime_no_stack); | |
1296 // Yes, install the full code. | |
1297 __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1298 __ str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
1299 __ Jump(entry); | |
1300 | |
1301 __ bind(&gotta_call_runtime); | |
1302 __ pop(closure); | |
1303 __ pop(new_target); | |
1304 __ bind(&gotta_call_runtime_no_stack); | |
1305 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1160 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
1306 GenerateTailCallToReturnedCode(masm); | 1161 GenerateTailCallToReturnedCode(masm); |
1307 } | 1162 } |
1308 | 1163 |
1309 | 1164 |
1310 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1165 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1311 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1166 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
1312 GenerateTailCallToReturnedCode(masm); | 1167 GenerateTailCallToReturnedCode(masm); |
1313 } | 1168 } |
1314 | 1169 |
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 } | 2597 } |
2743 } | 2598 } |
2744 | 2599 |
2745 | 2600 |
2746 #undef __ | 2601 #undef __ |
2747 | 2602 |
2748 } // namespace internal | 2603 } // namespace internal |
2749 } // namespace v8 | 2604 } // namespace v8 |
2750 | 2605 |
2751 #endif // V8_TARGET_ARCH_ARM | 2606 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |