| 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } else { | 667 } else { |
| 668 if (false_label_ != fall_through_) __ Branch(false_label_); | 668 if (false_label_ != fall_through_) __ Branch(false_label_); |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 | 671 |
| 672 | 672 |
| 673 void FullCodeGenerator::DoTest(Expression* condition, | 673 void FullCodeGenerator::DoTest(Expression* condition, |
| 674 Label* if_true, | 674 Label* if_true, |
| 675 Label* if_false, | 675 Label* if_false, |
| 676 Label* fall_through) { | 676 Label* fall_through) { |
| 677 if (CpuFeatures::IsSupported(FPU)) { | 677 ToBooleanStub stub(result_register()); |
| 678 ToBooleanStub stub(result_register()); | 678 __ CallStub(&stub, condition->test_id()); |
| 679 __ CallStub(&stub, condition->test_id()); | 679 __ mov(at, zero_reg); |
| 680 __ mov(at, zero_reg); | |
| 681 } else { | |
| 682 // Call the runtime to find the boolean value of the source and then | |
| 683 // translate it into control flow to the pair of labels. | |
| 684 __ push(result_register()); | |
| 685 __ CallRuntime(Runtime::kToBool, 1); | |
| 686 __ LoadRoot(at, Heap::kFalseValueRootIndex); | |
| 687 } | |
| 688 Split(ne, v0, Operand(at), if_true, if_false, fall_through); | 680 Split(ne, v0, Operand(at), if_true, if_false, fall_through); |
| 689 } | 681 } |
| 690 | 682 |
| 691 | 683 |
| 692 void FullCodeGenerator::Split(Condition cc, | 684 void FullCodeGenerator::Split(Condition cc, |
| 693 Register lhs, | 685 Register lhs, |
| 694 const Operand& rhs, | 686 const Operand& rhs, |
| 695 Label* if_true, | 687 Label* if_true, |
| 696 Label* if_false, | 688 Label* if_false, |
| 697 Label* fall_through) { | 689 Label* fall_through) { |
| (...skipping 2340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 | 3030 |
| 3039 // Allocate a heap number. | 3031 // Allocate a heap number. |
| 3040 __ CallRuntime(Runtime::kNumberAlloc, 0); | 3032 __ CallRuntime(Runtime::kNumberAlloc, 0); |
| 3041 __ mov(s0, v0); // Save result in s0, so it is saved thru CFunc call. | 3033 __ mov(s0, v0); // Save result in s0, so it is saved thru CFunc call. |
| 3042 | 3034 |
| 3043 __ bind(&heapnumber_allocated); | 3035 __ bind(&heapnumber_allocated); |
| 3044 | 3036 |
| 3045 // Convert 32 random bits in v0 to 0.(32 random bits) in a double | 3037 // Convert 32 random bits in v0 to 0.(32 random bits) in a double |
| 3046 // by computing: | 3038 // by computing: |
| 3047 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 3039 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
| 3048 if (CpuFeatures::IsSupported(FPU)) { | 3040 __ PrepareCallCFunction(1, a0); |
| 3049 __ PrepareCallCFunction(1, a0); | 3041 __ lw(a0, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
| 3050 __ lw(a0, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | 3042 __ lw(a0, FieldMemOperand(a0, GlobalObject::kNativeContextOffset)); |
| 3051 __ lw(a0, FieldMemOperand(a0, GlobalObject::kNativeContextOffset)); | 3043 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); |
| 3052 __ CallCFunction(ExternalReference::random_uint32_function(isolate()), 1); | |
| 3053 | 3044 |
| 3054 CpuFeatureScope scope(masm(), FPU); | 3045 // 0x41300000 is the top half of 1.0 x 2^20 as a double. |
| 3055 // 0x41300000 is the top half of 1.0 x 2^20 as a double. | 3046 __ li(a1, Operand(0x41300000)); |
| 3056 __ li(a1, Operand(0x41300000)); | 3047 // Move 0x41300000xxxxxxxx (x = random bits in v0) to FPU. |
| 3057 // Move 0x41300000xxxxxxxx (x = random bits in v0) to FPU. | 3048 __ Move(f12, v0, a1); |
| 3058 __ Move(f12, v0, a1); | 3049 // Move 0x4130000000000000 to FPU. |
| 3059 // Move 0x4130000000000000 to FPU. | 3050 __ Move(f14, zero_reg, a1); |
| 3060 __ Move(f14, zero_reg, a1); | 3051 // Subtract and store the result in the heap number. |
| 3061 // Subtract and store the result in the heap number. | 3052 __ sub_d(f0, f12, f14); |
| 3062 __ sub_d(f0, f12, f14); | 3053 __ sdc1(f0, FieldMemOperand(s0, HeapNumber::kValueOffset)); |
| 3063 __ sdc1(f0, FieldMemOperand(s0, HeapNumber::kValueOffset)); | 3054 __ mov(v0, s0); |
| 3064 __ mov(v0, s0); | |
| 3065 } else { | |
| 3066 __ PrepareCallCFunction(2, a0); | |
| 3067 __ mov(a0, s0); | |
| 3068 __ lw(a1, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); | |
| 3069 __ lw(a1, FieldMemOperand(a1, GlobalObject::kNativeContextOffset)); | |
| 3070 __ CallCFunction( | |
| 3071 ExternalReference::fill_heap_number_with_random_function(isolate()), 2); | |
| 3072 } | |
| 3073 | 3055 |
| 3074 context()->Plug(v0); | 3056 context()->Plug(v0); |
| 3075 } | 3057 } |
| 3076 | 3058 |
| 3077 | 3059 |
| 3078 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { | 3060 void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
| 3079 // Load the arguments on the stack and call the stub. | 3061 // Load the arguments on the stack and call the stub. |
| 3080 SubStringStub stub; | 3062 SubStringStub stub; |
| 3081 ZoneList<Expression*>* args = expr->arguments(); | 3063 ZoneList<Expression*>* args = expr->arguments(); |
| 3082 ASSERT(args->length() == 3); | 3064 ASSERT(args->length() == 3); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3200 context()->Plug(v0); | 3182 context()->Plug(v0); |
| 3201 } | 3183 } |
| 3202 | 3184 |
| 3203 | 3185 |
| 3204 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3186 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
| 3205 // Load the arguments on the stack and call the runtime function. | 3187 // Load the arguments on the stack and call the runtime function. |
| 3206 ZoneList<Expression*>* args = expr->arguments(); | 3188 ZoneList<Expression*>* args = expr->arguments(); |
| 3207 ASSERT(args->length() == 2); | 3189 ASSERT(args->length() == 2); |
| 3208 VisitForStackValue(args->at(0)); | 3190 VisitForStackValue(args->at(0)); |
| 3209 VisitForStackValue(args->at(1)); | 3191 VisitForStackValue(args->at(1)); |
| 3210 if (CpuFeatures::IsSupported(FPU)) { | 3192 MathPowStub stub(MathPowStub::ON_STACK); |
| 3211 MathPowStub stub(MathPowStub::ON_STACK); | 3193 __ CallStub(&stub); |
| 3212 __ CallStub(&stub); | |
| 3213 } else { | |
| 3214 __ CallRuntime(Runtime::kMath_pow, 2); | |
| 3215 } | |
| 3216 context()->Plug(v0); | 3194 context()->Plug(v0); |
| 3217 } | 3195 } |
| 3218 | 3196 |
| 3219 | 3197 |
| 3220 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { | 3198 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
| 3221 ZoneList<Expression*>* args = expr->arguments(); | 3199 ZoneList<Expression*>* args = expr->arguments(); |
| 3222 ASSERT(args->length() == 2); | 3200 ASSERT(args->length() == 2); |
| 3223 | 3201 |
| 3224 VisitForStackValue(args->at(0)); // Load the object. | 3202 VisitForStackValue(args->at(0)); // Load the object. |
| 3225 VisitForAccumulatorValue(args->at(1)); // Load the value. | 3203 VisitForAccumulatorValue(args->at(1)); // Load the value. |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4605 *context_length = 0; | 4583 *context_length = 0; |
| 4606 return previous_; | 4584 return previous_; |
| 4607 } | 4585 } |
| 4608 | 4586 |
| 4609 | 4587 |
| 4610 #undef __ | 4588 #undef __ |
| 4611 | 4589 |
| 4612 } } // namespace v8::internal | 4590 } } // namespace v8::internal |
| 4613 | 4591 |
| 4614 #endif // V8_TARGET_ARCH_MIPS | 4592 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |