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/crankshaft/arm64/lithium-codegen-arm64.h" | 5 #include "src/crankshaft/arm64/lithium-codegen-arm64.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 5163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5174 LOperand* value, | 5174 LOperand* value, |
5175 LOperand* temp1, | 5175 LOperand* temp1, |
5176 LOperand* temp2) { | 5176 LOperand* temp2) { |
5177 Register input = ToRegister(value); | 5177 Register input = ToRegister(value); |
5178 Register scratch1 = ToRegister(temp1); | 5178 Register scratch1 = ToRegister(temp1); |
5179 DoubleRegister dbl_scratch1 = double_scratch(); | 5179 DoubleRegister dbl_scratch1 = double_scratch(); |
5180 | 5180 |
5181 Label done; | 5181 Label done; |
5182 | 5182 |
5183 if (instr->truncating()) { | 5183 if (instr->truncating()) { |
| 5184 UseScratchRegisterScope temps(masm()); |
5184 Register output = ToRegister(instr->result()); | 5185 Register output = ToRegister(instr->result()); |
5185 Label check_bools; | 5186 Register input_map = temps.AcquireX(); |
5186 | 5187 Register input_instance_type = input_map; |
5187 // If it's not a heap number, jump to undefined check. | 5188 Label truncate; |
5188 __ JumpIfNotHeapNumber(input, &check_bools); | 5189 __ CompareObjectType(input, input_map, input_instance_type, |
5189 | 5190 HEAP_NUMBER_TYPE); |
5190 // A heap number: load value and convert to int32 using truncating function. | 5191 __ B(eq, &truncate); |
| 5192 __ Cmp(input_instance_type, ODDBALL_TYPE); |
| 5193 DeoptimizeIf(ne, instr, DeoptimizeReason::kNotANumberOrOddball); |
| 5194 __ Bind(&truncate); |
5191 __ TruncateHeapNumberToI(output, input); | 5195 __ TruncateHeapNumberToI(output, input); |
5192 __ B(&done); | |
5193 | |
5194 __ Bind(&check_bools); | |
5195 | |
5196 Register true_root = output; | |
5197 Register false_root = scratch1; | |
5198 __ LoadTrueFalseRoots(true_root, false_root); | |
5199 __ Cmp(input, true_root); | |
5200 __ Cset(output, eq); | |
5201 __ Ccmp(input, false_root, ZFlag, ne); | |
5202 __ B(eq, &done); | |
5203 | |
5204 // Output contains zero, undefined is converted to zero for truncating | |
5205 // conversions. | |
5206 DeoptimizeIfNotRoot(input, Heap::kUndefinedValueRootIndex, instr, | |
5207 DeoptimizeReason::kNotAHeapNumberUndefinedBoolean); | |
5208 } else { | 5196 } else { |
5209 Register output = ToRegister32(instr->result()); | 5197 Register output = ToRegister32(instr->result()); |
5210 DoubleRegister dbl_scratch2 = ToDoubleRegister(temp2); | 5198 DoubleRegister dbl_scratch2 = ToDoubleRegister(temp2); |
5211 | 5199 |
5212 DeoptimizeIfNotHeapNumber(input, instr); | 5200 DeoptimizeIfNotHeapNumber(input, instr); |
5213 | 5201 |
5214 // A heap number: load value and convert to int32 using non-truncating | 5202 // A heap number: load value and convert to int32 using non-truncating |
5215 // function. If the result is out of range, branch to deoptimize. | 5203 // function. If the result is out of range, branch to deoptimize. |
5216 __ Ldr(dbl_scratch1, FieldMemOperand(input, HeapNumber::kValueOffset)); | 5204 __ Ldr(dbl_scratch1, FieldMemOperand(input, HeapNumber::kValueOffset)); |
5217 __ TryRepresentDoubleAsInt32(output, dbl_scratch1, dbl_scratch2); | 5205 __ TryRepresentDoubleAsInt32(output, dbl_scratch1, dbl_scratch2); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5578 // Index is equal to negated out of object property index plus 1. | 5566 // Index is equal to negated out of object property index plus 1. |
5579 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5567 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
5580 __ Ldr(result, FieldMemOperand(result, | 5568 __ Ldr(result, FieldMemOperand(result, |
5581 FixedArray::kHeaderSize - kPointerSize)); | 5569 FixedArray::kHeaderSize - kPointerSize)); |
5582 __ Bind(deferred->exit()); | 5570 __ Bind(deferred->exit()); |
5583 __ Bind(&done); | 5571 __ Bind(&done); |
5584 } | 5572 } |
5585 | 5573 |
5586 } // namespace internal | 5574 } // namespace internal |
5587 } // namespace v8 | 5575 } // namespace v8 |
OLD | NEW |