OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 // uses this address to determine whether a frame is interpreted. | 1234 // uses this address to determine whether a frame is interpreted. |
1235 __ mov(r0, | 1235 __ mov(r0, |
1236 Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1236 Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1237 __ mtlr(r0); | 1237 __ mtlr(r0); |
1238 | 1238 |
1239 Generate_EnterBytecodeDispatch(masm); | 1239 Generate_EnterBytecodeDispatch(masm); |
1240 } | 1240 } |
1241 | 1241 |
1242 | 1242 |
1243 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1243 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1244 // ----------- S t a t e ------------- |
| 1245 // -- r3 : argument count (preserved for callee) |
| 1246 // -- r6 : new target (preserved for callee) |
| 1247 // -- r4 : target function (preserved for callee) |
| 1248 // ----------------------------------- |
| 1249 // First lookup code, maybe we don't need to compile! |
| 1250 Label gotta_call_runtime; |
| 1251 Label maybe_call_runtime; |
| 1252 Label try_shared; |
| 1253 Label loop_top, loop_bottom; |
| 1254 |
| 1255 Register closure = r4; |
| 1256 Register map = r9; |
| 1257 Register index = r5; |
| 1258 __ LoadP(map, |
| 1259 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1260 __ LoadP(map, |
| 1261 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1262 __ LoadP(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1263 __ CmpSmiLiteral(index, Smi::FromInt(2), r0); |
| 1264 __ blt(&gotta_call_runtime); |
| 1265 |
| 1266 // Find literals. |
| 1267 // r10 : native context |
| 1268 // r5 : length / index |
| 1269 // r9 : optimized code map |
| 1270 // r6 : new target |
| 1271 // r4 : closure |
| 1272 Register native_context = r10; |
| 1273 __ LoadP(native_context, NativeContextMemOperand()); |
| 1274 |
| 1275 __ bind(&loop_top); |
| 1276 Register temp = r11; |
| 1277 Register array_pointer = r8; |
| 1278 |
| 1279 // Does the native context match? |
| 1280 __ SmiToPtrArrayOffset(array_pointer, index); |
| 1281 __ add(array_pointer, map, array_pointer); |
| 1282 __ LoadP(temp, FieldMemOperand(array_pointer, |
| 1283 SharedFunctionInfo::kOffsetToPreviousContext)); |
| 1284 __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1285 __ cmp(temp, native_context); |
| 1286 __ bne(&loop_bottom); |
| 1287 // OSR id set to none? |
| 1288 __ LoadP(temp, |
| 1289 FieldMemOperand(array_pointer, |
| 1290 SharedFunctionInfo::kOffsetToPreviousOsrAstId)); |
| 1291 const int bailout_id = BailoutId::None().ToInt(); |
| 1292 __ CmpSmiLiteral(temp, Smi::FromInt(bailout_id), r0); |
| 1293 __ bne(&loop_bottom); |
| 1294 // Literals available? |
| 1295 __ LoadP(temp, |
| 1296 FieldMemOperand(array_pointer, |
| 1297 SharedFunctionInfo::kOffsetToPreviousLiterals)); |
| 1298 __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1299 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1300 |
| 1301 // Save the literals in the closure. |
| 1302 __ StoreP(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset), r0); |
| 1303 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, r7, |
| 1304 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1305 OMIT_SMI_CHECK); |
| 1306 |
| 1307 // Code available? |
| 1308 Register entry = r7; |
| 1309 __ LoadP(entry, |
| 1310 FieldMemOperand(array_pointer, |
| 1311 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
| 1312 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1313 __ JumpIfSmi(entry, &maybe_call_runtime); |
| 1314 |
| 1315 // Found literals and code. Get them into the closure and return. |
| 1316 // Store code entry in the closure. |
| 1317 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1318 |
| 1319 Label install_optimized_code_and_tailcall; |
| 1320 __ bind(&install_optimized_code_and_tailcall); |
| 1321 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); |
| 1322 __ RecordWriteCodeEntryField(closure, entry, r8); |
| 1323 |
| 1324 // Link the closure into the optimized function list. |
| 1325 // r7 : code entry |
| 1326 // r10: native context |
| 1327 // r4 : closure |
| 1328 __ LoadP( |
| 1329 r8, ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1330 __ StoreP(r8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset), |
| 1331 r0); |
| 1332 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r8, temp, |
| 1333 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1334 OMIT_SMI_CHECK); |
| 1335 const int function_list_offset = |
| 1336 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1337 __ StoreP( |
| 1338 closure, |
| 1339 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST), r0); |
| 1340 // Save closure before the write barrier. |
| 1341 __ mr(r8, closure); |
| 1342 __ RecordWriteContextSlot(native_context, function_list_offset, r8, temp, |
| 1343 kLRHasNotBeenSaved, kDontSaveFPRegs); |
| 1344 __ JumpToJSEntry(entry); |
| 1345 |
| 1346 __ bind(&loop_bottom); |
| 1347 __ SubSmiLiteral(index, index, Smi::FromInt(SharedFunctionInfo::kEntryLength), |
| 1348 r0); |
| 1349 __ CmpSmiLiteral(index, Smi::FromInt(1), r0); |
| 1350 __ bgt(&loop_top); |
| 1351 |
| 1352 // We found neither literals nor code. |
| 1353 __ b(&gotta_call_runtime); |
| 1354 |
| 1355 __ bind(&maybe_call_runtime); |
| 1356 |
| 1357 // Last possibility. Check the context free optimized code map entry. |
| 1358 __ LoadP(entry, |
| 1359 FieldMemOperand(map, FixedArray::kHeaderSize + |
| 1360 SharedFunctionInfo::kSharedCodeIndex)); |
| 1361 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1362 __ JumpIfSmi(entry, &try_shared); |
| 1363 |
| 1364 // Store code entry in the closure. |
| 1365 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1366 __ b(&install_optimized_code_and_tailcall); |
| 1367 |
| 1368 __ bind(&try_shared); |
| 1369 // Is the full code valid? |
| 1370 __ LoadP(entry, |
| 1371 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1372 __ LoadP(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); |
| 1373 __ lwz(r8, FieldMemOperand(entry, Code::kFlagsOffset)); |
| 1374 __ DecodeField<Code::KindField>(r8); |
| 1375 __ cmpi(r8, Operand(Code::BUILTIN)); |
| 1376 __ beq(&gotta_call_runtime); |
| 1377 // Yes, install the full code. |
| 1378 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1379 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); |
| 1380 __ RecordWriteCodeEntryField(closure, entry, r8); |
| 1381 __ JumpToJSEntry(entry); |
| 1382 |
| 1383 __ bind(&gotta_call_runtime); |
1244 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); | 1384 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
1245 } | 1385 } |
1246 | 1386 |
1247 | 1387 |
1248 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1388 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1249 GenerateTailCallToReturnedCode(masm, | 1389 GenerateTailCallToReturnedCode(masm, |
1250 Runtime::kCompileOptimized_NotConcurrent); | 1390 Runtime::kCompileOptimized_NotConcurrent); |
1251 } | 1391 } |
1252 | 1392 |
1253 | 1393 |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2715 __ bkpt(0); | 2855 __ bkpt(0); |
2716 } | 2856 } |
2717 } | 2857 } |
2718 | 2858 |
2719 | 2859 |
2720 #undef __ | 2860 #undef __ |
2721 } // namespace internal | 2861 } // namespace internal |
2722 } // namespace v8 | 2862 } // namespace v8 |
2723 | 2863 |
2724 #endif // V8_TARGET_ARCH_PPC | 2864 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |