 Chromium Code Reviews
 Chromium Code Reviews| 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 Label* is_string) { | |
| 1723 __ JumpIfSmi(input, is_not_string); | |
| 1724 | |
| 1725 Condition cond = masm_->IsObjectStringType(input, temp1, temp1); | |
| 1726 | |
| 1727 return cond; | |
| 1728 } | |
| 1729 | |
| 1730 | |
| 1731 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { | |
| 1732 Register reg = ToRegister(instr->InputAt(0)); | |
| 1733 Register temp = ToRegister(instr->TempAt(0)); | |
| 1734 | |
| 1735 int true_block = chunk_->LookupDestination(instr->true_block_id()); | |
| 1736 int false_block = chunk_->LookupDestination(instr->false_block_id()); | |
| 1737 Label* true_label = chunk_->GetAssemblyLabel(true_block); | |
| 1738 Label* false_label = chunk_->GetAssemblyLabel(false_block); | |
| 1739 | |
| 1740 Condition true_cond = EmitIsString(reg, temp, false_label, true_label); | |
| 1741 | |
| 1742 EmitBranch(true_block, false_block, true_cond); | |
| 1743 } | |
| 1744 | |
| 1745 | |
| 1719 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 1746 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 
| 1720 Operand input = ToOperand(instr->InputAt(0)); | 1747 Operand input = ToOperand(instr->InputAt(0)); | 
| 1721 | 1748 | 
| 1722 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1749 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 
| 1723 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1750 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 
| 1724 | 1751 | 
| 1725 __ test(input, Immediate(kSmiTagMask)); | 1752 __ test(input, Immediate(kSmiTagMask)); | 
| 1726 EmitBranch(true_block, false_block, zero); | 1753 EmitBranch(true_block, false_block, zero); | 
| 1727 } | 1754 } | 
| 1728 | 1755 | 
| 1729 | 1756 | 
| 1730 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { | 1757 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { | 
| 1731 Register input = ToRegister(instr->InputAt(0)); | 1758 Register input = ToRegister(instr->InputAt(0)); | 
| 1732 Register temp = ToRegister(instr->TempAt(0)); | 1759 Register temp = ToRegister(instr->TempAt(0)); | 
| 1733 | 1760 | 
| 1734 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1761 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 
| 1735 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1762 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 
| 1736 | 1763 | 
| 1737 STATIC_ASSERT(kSmiTag == 0); | 1764 STATIC_ASSERT(kSmiTag == 0); | 
| 1738 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); | 1765 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); | 
| 1739 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); | 1766 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); | 
| 1740 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), | 1767 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), | 
| 1741 1 << Map::kIsUndetectable); | 1768 1 << Map::kIsUndetectable); | 
| 1742 EmitBranch(true_block, false_block, not_zero); | 1769 EmitBranch(true_block, false_block, not_zero); | 
| 1743 } | 1770 } | 
| 1744 | 1771 | 
| 1745 | 1772 | 
| 1773 static Condition ComputeCompareCondition(Token::Value op) { | |
| 1774 switch (op) { | |
| 1775 case Token::EQ_STRICT: | |
| 1776 case Token::EQ: | |
| 1777 return equal; | |
| 1778 case Token::LT: | |
| 1779 return less; | |
| 1780 case Token::GT: | |
| 1781 return greater; | |
| 1782 case Token::LTE: | |
| 1783 return less_equal; | |
| 1784 case Token::GTE: | |
| 1785 return greater_equal; | |
| 1786 default: | |
| 1787 UNREACHABLE(); | |
| 1788 return no_condition; | |
| 1789 } | |
| 1790 } | |
| 1791 | |
| 1792 | |
| 1793 void LCodeGen::DoCompareGenericAndBranch(LCompareGenericAndBranch* instr) { | |
| 1794 Token::Value op = instr->op(); | |
| 1795 int true_block = chunk_->LookupDestination(instr->true_block_id()); | |
| 1796 int false_block = chunk_->LookupDestination(instr->false_block_id()); | |
| 1797 | |
| 1798 Handle<Code> ic = CompareIC::GetUninitialized(op); | |
| 
fschneider
2011/11/07 08:27:18
Use StringCompareStub instead. StringCompareStub s
 
indutny
2011/11/07 11:49:28
Just benchmarked it, and found that StringCompareS
 
fschneider
2011/11/07 15:34:00
Ok, thanks for trying out. Stick to the faster ver
 | |
| 1799 CallCode(ic, RelocInfo::CODE_TARGET, instr); | |
| 1800 | |
| 1801 Condition condition = ComputeCompareCondition(op); | |
| 1802 __ test(eax, Operand(eax)); | |
| 1803 | |
| 1804 EmitBranch(true_block, false_block, condition); | |
| 1805 } | |
| 1806 | |
| 1807 | |
| 1746 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 1808 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 
| 1747 InstanceType from = instr->from(); | 1809 InstanceType from = instr->from(); | 
| 1748 InstanceType to = instr->to(); | 1810 InstanceType to = instr->to(); | 
| 1749 if (from == FIRST_TYPE) return to; | 1811 if (from == FIRST_TYPE) return to; | 
| 1750 ASSERT(from == to || to == LAST_TYPE); | 1812 ASSERT(from == to || to == LAST_TYPE); | 
| 1751 return from; | 1813 return from; | 
| 1752 } | 1814 } | 
| 1753 | 1815 | 
| 1754 | 1816 | 
| 1755 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { | 1817 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { | 
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2009 __ StoreToSafepointRegisterSlot(temp, temp); | 2071 __ StoreToSafepointRegisterSlot(temp, temp); | 
| 2010 CallCodeGeneric(stub.GetCode(), | 2072 CallCodeGeneric(stub.GetCode(), | 
| 2011 RelocInfo::CODE_TARGET, | 2073 RelocInfo::CODE_TARGET, | 
| 2012 instr, | 2074 instr, | 
| 2013 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2075 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 
| 2014 // Put the result value into the eax slot and restore all registers. | 2076 // Put the result value into the eax slot and restore all registers. | 
| 2015 __ StoreToSafepointRegisterSlot(eax, eax); | 2077 __ StoreToSafepointRegisterSlot(eax, eax); | 
| 2016 } | 2078 } | 
| 2017 | 2079 | 
| 2018 | 2080 | 
| 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) { | 2081 void LCodeGen::DoCmpT(LCmpT* instr) { | 
| 2040 Token::Value op = instr->op(); | 2082 Token::Value op = instr->op(); | 
| 2041 | 2083 | 
| 2042 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2084 Handle<Code> ic = CompareIC::GetUninitialized(op); | 
| 2043 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2085 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 
| 2044 | 2086 | 
| 2045 Condition condition = ComputeCompareCondition(op); | 2087 Condition condition = ComputeCompareCondition(op); | 
| 2046 Label true_value, done; | 2088 Label true_value, done; | 
| 2047 __ test(eax, Operand(eax)); | 2089 __ test(eax, Operand(eax)); | 
| 2048 __ j(condition, &true_value, Label::kNear); | 2090 __ j(condition, &true_value, Label::kNear); | 
| (...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4583 env->deoptimization_index()); | 4625 env->deoptimization_index()); | 
| 4584 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4626 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 
| 4585 } | 4627 } | 
| 4586 | 4628 | 
| 4587 | 4629 | 
| 4588 #undef __ | 4630 #undef __ | 
| 4589 | 4631 | 
| 4590 } } // namespace v8::internal | 4632 } } // namespace v8::internal | 
| 4591 | 4633 | 
| 4592 #endif // V8_TARGET_ARCH_IA32 | 4634 #endif // V8_TARGET_ARCH_IA32 | 
| OLD | NEW |