OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 __ neg_d(result, temp); | 3017 __ neg_d(result, temp); |
3018 | 3018 |
3019 // Add +0 to convert -0 to +0. | 3019 // Add +0 to convert -0 to +0. |
3020 __ add_d(result, input, kDoubleRegZero); | 3020 __ add_d(result, input, kDoubleRegZero); |
3021 __ sqrt_d(result, result); | 3021 __ sqrt_d(result, result); |
3022 __ bind(&done); | 3022 __ bind(&done); |
3023 } | 3023 } |
3024 | 3024 |
3025 | 3025 |
3026 void LCodeGen::DoPower(LPower* instr) { | 3026 void LCodeGen::DoPower(LPower* instr) { |
3027 LOperand* left = instr->InputAt(0); | |
3028 LOperand* right = instr->InputAt(1); | |
3029 Register scratch = scratch0(); | |
3030 DoubleRegister result_reg = ToDoubleRegister(instr->result()); | |
3031 Representation exponent_type = instr->hydrogen()->right()->representation(); | 3027 Representation exponent_type = instr->hydrogen()->right()->representation(); |
3032 if (exponent_type.IsDouble()) { | 3028 // Having marked this as a call, we can use any registers. |
3033 // Prepare arguments and call C function. | 3029 // Just make sure that the input/output registers are the expected ones. |
3034 __ PrepareCallCFunction(0, 2, scratch); | 3030 ASSERT(!instr->InputAt(1)->IsDoubleRegister() || |
3035 __ SetCallCDoubleArguments(ToDoubleRegister(left), | 3031 ToDoubleRegister(instr->InputAt(1)).is(f4)); |
3036 ToDoubleRegister(right)); | 3032 ASSERT(!instr->InputAt(1)->IsRegister() || |
3037 __ CallCFunction( | 3033 ToRegister(instr->InputAt(1)).is(a2)); |
3038 ExternalReference::power_double_double_function(isolate()), 0, 2); | 3034 ASSERT(ToDoubleRegister(instr->InputAt(0)).is(f2)); |
| 3035 ASSERT(ToDoubleRegister(instr->result()).is(f0)); |
| 3036 |
| 3037 if (exponent_type.IsTagged()) { |
| 3038 Label no_deopt; |
| 3039 __ JumpIfSmi(a2, &no_deopt); |
| 3040 __ lw(t3, FieldMemOperand(a2, HeapObject::kMapOffset)); |
| 3041 DeoptimizeIf(ne, instr->environment(), t3, Operand(at)); |
| 3042 __ bind(&no_deopt); |
| 3043 MathPowStub stub(MathPowStub::TAGGED); |
| 3044 __ CallStub(&stub); |
3039 } else if (exponent_type.IsInteger32()) { | 3045 } else if (exponent_type.IsInteger32()) { |
3040 ASSERT(ToRegister(right).is(a0)); | 3046 MathPowStub stub(MathPowStub::INTEGER); |
3041 // Prepare arguments and call C function. | 3047 __ CallStub(&stub); |
3042 __ PrepareCallCFunction(1, 1, scratch); | |
3043 __ SetCallCDoubleArguments(ToDoubleRegister(left), ToRegister(right)); | |
3044 __ CallCFunction( | |
3045 ExternalReference::power_double_int_function(isolate()), 1, 1); | |
3046 } else { | 3048 } else { |
3047 ASSERT(exponent_type.IsTagged()); | 3049 ASSERT(exponent_type.IsDouble()); |
3048 ASSERT(instr->hydrogen()->left()->representation().IsDouble()); | 3050 MathPowStub stub(MathPowStub::DOUBLE); |
3049 | 3051 __ CallStub(&stub); |
3050 Register right_reg = ToRegister(right); | |
3051 | |
3052 // Check for smi on the right hand side. | |
3053 Label non_smi, call; | |
3054 __ JumpIfNotSmi(right_reg, &non_smi); | |
3055 | |
3056 // Untag smi and convert it to a double. | |
3057 __ SmiUntag(right_reg); | |
3058 FPURegister single_scratch = double_scratch0(); | |
3059 __ mtc1(right_reg, single_scratch); | |
3060 __ cvt_d_w(result_reg, single_scratch); | |
3061 __ Branch(&call); | |
3062 | |
3063 // Heap number map check. | |
3064 __ bind(&non_smi); | |
3065 __ lw(scratch, FieldMemOperand(right_reg, HeapObject::kMapOffset)); | |
3066 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | |
3067 DeoptimizeIf(ne, instr->environment(), scratch, Operand(at)); | |
3068 __ ldc1(result_reg, FieldMemOperand(right_reg, HeapNumber::kValueOffset)); | |
3069 | |
3070 // Prepare arguments and call C function. | |
3071 __ bind(&call); | |
3072 __ PrepareCallCFunction(0, 2, scratch); | |
3073 __ SetCallCDoubleArguments(ToDoubleRegister(left), result_reg); | |
3074 __ CallCFunction( | |
3075 ExternalReference::power_double_double_function(isolate()), 0, 2); | |
3076 } | 3052 } |
3077 // Store the result in the result register. | |
3078 __ GetCFunctionDoubleResult(result_reg); | |
3079 } | 3053 } |
3080 | 3054 |
3081 | 3055 |
3082 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { | 3056 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { |
3083 ASSERT(ToDoubleRegister(instr->result()).is(f4)); | 3057 ASSERT(ToDoubleRegister(instr->result()).is(f4)); |
3084 TranscendentalCacheStub stub(TranscendentalCache::LOG, | 3058 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
3085 TranscendentalCacheStub::UNTAGGED); | 3059 TranscendentalCacheStub::UNTAGGED); |
3086 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 3060 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
3087 } | 3061 } |
3088 | 3062 |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4676 ASSERT(!environment->HasBeenRegistered()); | 4650 ASSERT(!environment->HasBeenRegistered()); |
4677 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4651 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4678 ASSERT(osr_pc_offset_ == -1); | 4652 ASSERT(osr_pc_offset_ == -1); |
4679 osr_pc_offset_ = masm()->pc_offset(); | 4653 osr_pc_offset_ = masm()->pc_offset(); |
4680 } | 4654 } |
4681 | 4655 |
4682 | 4656 |
4683 #undef __ | 4657 #undef __ |
4684 | 4658 |
4685 } } // namespace v8::internal | 4659 } } // namespace v8::internal |
OLD | NEW |