| 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 4128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4139 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 4139 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); |
| 4140 } | 4140 } |
| 4141 } | 4141 } |
| 4142 | 4142 |
| 4143 | 4143 |
| 4144 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { | 4144 void LCodeGen::DoCallRuntime(LCallRuntime* instr) { |
| 4145 CallRuntime(instr->function(), instr->arity(), instr); | 4145 CallRuntime(instr->function(), instr->arity(), instr); |
| 4146 } | 4146 } |
| 4147 | 4147 |
| 4148 | 4148 |
| 4149 void LCodeGen::DoStoreCodeEntry(LStoreCodeEntry* instr) { |
| 4150 Register function = ToRegister(instr->function()); |
| 4151 Register code_object = ToRegister(instr->code_object()); |
| 4152 __ add(code_object, code_object, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 4153 __ str(code_object, |
| 4154 FieldMemOperand(function, JSFunction::kCodeEntryOffset)); |
| 4155 } |
| 4156 |
| 4157 |
| 4149 void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { | 4158 void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { |
| 4150 Register result = ToRegister(instr->result()); | 4159 Register result = ToRegister(instr->result()); |
| 4151 Register base = ToRegister(instr->base_object()); | 4160 Register base = ToRegister(instr->base_object()); |
| 4152 __ add(result, base, Operand(instr->offset())); | 4161 __ add(result, base, Operand(instr->offset())); |
| 4153 } | 4162 } |
| 4154 | 4163 |
| 4155 | 4164 |
| 4156 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 4165 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
| 4157 Representation representation = instr->representation(); | 4166 Representation representation = instr->representation(); |
| 4158 | 4167 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4901 __ vcvt_f64_s32(result_reg, flt_scratch); | 4910 __ vcvt_f64_s32(result_reg, flt_scratch); |
| 4902 __ bind(&done); | 4911 __ bind(&done); |
| 4903 } | 4912 } |
| 4904 | 4913 |
| 4905 | 4914 |
| 4906 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 4915 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
| 4907 Register input_reg = ToRegister(instr->value()); | 4916 Register input_reg = ToRegister(instr->value()); |
| 4908 Register scratch1 = scratch0(); | 4917 Register scratch1 = scratch0(); |
| 4909 Register scratch2 = ToRegister(instr->temp()); | 4918 Register scratch2 = ToRegister(instr->temp()); |
| 4910 LowDwVfpRegister double_scratch = double_scratch0(); | 4919 LowDwVfpRegister double_scratch = double_scratch0(); |
| 4911 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->temp3()); | 4920 DwVfpRegister double_scratch2 = ToDoubleRegister(instr->temp2()); |
| 4912 | 4921 |
| 4913 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); | 4922 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); |
| 4914 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); | 4923 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); |
| 4915 | 4924 |
| 4916 Label done; | 4925 Label done; |
| 4917 | 4926 |
| 4918 // The input was optimistically untagged; revert it. | 4927 // The input was optimistically untagged; revert it. |
| 4919 // The carry flag is set when we reach this deferred code as we just executed | 4928 // The carry flag is set when we reach this deferred code as we just executed |
| 4920 // SmiUntag(heap_object, SetCC) | 4929 // SmiUntag(heap_object, SetCC) |
| 4921 STATIC_ASSERT(kHeapObjectTag == 1); | 4930 STATIC_ASSERT(kHeapObjectTag == 1); |
| 4922 __ adc(input_reg, input_reg, Operand(input_reg)); | 4931 __ adc(scratch2, input_reg, Operand(input_reg)); |
| 4923 | 4932 |
| 4924 // Heap number map check. | 4933 // Heap number map check. |
| 4925 __ ldr(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); | 4934 __ ldr(scratch1, FieldMemOperand(scratch2, HeapObject::kMapOffset)); |
| 4926 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 4935 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 4927 __ cmp(scratch1, Operand(ip)); | 4936 __ cmp(scratch1, Operand(ip)); |
| 4928 | 4937 |
| 4929 if (instr->truncating()) { | 4938 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 | 4939 // Performs a truncating conversion of a floating point number as used by |
| 4935 // the JS bitwise operations. | 4940 // the JS bitwise operations. |
| 4936 Label heap_number; | 4941 Label heap_number; |
| 4937 __ b(eq, &heap_number); | 4942 __ b(eq, &heap_number); |
| 4938 // Check for undefined. Undefined is converted to zero for truncating | 4943 // Check for undefined. Undefined is converted to zero for truncating |
| 4939 // conversions. | 4944 // conversions. |
| 4940 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 4945 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 4941 __ cmp(input_reg, Operand(ip)); | 4946 __ cmp(scratch2, Operand(ip)); |
| 4942 DeoptimizeIf(ne, instr->environment()); | 4947 DeoptimizeIf(ne, instr->environment()); |
| 4943 __ mov(input_reg, Operand::Zero()); | 4948 __ mov(input_reg, Operand::Zero()); |
| 4944 __ b(&done); | 4949 __ b(&done); |
| 4945 | 4950 |
| 4946 __ bind(&heap_number); | 4951 __ bind(&heap_number); |
| 4947 __ sub(scratch1, input_reg, Operand(kHeapObjectTag)); | 4952 __ 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 { | 4953 } else { |
| 4954 // Deoptimize if we don't have a heap number. | 4954 // Deoptimize if we don't have a heap number. |
| 4955 DeoptimizeIf(ne, instr->environment()); | 4955 DeoptimizeIf(ne, instr->environment()); |
| 4956 | 4956 |
| 4957 __ sub(ip, input_reg, Operand(kHeapObjectTag)); | 4957 __ sub(ip, scratch2, Operand(kHeapObjectTag)); |
| 4958 __ vldr(double_scratch2, ip, HeapNumber::kValueOffset); | 4958 __ vldr(double_scratch2, ip, HeapNumber::kValueOffset); |
| 4959 __ TryDoubleToInt32Exact(input_reg, double_scratch2, double_scratch); | 4959 __ TryDoubleToInt32Exact(input_reg, double_scratch2, double_scratch); |
| 4960 DeoptimizeIf(ne, instr->environment()); | 4960 DeoptimizeIf(ne, instr->environment()); |
| 4961 | 4961 |
| 4962 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 4962 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 4963 __ cmp(input_reg, Operand::Zero()); | 4963 __ cmp(input_reg, Operand::Zero()); |
| 4964 __ b(ne, &done); | 4964 __ b(ne, &done); |
| 4965 __ VmovHigh(scratch1, double_scratch2); | 4965 __ VmovHigh(scratch1, double_scratch2); |
| 4966 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 4966 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 4967 DeoptimizeIf(ne, instr->environment()); | 4967 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(), | 5019 instr->hydrogen()->can_convert_undefined_to_nan(), |
| 5020 instr->hydrogen()->deoptimize_on_minus_zero(), | 5020 instr->hydrogen()->deoptimize_on_minus_zero(), |
| 5021 instr->environment(), | 5021 instr->environment(), |
| 5022 mode); | 5022 mode); |
| 5023 } | 5023 } |
| 5024 | 5024 |
| 5025 | 5025 |
| 5026 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 5026 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
| 5027 Register result_reg = ToRegister(instr->result()); | 5027 Register result_reg = ToRegister(instr->result()); |
| 5028 Register scratch1 = scratch0(); | 5028 Register scratch1 = scratch0(); |
| 5029 Register scratch2 = ToRegister(instr->temp()); | |
| 5030 DwVfpRegister double_input = ToDoubleRegister(instr->value()); | 5029 DwVfpRegister double_input = ToDoubleRegister(instr->value()); |
| 5031 LowDwVfpRegister double_scratch = double_scratch0(); | 5030 LowDwVfpRegister double_scratch = double_scratch0(); |
| 5032 | 5031 |
| 5033 if (instr->truncating()) { | 5032 if (instr->truncating()) { |
| 5034 Register scratch3 = ToRegister(instr->temp2()); | 5033 __ TruncateDoubleToI(result_reg, double_input); |
| 5035 __ ECMAToInt32(result_reg, double_input, | |
| 5036 scratch1, scratch2, scratch3, double_scratch); | |
| 5037 } else { | 5034 } else { |
| 5038 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | 5035 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); |
| 5039 // Deoptimize if the input wasn't a int32 (inside a double). | 5036 // Deoptimize if the input wasn't a int32 (inside a double). |
| 5040 DeoptimizeIf(ne, instr->environment()); | 5037 DeoptimizeIf(ne, instr->environment()); |
| 5041 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5038 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 5042 Label done; | 5039 Label done; |
| 5043 __ cmp(result_reg, Operand::Zero()); | 5040 __ cmp(result_reg, Operand::Zero()); |
| 5044 __ b(ne, &done); | 5041 __ b(ne, &done); |
| 5045 __ VmovHigh(scratch1, double_input); | 5042 __ VmovHigh(scratch1, double_input); |
| 5046 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 5043 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| 5047 DeoptimizeIf(ne, instr->environment()); | 5044 DeoptimizeIf(ne, instr->environment()); |
| 5048 __ bind(&done); | 5045 __ bind(&done); |
| 5049 } | 5046 } |
| 5050 } | 5047 } |
| 5051 } | 5048 } |
| 5052 | 5049 |
| 5053 | 5050 |
| 5054 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { | 5051 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { |
| 5055 Register result_reg = ToRegister(instr->result()); | 5052 Register result_reg = ToRegister(instr->result()); |
| 5056 Register scratch1 = scratch0(); | 5053 Register scratch1 = scratch0(); |
| 5057 Register scratch2 = ToRegister(instr->temp()); | |
| 5058 DwVfpRegister double_input = ToDoubleRegister(instr->value()); | 5054 DwVfpRegister double_input = ToDoubleRegister(instr->value()); |
| 5059 LowDwVfpRegister double_scratch = double_scratch0(); | 5055 LowDwVfpRegister double_scratch = double_scratch0(); |
| 5060 | 5056 |
| 5061 if (instr->truncating()) { | 5057 if (instr->truncating()) { |
| 5062 Register scratch3 = ToRegister(instr->temp2()); | 5058 __ TruncateDoubleToI(result_reg, double_input); |
| 5063 __ ECMAToInt32(result_reg, double_input, | |
| 5064 scratch1, scratch2, scratch3, double_scratch); | |
| 5065 } else { | 5059 } else { |
| 5066 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); | 5060 __ TryDoubleToInt32Exact(result_reg, double_input, double_scratch); |
| 5067 // Deoptimize if the input wasn't a int32 (inside a double). | 5061 // Deoptimize if the input wasn't a int32 (inside a double). |
| 5068 DeoptimizeIf(ne, instr->environment()); | 5062 DeoptimizeIf(ne, instr->environment()); |
| 5069 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 5063 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 5070 Label done; | 5064 Label done; |
| 5071 __ cmp(result_reg, Operand::Zero()); | 5065 __ cmp(result_reg, Operand::Zero()); |
| 5072 __ b(ne, &done); | 5066 __ b(ne, &done); |
| 5073 __ VmovHigh(scratch1, double_input); | 5067 __ VmovHigh(scratch1, double_input); |
| 5074 __ tst(scratch1, Operand(HeapNumber::kSignMask)); | 5068 __ tst(scratch1, Operand(HeapNumber::kSignMask)); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5425 } | 5419 } |
| 5426 | 5420 |
| 5427 | 5421 |
| 5428 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { | 5422 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { |
| 5429 // Use the fast case closure allocation code that allocates in new | 5423 // Use the fast case closure allocation code that allocates in new |
| 5430 // space for nested functions that don't need literals cloning. | 5424 // space for nested functions that don't need literals cloning. |
| 5431 bool pretenure = instr->hydrogen()->pretenure(); | 5425 bool pretenure = instr->hydrogen()->pretenure(); |
| 5432 if (!pretenure && instr->hydrogen()->has_no_literals()) { | 5426 if (!pretenure && instr->hydrogen()->has_no_literals()) { |
| 5433 FastNewClosureStub stub(instr->hydrogen()->language_mode(), | 5427 FastNewClosureStub stub(instr->hydrogen()->language_mode(), |
| 5434 instr->hydrogen()->is_generator()); | 5428 instr->hydrogen()->is_generator()); |
| 5435 __ mov(r1, Operand(instr->hydrogen()->shared_info())); | 5429 __ mov(r2, Operand(instr->hydrogen()->shared_info())); |
| 5436 __ push(r1); | |
| 5437 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 5430 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 5438 } else { | 5431 } else { |
| 5439 __ mov(r2, Operand(instr->hydrogen()->shared_info())); | 5432 __ mov(r2, Operand(instr->hydrogen()->shared_info())); |
| 5440 __ mov(r1, Operand(pretenure ? factory()->true_value() | 5433 __ mov(r1, Operand(pretenure ? factory()->true_value() |
| 5441 : factory()->false_value())); | 5434 : factory()->false_value())); |
| 5442 __ Push(cp, r2, r1); | 5435 __ Push(cp, r2, r1); |
| 5443 CallRuntime(Runtime::kNewClosure, 3, instr); | 5436 CallRuntime(Runtime::kNewClosure, 3, instr); |
| 5444 } | 5437 } |
| 5445 } | 5438 } |
| 5446 | 5439 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5788 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5781 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5789 __ ldr(result, FieldMemOperand(scratch, | 5782 __ ldr(result, FieldMemOperand(scratch, |
| 5790 FixedArray::kHeaderSize - kPointerSize)); | 5783 FixedArray::kHeaderSize - kPointerSize)); |
| 5791 __ bind(&done); | 5784 __ bind(&done); |
| 5792 } | 5785 } |
| 5793 | 5786 |
| 5794 | 5787 |
| 5795 #undef __ | 5788 #undef __ |
| 5796 | 5789 |
| 5797 } } // namespace v8::internal | 5790 } } // namespace v8::internal |
| OLD | NEW |