OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 int LCodeGen::GetNextEmittedBlock() const { | 1964 int LCodeGen::GetNextEmittedBlock() const { |
1965 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | 1965 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { |
1966 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | 1966 if (!chunk_->GetLabel(i)->HasReplacement()) return i; |
1967 } | 1967 } |
1968 return -1; | 1968 return -1; |
1969 } | 1969 } |
1970 | 1970 |
1971 template<class InstrType> | 1971 template<class InstrType> |
1972 void LCodeGen::EmitBranch(InstrType instr, | 1972 void LCodeGen::EmitBranch(InstrType instr, |
1973 Condition cc, Register src1, const Operand& src2) { | 1973 Condition cc, Register src1, const Operand& src2) { |
| 1974 int left_block = instr->TrueDestination(chunk_); |
1974 int right_block = instr->FalseDestination(chunk_); | 1975 int right_block = instr->FalseDestination(chunk_); |
1975 int left_block = instr->TrueDestination(chunk_); | |
1976 | 1976 |
1977 int next_block = GetNextEmittedBlock(); | 1977 int next_block = GetNextEmittedBlock(); |
1978 if (right_block == left_block) { | 1978 if (right_block == left_block || cc == al) { |
1979 EmitGoto(left_block); | 1979 EmitGoto(left_block); |
1980 } else if (left_block == next_block) { | 1980 } else if (left_block == next_block) { |
1981 __ Branch(chunk_->GetAssemblyLabel(right_block), | 1981 __ Branch(chunk_->GetAssemblyLabel(right_block), |
1982 NegateCondition(cc), src1, src2); | 1982 NegateCondition(cc), src1, src2); |
1983 } else if (right_block == next_block) { | 1983 } else if (right_block == next_block) { |
1984 __ Branch(chunk_->GetAssemblyLabel(left_block), cc, src1, src2); | 1984 __ Branch(chunk_->GetAssemblyLabel(left_block), cc, src1, src2); |
1985 } else { | 1985 } else { |
1986 __ Branch(chunk_->GetAssemblyLabel(left_block), cc, src1, src2); | 1986 __ Branch(chunk_->GetAssemblyLabel(left_block), cc, src1, src2); |
1987 __ Branch(chunk_->GetAssemblyLabel(right_block)); | 1987 __ Branch(chunk_->GetAssemblyLabel(right_block)); |
1988 } | 1988 } |
(...skipping 19 matching lines...) Expand all Loading... |
2008 __ Branch(chunk_->GetAssemblyLabel(right_block)); | 2008 __ Branch(chunk_->GetAssemblyLabel(right_block)); |
2009 } | 2009 } |
2010 } | 2010 } |
2011 | 2011 |
2012 | 2012 |
2013 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { | 2013 void LCodeGen::DoDebugBreak(LDebugBreak* instr) { |
2014 __ stop("LDebugBreak"); | 2014 __ stop("LDebugBreak"); |
2015 } | 2015 } |
2016 | 2016 |
2017 | 2017 |
| 2018 void LCodeGen::DoIsNumberAndBranch(LIsNumberAndBranch* instr) { |
| 2019 Representation r = instr->hydrogen()->value()->representation(); |
| 2020 if (r.IsSmiOrInteger32() || r.IsDouble()) { |
| 2021 EmitBranch(instr, al, zero_reg, Operand(zero_reg)); |
| 2022 } else { |
| 2023 ASSERT(r.IsTagged()); |
| 2024 Register reg = ToRegister(instr->value()); |
| 2025 HType type = instr->hydrogen()->value()->type(); |
| 2026 if (type.IsTaggedNumber()) { |
| 2027 EmitBranch(instr, al, zero_reg, Operand(zero_reg)); |
| 2028 } |
| 2029 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
| 2030 __ lw(scratch0(), FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 2031 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
| 2032 EmitBranch(instr, eq, scratch0(), Operand(at)); |
| 2033 } |
| 2034 } |
| 2035 |
| 2036 |
2018 void LCodeGen::DoBranch(LBranch* instr) { | 2037 void LCodeGen::DoBranch(LBranch* instr) { |
2019 Representation r = instr->hydrogen()->value()->representation(); | 2038 Representation r = instr->hydrogen()->value()->representation(); |
2020 if (r.IsInteger32() || r.IsSmi()) { | 2039 if (r.IsInteger32() || r.IsSmi()) { |
2021 ASSERT(!info()->IsStub()); | 2040 ASSERT(!info()->IsStub()); |
2022 Register reg = ToRegister(instr->value()); | 2041 Register reg = ToRegister(instr->value()); |
2023 EmitBranch(instr, ne, reg, Operand(zero_reg)); | 2042 EmitBranch(instr, ne, reg, Operand(zero_reg)); |
2024 } else if (r.IsDouble()) { | 2043 } else if (r.IsDouble()) { |
2025 ASSERT(!info()->IsStub()); | 2044 ASSERT(!info()->IsStub()); |
2026 DoubleRegister reg = ToDoubleRegister(instr->value()); | 2045 DoubleRegister reg = ToDoubleRegister(instr->value()); |
2027 // Test the double value. Zero and NaN are false. | 2046 // Test the double value. Zero and NaN are false. |
(...skipping 3874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5902 __ Subu(scratch, result, scratch); | 5921 __ Subu(scratch, result, scratch); |
5903 __ lw(result, FieldMemOperand(scratch, | 5922 __ lw(result, FieldMemOperand(scratch, |
5904 FixedArray::kHeaderSize - kPointerSize)); | 5923 FixedArray::kHeaderSize - kPointerSize)); |
5905 __ bind(&done); | 5924 __ bind(&done); |
5906 } | 5925 } |
5907 | 5926 |
5908 | 5927 |
5909 #undef __ | 5928 #undef __ |
5910 | 5929 |
5911 } } // namespace v8::internal | 5930 } } // namespace v8::internal |
OLD | NEW |