| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h" | 7 #include "src/crankshaft/ia32/lithium-codegen-ia32.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 4290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4301 | 4301 |
| 4302 | 4302 |
| 4303 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 4303 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
| 4304 Register input_reg = ToRegister(instr->value()); | 4304 Register input_reg = ToRegister(instr->value()); |
| 4305 | 4305 |
| 4306 // The input was optimistically untagged; revert it. | 4306 // The input was optimistically untagged; revert it. |
| 4307 STATIC_ASSERT(kSmiTagSize == 1); | 4307 STATIC_ASSERT(kSmiTagSize == 1); |
| 4308 __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); | 4308 __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); |
| 4309 | 4309 |
| 4310 if (instr->truncating()) { | 4310 if (instr->truncating()) { |
| 4311 Label no_heap_number, check_bools, check_false; | 4311 Label truncate; |
| 4312 | 4312 Label::Distance truncate_distance = |
| 4313 // Heap number map check. | 4313 DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
| 4314 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 4314 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 4315 factory()->heap_number_map()); | 4315 factory()->heap_number_map()); |
| 4316 __ j(not_equal, &no_heap_number, Label::kNear); | 4316 __ j(equal, &truncate, truncate_distance); |
| 4317 __ push(input_reg); |
| 4318 __ CmpObjectType(input_reg, ODDBALL_TYPE, input_reg); |
| 4319 __ pop(input_reg); |
| 4320 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotANumberOrOddball); |
| 4321 __ bind(&truncate); |
| 4317 __ TruncateHeapNumberToI(input_reg, input_reg); | 4322 __ TruncateHeapNumberToI(input_reg, input_reg); |
| 4318 __ jmp(done); | |
| 4319 | |
| 4320 __ bind(&no_heap_number); | |
| 4321 // Check for Oddballs. Undefined/False is converted to zero and True to one | |
| 4322 // for truncating conversions. | |
| 4323 __ cmp(input_reg, factory()->undefined_value()); | |
| 4324 __ j(not_equal, &check_bools, Label::kNear); | |
| 4325 __ Move(input_reg, Immediate(0)); | |
| 4326 __ jmp(done); | |
| 4327 | |
| 4328 __ bind(&check_bools); | |
| 4329 __ cmp(input_reg, factory()->true_value()); | |
| 4330 __ j(not_equal, &check_false, Label::kNear); | |
| 4331 __ Move(input_reg, Immediate(1)); | |
| 4332 __ jmp(done); | |
| 4333 | |
| 4334 __ bind(&check_false); | |
| 4335 __ cmp(input_reg, factory()->false_value()); | |
| 4336 DeoptimizeIf(not_equal, instr, | |
| 4337 DeoptimizeReason::kNotAHeapNumberUndefinedBoolean); | |
| 4338 __ Move(input_reg, Immediate(0)); | |
| 4339 } else { | 4323 } else { |
| 4340 XMMRegister scratch = ToDoubleRegister(instr->temp()); | 4324 XMMRegister scratch = ToDoubleRegister(instr->temp()); |
| 4341 DCHECK(!scratch.is(xmm0)); | 4325 DCHECK(!scratch.is(xmm0)); |
| 4342 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | 4326 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 4343 isolate()->factory()->heap_number_map()); | 4327 isolate()->factory()->heap_number_map()); |
| 4344 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); | 4328 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); |
| 4345 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4329 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 4346 __ cvttsd2si(input_reg, Operand(xmm0)); | 4330 __ cvttsd2si(input_reg, Operand(xmm0)); |
| 4347 __ Cvtsi2sd(scratch, Operand(input_reg)); | 4331 __ Cvtsi2sd(scratch, Operand(input_reg)); |
| 4348 __ ucomisd(xmm0, scratch); | 4332 __ ucomisd(xmm0, scratch); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5166 __ bind(deferred->exit()); | 5150 __ bind(deferred->exit()); |
| 5167 __ bind(&done); | 5151 __ bind(&done); |
| 5168 } | 5152 } |
| 5169 | 5153 |
| 5170 #undef __ | 5154 #undef __ |
| 5171 | 5155 |
| 5172 } // namespace internal | 5156 } // namespace internal |
| 5173 } // namespace v8 | 5157 } // namespace v8 |
| 5174 | 5158 |
| 5175 #endif // V8_TARGET_ARCH_IA32 | 5159 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |