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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 // (See LCodeGen::DoInstanceOfKnownGlobal) | 1372 // (See LCodeGen::DoInstanceOfKnownGlobal) |
1373 void InstanceofStub::Generate(MacroAssembler* masm) { | 1373 void InstanceofStub::Generate(MacroAssembler* masm) { |
1374 // Call site inlining and patching implies arguments in registers. | 1374 // Call site inlining and patching implies arguments in registers. |
1375 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); | 1375 DCHECK(HasArgsInRegisters() || !HasCallSiteInlineCheck()); |
1376 | 1376 |
1377 // Fixed register usage throughout the stub: | 1377 // Fixed register usage throughout the stub: |
1378 const Register object = r3; // Object (lhs). | 1378 const Register object = r3; // Object (lhs). |
1379 Register map = r6; // Map of the object. | 1379 Register map = r6; // Map of the object. |
1380 const Register function = r4; // Function (rhs). | 1380 const Register function = r4; // Function (rhs). |
1381 const Register prototype = r7; // Prototype of the function. | 1381 const Register prototype = r7; // Prototype of the function. |
1382 const Register inline_site = r9; | 1382 // The map_check_delta was stored in r8 |
| 1383 // The bool_load_delta was stored in r9 |
| 1384 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). |
| 1385 const Register map_check_delta = r8; |
| 1386 const Register bool_load_delta = r9; |
| 1387 const Register inline_site = r10; |
1383 const Register scratch = r5; | 1388 const Register scratch = r5; |
1384 Register scratch3 = no_reg; | 1389 Register scratch3 = no_reg; |
1385 | |
1386 // delta = mov + tagged LoadP + cmp + bne | |
1387 const int32_t kDeltaToLoadBoolResult = | |
1388 (Assembler::kMovInstructions + Assembler::kTaggedLoadInstructions + 2) * | |
1389 Assembler::kInstrSize; | |
1390 | |
1391 Label slow, loop, is_instance, is_not_instance, not_js_object; | 1390 Label slow, loop, is_instance, is_not_instance, not_js_object; |
1392 | 1391 |
1393 if (!HasArgsInRegisters()) { | 1392 if (!HasArgsInRegisters()) { |
1394 __ LoadP(object, MemOperand(sp, 1 * kPointerSize)); | 1393 __ LoadP(object, MemOperand(sp, 1 * kPointerSize)); |
1395 __ LoadP(function, MemOperand(sp, 0)); | 1394 __ LoadP(function, MemOperand(sp, 0)); |
1396 } | 1395 } |
1397 | 1396 |
1398 // Check that the left hand is a JS object and load map. | 1397 // Check that the left hand is a JS object and load map. |
1399 __ JumpIfSmi(object, ¬_js_object); | 1398 __ JumpIfSmi(object, ¬_js_object); |
1400 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); | 1399 __ IsObjectJSObjectType(object, map, scratch, ¬_js_object); |
(...skipping 21 matching lines...) Expand all Loading... |
1422 | 1421 |
1423 // Update the global instanceof or call site inlined cache with the current | 1422 // Update the global instanceof or call site inlined cache with the current |
1424 // map and function. The cached answer will be set when it is known below. | 1423 // map and function. The cached answer will be set when it is known below. |
1425 if (!HasCallSiteInlineCheck()) { | 1424 if (!HasCallSiteInlineCheck()) { |
1426 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | 1425 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); |
1427 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); | 1426 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); |
1428 } else { | 1427 } else { |
1429 DCHECK(HasArgsInRegisters()); | 1428 DCHECK(HasArgsInRegisters()); |
1430 // Patch the (relocated) inlined map check. | 1429 // Patch the (relocated) inlined map check. |
1431 | 1430 |
1432 // The offset was stored in r8 | 1431 const Register offset = map_check_delta; |
1433 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal). | |
1434 const Register offset = r8; | |
1435 __ mflr(inline_site); | 1432 __ mflr(inline_site); |
1436 __ sub(inline_site, inline_site, offset); | 1433 __ sub(inline_site, inline_site, offset); |
1437 // Get the map location in r8 and patch it. | 1434 // Get the map location in offset and patch it. |
1438 __ GetRelocatedValue(inline_site, offset, scratch); | 1435 __ GetRelocatedValue(inline_site, offset, scratch); |
1439 __ StoreP(map, FieldMemOperand(offset, Cell::kValueOffset), r0); | 1436 __ StoreP(map, FieldMemOperand(offset, Cell::kValueOffset), r0); |
1440 | 1437 |
1441 __ mr(r10, map); | 1438 __ mr(r11, map); |
1442 __ RecordWriteField(offset, Cell::kValueOffset, r10, function, | 1439 __ RecordWriteField(offset, Cell::kValueOffset, r11, function, |
1443 kLRHasNotBeenSaved, kDontSaveFPRegs, | 1440 kLRHasNotBeenSaved, kDontSaveFPRegs, |
1444 OMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 1441 OMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
1445 } | 1442 } |
1446 | 1443 |
1447 // Register mapping: r6 is object map and r7 is function prototype. | 1444 // Register mapping: r6 is object map and r7 is function prototype. |
1448 // Get prototype of object into r5. | 1445 // Get prototype of object into r5. |
1449 __ LoadP(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); | 1446 __ LoadP(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); |
1450 | 1447 |
1451 // We don't need map any more. Use it as a scratch register. | 1448 // We don't need map any more. Use it as a scratch register. |
1452 scratch3 = map; | 1449 scratch3 = map; |
(...skipping 14 matching lines...) Expand all Loading... |
1467 __ bind(&is_instance); | 1464 __ bind(&is_instance); |
1468 if (!HasCallSiteInlineCheck()) { | 1465 if (!HasCallSiteInlineCheck()) { |
1469 __ LoadSmiLiteral(r3, Smi::FromInt(0)); | 1466 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1470 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); | 1467 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
1471 if (ReturnTrueFalseObject()) { | 1468 if (ReturnTrueFalseObject()) { |
1472 __ Move(r3, factory->true_value()); | 1469 __ Move(r3, factory->true_value()); |
1473 } | 1470 } |
1474 } else { | 1471 } else { |
1475 // Patch the call site to return true. | 1472 // Patch the call site to return true. |
1476 __ LoadRoot(r3, Heap::kTrueValueRootIndex); | 1473 __ LoadRoot(r3, Heap::kTrueValueRootIndex); |
1477 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); | 1474 __ add(inline_site, inline_site, bool_load_delta); |
1478 // Get the boolean result location in scratch and patch it. | 1475 // Get the boolean result location in scratch and patch it. |
1479 __ SetRelocatedValue(inline_site, scratch, r3); | 1476 __ SetRelocatedValue(inline_site, scratch, r3); |
1480 | 1477 |
1481 if (!ReturnTrueFalseObject()) { | 1478 if (!ReturnTrueFalseObject()) { |
1482 __ LoadSmiLiteral(r3, Smi::FromInt(0)); | 1479 __ LoadSmiLiteral(r3, Smi::FromInt(0)); |
1483 } | 1480 } |
1484 } | 1481 } |
1485 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1482 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1486 | 1483 |
1487 __ bind(&is_not_instance); | 1484 __ bind(&is_not_instance); |
1488 if (!HasCallSiteInlineCheck()) { | 1485 if (!HasCallSiteInlineCheck()) { |
1489 __ LoadSmiLiteral(r3, Smi::FromInt(1)); | 1486 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1490 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); | 1487 __ StoreRoot(r3, Heap::kInstanceofCacheAnswerRootIndex); |
1491 if (ReturnTrueFalseObject()) { | 1488 if (ReturnTrueFalseObject()) { |
1492 __ Move(r3, factory->false_value()); | 1489 __ Move(r3, factory->false_value()); |
1493 } | 1490 } |
1494 } else { | 1491 } else { |
1495 // Patch the call site to return false. | 1492 // Patch the call site to return false. |
1496 __ LoadRoot(r3, Heap::kFalseValueRootIndex); | 1493 __ LoadRoot(r3, Heap::kFalseValueRootIndex); |
1497 __ addi(inline_site, inline_site, Operand(kDeltaToLoadBoolResult)); | 1494 __ add(inline_site, inline_site, bool_load_delta); |
1498 // Get the boolean result location in scratch and patch it. | 1495 // Get the boolean result location in scratch and patch it. |
1499 __ SetRelocatedValue(inline_site, scratch, r3); | 1496 __ SetRelocatedValue(inline_site, scratch, r3); |
1500 | 1497 |
1501 if (!ReturnTrueFalseObject()) { | 1498 if (!ReturnTrueFalseObject()) { |
1502 __ LoadSmiLiteral(r3, Smi::FromInt(1)); | 1499 __ LoadSmiLiteral(r3, Smi::FromInt(1)); |
1503 } | 1500 } |
1504 } | 1501 } |
1505 __ Ret(HasArgsInRegisters() ? 0 : 2); | 1502 __ Ret(HasArgsInRegisters() ? 0 : 2); |
1506 | 1503 |
1507 Label object_not_null, object_not_null_or_smi; | 1504 Label object_not_null, object_not_null_or_smi; |
(...skipping 4158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5666 kStackUnwindSpace, NULL, | 5663 kStackUnwindSpace, NULL, |
5667 MemOperand(fp, 6 * kPointerSize), NULL); | 5664 MemOperand(fp, 6 * kPointerSize), NULL); |
5668 } | 5665 } |
5669 | 5666 |
5670 | 5667 |
5671 #undef __ | 5668 #undef __ |
5672 } // namespace internal | 5669 } // namespace internal |
5673 } // namespace v8 | 5670 } // namespace v8 |
5674 | 5671 |
5675 #endif // V8_TARGET_ARCH_PPC | 5672 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |