| 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 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2927 } | 2927 } |
| 2928 | 2928 |
| 2929 | 2929 |
| 2930 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { | 2930 void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) { |
| 2931 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2931 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 2932 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2932 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
| 2933 __ sqrtsd(input_reg, input_reg); | 2933 __ sqrtsd(input_reg, input_reg); |
| 2934 } | 2934 } |
| 2935 | 2935 |
| 2936 | 2936 |
| 2937 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { | 2937 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { |
| 2938 XMMRegister xmm_scratch = xmm0; | 2938 XMMRegister xmm_scratch = xmm0; |
| 2939 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 2939 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 2940 Register scratch = ToRegister(instr->temp()); |
| 2940 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2941 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
| 2941 | 2942 |
| 2942 Label return_infinity, done; | 2943 // Note that according to ECMA-262 15.8.2.13: |
| 2943 // Check base for +/- infinity. | 2944 // Math.pow(-Infinity, 0.5) == Infinity |
| 2944 __ push(ecx); // TODO(1848): reserve this register. | 2945 // Math.sqrt(-Infinity) == NaN |
| 2945 __ mov(ecx, factory()->infinity_value()); | 2946 Label done, sqrt; |
| 2946 __ ucomisd(input_reg, FieldOperand(ecx, HeapNumber::kValueOffset)); | 2947 // Check base for -Infinity. According to IEEE-754, single-precision |
| 2947 __ j(equal, &return_infinity, Label::kNear); | 2948 // -Infinity has the highest 9 bits set and the lowest 23 bits cleared. |
| 2948 __ xorps(xmm_scratch, xmm_scratch); | 2949 __ mov(scratch, 0xFF800000); |
| 2949 __ subsd(xmm_scratch, input_reg); | 2950 __ movd(xmm_scratch, scratch); |
| 2950 __ ucomisd(xmm_scratch, FieldOperand(ecx, HeapNumber::kValueOffset)); | 2951 __ cvtss2sd(xmm_scratch, xmm_scratch); |
| 2951 __ j(equal, &return_infinity, Label::kNear); | 2952 __ ucomisd(input_reg, xmm_scratch); |
| 2953 __ j(not_equal, &sqrt, Label::kNear); |
| 2954 // If input is -Infinity, return Infinity. |
| 2955 __ xorps(input_reg, input_reg); |
| 2956 __ subsd(input_reg, xmm_scratch); |
| 2957 __ jmp(&done, Label::kNear); |
| 2952 | 2958 |
| 2953 __ pop(ecx); | 2959 // Square root. |
| 2960 __ bind(&sqrt); |
| 2954 __ xorps(xmm_scratch, xmm_scratch); | 2961 __ xorps(xmm_scratch, xmm_scratch); |
| 2955 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. | 2962 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. |
| 2956 __ sqrtsd(input_reg, input_reg); | 2963 __ sqrtsd(input_reg, input_reg); |
| 2957 __ jmp(&done, Label::kNear); | |
| 2958 | |
| 2959 __ bind(&return_infinity); | |
| 2960 __ movdbl(input_reg, FieldOperand(ecx, HeapNumber::kValueOffset)); | |
| 2961 __ pop(ecx); | |
| 2962 __ bind(&done); | 2964 __ bind(&done); |
| 2963 } | 2965 } |
| 2964 | 2966 |
| 2965 | 2967 |
| 2966 void LCodeGen::DoPower(LPower* instr) { | 2968 void LCodeGen::DoPower(LPower* instr) { |
| 2967 Representation exponent_type = instr->hydrogen()->right()->representation(); | 2969 Representation exponent_type = instr->hydrogen()->right()->representation(); |
| 2968 // Having marked this as a call, we can use any registers. | 2970 // Having marked this as a call, we can use any registers. |
| 2969 // Just make sure that the input registers are the expected ones. | 2971 // Just make sure that the input registers are the expected ones. |
| 2970 ASSERT(!instr->InputAt(1)->IsDoubleRegister() || | 2972 ASSERT(!instr->InputAt(1)->IsDoubleRegister() || |
| 2971 ToDoubleRegister(instr->InputAt(1)).is(xmm2)); | 2973 ToDoubleRegister(instr->InputAt(1)).is(xmm2)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 break; | 3057 break; |
| 3056 case kMathFloor: | 3058 case kMathFloor: |
| 3057 DoMathFloor(instr); | 3059 DoMathFloor(instr); |
| 3058 break; | 3060 break; |
| 3059 case kMathRound: | 3061 case kMathRound: |
| 3060 DoMathRound(instr); | 3062 DoMathRound(instr); |
| 3061 break; | 3063 break; |
| 3062 case kMathSqrt: | 3064 case kMathSqrt: |
| 3063 DoMathSqrt(instr); | 3065 DoMathSqrt(instr); |
| 3064 break; | 3066 break; |
| 3065 case kMathPowHalf: | |
| 3066 DoMathPowHalf(instr); | |
| 3067 break; | |
| 3068 case kMathCos: | 3067 case kMathCos: |
| 3069 DoMathCos(instr); | 3068 DoMathCos(instr); |
| 3070 break; | 3069 break; |
| 3071 case kMathSin: | 3070 case kMathSin: |
| 3072 DoMathSin(instr); | 3071 DoMathSin(instr); |
| 3073 break; | 3072 break; |
| 3074 case kMathTan: | 3073 case kMathTan: |
| 3075 DoMathTan(instr); | 3074 DoMathTan(instr); |
| 3076 break; | 3075 break; |
| 3077 case kMathLog: | 3076 case kMathLog: |
| (...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4634 this, pointers, Safepoint::kLazyDeopt); | 4633 this, pointers, Safepoint::kLazyDeopt); |
| 4635 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4634 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
| 4636 } | 4635 } |
| 4637 | 4636 |
| 4638 | 4637 |
| 4639 #undef __ | 4638 #undef __ |
| 4640 | 4639 |
| 4641 } } // namespace v8::internal | 4640 } } // namespace v8::internal |
| 4642 | 4641 |
| 4643 #endif // V8_TARGET_ARCH_IA32 | 4642 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |