| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" | 7 #include "src/crankshaft/x87/lithium-codegen-x87.h" |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 } else if (type.IsJSArray()) { | 2130 } else if (type.IsJSArray()) { |
| 2131 DCHECK(!info()->IsStub()); | 2131 DCHECK(!info()->IsStub()); |
| 2132 EmitBranch(instr, no_condition); | 2132 EmitBranch(instr, no_condition); |
| 2133 } else if (type.IsHeapNumber()) { | 2133 } else if (type.IsHeapNumber()) { |
| 2134 UNREACHABLE(); | 2134 UNREACHABLE(); |
| 2135 } else if (type.IsString()) { | 2135 } else if (type.IsString()) { |
| 2136 DCHECK(!info()->IsStub()); | 2136 DCHECK(!info()->IsStub()); |
| 2137 __ cmp(FieldOperand(reg, String::kLengthOffset), Immediate(0)); | 2137 __ cmp(FieldOperand(reg, String::kLengthOffset), Immediate(0)); |
| 2138 EmitBranch(instr, not_equal); | 2138 EmitBranch(instr, not_equal); |
| 2139 } else { | 2139 } else { |
| 2140 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types(); | 2140 ToBooleanICStub::Types expected = |
| 2141 if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic(); | 2141 instr->hydrogen()->expected_input_types(); |
| 2142 if (expected.IsEmpty()) expected = ToBooleanICStub::Types::Generic(); |
| 2142 | 2143 |
| 2143 if (expected.Contains(ToBooleanStub::UNDEFINED)) { | 2144 if (expected.Contains(ToBooleanICStub::UNDEFINED)) { |
| 2144 // undefined -> false. | 2145 // undefined -> false. |
| 2145 __ cmp(reg, factory()->undefined_value()); | 2146 __ cmp(reg, factory()->undefined_value()); |
| 2146 __ j(equal, instr->FalseLabel(chunk_)); | 2147 __ j(equal, instr->FalseLabel(chunk_)); |
| 2147 } | 2148 } |
| 2148 if (expected.Contains(ToBooleanStub::BOOLEAN)) { | 2149 if (expected.Contains(ToBooleanICStub::BOOLEAN)) { |
| 2149 // true -> true. | 2150 // true -> true. |
| 2150 __ cmp(reg, factory()->true_value()); | 2151 __ cmp(reg, factory()->true_value()); |
| 2151 __ j(equal, instr->TrueLabel(chunk_)); | 2152 __ j(equal, instr->TrueLabel(chunk_)); |
| 2152 // false -> false. | 2153 // false -> false. |
| 2153 __ cmp(reg, factory()->false_value()); | 2154 __ cmp(reg, factory()->false_value()); |
| 2154 __ j(equal, instr->FalseLabel(chunk_)); | 2155 __ j(equal, instr->FalseLabel(chunk_)); |
| 2155 } | 2156 } |
| 2156 if (expected.Contains(ToBooleanStub::NULL_TYPE)) { | 2157 if (expected.Contains(ToBooleanICStub::NULL_TYPE)) { |
| 2157 // 'null' -> false. | 2158 // 'null' -> false. |
| 2158 __ cmp(reg, factory()->null_value()); | 2159 __ cmp(reg, factory()->null_value()); |
| 2159 __ j(equal, instr->FalseLabel(chunk_)); | 2160 __ j(equal, instr->FalseLabel(chunk_)); |
| 2160 } | 2161 } |
| 2161 | 2162 |
| 2162 if (expected.Contains(ToBooleanStub::SMI)) { | 2163 if (expected.Contains(ToBooleanICStub::SMI)) { |
| 2163 // Smis: 0 -> false, all other -> true. | 2164 // Smis: 0 -> false, all other -> true. |
| 2164 __ test(reg, Operand(reg)); | 2165 __ test(reg, Operand(reg)); |
| 2165 __ j(equal, instr->FalseLabel(chunk_)); | 2166 __ j(equal, instr->FalseLabel(chunk_)); |
| 2166 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); | 2167 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); |
| 2167 } else if (expected.NeedsMap()) { | 2168 } else if (expected.NeedsMap()) { |
| 2168 // If we need a map later and have a Smi -> deopt. | 2169 // If we need a map later and have a Smi -> deopt. |
| 2169 __ test(reg, Immediate(kSmiTagMask)); | 2170 __ test(reg, Immediate(kSmiTagMask)); |
| 2170 DeoptimizeIf(zero, instr, Deoptimizer::kSmi); | 2171 DeoptimizeIf(zero, instr, Deoptimizer::kSmi); |
| 2171 } | 2172 } |
| 2172 | 2173 |
| 2173 Register map = no_reg; // Keep the compiler happy. | 2174 Register map = no_reg; // Keep the compiler happy. |
| 2174 if (expected.NeedsMap()) { | 2175 if (expected.NeedsMap()) { |
| 2175 map = ToRegister(instr->temp()); | 2176 map = ToRegister(instr->temp()); |
| 2176 DCHECK(!map.is(reg)); | 2177 DCHECK(!map.is(reg)); |
| 2177 __ mov(map, FieldOperand(reg, HeapObject::kMapOffset)); | 2178 __ mov(map, FieldOperand(reg, HeapObject::kMapOffset)); |
| 2178 | 2179 |
| 2179 if (expected.CanBeUndetectable()) { | 2180 if (expected.CanBeUndetectable()) { |
| 2180 // Undetectable -> false. | 2181 // Undetectable -> false. |
| 2181 __ test_b(FieldOperand(map, Map::kBitFieldOffset), | 2182 __ test_b(FieldOperand(map, Map::kBitFieldOffset), |
| 2182 1 << Map::kIsUndetectable); | 2183 1 << Map::kIsUndetectable); |
| 2183 __ j(not_zero, instr->FalseLabel(chunk_)); | 2184 __ j(not_zero, instr->FalseLabel(chunk_)); |
| 2184 } | 2185 } |
| 2185 } | 2186 } |
| 2186 | 2187 |
| 2187 if (expected.Contains(ToBooleanStub::SPEC_OBJECT)) { | 2188 if (expected.Contains(ToBooleanICStub::SPEC_OBJECT)) { |
| 2188 // spec object -> true. | 2189 // spec object -> true. |
| 2189 __ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE); | 2190 __ CmpInstanceType(map, FIRST_JS_RECEIVER_TYPE); |
| 2190 __ j(above_equal, instr->TrueLabel(chunk_)); | 2191 __ j(above_equal, instr->TrueLabel(chunk_)); |
| 2191 } | 2192 } |
| 2192 | 2193 |
| 2193 if (expected.Contains(ToBooleanStub::STRING)) { | 2194 if (expected.Contains(ToBooleanICStub::STRING)) { |
| 2194 // String value -> false iff empty. | 2195 // String value -> false iff empty. |
| 2195 Label not_string; | 2196 Label not_string; |
| 2196 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE); | 2197 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE); |
| 2197 __ j(above_equal, ¬_string, Label::kNear); | 2198 __ j(above_equal, ¬_string, Label::kNear); |
| 2198 __ cmp(FieldOperand(reg, String::kLengthOffset), Immediate(0)); | 2199 __ cmp(FieldOperand(reg, String::kLengthOffset), Immediate(0)); |
| 2199 __ j(not_zero, instr->TrueLabel(chunk_)); | 2200 __ j(not_zero, instr->TrueLabel(chunk_)); |
| 2200 __ jmp(instr->FalseLabel(chunk_)); | 2201 __ jmp(instr->FalseLabel(chunk_)); |
| 2201 __ bind(¬_string); | 2202 __ bind(¬_string); |
| 2202 } | 2203 } |
| 2203 | 2204 |
| 2204 if (expected.Contains(ToBooleanStub::SYMBOL)) { | 2205 if (expected.Contains(ToBooleanICStub::SYMBOL)) { |
| 2205 // Symbol value -> true. | 2206 // Symbol value -> true. |
| 2206 __ CmpInstanceType(map, SYMBOL_TYPE); | 2207 __ CmpInstanceType(map, SYMBOL_TYPE); |
| 2207 __ j(equal, instr->TrueLabel(chunk_)); | 2208 __ j(equal, instr->TrueLabel(chunk_)); |
| 2208 } | 2209 } |
| 2209 | 2210 |
| 2210 if (expected.Contains(ToBooleanStub::SIMD_VALUE)) { | 2211 if (expected.Contains(ToBooleanICStub::SIMD_VALUE)) { |
| 2211 // SIMD value -> true. | 2212 // SIMD value -> true. |
| 2212 __ CmpInstanceType(map, SIMD128_VALUE_TYPE); | 2213 __ CmpInstanceType(map, SIMD128_VALUE_TYPE); |
| 2213 __ j(equal, instr->TrueLabel(chunk_)); | 2214 __ j(equal, instr->TrueLabel(chunk_)); |
| 2214 } | 2215 } |
| 2215 | 2216 |
| 2216 if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { | 2217 if (expected.Contains(ToBooleanICStub::HEAP_NUMBER)) { |
| 2217 // heap number -> false iff +0, -0, or NaN. | 2218 // heap number -> false iff +0, -0, or NaN. |
| 2218 Label not_heap_number; | 2219 Label not_heap_number; |
| 2219 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), | 2220 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), |
| 2220 factory()->heap_number_map()); | 2221 factory()->heap_number_map()); |
| 2221 __ j(not_equal, ¬_heap_number, Label::kNear); | 2222 __ j(not_equal, ¬_heap_number, Label::kNear); |
| 2222 __ fldz(); | 2223 __ fldz(); |
| 2223 __ fld_d(FieldOperand(reg, HeapNumber::kValueOffset)); | 2224 __ fld_d(FieldOperand(reg, HeapNumber::kValueOffset)); |
| 2224 __ FCmp(); | 2225 __ FCmp(); |
| 2225 __ j(zero, instr->FalseLabel(chunk_)); | 2226 __ j(zero, instr->FalseLabel(chunk_)); |
| 2226 __ jmp(instr->TrueLabel(chunk_)); | 2227 __ jmp(instr->TrueLabel(chunk_)); |
| (...skipping 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5759 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); | 5760 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); |
| 5760 } | 5761 } |
| 5761 | 5762 |
| 5762 | 5763 |
| 5763 #undef __ | 5764 #undef __ |
| 5764 | 5765 |
| 5765 } // namespace internal | 5766 } // namespace internal |
| 5766 } // namespace v8 | 5767 } // namespace v8 |
| 5767 | 5768 |
| 5768 #endif // V8_TARGET_ARCH_X87 | 5769 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |