OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 __ mov(r0, Operand(Factory::true_value()), LeaveCC, eq); | 1581 __ mov(r0, Operand(Factory::true_value()), LeaveCC, eq); |
1582 } | 1582 } |
1583 | 1583 |
1584 | 1584 |
1585 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { | 1585 void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) { |
1586 Abort("DoInstanceOfAndBranch unimplemented."); | 1586 Abort("DoInstanceOfAndBranch unimplemented."); |
1587 } | 1587 } |
1588 | 1588 |
1589 | 1589 |
1590 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { | 1590 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
1591 Abort("DoInstanceOfKnownGlobal unimplemented."); | 1591 class DeferredInstanceOfKnownGlobal: public LDeferredCode { |
1592 public: | |
1593 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, | |
1594 LInstanceOfKnownGlobal* instr) | |
1595 : LDeferredCode(codegen), instr_(instr) { } | |
1596 virtual void Generate() { | |
1597 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_); | |
1598 } | |
1599 | |
1600 Label* map_check() { return &map_check_; } | |
1601 | |
1602 private: | |
1603 LInstanceOfKnownGlobal* instr_; | |
1604 Label map_check_; | |
1605 }; | |
1606 | |
1607 DeferredInstanceOfKnownGlobal* deferred; | |
1608 deferred = new DeferredInstanceOfKnownGlobal(this, instr); | |
1609 | |
1610 Label done, false_result; | |
1611 Register object = ToRegister(instr->input()); | |
1612 Register temp = ToRegister(instr->temp()); | |
1613 Register result = ToRegister(instr->result()); | |
1614 | |
1615 ASSERT(object.is(r0)); | |
1616 ASSERT(result.is(r0)); | |
1617 | |
1618 // A Smi is not instance of anything. | |
1619 __ BranchOnSmi(object, &false_result); | |
1620 | |
1621 // This is the inlined call site instanceof cache. The two occurences of the | |
1622 // hole value will be patched to the last map/result pair generated by the | |
1623 // instanceof stub. | |
1624 Label cache_miss; | |
1625 Register map = temp; | |
1626 __ ldr(map, FieldMemOperand(object, HeapObject::kMapOffset)); | |
1627 __ bind(deferred->map_check()); // Label for calculating code patching. | |
1628 // We use Factory::the_hole_value() on purpose to force relocation to be | |
Søren Thygesen Gjesse
2011/01/13 15:14:36
Extend comment with "instead of loading from the r
Alexandre
2011/01/14 17:53:40
It is. Updated.
On 2011/01/13 15:14:36, Søren Gjes
| |
1629 // able to later patch with the cached map. | |
1630 __ mov(ip, Operand(Factory::the_hole_value())); | |
1631 __ cmp(map, Operand(ip)); | |
1632 __ b(ne, &cache_miss); | |
1633 // We use Factory::the_hole_value() on purpose to force relocation to be | |
Søren Thygesen Gjesse
2011/01/13 15:14:36
Ditto.
Alexandre
2011/01/14 17:53:40
Done.
| |
1634 // able to later patch with true or false. | |
1635 __ mov(ip, Operand(Factory::the_hole_value())); | |
1636 __ b(&done); | |
1637 | |
1638 // The inlined call site cache did not match. Check null and string before | |
1639 // calling the deferred code. | |
1640 __ bind(&cache_miss); | |
1641 // Null is not instance of anything. | |
1642 __ LoadRoot(ip, Heap::kNullValueRootIndex); | |
1643 __ cmp(object, Operand(ip)); | |
1644 __ b(eq, &false_result); | |
1645 | |
1646 // String values is not instance of anything. | |
1647 Condition is_string = masm_->IsObjectStringType(object, temp); | |
1648 __ b(is_string, &false_result); | |
1649 | |
1650 // Go to the deferred code. | |
1651 __ b(deferred->entry()); | |
1652 | |
1653 __ bind(&false_result); | |
1654 __ LoadRoot(result, Heap::kFalseValueRootIndex); | |
1655 | |
1656 // Here result has either true or false. Deferred code also produces true or | |
1657 // false object. | |
1658 __ bind(deferred->exit()); | |
1659 __ bind(&done); | |
1660 } | |
1661 | |
1662 | |
1663 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | |
1664 Label* map_check) { | |
1665 Register result = ToRegister(instr->result()); | |
1666 | |
1667 InstanceofStub::Flags flags = InstanceofStub::kNoFlags; | |
1668 flags = static_cast<InstanceofStub::Flags>( | |
1669 flags | InstanceofStub::kArgsInRegisters); | |
1670 flags = static_cast<InstanceofStub::Flags>( | |
1671 flags | InstanceofStub::kCallSiteInlineCheck); | |
1672 flags = static_cast<InstanceofStub::Flags>( | |
1673 flags | InstanceofStub::kReturnTrueFalseObject); | |
1674 InstanceofStub stub(flags); | |
1675 | |
1676 __ PushSafepointRegisters(); | |
1677 | |
1678 // Get the temp register reserved by the instruction. This needs to be r4 as | |
1679 // its slot of the pushing of safepoint registers is used to communicate the | |
1680 // offset to the location of the map check. | |
1681 Register temp = ToRegister(instr->temp()); | |
1682 ASSERT(temp.is(r4)); | |
1683 __ mov(InstanceofStub::right(), Operand(instr->function())); | |
1684 static const int kAdditionalDelta = 4; // 3 instructions + 1 for reloc info. | |
Søren Thygesen Gjesse
2011/01/13 15:14:36
I think the 4 here is 4 instructions Call always g
Alexandre
2011/01/14 17:53:40
The +1 was referring to the additional instruction
| |
1685 int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta; | |
1686 Label before_push_delta; | |
1687 __ bind(&before_push_delta); | |
1688 __ mov(temp, Operand(delta * kPointerSize)); | |
Søren Thygesen Gjesse
2011/01/13 15:14:36
On IA32 we have EspIndexForPushAll, and I think we
Alexandre
2011/01/14 17:53:40
Added SafepointRegisterSlot and StoreToSafepoint
| |
1689 __ str(temp, MemOperand(sp, temp.code() * kPointerSize)); | |
1690 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); | |
1691 ASSERT_EQ(kAdditionalDelta, | |
1692 masm_->InstructionsGeneratedSince(&before_push_delta)); | |
1693 RecordSafepointWithRegisters( | |
1694 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); | |
1695 // Put the result value into the result register slot and | |
1696 // restore all registers. | |
1697 __ str(r0, MemOperand(sp, result.code() * kPointerSize)); | |
1698 | |
1699 __ PopSafepointRegisters(); | |
1592 } | 1700 } |
1593 | 1701 |
1594 | 1702 |
1595 static Condition ComputeCompareCondition(Token::Value op) { | 1703 static Condition ComputeCompareCondition(Token::Value op) { |
1596 switch (op) { | 1704 switch (op) { |
1597 case Token::EQ_STRICT: | 1705 case Token::EQ_STRICT: |
1598 case Token::EQ: | 1706 case Token::EQ: |
1599 return eq; | 1707 return eq; |
1600 case Token::LT: | 1708 case Token::LT: |
1601 return lt; | 1709 return lt; |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2830 | 2938 |
2831 | 2939 |
2832 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2940 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
2833 Abort("DoOsrEntry unimplemented."); | 2941 Abort("DoOsrEntry unimplemented."); |
2834 } | 2942 } |
2835 | 2943 |
2836 | 2944 |
2837 #undef __ | 2945 #undef __ |
2838 | 2946 |
2839 } } // namespace v8::internal | 2947 } } // namespace v8::internal |
OLD | NEW |