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 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 int LCodeGen::GetNextEmittedBlock() const { | 2082 int LCodeGen::GetNextEmittedBlock() const { |
2083 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | 2083 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { |
2084 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | 2084 if (!chunk_->GetLabel(i)->HasReplacement()) return i; |
2085 } | 2085 } |
2086 return -1; | 2086 return -1; |
2087 } | 2087 } |
2088 | 2088 |
2089 | 2089 |
2090 template<class InstrType> | 2090 template<class InstrType> |
2091 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { | 2091 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { |
| 2092 int left_block = instr->TrueDestination(chunk_); |
2092 int right_block = instr->FalseDestination(chunk_); | 2093 int right_block = instr->FalseDestination(chunk_); |
2093 int left_block = instr->TrueDestination(chunk_); | |
2094 | 2094 |
2095 int next_block = GetNextEmittedBlock(); | 2095 int next_block = GetNextEmittedBlock(); |
2096 | 2096 |
2097 if (right_block == left_block) { | 2097 if (right_block == left_block || cc == no_condition) { |
2098 EmitGoto(left_block); | 2098 EmitGoto(left_block); |
2099 } else if (left_block == next_block) { | 2099 } else if (left_block == next_block) { |
2100 __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); | 2100 __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); |
2101 } else if (right_block == next_block) { | 2101 } else if (right_block == next_block) { |
2102 __ j(cc, chunk_->GetAssemblyLabel(left_block)); | 2102 __ j(cc, chunk_->GetAssemblyLabel(left_block)); |
2103 } else { | 2103 } else { |
2104 __ j(cc, chunk_->GetAssemblyLabel(left_block)); | 2104 __ j(cc, chunk_->GetAssemblyLabel(left_block)); |
2105 __ jmp(chunk_->GetAssemblyLabel(right_block)); | 2105 __ jmp(chunk_->GetAssemblyLabel(right_block)); |
2106 } | 2106 } |
2107 } | 2107 } |
2108 | 2108 |
2109 | 2109 |
| 2110 void LCodeGen::DoIsNumberAndBranch(LIsNumberAndBranch* instr) { |
| 2111 Representation r = instr->hydrogen()->value()->representation(); |
| 2112 if (r.IsSmiOrInteger32() || r.IsDouble()) { |
| 2113 EmitBranch(instr, no_condition); |
| 2114 } else { |
| 2115 ASSERT(r.IsTagged()); |
| 2116 Register reg = ToRegister(instr->value()); |
| 2117 HType type = instr->hydrogen()->value()->type(); |
| 2118 if (type.IsTaggedNumber()) { |
| 2119 EmitBranch(instr, no_condition); |
| 2120 } |
| 2121 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
| 2122 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), |
| 2123 factory()->heap_number_map()); |
| 2124 EmitBranch(instr, equal); |
| 2125 } |
| 2126 } |
| 2127 |
| 2128 |
2110 void LCodeGen::DoBranch(LBranch* instr) { | 2129 void LCodeGen::DoBranch(LBranch* instr) { |
2111 Representation r = instr->hydrogen()->value()->representation(); | 2130 Representation r = instr->hydrogen()->value()->representation(); |
2112 if (r.IsSmiOrInteger32()) { | 2131 if (r.IsSmiOrInteger32()) { |
2113 ASSERT(!info()->IsStub()); | 2132 ASSERT(!info()->IsStub()); |
2114 Register reg = ToRegister(instr->value()); | 2133 Register reg = ToRegister(instr->value()); |
2115 __ test(reg, Operand(reg)); | 2134 __ test(reg, Operand(reg)); |
2116 EmitBranch(instr, not_zero); | 2135 EmitBranch(instr, not_zero); |
2117 } else if (r.IsDouble()) { | 2136 } else if (r.IsDouble()) { |
2118 ASSERT(!info()->IsStub()); | 2137 ASSERT(!info()->IsStub()); |
2119 CpuFeatureScope scope(masm(), SSE2); | 2138 CpuFeatureScope scope(masm(), SSE2); |
(...skipping 4440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6560 FixedArray::kHeaderSize - kPointerSize)); | 6579 FixedArray::kHeaderSize - kPointerSize)); |
6561 __ bind(&done); | 6580 __ bind(&done); |
6562 } | 6581 } |
6563 | 6582 |
6564 | 6583 |
6565 #undef __ | 6584 #undef __ |
6566 | 6585 |
6567 } } // namespace v8::internal | 6586 } } // namespace v8::internal |
6568 | 6587 |
6569 #endif // V8_TARGET_ARCH_IA32 | 6588 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |