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