OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/crankshaft/x64/lithium-codegen-x64.h" | 7 #include "src/crankshaft/x64/lithium-codegen-x64.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 4576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 __ SmiToInteger32(kScratchRegister, input_reg); | 4587 __ SmiToInteger32(kScratchRegister, input_reg); |
4588 __ Cvtlsi2sd(result_reg, kScratchRegister); | 4588 __ Cvtlsi2sd(result_reg, kScratchRegister); |
4589 __ bind(&done); | 4589 __ bind(&done); |
4590 } | 4590 } |
4591 | 4591 |
4592 | 4592 |
4593 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { | 4593 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
4594 Register input_reg = ToRegister(instr->value()); | 4594 Register input_reg = ToRegister(instr->value()); |
4595 | 4595 |
4596 if (instr->truncating()) { | 4596 if (instr->truncating()) { |
4597 Label no_heap_number, check_bools, check_false; | 4597 Register input_map_reg = kScratchRegister; |
4598 | 4598 Label truncate; |
4599 // Heap number map check. | 4599 Label::Distance truncate_distance = |
4600 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 4600 DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
4601 Heap::kHeapNumberMapRootIndex); | 4601 __ movp(input_map_reg, FieldOperand(input_reg, HeapObject::kMapOffset)); |
4602 __ j(not_equal, &no_heap_number, Label::kNear); | 4602 __ JumpIfRoot(input_map_reg, Heap::kHeapNumberMapRootIndex, &truncate, |
| 4603 truncate_distance); |
| 4604 __ CmpInstanceType(input_map_reg, ODDBALL_TYPE); |
| 4605 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotANumberOrOddball); |
| 4606 __ bind(&truncate); |
4603 __ TruncateHeapNumberToI(input_reg, input_reg); | 4607 __ TruncateHeapNumberToI(input_reg, input_reg); |
4604 __ jmp(done); | |
4605 | |
4606 __ bind(&no_heap_number); | |
4607 // Check for Oddballs. Undefined/False is converted to zero and True to one | |
4608 // for truncating conversions. | |
4609 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | |
4610 __ j(not_equal, &check_bools, Label::kNear); | |
4611 __ Set(input_reg, 0); | |
4612 __ jmp(done); | |
4613 | |
4614 __ bind(&check_bools); | |
4615 __ CompareRoot(input_reg, Heap::kTrueValueRootIndex); | |
4616 __ j(not_equal, &check_false, Label::kNear); | |
4617 __ Set(input_reg, 1); | |
4618 __ jmp(done); | |
4619 | |
4620 __ bind(&check_false); | |
4621 __ CompareRoot(input_reg, Heap::kFalseValueRootIndex); | |
4622 DeoptimizeIf(not_equal, instr, | |
4623 DeoptimizeReason::kNotAHeapNumberUndefinedBoolean); | |
4624 __ Set(input_reg, 0); | |
4625 } else { | 4608 } else { |
4626 XMMRegister scratch = ToDoubleRegister(instr->temp()); | 4609 XMMRegister scratch = ToDoubleRegister(instr->temp()); |
4627 DCHECK(!scratch.is(double_scratch0())); | 4610 DCHECK(!scratch.is(double_scratch0())); |
4628 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 4611 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
4629 Heap::kHeapNumberMapRootIndex); | 4612 Heap::kHeapNumberMapRootIndex); |
4630 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); | 4613 DeoptimizeIf(not_equal, instr, DeoptimizeReason::kNotAHeapNumber); |
4631 __ Movsd(double_scratch0(), | 4614 __ Movsd(double_scratch0(), |
4632 FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4615 FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4633 __ Cvttsd2si(input_reg, double_scratch0()); | 4616 __ Cvttsd2si(input_reg, double_scratch0()); |
4634 __ Cvtlsi2sd(scratch, input_reg); | 4617 __ Cvtlsi2sd(scratch, input_reg); |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5448 __ bind(deferred->exit()); | 5431 __ bind(deferred->exit()); |
5449 __ bind(&done); | 5432 __ bind(&done); |
5450 } | 5433 } |
5451 | 5434 |
5452 #undef __ | 5435 #undef __ |
5453 | 5436 |
5454 } // namespace internal | 5437 } // namespace internal |
5455 } // namespace v8 | 5438 } // namespace v8 |
5456 | 5439 |
5457 #endif // V8_TARGET_ARCH_X64 | 5440 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |