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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/hydrogen-osr.h" | 10 #include "src/hydrogen-osr.h" |
(...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { | 2403 void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) { |
2404 Representation rep = instr->hydrogen()->value()->representation(); | 2404 Representation rep = instr->hydrogen()->value()->representation(); |
2405 DCHECK(!rep.IsInteger32()); | 2405 DCHECK(!rep.IsInteger32()); |
2406 | 2406 |
2407 if (rep.IsDouble()) { | 2407 if (rep.IsDouble()) { |
2408 XMMRegister value = ToDoubleRegister(instr->value()); | 2408 XMMRegister value = ToDoubleRegister(instr->value()); |
2409 XMMRegister xmm_scratch = double_scratch0(); | 2409 XMMRegister xmm_scratch = double_scratch0(); |
2410 __ Xorpd(xmm_scratch, xmm_scratch); | 2410 __ Xorpd(xmm_scratch, xmm_scratch); |
2411 __ ucomisd(xmm_scratch, value); | 2411 __ ucomisd(xmm_scratch, value); |
2412 EmitFalseBranch(instr, not_equal); | 2412 EmitFalseBranch(instr, not_equal); |
2413 __ movmskpd(kScratchRegister, value); | 2413 __ Movmskpd(kScratchRegister, value); |
2414 __ testl(kScratchRegister, Immediate(1)); | 2414 __ testl(kScratchRegister, Immediate(1)); |
2415 EmitBranch(instr, not_zero); | 2415 EmitBranch(instr, not_zero); |
2416 } else { | 2416 } else { |
2417 Register value = ToRegister(instr->value()); | 2417 Register value = ToRegister(instr->value()); |
2418 Handle<Map> map = masm()->isolate()->factory()->heap_number_map(); | 2418 Handle<Map> map = masm()->isolate()->factory()->heap_number_map(); |
2419 __ CheckMap(value, map, instr->FalseLabel(chunk()), DO_SMI_CHECK); | 2419 __ CheckMap(value, map, instr->FalseLabel(chunk()), DO_SMI_CHECK); |
2420 __ cmpl(FieldOperand(value, HeapNumber::kExponentOffset), | 2420 __ cmpl(FieldOperand(value, HeapNumber::kExponentOffset), |
2421 Immediate(0x1)); | 2421 Immediate(0x1)); |
2422 EmitFalseBranch(instr, no_overflow); | 2422 EmitFalseBranch(instr, no_overflow); |
2423 __ cmpl(FieldOperand(value, HeapNumber::kMantissaOffset), | 2423 __ cmpl(FieldOperand(value, HeapNumber::kMantissaOffset), |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3617 // Deoptimize on unordered. | 3617 // Deoptimize on unordered. |
3618 __ Xorpd(xmm_scratch, xmm_scratch); // Zero the register. | 3618 __ Xorpd(xmm_scratch, xmm_scratch); // Zero the register. |
3619 __ ucomisd(input_reg, xmm_scratch); | 3619 __ ucomisd(input_reg, xmm_scratch); |
3620 DeoptimizeIf(parity_even, instr, Deoptimizer::kNaN); | 3620 DeoptimizeIf(parity_even, instr, Deoptimizer::kNaN); |
3621 __ j(below, &negative_sign, Label::kNear); | 3621 __ j(below, &negative_sign, Label::kNear); |
3622 | 3622 |
3623 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 3623 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
3624 // Check for negative zero. | 3624 // Check for negative zero. |
3625 Label positive_sign; | 3625 Label positive_sign; |
3626 __ j(above, &positive_sign, Label::kNear); | 3626 __ j(above, &positive_sign, Label::kNear); |
3627 __ movmskpd(output_reg, input_reg); | 3627 __ Movmskpd(output_reg, input_reg); |
3628 __ testq(output_reg, Immediate(1)); | 3628 __ testl(output_reg, Immediate(1)); |
3629 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); | 3629 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); |
3630 __ Set(output_reg, 0); | 3630 __ Set(output_reg, 0); |
3631 __ jmp(&done); | 3631 __ jmp(&done); |
3632 __ bind(&positive_sign); | 3632 __ bind(&positive_sign); |
3633 } | 3633 } |
3634 | 3634 |
3635 // Use truncating instruction (OK because input is positive). | 3635 // Use truncating instruction (OK because input is positive). |
3636 __ Cvttsd2si(output_reg, input_reg); | 3636 __ Cvttsd2si(output_reg, input_reg); |
3637 // Overflow is signalled with minint. | 3637 // Overflow is signalled with minint. |
3638 __ cmpl(output_reg, Immediate(0x1)); | 3638 __ cmpl(output_reg, Immediate(0x1)); |
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4920 __ j(not_equal, &convert, Label::kNear); | 4920 __ j(not_equal, &convert, Label::kNear); |
4921 } else { | 4921 } else { |
4922 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); | 4922 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); |
4923 } | 4923 } |
4924 | 4924 |
4925 if (deoptimize_on_minus_zero) { | 4925 if (deoptimize_on_minus_zero) { |
4926 XMMRegister xmm_scratch = double_scratch0(); | 4926 XMMRegister xmm_scratch = double_scratch0(); |
4927 __ Xorpd(xmm_scratch, xmm_scratch); | 4927 __ Xorpd(xmm_scratch, xmm_scratch); |
4928 __ ucomisd(xmm_scratch, result_reg); | 4928 __ ucomisd(xmm_scratch, result_reg); |
4929 __ j(not_equal, &done, Label::kNear); | 4929 __ j(not_equal, &done, Label::kNear); |
4930 __ movmskpd(kScratchRegister, result_reg); | 4930 __ Movmskpd(kScratchRegister, result_reg); |
4931 __ testq(kScratchRegister, Immediate(1)); | 4931 __ testl(kScratchRegister, Immediate(1)); |
4932 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); | 4932 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); |
4933 } | 4933 } |
4934 __ jmp(&done, Label::kNear); | 4934 __ jmp(&done, Label::kNear); |
4935 | 4935 |
4936 if (can_convert_undefined_to_nan) { | 4936 if (can_convert_undefined_to_nan) { |
4937 __ bind(&convert); | 4937 __ bind(&convert); |
4938 | 4938 |
4939 // Convert undefined (and hole) to NaN. Compute NaN as 0/0. | 4939 // Convert undefined (and hole) to NaN. Compute NaN as 0/0. |
4940 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | 4940 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
4941 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumberUndefined); | 4941 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumberUndefined); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4995 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); | 4995 DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); |
4996 __ Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 4996 __ Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4997 __ Cvttsd2si(input_reg, xmm0); | 4997 __ Cvttsd2si(input_reg, xmm0); |
4998 __ Cvtlsi2sd(scratch, input_reg); | 4998 __ Cvtlsi2sd(scratch, input_reg); |
4999 __ ucomisd(xmm0, scratch); | 4999 __ ucomisd(xmm0, scratch); |
5000 DeoptimizeIf(not_equal, instr, Deoptimizer::kLostPrecision); | 5000 DeoptimizeIf(not_equal, instr, Deoptimizer::kLostPrecision); |
5001 DeoptimizeIf(parity_even, instr, Deoptimizer::kNaN); | 5001 DeoptimizeIf(parity_even, instr, Deoptimizer::kNaN); |
5002 if (instr->hydrogen()->GetMinusZeroMode() == FAIL_ON_MINUS_ZERO) { | 5002 if (instr->hydrogen()->GetMinusZeroMode() == FAIL_ON_MINUS_ZERO) { |
5003 __ testl(input_reg, input_reg); | 5003 __ testl(input_reg, input_reg); |
5004 __ j(not_zero, done); | 5004 __ j(not_zero, done); |
5005 __ movmskpd(input_reg, xmm0); | 5005 __ Movmskpd(input_reg, xmm0); |
5006 __ andl(input_reg, Immediate(1)); | 5006 __ andl(input_reg, Immediate(1)); |
5007 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); | 5007 DeoptimizeIf(not_zero, instr, Deoptimizer::kMinusZero); |
5008 } | 5008 } |
5009 } | 5009 } |
5010 } | 5010 } |
5011 | 5011 |
5012 | 5012 |
5013 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 5013 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
5014 class DeferredTaggedToI final : public LDeferredCode { | 5014 class DeferredTaggedToI final : public LDeferredCode { |
5015 public: | 5015 public: |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5905 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5905 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5906 } | 5906 } |
5907 | 5907 |
5908 | 5908 |
5909 #undef __ | 5909 #undef __ |
5910 | 5910 |
5911 } // namespace internal | 5911 } // namespace internal |
5912 } // namespace v8 | 5912 } // namespace v8 |
5913 | 5913 |
5914 #endif // V8_TARGET_ARCH_X64 | 5914 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |