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 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1709 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1710 Label* true_label = chunk_->GetAssemblyLabel(true_block); | 1710 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
1711 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 1711 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
1712 | 1712 |
1713 Condition true_cond = EmitIsObject(reg, temp, false_label, true_label); | 1713 Condition true_cond = EmitIsObject(reg, temp, false_label, true_label); |
1714 | 1714 |
1715 EmitBranch(true_block, false_block, true_cond); | 1715 EmitBranch(true_block, false_block, true_cond); |
1716 } | 1716 } |
1717 | 1717 |
1718 | 1718 |
| 1719 Condition LCodeGen::EmitIsString(Register input, |
| 1720 Register temp1, |
| 1721 Label* is_not_string) { |
| 1722 __ JumpIfSmi(input, is_not_string); |
| 1723 |
| 1724 Condition cond = masm_->IsObjectStringType(input, temp1, temp1); |
| 1725 |
| 1726 return cond; |
| 1727 } |
| 1728 |
| 1729 |
| 1730 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { |
| 1731 Register reg = ToRegister(instr->InputAt(0)); |
| 1732 Register temp = ToRegister(instr->TempAt(0)); |
| 1733 |
| 1734 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1735 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1736 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1737 |
| 1738 Condition true_cond = EmitIsString(reg, temp, false_label); |
| 1739 |
| 1740 EmitBranch(true_block, false_block, true_cond); |
| 1741 } |
| 1742 |
| 1743 |
1719 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 1744 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { |
1720 Operand input = ToOperand(instr->InputAt(0)); | 1745 Operand input = ToOperand(instr->InputAt(0)); |
1721 | 1746 |
1722 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1747 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1723 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1748 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1724 | 1749 |
1725 __ test(input, Immediate(kSmiTagMask)); | 1750 __ test(input, Immediate(kSmiTagMask)); |
1726 EmitBranch(true_block, false_block, zero); | 1751 EmitBranch(true_block, false_block, zero); |
1727 } | 1752 } |
1728 | 1753 |
1729 | 1754 |
1730 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { | 1755 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { |
1731 Register input = ToRegister(instr->InputAt(0)); | 1756 Register input = ToRegister(instr->InputAt(0)); |
1732 Register temp = ToRegister(instr->TempAt(0)); | 1757 Register temp = ToRegister(instr->TempAt(0)); |
1733 | 1758 |
1734 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1759 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1735 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1760 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1736 | 1761 |
1737 STATIC_ASSERT(kSmiTag == 0); | 1762 STATIC_ASSERT(kSmiTag == 0); |
1738 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); | 1763 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); |
1739 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); | 1764 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); |
1740 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), | 1765 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), |
1741 1 << Map::kIsUndetectable); | 1766 1 << Map::kIsUndetectable); |
1742 EmitBranch(true_block, false_block, not_zero); | 1767 EmitBranch(true_block, false_block, not_zero); |
1743 } | 1768 } |
1744 | 1769 |
1745 | 1770 |
| 1771 static Condition ComputeCompareCondition(Token::Value op) { |
| 1772 switch (op) { |
| 1773 case Token::EQ_STRICT: |
| 1774 case Token::EQ: |
| 1775 return equal; |
| 1776 case Token::LT: |
| 1777 return less; |
| 1778 case Token::GT: |
| 1779 return greater; |
| 1780 case Token::LTE: |
| 1781 return less_equal; |
| 1782 case Token::GTE: |
| 1783 return greater_equal; |
| 1784 default: |
| 1785 UNREACHABLE(); |
| 1786 return no_condition; |
| 1787 } |
| 1788 } |
| 1789 |
| 1790 |
| 1791 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { |
| 1792 Token::Value op = instr->op(); |
| 1793 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1794 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1795 |
| 1796 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 1797 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1798 |
| 1799 Condition condition = ComputeCompareCondition(op); |
| 1800 __ test(eax, Operand(eax)); |
| 1801 |
| 1802 EmitBranch(true_block, false_block, condition); |
| 1803 } |
| 1804 |
| 1805 |
1746 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 1806 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { |
1747 InstanceType from = instr->from(); | 1807 InstanceType from = instr->from(); |
1748 InstanceType to = instr->to(); | 1808 InstanceType to = instr->to(); |
1749 if (from == FIRST_TYPE) return to; | 1809 if (from == FIRST_TYPE) return to; |
1750 ASSERT(from == to || to == LAST_TYPE); | 1810 ASSERT(from == to || to == LAST_TYPE); |
1751 return from; | 1811 return from; |
1752 } | 1812 } |
1753 | 1813 |
1754 | 1814 |
1755 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { | 1815 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 __ StoreToSafepointRegisterSlot(temp, temp); | 2069 __ StoreToSafepointRegisterSlot(temp, temp); |
2010 CallCodeGeneric(stub.GetCode(), | 2070 CallCodeGeneric(stub.GetCode(), |
2011 RelocInfo::CODE_TARGET, | 2071 RelocInfo::CODE_TARGET, |
2012 instr, | 2072 instr, |
2013 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2073 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
2014 // Put the result value into the eax slot and restore all registers. | 2074 // Put the result value into the eax slot and restore all registers. |
2015 __ StoreToSafepointRegisterSlot(eax, eax); | 2075 __ StoreToSafepointRegisterSlot(eax, eax); |
2016 } | 2076 } |
2017 | 2077 |
2018 | 2078 |
2019 static Condition ComputeCompareCondition(Token::Value op) { | |
2020 switch (op) { | |
2021 case Token::EQ_STRICT: | |
2022 case Token::EQ: | |
2023 return equal; | |
2024 case Token::LT: | |
2025 return less; | |
2026 case Token::GT: | |
2027 return greater; | |
2028 case Token::LTE: | |
2029 return less_equal; | |
2030 case Token::GTE: | |
2031 return greater_equal; | |
2032 default: | |
2033 UNREACHABLE(); | |
2034 return no_condition; | |
2035 } | |
2036 } | |
2037 | |
2038 | |
2039 void LCodeGen::DoCmpT(LCmpT* instr) { | 2079 void LCodeGen::DoCmpT(LCmpT* instr) { |
2040 Token::Value op = instr->op(); | 2080 Token::Value op = instr->op(); |
2041 | 2081 |
2042 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2082 Handle<Code> ic = CompareIC::GetUninitialized(op); |
2043 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2083 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2044 | 2084 |
2045 Condition condition = ComputeCompareCondition(op); | 2085 Condition condition = ComputeCompareCondition(op); |
2046 Label true_value, done; | 2086 Label true_value, done; |
2047 __ test(eax, Operand(eax)); | 2087 __ test(eax, Operand(eax)); |
2048 __ j(condition, &true_value, Label::kNear); | 2088 __ j(condition, &true_value, Label::kNear); |
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4583 env->deoptimization_index()); | 4623 env->deoptimization_index()); |
4584 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4624 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4585 } | 4625 } |
4586 | 4626 |
4587 | 4627 |
4588 #undef __ | 4628 #undef __ |
4589 | 4629 |
4590 } } // namespace v8::internal | 4630 } } // namespace v8::internal |
4591 | 4631 |
4592 #endif // V8_TARGET_ARCH_IA32 | 4632 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |