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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 | 1335 |
1336 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1336 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
1337 // ----------- S t a t e ------------- | 1337 // ----------- S t a t e ------------- |
1338 // -- r3 : argument count (preserved for callee) | 1338 // -- r3 : argument count (preserved for callee) |
1339 // -- r6 : new target (preserved for callee) | 1339 // -- r6 : new target (preserved for callee) |
1340 // -- r4 : target function (preserved for callee) | 1340 // -- r4 : target function (preserved for callee) |
1341 // ----------------------------------- | 1341 // ----------------------------------- |
1342 // First lookup code, maybe we don't need to compile! | 1342 // First lookup code, maybe we don't need to compile! |
1343 Label gotta_call_runtime; | 1343 Label gotta_call_runtime; |
1344 Label try_shared; | 1344 Label try_shared; |
| 1345 Label loop_top, loop_bottom; |
1345 | 1346 |
1346 Register closure = r4; | 1347 Register closure = r4; |
| 1348 Register map = r9; |
1347 Register index = r5; | 1349 Register index = r5; |
1348 | 1350 |
1349 // Do we have a valid feedback vector? | 1351 // Do we have a valid feedback vector? |
1350 __ LoadP(index, FieldMemOperand(closure, JSFunction::kFeedbackVectorOffset)); | 1352 __ LoadP(index, FieldMemOperand(closure, JSFunction::kFeedbackVectorOffset)); |
1351 __ LoadP(index, FieldMemOperand(index, Cell::kValueOffset)); | 1353 __ LoadP(index, FieldMemOperand(index, Cell::kValueOffset)); |
1352 __ JumpIfRoot(index, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); | 1354 __ JumpIfRoot(index, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); |
1353 | 1355 |
1354 // Is optimized code available in the feedback vector? | 1356 __ LoadP(map, |
| 1357 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1358 __ LoadP(map, |
| 1359 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1360 __ LoadP(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1361 __ CmpSmiLiteral(index, Smi::FromInt(2), r0); |
| 1362 __ blt(&try_shared); |
| 1363 |
| 1364 // r10 : native context |
| 1365 // r5 : length / index |
| 1366 // r9 : optimized code map |
| 1367 // r6 : new target |
| 1368 // r4 : closure |
| 1369 Register native_context = r10; |
| 1370 __ LoadP(native_context, NativeContextMemOperand()); |
| 1371 |
| 1372 __ bind(&loop_top); |
| 1373 Register temp = r11; |
| 1374 Register array_pointer = r8; |
| 1375 |
| 1376 // Does the native context match? |
| 1377 __ SmiToPtrArrayOffset(array_pointer, index); |
| 1378 __ add(array_pointer, map, array_pointer); |
| 1379 __ LoadP(temp, FieldMemOperand(array_pointer, |
| 1380 SharedFunctionInfo::kOffsetToPreviousContext)); |
| 1381 __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1382 __ cmp(temp, native_context); |
| 1383 __ bne(&loop_bottom); |
| 1384 |
| 1385 // Code available? |
1355 Register entry = r7; | 1386 Register entry = r7; |
1356 __ LoadP(entry, FieldMemOperand(index, FeedbackVector::kOptimizedCodeIndex * | 1387 __ LoadP(entry, |
1357 kPointerSize + | 1388 FieldMemOperand(array_pointer, |
1358 FeedbackVector::kHeaderSize)); | 1389 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1359 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | 1390 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
1360 __ JumpIfSmi(entry, &try_shared); | 1391 __ JumpIfSmi(entry, &try_shared); |
1361 | 1392 |
| 1393 // Found code. Get it into the closure and return. |
1362 // Store code entry in the closure. | 1394 // Store code entry in the closure. |
1363 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1395 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1364 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); | 1396 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); |
1365 __ RecordWriteCodeEntryField(closure, entry, r8); | 1397 __ RecordWriteCodeEntryField(closure, entry, r8); |
1366 | 1398 |
1367 // Load native context into r9. | |
1368 Register native_context = r9; | |
1369 __ LoadP(native_context, NativeContextMemOperand()); | |
1370 | |
1371 // Link the closure into the optimized function list. | 1399 // Link the closure into the optimized function list. |
| 1400 // r7 : code entry |
| 1401 // r10: native context |
| 1402 // r4 : closure |
1372 __ LoadP( | 1403 __ LoadP( |
1373 r8, ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | 1404 r8, ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
1374 __ StoreP(r8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset), | 1405 __ StoreP(r8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset), |
1375 r0); | 1406 r0); |
1376 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r8, r5, | 1407 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r8, temp, |
1377 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1408 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
1378 OMIT_SMI_CHECK); | 1409 OMIT_SMI_CHECK); |
1379 const int function_list_offset = | 1410 const int function_list_offset = |
1380 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | 1411 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
1381 __ StoreP( | 1412 __ StoreP( |
1382 closure, | 1413 closure, |
1383 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST), r0); | 1414 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST), r0); |
1384 // Save closure before the write barrier. | 1415 // Save closure before the write barrier. |
1385 __ mr(r8, closure); | 1416 __ mr(r8, closure); |
1386 __ RecordWriteContextSlot(native_context, function_list_offset, r8, r5, | 1417 __ RecordWriteContextSlot(native_context, function_list_offset, r8, temp, |
1387 kLRHasNotBeenSaved, kDontSaveFPRegs); | 1418 kLRHasNotBeenSaved, kDontSaveFPRegs); |
1388 __ JumpToJSEntry(entry); | 1419 __ JumpToJSEntry(entry); |
1389 | 1420 |
1390 // We found no optimized code. | 1421 __ bind(&loop_bottom); |
| 1422 __ SubSmiLiteral(index, index, Smi::FromInt(SharedFunctionInfo::kEntryLength), |
| 1423 r0); |
| 1424 __ CmpSmiLiteral(index, Smi::FromInt(1), r0); |
| 1425 __ bgt(&loop_top); |
| 1426 |
| 1427 // We found no code. |
| 1428 __ b(&gotta_call_runtime); |
| 1429 |
1391 __ bind(&try_shared); | 1430 __ bind(&try_shared); |
1392 __ LoadP(entry, | 1431 __ LoadP(entry, |
1393 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1432 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1394 // Is the shared function marked for tier up? | 1433 // Is the shared function marked for tier up? |
1395 __ lbz(r8, FieldMemOperand(entry, | 1434 __ lbz(r8, FieldMemOperand(entry, |
1396 SharedFunctionInfo::kMarkedForTierUpByteOffset)); | 1435 SharedFunctionInfo::kMarkedForTierUpByteOffset)); |
1397 __ TestBit(r8, SharedFunctionInfo::kMarkedForTierUpBitWithinByte, r0); | 1436 __ TestBit(r8, SharedFunctionInfo::kMarkedForTierUpBitWithinByte, r0); |
1398 __ bne(&gotta_call_runtime, cr0); | 1437 __ bne(&gotta_call_runtime, cr0); |
1399 | 1438 |
1400 // If SFI points to anything other than CompileLazy, install that. | 1439 // If SFI points to anything other than CompileLazy, install that. |
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 } | 3113 } |
3075 // Now jump to the instructions of the returned code object. | 3114 // Now jump to the instructions of the returned code object. |
3076 __ Jump(r11); | 3115 __ Jump(r11); |
3077 } | 3116 } |
3078 | 3117 |
3079 #undef __ | 3118 #undef __ |
3080 } // namespace internal | 3119 } // namespace internal |
3081 } // namespace v8 | 3120 } // namespace v8 |
3082 | 3121 |
3083 #endif // V8_TARGET_ARCH_PPC | 3122 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |