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 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 Label* false_label = chunk_->GetAssemblyLabel(false_block); | 1670 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
1671 | 1671 |
1672 Condition true_cond = | 1672 Condition true_cond = |
1673 EmitIsObject(reg, temp1, temp2, false_label, true_label); | 1673 EmitIsObject(reg, temp1, temp2, false_label, true_label); |
1674 | 1674 |
1675 EmitBranch(true_block, false_block, true_cond, temp2, | 1675 EmitBranch(true_block, false_block, true_cond, temp2, |
1676 Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 1676 Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
1677 } | 1677 } |
1678 | 1678 |
1679 | 1679 |
| 1680 Condition LCodeGen::EmitIsString(Register input, |
| 1681 Register temp1, |
| 1682 Label* is_not_string) { |
| 1683 __ JumpIfSmi(input, is_not_string); |
| 1684 __ GetObjectType(input, temp1, temp1); |
| 1685 |
| 1686 return lt; |
| 1687 } |
| 1688 |
| 1689 |
| 1690 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { |
| 1691 Register reg = ToRegister(instr->InputAt(0)); |
| 1692 Register temp1 = ToRegister(instr->TempAt(0)); |
| 1693 |
| 1694 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1695 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1696 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1697 |
| 1698 Condition true_cond = |
| 1699 EmitIsString(reg, temp1, false_label); |
| 1700 |
| 1701 EmitBranch(true_block, false_block, true_cond, temp1, |
| 1702 Operand(FIRST_NONSTRING_TYPE)); |
| 1703 } |
| 1704 |
| 1705 |
1680 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { | 1706 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) { |
1681 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1707 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1682 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1708 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1683 | 1709 |
1684 Register input_reg = EmitLoadRegister(instr->InputAt(0), at); | 1710 Register input_reg = EmitLoadRegister(instr->InputAt(0), at); |
1685 __ And(at, input_reg, kSmiTagMask); | 1711 __ And(at, input_reg, kSmiTagMask); |
1686 EmitBranch(true_block, false_block, eq, at, Operand(zero_reg)); | 1712 EmitBranch(true_block, false_block, eq, at, Operand(zero_reg)); |
1687 } | 1713 } |
1688 | 1714 |
1689 | 1715 |
1690 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { | 1716 void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { |
1691 Register input = ToRegister(instr->InputAt(0)); | 1717 Register input = ToRegister(instr->InputAt(0)); |
1692 Register temp = ToRegister(instr->TempAt(0)); | 1718 Register temp = ToRegister(instr->TempAt(0)); |
1693 | 1719 |
1694 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1720 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
1695 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1721 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
1696 | 1722 |
1697 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); | 1723 __ JumpIfSmi(input, chunk_->GetAssemblyLabel(false_block)); |
1698 __ lw(temp, FieldMemOperand(input, HeapObject::kMapOffset)); | 1724 __ lw(temp, FieldMemOperand(input, HeapObject::kMapOffset)); |
1699 __ lbu(temp, FieldMemOperand(temp, Map::kBitFieldOffset)); | 1725 __ lbu(temp, FieldMemOperand(temp, Map::kBitFieldOffset)); |
1700 __ And(at, temp, Operand(1 << Map::kIsUndetectable)); | 1726 __ And(at, temp, Operand(1 << Map::kIsUndetectable)); |
1701 EmitBranch(true_block, false_block, ne, at, Operand(zero_reg)); | 1727 EmitBranch(true_block, false_block, ne, at, Operand(zero_reg)); |
1702 } | 1728 } |
1703 | 1729 |
1704 | 1730 |
| 1731 static Condition ComputeCompareCondition(Token::Value op) { |
| 1732 switch (op) { |
| 1733 case Token::EQ_STRICT: |
| 1734 case Token::EQ: |
| 1735 return eq; |
| 1736 case Token::LT: |
| 1737 return lt; |
| 1738 case Token::GT: |
| 1739 return gt; |
| 1740 case Token::LTE: |
| 1741 return le; |
| 1742 case Token::GTE: |
| 1743 return ge; |
| 1744 default: |
| 1745 UNREACHABLE(); |
| 1746 return kNoCondition; |
| 1747 } |
| 1748 } |
| 1749 |
| 1750 |
| 1751 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) { |
| 1752 Token::Value op = instr->op(); |
| 1753 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1754 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1755 |
| 1756 Handle<Code> ic = CompareIC::GetUninitialized(op); |
| 1757 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 1758 |
| 1759 Condition condition = ComputeCompareCondition(op); |
| 1760 |
| 1761 EmitBranch(true_block, false_block, condition, v0, Operand(zero_reg)); |
| 1762 } |
| 1763 |
| 1764 |
1705 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { | 1765 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) { |
1706 InstanceType from = instr->from(); | 1766 InstanceType from = instr->from(); |
1707 InstanceType to = instr->to(); | 1767 InstanceType to = instr->to(); |
1708 if (from == FIRST_TYPE) return to; | 1768 if (from == FIRST_TYPE) return to; |
1709 ASSERT(from == to || to == LAST_TYPE); | 1769 ASSERT(from == to || to == LAST_TYPE); |
1710 return from; | 1770 return from; |
1711 } | 1771 } |
1712 | 1772 |
1713 | 1773 |
1714 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { | 1774 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2055 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
1996 ASSERT(instr->HasDeoptimizationEnvironment()); | 2056 ASSERT(instr->HasDeoptimizationEnvironment()); |
1997 LEnvironment* env = instr->deoptimization_environment(); | 2057 LEnvironment* env = instr->deoptimization_environment(); |
1998 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 2058 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
1999 // Put the result value into the result register slot and | 2059 // Put the result value into the result register slot and |
2000 // restore all registers. | 2060 // restore all registers. |
2001 __ StoreToSafepointRegisterSlot(result, result); | 2061 __ StoreToSafepointRegisterSlot(result, result); |
2002 } | 2062 } |
2003 | 2063 |
2004 | 2064 |
2005 static Condition ComputeCompareCondition(Token::Value op) { | |
2006 switch (op) { | |
2007 case Token::EQ_STRICT: | |
2008 case Token::EQ: | |
2009 return eq; | |
2010 case Token::LT: | |
2011 return lt; | |
2012 case Token::GT: | |
2013 return gt; | |
2014 case Token::LTE: | |
2015 return le; | |
2016 case Token::GTE: | |
2017 return ge; | |
2018 default: | |
2019 UNREACHABLE(); | |
2020 return kNoCondition; | |
2021 } | |
2022 } | |
2023 | |
2024 | |
2025 void LCodeGen::DoCmpT(LCmpT* instr) { | 2065 void LCodeGen::DoCmpT(LCmpT* instr) { |
2026 Token::Value op = instr->op(); | 2066 Token::Value op = instr->op(); |
2027 | 2067 |
2028 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2068 Handle<Code> ic = CompareIC::GetUninitialized(op); |
2029 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2069 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2030 // On MIPS there is no need for a "no inlined smi code" marker (nop). | 2070 // On MIPS there is no need for a "no inlined smi code" marker (nop). |
2031 | 2071 |
2032 Condition condition = ComputeCompareCondition(op); | 2072 Condition condition = ComputeCompareCondition(op); |
2033 // A minor optimization that relies on LoadRoot always emitting one | 2073 // A minor optimization that relies on LoadRoot always emitting one |
2034 // instruction. | 2074 // instruction. |
(...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4591 ASSERT(!environment->HasBeenRegistered()); | 4631 ASSERT(!environment->HasBeenRegistered()); |
4592 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4632 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4593 ASSERT(osr_pc_offset_ == -1); | 4633 ASSERT(osr_pc_offset_ == -1); |
4594 osr_pc_offset_ = masm()->pc_offset(); | 4634 osr_pc_offset_ = masm()->pc_offset(); |
4595 } | 4635 } |
4596 | 4636 |
4597 | 4637 |
4598 #undef __ | 4638 #undef __ |
4599 | 4639 |
4600 } } // namespace v8::internal | 4640 } } // namespace v8::internal |
OLD | NEW |