| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 | 755 |
| 756 // Check if the value is a smi. | 756 // Check if the value is a smi. |
| 757 __ cmp(tos, Operand(Smi::FromInt(0))); | 757 __ cmp(tos, Operand(Smi::FromInt(0))); |
| 758 | 758 |
| 759 if (!known_smi) { | 759 if (!known_smi) { |
| 760 false_target->Branch(eq); | 760 false_target->Branch(eq); |
| 761 __ tst(tos, Operand(kSmiTagMask)); | 761 __ tst(tos, Operand(kSmiTagMask)); |
| 762 true_target->Branch(eq); | 762 true_target->Branch(eq); |
| 763 | 763 |
| 764 // Slow case. | 764 // Slow case. |
| 765 if (CpuFeatures::IsSupported(VFP3)) { | 765 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 766 CpuFeatures::Scope scope(VFP3); | 766 CpuFeatures::Scope scope(VFP3); |
| 767 // Implements the slow case by using ToBooleanStub. | 767 // Implements the slow case by using ToBooleanStub. |
| 768 // The ToBooleanStub takes a single argument, and | 768 // The ToBooleanStub takes a single argument, and |
| 769 // returns a non-zero value for true, or zero for false. | 769 // returns a non-zero value for true, or zero for false. |
| 770 // Both the argument value and the return value use the | 770 // Both the argument value and the return value use the |
| 771 // register assigned to tos_ | 771 // register assigned to tos_ |
| 772 ToBooleanStub stub(tos); | 772 ToBooleanStub stub(tos); |
| 773 frame_->CallStub(&stub, 0); | 773 frame_->CallStub(&stub, 0); |
| 774 // Convert the result in "tos" to a condition code. | 774 // Convert the result in "tos" to a condition code. |
| 775 __ cmp(tos, Operand(0, RelocInfo::NONE)); | 775 __ cmp(tos, Operand(0, RelocInfo::NONE)); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 952 |
| 953 __ b(cond, &non_smi_input_); | 953 __ b(cond, &non_smi_input_); |
| 954 } | 954 } |
| 955 | 955 |
| 956 | 956 |
| 957 // For bit operations the result is always 32bits so we handle the case where | 957 // For bit operations the result is always 32bits so we handle the case where |
| 958 // the result does not fit in a Smi without calling the generic stub. | 958 // the result does not fit in a Smi without calling the generic stub. |
| 959 void DeferredInlineSmiOperation::JumpToAnswerOutOfRange(Condition cond) { | 959 void DeferredInlineSmiOperation::JumpToAnswerOutOfRange(Condition cond) { |
| 960 ASSERT(Token::IsBitOp(op_)); | 960 ASSERT(Token::IsBitOp(op_)); |
| 961 | 961 |
| 962 if ((op_ == Token::SHR) && !CpuFeatures::IsSupported(VFP3)) { | 962 if ((op_ == Token::SHR) && |
| 963 !Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 963 // >>> requires an unsigned to double conversion and the non VFP code | 964 // >>> requires an unsigned to double conversion and the non VFP code |
| 964 // does not support this conversion. | 965 // does not support this conversion. |
| 965 __ b(cond, entry_label()); | 966 __ b(cond, entry_label()); |
| 966 } else { | 967 } else { |
| 967 __ b(cond, &answer_out_of_range_); | 968 __ b(cond, &answer_out_of_range_); |
| 968 } | 969 } |
| 969 } | 970 } |
| 970 | 971 |
| 971 | 972 |
| 972 // On entry the non-constant side of the binary operation is in tos_register_ | 973 // On entry the non-constant side of the binary operation is in tos_register_ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 if (answer_out_of_range_.is_linked()) { | 1057 if (answer_out_of_range_.is_linked()) { |
| 1057 GenerateAnswerOutOfRange(); | 1058 GenerateAnswerOutOfRange(); |
| 1058 } | 1059 } |
| 1059 } | 1060 } |
| 1060 | 1061 |
| 1061 | 1062 |
| 1062 // Convert and write the integer answer into heap_number. | 1063 // Convert and write the integer answer into heap_number. |
| 1063 void DeferredInlineSmiOperation::WriteNonSmiAnswer(Register answer, | 1064 void DeferredInlineSmiOperation::WriteNonSmiAnswer(Register answer, |
| 1064 Register heap_number, | 1065 Register heap_number, |
| 1065 Register scratch) { | 1066 Register scratch) { |
| 1066 if (CpuFeatures::IsSupported(VFP3)) { | 1067 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 1067 CpuFeatures::Scope scope(VFP3); | 1068 CpuFeatures::Scope scope(VFP3); |
| 1068 __ vmov(s0, answer); | 1069 __ vmov(s0, answer); |
| 1069 if (op_ == Token::SHR) { | 1070 if (op_ == Token::SHR) { |
| 1070 __ vcvt_f64_u32(d0, s0); | 1071 __ vcvt_f64_u32(d0, s0); |
| 1071 } else { | 1072 } else { |
| 1072 __ vcvt_f64_s32(d0, s0); | 1073 __ vcvt_f64_s32(d0, s0); |
| 1073 } | 1074 } |
| 1074 __ sub(scratch, heap_number, Operand(kHeapObjectTag)); | 1075 __ sub(scratch, heap_number, Operand(kHeapObjectTag)); |
| 1075 __ vstr(d0, scratch, HeapNumber::kValueOffset); | 1076 __ vstr(d0, scratch, HeapNumber::kValueOffset); |
| 1076 } else { | 1077 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 } | 1127 } |
| 1127 break; | 1128 break; |
| 1128 case Token::SHR: | 1129 case Token::SHR: |
| 1129 ASSERT(!reversed_); | 1130 ASSERT(!reversed_); |
| 1130 if (shift_value != 0) { | 1131 if (shift_value != 0) { |
| 1131 __ mov(int32, Operand(int32, LSR, shift_value), SetCC); | 1132 __ mov(int32, Operand(int32, LSR, shift_value), SetCC); |
| 1132 } else { | 1133 } else { |
| 1133 // SHR is special because it is required to produce a positive answer. | 1134 // SHR is special because it is required to produce a positive answer. |
| 1134 __ cmp(int32, Operand(0, RelocInfo::NONE)); | 1135 __ cmp(int32, Operand(0, RelocInfo::NONE)); |
| 1135 } | 1136 } |
| 1136 if (CpuFeatures::IsSupported(VFP3)) { | 1137 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 1137 __ b(mi, &result_not_a_smi); | 1138 __ b(mi, &result_not_a_smi); |
| 1138 } else { | 1139 } else { |
| 1139 // Non VFP code cannot convert from unsigned to double, so fall back | 1140 // Non VFP code cannot convert from unsigned to double, so fall back |
| 1140 // to GenericBinaryOpStub. | 1141 // to GenericBinaryOpStub. |
| 1141 __ b(mi, entry_label()); | 1142 __ b(mi, entry_label()); |
| 1142 } | 1143 } |
| 1143 break; | 1144 break; |
| 1144 case Token::SHL: | 1145 case Token::SHL: |
| 1145 ASSERT(!reversed_); | 1146 ASSERT(!reversed_); |
| 1146 if (shift_value != 0) { | 1147 if (shift_value != 0) { |
| (...skipping 3443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4590 cc_reg_ = eq; | 4591 cc_reg_ = eq; |
| 4591 } | 4592 } |
| 4592 | 4593 |
| 4593 | 4594 |
| 4594 // Generates the Math.pow method. | 4595 // Generates the Math.pow method. |
| 4595 void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) { | 4596 void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) { |
| 4596 ASSERT(args->length() == 2); | 4597 ASSERT(args->length() == 2); |
| 4597 Load(args->at(0)); | 4598 Load(args->at(0)); |
| 4598 Load(args->at(1)); | 4599 Load(args->at(1)); |
| 4599 | 4600 |
| 4600 if (!CpuFeatures::IsSupported(VFP3)) { | 4601 if (!Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 4601 frame_->CallRuntime(Runtime::kMath_pow, 2); | 4602 frame_->CallRuntime(Runtime::kMath_pow, 2); |
| 4602 frame_->EmitPush(r0); | 4603 frame_->EmitPush(r0); |
| 4603 } else { | 4604 } else { |
| 4604 CpuFeatures::Scope scope(VFP3); | 4605 CpuFeatures::Scope scope(VFP3); |
| 4605 JumpTarget runtime, done; | 4606 JumpTarget runtime, done; |
| 4606 Label exponent_nonsmi, base_nonsmi, powi, not_minus_half, allocate_return; | 4607 Label exponent_nonsmi, base_nonsmi, powi, not_minus_half, allocate_return; |
| 4607 | 4608 |
| 4608 Register scratch1 = VirtualFrame::scratch0(); | 4609 Register scratch1 = VirtualFrame::scratch0(); |
| 4609 Register scratch2 = VirtualFrame::scratch1(); | 4610 Register scratch2 = VirtualFrame::scratch1(); |
| 4610 | 4611 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4744 frame_->EmitPush(base); | 4745 frame_->EmitPush(base); |
| 4745 } | 4746 } |
| 4746 } | 4747 } |
| 4747 | 4748 |
| 4748 | 4749 |
| 4749 // Generates the Math.sqrt method. | 4750 // Generates the Math.sqrt method. |
| 4750 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { | 4751 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { |
| 4751 ASSERT(args->length() == 1); | 4752 ASSERT(args->length() == 1); |
| 4752 Load(args->at(0)); | 4753 Load(args->at(0)); |
| 4753 | 4754 |
| 4754 if (!CpuFeatures::IsSupported(VFP3)) { | 4755 if (!Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 4755 frame_->CallRuntime(Runtime::kMath_sqrt, 1); | 4756 frame_->CallRuntime(Runtime::kMath_sqrt, 1); |
| 4756 frame_->EmitPush(r0); | 4757 frame_->EmitPush(r0); |
| 4757 } else { | 4758 } else { |
| 4758 CpuFeatures::Scope scope(VFP3); | 4759 CpuFeatures::Scope scope(VFP3); |
| 4759 JumpTarget runtime, done; | 4760 JumpTarget runtime, done; |
| 4760 | 4761 |
| 4761 Register scratch1 = VirtualFrame::scratch0(); | 4762 Register scratch1 = VirtualFrame::scratch0(); |
| 4762 Register scratch2 = VirtualFrame::scratch1(); | 4763 Register scratch2 = VirtualFrame::scratch1(); |
| 4763 | 4764 |
| 4764 // Get the value from the frame. | 4765 // Get the value from the frame. |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5333 __ bind(&slow_allocate_heapnumber); | 5334 __ bind(&slow_allocate_heapnumber); |
| 5334 // Allocate a heap number. | 5335 // Allocate a heap number. |
| 5335 __ CallRuntime(Runtime::kNumberAlloc, 0); | 5336 __ CallRuntime(Runtime::kNumberAlloc, 0); |
| 5336 __ mov(r4, Operand(r0)); | 5337 __ mov(r4, Operand(r0)); |
| 5337 | 5338 |
| 5338 __ bind(&heapnumber_allocated); | 5339 __ bind(&heapnumber_allocated); |
| 5339 | 5340 |
| 5340 // Convert 32 random bits in r0 to 0.(32 random bits) in a double | 5341 // Convert 32 random bits in r0 to 0.(32 random bits) in a double |
| 5341 // by computing: | 5342 // by computing: |
| 5342 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 5343 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 5343 if (CpuFeatures::IsSupported(VFP3)) { | 5344 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 5344 __ PrepareCallCFunction(1, r0); | 5345 __ PrepareCallCFunction(0, r1); |
| 5345 __ mov(r0, Operand(ExternalReference::isolate_address())); | 5346 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 0); |
| 5346 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | |
| 5347 | 5347 |
| 5348 CpuFeatures::Scope scope(VFP3); | 5348 CpuFeatures::Scope scope(VFP3); |
| 5349 // 0x41300000 is the top half of 1.0 x 2^20 as a double. | 5349 // 0x41300000 is the top half of 1.0 x 2^20 as a double. |
| 5350 // Create this constant using mov/orr to avoid PC relative load. | 5350 // Create this constant using mov/orr to avoid PC relative load. |
| 5351 __ mov(r1, Operand(0x41000000)); | 5351 __ mov(r1, Operand(0x41000000)); |
| 5352 __ orr(r1, r1, Operand(0x300000)); | 5352 __ orr(r1, r1, Operand(0x300000)); |
| 5353 // Move 0x41300000xxxxxxxx (x = random bits) to VFP. | 5353 // Move 0x41300000xxxxxxxx (x = random bits) to VFP. |
| 5354 __ vmov(d7, r0, r1); | 5354 __ vmov(d7, r0, r1); |
| 5355 // Move 0x4130000000000000 to VFP. | 5355 // Move 0x4130000000000000 to VFP. |
| 5356 __ mov(r0, Operand(0, RelocInfo::NONE)); | 5356 __ mov(r0, Operand(0, RelocInfo::NONE)); |
| 5357 __ vmov(d8, r0, r1); | 5357 __ vmov(d8, r0, r1); |
| 5358 // Subtract and store the result in the heap number. | 5358 // Subtract and store the result in the heap number. |
| 5359 __ vsub(d7, d7, d8); | 5359 __ vsub(d7, d7, d8); |
| 5360 __ sub(r0, r4, Operand(kHeapObjectTag)); | 5360 __ sub(r0, r4, Operand(kHeapObjectTag)); |
| 5361 __ vstr(d7, r0, HeapNumber::kValueOffset); | 5361 __ vstr(d7, r0, HeapNumber::kValueOffset); |
| 5362 frame_->EmitPush(r4); | 5362 frame_->EmitPush(r4); |
| 5363 } else { | 5363 } else { |
| 5364 __ PrepareCallCFunction(2, r0); | |
| 5365 __ mov(r0, Operand(r4)); | 5364 __ mov(r0, Operand(r4)); |
| 5366 __ mov(r1, Operand(ExternalReference::isolate_address())); | 5365 __ PrepareCallCFunction(1, r1); |
| 5367 __ CallCFunction( | 5366 __ CallCFunction( |
| 5368 ExternalReference::fill_heap_number_with_random_function(isolate()), 2); | 5367 ExternalReference::fill_heap_number_with_random_function(isolate()), 1); |
| 5369 frame_->EmitPush(r0); | 5368 frame_->EmitPush(r0); |
| 5370 } | 5369 } |
| 5371 } | 5370 } |
| 5372 | 5371 |
| 5373 | 5372 |
| 5374 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { | 5373 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { |
| 5375 ASSERT_EQ(2, args->length()); | 5374 ASSERT_EQ(2, args->length()); |
| 5376 | 5375 |
| 5377 Load(args->at(0)); | 5376 Load(args->at(0)); |
| 5378 Load(args->at(1)); | 5377 Load(args->at(1)); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5649 } | 5648 } |
| 5650 Load(args->at(n_args + 1)); // function | 5649 Load(args->at(n_args + 1)); // function |
| 5651 frame_->CallJSFunction(n_args); | 5650 frame_->CallJSFunction(n_args); |
| 5652 frame_->EmitPush(r0); | 5651 frame_->EmitPush(r0); |
| 5653 } | 5652 } |
| 5654 | 5653 |
| 5655 | 5654 |
| 5656 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { | 5655 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { |
| 5657 ASSERT_EQ(args->length(), 1); | 5656 ASSERT_EQ(args->length(), 1); |
| 5658 Load(args->at(0)); | 5657 Load(args->at(0)); |
| 5659 if (CpuFeatures::IsSupported(VFP3)) { | 5658 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 5660 TranscendentalCacheStub stub(TranscendentalCache::SIN, | 5659 TranscendentalCacheStub stub(TranscendentalCache::SIN, |
| 5661 TranscendentalCacheStub::TAGGED); | 5660 TranscendentalCacheStub::TAGGED); |
| 5662 frame_->SpillAllButCopyTOSToR0(); | 5661 frame_->SpillAllButCopyTOSToR0(); |
| 5663 frame_->CallStub(&stub, 1); | 5662 frame_->CallStub(&stub, 1); |
| 5664 } else { | 5663 } else { |
| 5665 frame_->CallRuntime(Runtime::kMath_sin, 1); | 5664 frame_->CallRuntime(Runtime::kMath_sin, 1); |
| 5666 } | 5665 } |
| 5667 frame_->EmitPush(r0); | 5666 frame_->EmitPush(r0); |
| 5668 } | 5667 } |
| 5669 | 5668 |
| 5670 | 5669 |
| 5671 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { | 5670 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { |
| 5672 ASSERT_EQ(args->length(), 1); | 5671 ASSERT_EQ(args->length(), 1); |
| 5673 Load(args->at(0)); | 5672 Load(args->at(0)); |
| 5674 if (CpuFeatures::IsSupported(VFP3)) { | 5673 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 5675 TranscendentalCacheStub stub(TranscendentalCache::COS, | 5674 TranscendentalCacheStub stub(TranscendentalCache::COS, |
| 5676 TranscendentalCacheStub::TAGGED); | 5675 TranscendentalCacheStub::TAGGED); |
| 5677 frame_->SpillAllButCopyTOSToR0(); | 5676 frame_->SpillAllButCopyTOSToR0(); |
| 5678 frame_->CallStub(&stub, 1); | 5677 frame_->CallStub(&stub, 1); |
| 5679 } else { | 5678 } else { |
| 5680 frame_->CallRuntime(Runtime::kMath_cos, 1); | 5679 frame_->CallRuntime(Runtime::kMath_cos, 1); |
| 5681 } | 5680 } |
| 5682 frame_->EmitPush(r0); | 5681 frame_->EmitPush(r0); |
| 5683 } | 5682 } |
| 5684 | 5683 |
| 5685 | 5684 |
| 5686 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { | 5685 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { |
| 5687 ASSERT_EQ(args->length(), 1); | 5686 ASSERT_EQ(args->length(), 1); |
| 5688 Load(args->at(0)); | 5687 Load(args->at(0)); |
| 5689 if (CpuFeatures::IsSupported(VFP3)) { | 5688 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 5690 TranscendentalCacheStub stub(TranscendentalCache::LOG, | 5689 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
| 5691 TranscendentalCacheStub::TAGGED); | 5690 TranscendentalCacheStub::TAGGED); |
| 5692 frame_->SpillAllButCopyTOSToR0(); | 5691 frame_->SpillAllButCopyTOSToR0(); |
| 5693 frame_->CallStub(&stub, 1); | 5692 frame_->CallStub(&stub, 1); |
| 5694 } else { | 5693 } else { |
| 5695 frame_->CallRuntime(Runtime::kMath_log, 1); | 5694 frame_->CallRuntime(Runtime::kMath_log, 1); |
| 5696 } | 5695 } |
| 5697 frame_->EmitPush(r0); | 5696 frame_->EmitPush(r0); |
| 5698 } | 5697 } |
| 5699 | 5698 |
| (...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7409 specialized_on_rhs_ ? "_ConstantRhs" : "", | 7408 specialized_on_rhs_ ? "_ConstantRhs" : "", |
| 7410 BinaryOpIC::GetName(runtime_operands_type_)); | 7409 BinaryOpIC::GetName(runtime_operands_type_)); |
| 7411 return name_; | 7410 return name_; |
| 7412 } | 7411 } |
| 7413 | 7412 |
| 7414 #undef __ | 7413 #undef __ |
| 7415 | 7414 |
| 7416 } } // namespace v8::internal | 7415 } } // namespace v8::internal |
| 7417 | 7416 |
| 7418 #endif // V8_TARGET_ARCH_ARM | 7417 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |