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 2932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 // Note that according to ECMA-262 15.8.2.13: | 2943 // Note that according to ECMA-262 15.8.2.13: |
2944 // Math.pow(-Infinity, 0.5) == Infinity | 2944 // Math.pow(-Infinity, 0.5) == Infinity |
2945 // Math.sqrt(-Infinity) == NaN | 2945 // Math.sqrt(-Infinity) == NaN |
2946 Label done, sqrt; | 2946 Label done, sqrt; |
2947 // Check base for -Infinity. According to IEEE-754, single-precision | 2947 // Check base for -Infinity. According to IEEE-754, single-precision |
2948 // -Infinity has the highest 9 bits set and the lowest 23 bits cleared. | 2948 // -Infinity has the highest 9 bits set and the lowest 23 bits cleared. |
2949 __ mov(scratch, 0xFF800000); | 2949 __ mov(scratch, 0xFF800000); |
2950 __ movd(xmm_scratch, scratch); | 2950 __ movd(xmm_scratch, scratch); |
2951 __ cvtss2sd(xmm_scratch, xmm_scratch); | 2951 __ cvtss2sd(xmm_scratch, xmm_scratch); |
2952 __ ucomisd(input_reg, xmm_scratch); | 2952 __ ucomisd(input_reg, xmm_scratch); |
| 2953 // Comparing -Infinity with NaN results in "unordered", which sets the |
| 2954 // zero flag as if both were equal. However, it also sets the carry flag. |
2953 __ j(not_equal, &sqrt, Label::kNear); | 2955 __ j(not_equal, &sqrt, Label::kNear); |
| 2956 __ j(carry, &sqrt, Label::kNear); |
2954 // If input is -Infinity, return Infinity. | 2957 // If input is -Infinity, return Infinity. |
2955 __ xorps(input_reg, input_reg); | 2958 __ xorps(input_reg, input_reg); |
2956 __ subsd(input_reg, xmm_scratch); | 2959 __ subsd(input_reg, xmm_scratch); |
2957 __ jmp(&done, Label::kNear); | 2960 __ jmp(&done, Label::kNear); |
2958 | 2961 |
2959 // Square root. | 2962 // Square root. |
2960 __ bind(&sqrt); | 2963 __ bind(&sqrt); |
2961 __ xorps(xmm_scratch, xmm_scratch); | 2964 __ xorps(xmm_scratch, xmm_scratch); |
2962 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. | 2965 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. |
2963 __ sqrtsd(input_reg, input_reg); | 2966 __ sqrtsd(input_reg, input_reg); |
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4633 this, pointers, Safepoint::kLazyDeopt); | 4636 this, pointers, Safepoint::kLazyDeopt); |
4634 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4637 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4635 } | 4638 } |
4636 | 4639 |
4637 | 4640 |
4638 #undef __ | 4641 #undef __ |
4639 | 4642 |
4640 } } // namespace v8::internal | 4643 } } // namespace v8::internal |
4641 | 4644 |
4642 #endif // V8_TARGET_ARCH_IA32 | 4645 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |