| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 __ cmpl(exponent, Immediate(0x80000000u)); | 952 __ cmpl(exponent, Immediate(0x80000000u)); |
| 953 __ j(equal, &call_runtime); | 953 __ j(equal, &call_runtime); |
| 954 | 954 |
| 955 if (exponent_type_ == ON_STACK) { | 955 if (exponent_type_ == ON_STACK) { |
| 956 // Detect square root case. Crankshaft detects constant +/-0.5 at | 956 // Detect square root case. Crankshaft detects constant +/-0.5 at |
| 957 // compile time and uses DoMathPowHalf instead. We then skip this check | 957 // compile time and uses DoMathPowHalf instead. We then skip this check |
| 958 // for non-constant cases of +/-0.5 as these hardly occur. | 958 // for non-constant cases of +/-0.5 as these hardly occur. |
| 959 Label continue_sqrt, continue_rsqrt, not_plus_half; | 959 Label continue_sqrt, continue_rsqrt, not_plus_half; |
| 960 // Test for 0.5. | 960 // Test for 0.5. |
| 961 // Load double_scratch with 0.5. | 961 // Load double_scratch with 0.5. |
| 962 __ movq(scratch, V8_UINT64_C(0x3FE0000000000000)); | 962 __ MoveInteger64(scratch, V8_UINT64_C(0x3FE0000000000000)); |
| 963 __ movq(double_scratch, scratch); | 963 __ movq(double_scratch, scratch); |
| 964 // Already ruled out NaNs for exponent. | 964 // Already ruled out NaNs for exponent. |
| 965 __ ucomisd(double_scratch, double_exponent); | 965 __ ucomisd(double_scratch, double_exponent); |
| 966 __ j(not_equal, ¬_plus_half, Label::kNear); | 966 __ j(not_equal, ¬_plus_half, Label::kNear); |
| 967 | 967 |
| 968 // Calculates square root of base. Check for the special case of | 968 // Calculates square root of base. Check for the special case of |
| 969 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). | 969 // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13). |
| 970 // According to IEEE-754, double-precision -Infinity has the highest | 970 // According to IEEE-754, double-precision -Infinity has the highest |
| 971 // 12 bits set and the lowest 52 bits cleared. | 971 // 12 bits set and the lowest 52 bits cleared. |
| 972 __ movq(scratch, V8_UINT64_C(0xFFF0000000000000)); | 972 __ MoveInteger64(scratch, V8_UINT64_C(0xFFF0000000000000)); |
| 973 __ movq(double_scratch, scratch); | 973 __ movq(double_scratch, scratch); |
| 974 __ ucomisd(double_scratch, double_base); | 974 __ ucomisd(double_scratch, double_base); |
| 975 // Comparing -Infinity with NaN results in "unordered", which sets the | 975 // Comparing -Infinity with NaN results in "unordered", which sets the |
| 976 // zero flag as if both were equal. However, it also sets the carry flag. | 976 // zero flag as if both were equal. However, it also sets the carry flag. |
| 977 __ j(not_equal, &continue_sqrt, Label::kNear); | 977 __ j(not_equal, &continue_sqrt, Label::kNear); |
| 978 __ j(carry, &continue_sqrt, Label::kNear); | 978 __ j(carry, &continue_sqrt, Label::kNear); |
| 979 | 979 |
| 980 // Set result to Infinity in the special case. | 980 // Set result to Infinity in the special case. |
| 981 __ xorps(double_result, double_result); | 981 __ xorps(double_result, double_result); |
| 982 __ subsd(double_result, double_scratch); | 982 __ subsd(double_result, double_scratch); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 994 // Load double_scratch with -0.5 by substracting 1. | 994 // Load double_scratch with -0.5 by substracting 1. |
| 995 __ subsd(double_scratch, double_result); | 995 __ subsd(double_scratch, double_result); |
| 996 // Already ruled out NaNs for exponent. | 996 // Already ruled out NaNs for exponent. |
| 997 __ ucomisd(double_scratch, double_exponent); | 997 __ ucomisd(double_scratch, double_exponent); |
| 998 __ j(not_equal, &fast_power, Label::kNear); | 998 __ j(not_equal, &fast_power, Label::kNear); |
| 999 | 999 |
| 1000 // Calculates reciprocal of square root of base. Check for the special | 1000 // Calculates reciprocal of square root of base. Check for the special |
| 1001 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). | 1001 // case of Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13). |
| 1002 // According to IEEE-754, double-precision -Infinity has the highest | 1002 // According to IEEE-754, double-precision -Infinity has the highest |
| 1003 // 12 bits set and the lowest 52 bits cleared. | 1003 // 12 bits set and the lowest 52 bits cleared. |
| 1004 __ movq(scratch, V8_UINT64_C(0xFFF0000000000000)); | 1004 __ MoveInteger64(scratch, V8_UINT64_C(0xFFF0000000000000)); |
| 1005 __ movq(double_scratch, scratch); | 1005 __ movq(double_scratch, scratch); |
| 1006 __ ucomisd(double_scratch, double_base); | 1006 __ ucomisd(double_scratch, double_base); |
| 1007 // Comparing -Infinity with NaN results in "unordered", which sets the | 1007 // Comparing -Infinity with NaN results in "unordered", which sets the |
| 1008 // zero flag as if both were equal. However, it also sets the carry flag. | 1008 // zero flag as if both were equal. However, it also sets the carry flag. |
| 1009 __ j(not_equal, &continue_rsqrt, Label::kNear); | 1009 __ j(not_equal, &continue_rsqrt, Label::kNear); |
| 1010 __ j(carry, &continue_rsqrt, Label::kNear); | 1010 __ j(carry, &continue_rsqrt, Label::kNear); |
| 1011 | 1011 |
| 1012 // Set result to 0 in the special case. | 1012 // Set result to 0 in the special case. |
| 1013 __ xorps(double_result, double_result); | 1013 __ xorps(double_result, double_result); |
| 1014 __ jmp(&done); | 1014 __ jmp(&done); |
| (...skipping 4798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5813 __ bind(&fast_elements_case); | 5813 __ bind(&fast_elements_case); |
| 5814 GenerateCase(masm, FAST_ELEMENTS); | 5814 GenerateCase(masm, FAST_ELEMENTS); |
| 5815 } | 5815 } |
| 5816 | 5816 |
| 5817 | 5817 |
| 5818 #undef __ | 5818 #undef __ |
| 5819 | 5819 |
| 5820 } } // namespace v8::internal | 5820 } } // namespace v8::internal |
| 5821 | 5821 |
| 5822 #endif // V8_TARGET_ARCH_X64 | 5822 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |