OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4901 __ vcvt_f64_s32(result_reg, flt_scratch); | 4901 __ vcvt_f64_s32(result_reg, flt_scratch); |
4902 __ bind(&done); | 4902 __ bind(&done); |
4903 } | 4903 } |
4904 | 4904 |
4905 | 4905 |
4906 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 4906 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
4907 Register input_reg = ToRegister(instr->value()); | 4907 Register input_reg = ToRegister(instr->value()); |
4908 Register scratch1 = scratch0(); | 4908 Register scratch1 = scratch0(); |
4909 Register scratch2 = ToRegister(instr->temp()); | 4909 Register scratch2 = ToRegister(instr->temp()); |
4910 LowDwVfpRegister double_scratch = double_scratch0(); | 4910 LowDwVfpRegister double_scratch = double_scratch0(); |
4911 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->temp3()); | 4911 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->temp2()); |
4912 | 4912 |
4913 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); | 4913 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); |
4914 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); | 4914 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); |
4915 | 4915 |
4916 Label done; | 4916 Label done; |
4917 | 4917 |
4918 // The input was optimistically untagged; revert it. | 4918 // The input was optimistically untagged; revert it. |
4919 // The carry flag is set when we reach this deferred code as we just executed | 4919 // The carry flag is set when we reach this deferred code as we just executed |
4920 // SmiUntag(heap_object, SetCC) | 4920 // SmiUntag(heap_object, SetCC) |
4921 STATIC_ASSERT(kHeapObjectTag == 1); | 4921 STATIC_ASSERT(kHeapObjectTag == 1); |
4922 __ adc(input_reg, input_reg, Operand(input_reg)); | 4922 __ adc(scratch2, input_reg, Operand(input_reg)); |
4923 | 4923 |
4924 // Heap number map check. | 4924 // Heap number map check. |
4925 __ ldr(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 4925 __ ldr(scratch1, FieldMemOperand(scratch2, HeapObject::kMapOffset)); |
4926 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 4926 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
4927 __ cmp(scratch1, Operand(ip)); | 4927 __ cmp(scratch1, Operand(ip)); |
4928 | 4928 |
4929 if (instr->truncating()) { | 4929 if (instr->truncating()) { |
4930 Register scratch3 = ToRegister(instr->temp2()); | |
4931 ASSERT(!scratch3.is(input_reg) && | |
4932 !scratch3.is(scratch1) && | |
4933 !scratch3.is(scratch2)); | |
4934 // Performs a truncating conversion of a floating point number as used by | 4930 // Performs a truncating conversion of a floating point number as used by |
4935 // the JS bitwise operations. | 4931 // the JS bitwise operations. |
4936 Label heap_number; | 4932 Label heap_number; |
4937 __ b(eq, &heap_number); | 4933 __ b(eq, &heap_number); |
4938 // Check for undefined. Undefined is converted to zero for truncating | 4934 // Check for undefined. Undefined is converted to zero for truncating |
4939 // conversions. | 4935 // conversions. |
4940 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 4936 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
4941 __ cmp(input_reg, Operand(ip)); | 4937 __ cmp(scratch2, Operand(ip)); |
4942 DeoptimizeIf(ne, instr->environment()); | 4938 DeoptimizeIf(ne, instr->environment()); |
4943 __ mov(input_reg, Operand::Zero()); | 4939 __ mov(input_reg, Operand::Zero()); |
4944 __ b(&done); | 4940 __ b(&done); |
4945 | 4941 |
4946 __ bind(&heap_number); | 4942 __ bind(&heap_number); |
4947 __ sub(scratch1, input_reg, Operand(kHeapObjectTag)); | 4943 __ TruncateHeapNumberToI(input_reg, scratch2); |
4948 __ vldr(double_scratch2, scratch1, HeapNumber::kValueOffset); | |
4949 | |
4950 __ ECMAToInt32(input_reg, double_scratch2, | |
4951 scratch1, scratch2, scratch3, double_scratch); | |
4952 | |
4953 } else { | 4944 } else { |
4954 // Deoptimize if we don't have a heap number. | 4945 // Deoptimize if we don't have a heap number. |
4955 DeoptimizeIf(ne, instr->environment()); | 4946 DeoptimizeIf(ne, instr->environment()); |
4956 | 4947 |
4957 __ sub(ip, input_reg, Operand(kHeapObjectTag)); | 4948 __ sub(ip, scratch2, Operand(kHeapObjectTag)); |
4958 __ vldr(double_scratch2, ip, HeapNumber::kValueOffset); | 4949 __ vldr(double_scratch2, ip, HeapNumber::kValueOffset); |
4959 __ TryDoubleToInt32Exact(input_reg, double_scratch2, double_scratch); | 4950 __ TryDoubleToInt32Exact(input_reg, double_scratch2, double_scratch); |
4960 DeoptimizeIf(ne, instr->environment()); | 4951 DeoptimizeIf(ne, instr->environment()); |
4961 | 4952 |
4962 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4953 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
4963 __ cmp(input_reg, Operand::Zero()); | 4954 __ cmp(input_reg, Operand::Zero()); |
4964 __ b(ne, &done); | 4955 __ b(ne, &done); |
4965 __ VmovHigh(scratch1, double_scratch2); | 4956 __ VmovHigh(scratch1, double_scratch2); |
4966 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 4957 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
4967 DeoptimizeIf(ne, instr->environment()); | 4958 DeoptimizeIf(ne, instr->environment()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5019 instr->hydrogen()->can_convert_undefined_to_nan(), | 5010 instr->hydrogen()->can_convert_undefined_to_nan(), |
5020 instr->hydrogen()->deoptimize_on_minus_zero(), | 5011 instr->hydrogen()->deoptimize_on_minus_zero(), |
5021 instr->environment(), | 5012 instr->environment(), |
5022 mode); | 5013 mode); |
5023 } | 5014 } |
5024 | 5015 |
5025 | 5016 |
5026 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 5017 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
5027 Register result_reg = ToRegister(instr->result()); | 5018 Register result_reg = ToRegister(instr->result()); |
5028 Register scratch1 = scratch0(); | 5019 Register scratch1 = scratch0(); |
5029 Register scratch2 = ToRegister(instr->temp()); | |
5030 DwVfpRegister double_input = ToDoubleRegister(instr->value()); | 5020 DwVfpRegister double_input = ToDoubleRegister(instr->value()); |
5031 LowDwVfpRegister double_scratch = double_scratch0(); | 5021 LowDwVfpRegister double_scratch = double_scratch0(); |
5032 | 5022 |
5033 if (instr->truncating()) { | 5023 if (instr->truncating()) { |
5034 Register scratch3 = ToRegister(instr->temp2()); | 5024 __ TruncateDoubleToI(result_reg, double_input); |
5035 __ ECMAToInt32(result_reg, double_input, | |
5036 scratch1, scratch2, scratch3, double_scratch); | |
5037 } else { | 5025 } else { |
5038 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | 5026 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); |
5039 // Deoptimize if the input wasn't a int32 (inside a double). | 5027 // Deoptimize if the input wasn't a int32 (inside a double). |
5040 DeoptimizeIf(ne, instr->environment()); | 5028 DeoptimizeIf(ne, instr->environment()); |
5041 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5029 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
5042 Label done; | 5030 Label done; |
5043 __ cmp(result_reg, Operand::Zero()); | 5031 __ cmp(result_reg, Operand::Zero()); |
5044 __ b(ne, &done); | 5032 __ b(ne, &done); |
5045 __ VmovHigh(scratch1, double_input); | 5033 __ VmovHigh(scratch1, double_input); |
5046 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 5034 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
5047 DeoptimizeIf(ne, instr->environment()); | 5035 DeoptimizeIf(ne, instr->environment()); |
5048 __ bind(&done); | 5036 __ bind(&done); |
5049 } | 5037 } |
5050 } | 5038 } |
5051 } | 5039 } |
5052 | 5040 |
5053 | 5041 |
5054 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { | 5042 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { |
5055 Register result_reg = ToRegister(instr->result()); | 5043 Register result_reg = ToRegister(instr->result()); |
5056 Register scratch1 = scratch0(); | 5044 Register scratch1 = scratch0(); |
5057 Register scratch2 = ToRegister(instr->temp()); | |
5058 DwVfpRegister double_input = ToDoubleRegister(instr->value()); | 5045 DwVfpRegister double_input = ToDoubleRegister(instr->value()); |
5059 LowDwVfpRegister double_scratch = double_scratch0(); | 5046 LowDwVfpRegister double_scratch = double_scratch0(); |
5060 | 5047 |
5061 if (instr->truncating()) { | 5048 if (instr->truncating()) { |
5062 Register scratch3 = ToRegister(instr->temp2()); | 5049 __ TruncateDoubleToI(result_reg, double_input); |
5063 __ ECMAToInt32(result_reg, double_input, | |
5064 scratch1, scratch2, scratch3, double_scratch); | |
5065 } else { | 5050 } else { |
5066 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | 5051 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); |
5067 // Deoptimize if the input wasn't a int32 (inside a double). | 5052 // Deoptimize if the input wasn't a int32 (inside a double). |
5068 DeoptimizeIf(ne, instr->environment()); | 5053 DeoptimizeIf(ne, instr->environment()); |
5069 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5054 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
5070 Label done; | 5055 Label done; |
5071 __ cmp(result_reg, Operand::Zero()); | 5056 __ cmp(result_reg, Operand::Zero()); |
5072 __ b(ne, &done); | 5057 __ b(ne, &done); |
5073 __ VmovHigh(scratch1, double_input); | 5058 __ VmovHigh(scratch1, double_input); |
5074 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 5059 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5788 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5773 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5789 __ ldr(result, FieldMemOperand(scratch, | 5774 __ ldr(result, FieldMemOperand(scratch, |
5790 FixedArray::kHeaderSize - kPointerSize)); | 5775 FixedArray::kHeaderSize - kPointerSize)); |
5791 __ bind(&done); | 5776 __ bind(&done); |
5792 } | 5777 } |
5793 | 5778 |
5794 | 5779 |
5795 #undef __ | 5780 #undef __ |
5796 | 5781 |
5797 } } // namespace v8::internal | 5782 } } // namespace v8::internal |
OLD | NEW |