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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 4945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4956 __ CompareRoot(input_reg, Heap::kTrueValueRootIndex); | 4956 __ CompareRoot(input_reg, Heap::kTrueValueRootIndex); |
4957 __ j(not_equal, &check_false, Label::kNear); | 4957 __ j(not_equal, &check_false, Label::kNear); |
4958 __ Set(input_reg, 1); | 4958 __ Set(input_reg, 1); |
4959 __ jmp(done); | 4959 __ jmp(done); |
4960 | 4960 |
4961 __ bind(&check_false); | 4961 __ bind(&check_false); |
4962 __ CompareRoot(input_reg, Heap::kFalseValueRootIndex); | 4962 __ CompareRoot(input_reg, Heap::kFalseValueRootIndex); |
4963 __ RecordComment("Deferred TaggedToI: cannot truncate"); | 4963 __ RecordComment("Deferred TaggedToI: cannot truncate"); |
4964 DeoptimizeIf(not_equal, instr->environment()); | 4964 DeoptimizeIf(not_equal, instr->environment()); |
4965 __ Set(input_reg, 0); | 4965 __ Set(input_reg, 0); |
4966 __ jmp(done); | |
4967 } else { | 4966 } else { |
4968 Label bailout; | 4967 XMMRegister scratch = ToDoubleRegister(instr->temp()); |
4969 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); | 4968 DCHECK(!scratch.is(xmm0)); |
4970 __ TaggedToI(input_reg, input_reg, xmm_temp, | 4969 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
4971 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear); | 4970 Heap::kHeapNumberMapRootIndex); |
4972 | 4971 __ RecordComment("Deferred TaggedToI: not a heap number"); |
4973 __ jmp(done); | 4972 DeoptimizeIf(not_equal, instr->environment()); |
4974 __ bind(&bailout); | 4973 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
4975 DeoptimizeIf(no_condition, instr->environment()); | 4974 __ cvttsd2si(input_reg, xmm0); |
| 4975 __ Cvtlsi2sd(scratch, input_reg); |
| 4976 __ ucomisd(xmm0, scratch); |
| 4977 __ RecordComment("Deferred TaggedToI: lost precision"); |
| 4978 DeoptimizeIf(not_equal, instr->environment()); |
| 4979 __ RecordComment("Deferred TaggedToI: NaN"); |
| 4980 DeoptimizeIf(parity_even, instr->environment()); |
| 4981 if (instr->hydrogen()->GetMinusZeroMode() == FAIL_ON_MINUS_ZERO) { |
| 4982 __ testl(input_reg, input_reg); |
| 4983 __ j(not_zero, done); |
| 4984 __ movmskpd(input_reg, xmm0); |
| 4985 __ andl(input_reg, Immediate(1)); |
| 4986 __ RecordComment("Deferred TaggedToI: minus zero"); |
| 4987 DeoptimizeIf(not_zero, instr->environment()); |
| 4988 } |
4976 } | 4989 } |
4977 } | 4990 } |
4978 | 4991 |
4979 | 4992 |
4980 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 4993 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
4981 class DeferredTaggedToI FINAL : public LDeferredCode { | 4994 class DeferredTaggedToI FINAL : public LDeferredCode { |
4982 public: | 4995 public: |
4983 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) | 4996 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) |
4984 : LDeferredCode(codegen), instr_(instr) { } | 4997 : LDeferredCode(codegen), instr_(instr) { } |
4985 virtual void Generate() OVERRIDE { | 4998 virtual void Generate() OVERRIDE { |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5876 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5889 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5877 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5890 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5878 } | 5891 } |
5879 | 5892 |
5880 | 5893 |
5881 #undef __ | 5894 #undef __ |
5882 | 5895 |
5883 } } // namespace v8::internal | 5896 } } // namespace v8::internal |
5884 | 5897 |
5885 #endif // V8_TARGET_ARCH_X64 | 5898 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |