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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/hydrogen-osr.h" | 9 #include "src/hydrogen-osr.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 4955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4966 __ mov(input_reg, zero_reg); // In delay slot. | 4966 __ mov(input_reg, zero_reg); // In delay slot. |
4967 | 4967 |
4968 __ bind(&check_bools); | 4968 __ bind(&check_bools); |
4969 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 4969 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
4970 __ Branch(&check_false, ne, scratch2, Operand(at)); | 4970 __ Branch(&check_false, ne, scratch2, Operand(at)); |
4971 __ Branch(USE_DELAY_SLOT, &done); | 4971 __ Branch(USE_DELAY_SLOT, &done); |
4972 __ li(input_reg, Operand(1)); // In delay slot. | 4972 __ li(input_reg, Operand(1)); // In delay slot. |
4973 | 4973 |
4974 __ bind(&check_false); | 4974 __ bind(&check_false); |
4975 __ LoadRoot(at, Heap::kFalseValueRootIndex); | 4975 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
| 4976 __ RecordComment("Deferred TaggedToI: cannot truncate"); |
4976 DeoptimizeIf(ne, instr->environment(), scratch2, Operand(at)); | 4977 DeoptimizeIf(ne, instr->environment(), scratch2, Operand(at)); |
4977 __ Branch(USE_DELAY_SLOT, &done); | 4978 __ Branch(USE_DELAY_SLOT, &done); |
4978 __ mov(input_reg, zero_reg); // In delay slot. | 4979 __ mov(input_reg, zero_reg); // In delay slot. |
4979 } else { | 4980 } else { |
4980 // Deoptimize if we don't have a heap number. | 4981 __ RecordComment("Deferred TaggedToI: not a heap number"); |
4981 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at)); | 4982 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at)); |
4982 | 4983 |
4983 // Load the double value. | 4984 // Load the double value. |
4984 __ ldc1(double_scratch, | 4985 __ ldc1(double_scratch, |
4985 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); | 4986 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); |
4986 | 4987 |
4987 Register except_flag = scratch2; | 4988 Register except_flag = scratch2; |
4988 __ EmitFPUTruncate(kRoundToZero, | 4989 __ EmitFPUTruncate(kRoundToZero, |
4989 input_reg, | 4990 input_reg, |
4990 double_scratch, | 4991 double_scratch, |
4991 scratch1, | 4992 scratch1, |
4992 double_scratch2, | 4993 double_scratch2, |
4993 except_flag, | 4994 except_flag, |
4994 kCheckForInexactConversion); | 4995 kCheckForInexactConversion); |
4995 | 4996 |
4996 // Deopt if the operation did not succeed. | 4997 __ RecordComment("Deferred TaggedToI: lost precision or NaN"); |
4997 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); | 4998 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); |
4998 | 4999 |
4999 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5000 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
5000 __ Branch(&done, ne, input_reg, Operand(zero_reg)); | 5001 __ Branch(&done, ne, input_reg, Operand(zero_reg)); |
5001 | 5002 |
5002 __ mfhc1(scratch1, double_scratch); // Get exponent/sign bits. | 5003 __ mfhc1(scratch1, double_scratch); // Get exponent/sign bits. |
5003 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); | 5004 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); |
| 5005 __ RecordComment("Deferred TaggedToI: minus zero"); |
5004 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); | 5006 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); |
5005 } | 5007 } |
5006 } | 5008 } |
5007 __ bind(&done); | 5009 __ bind(&done); |
5008 } | 5010 } |
5009 | 5011 |
5010 | 5012 |
5011 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 5013 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
5012 class DeferredTaggedToI FINAL : public LDeferredCode { | 5014 class DeferredTaggedToI FINAL : public LDeferredCode { |
5013 public: | 5015 public: |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5968 __ li(at, scope_info); | 5970 __ li(at, scope_info); |
5969 __ Push(at, ToRegister(instr->function())); | 5971 __ Push(at, ToRegister(instr->function())); |
5970 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5972 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5971 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5973 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5972 } | 5974 } |
5973 | 5975 |
5974 | 5976 |
5975 #undef __ | 5977 #undef __ |
5976 | 5978 |
5977 } } // namespace v8::internal | 5979 } } // namespace v8::internal |
OLD | NEW |