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), RelocInfo::NONE64); | 962 __ movq(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), RelocInfo::NONE64); | 972 __ movq(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), RelocInfo::NONE64); | 1004 __ movq(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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); | 3023 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); |
3024 // Set up frame. | 3024 // Set up frame. |
3025 __ push(rbp); | 3025 __ push(rbp); |
3026 __ movq(rbp, rsp); | 3026 __ movq(rbp, rsp); |
3027 | 3027 |
3028 // Push the stack frame type marker twice. | 3028 // Push the stack frame type marker twice. |
3029 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 3029 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
3030 // Scratch register is neither callee-save, nor an argument register on any | 3030 // Scratch register is neither callee-save, nor an argument register on any |
3031 // platform. It's free to use at this point. | 3031 // platform. It's free to use at this point. |
3032 // Cannot use smi-register for loading yet. | 3032 // Cannot use smi-register for loading yet. |
3033 __ movq(kScratchRegister, | 3033 __ movq(kScratchRegister, Smi::FromInt(marker), RelocInfo::NONE64); |
3034 reinterpret_cast<uint64_t>(Smi::FromInt(marker)), | |
3035 RelocInfo::NONE64); | |
3036 __ push(kScratchRegister); // context slot | 3034 __ push(kScratchRegister); // context slot |
3037 __ push(kScratchRegister); // function slot | 3035 __ push(kScratchRegister); // function slot |
3038 // Save callee-saved registers (X64/Win64 calling conventions). | 3036 // Save callee-saved registers (X64/Win64 calling conventions). |
3039 __ push(r12); | 3037 __ push(r12); |
3040 __ push(r13); | 3038 __ push(r13); |
3041 __ push(r14); | 3039 __ push(r14); |
3042 __ push(r15); | 3040 __ push(r15); |
3043 #ifdef _WIN64 | 3041 #ifdef _WIN64 |
3044 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 3042 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
3045 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 3043 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
(...skipping 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5838 __ bind(&fast_elements_case); | 5836 __ bind(&fast_elements_case); |
5839 GenerateCase(masm, FAST_ELEMENTS); | 5837 GenerateCase(masm, FAST_ELEMENTS); |
5840 } | 5838 } |
5841 | 5839 |
5842 | 5840 |
5843 #undef __ | 5841 #undef __ |
5844 | 5842 |
5845 } } // namespace v8::internal | 5843 } } // namespace v8::internal |
5846 | 5844 |
5847 #endif // V8_TARGET_ARCH_X64 | 5845 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |