| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 Label valid_result; | 103 Label valid_result; |
| 104 Label return_result; | 104 Label return_result; |
| 105 // If Invalid Operand or Zero Division exceptions are set, | 105 // If Invalid Operand or Zero Division exceptions are set, |
| 106 // return NaN. | 106 // return NaN. |
| 107 __ testb(rax, Immediate(5)); | 107 __ testb(rax, Immediate(5)); |
| 108 __ j(zero, &valid_result); | 108 __ j(zero, &valid_result); |
| 109 __ fstp(0); // Drop result in st(0). | 109 __ fstp(0); // Drop result in st(0). |
| 110 int64_t kNaNValue = V8_INT64_C(0x7ff8000000000000); | 110 int64_t kNaNValue = V8_INT64_C(0x7ff8000000000000); |
| 111 __ movq(rcx, kNaNValue, RelocInfo::NONE); | 111 __ movq(rcx, kNaNValue, RelocInfo::NONE); |
| 112 __ movq(Operand(rsp, kPointerSize), rcx); | 112 __ movq(Operand(rsp, kPointerSize), rcx); |
| 113 __ movsd(xmm0, Operand(rsp, kPointerSize)); | 113 __ LoadDbl(xmm0, Operand(rsp, kPointerSize)); |
| 114 __ jmp(&return_result); | 114 __ jmp(&return_result); |
| 115 | 115 |
| 116 // If result is valid, return that. | 116 // If result is valid, return that. |
| 117 __ bind(&valid_result); | 117 __ bind(&valid_result); |
| 118 __ fstp_d(Operand(rsp, kPointerSize)); | 118 __ fstp_d(Operand(rsp, kPointerSize)); |
| 119 __ movsd(xmm0, Operand(rsp, kPointerSize)); | 119 __ LoadDbl(xmm0, Operand(rsp, kPointerSize)); |
| 120 | 120 |
| 121 // Clean up FPU stack and exceptions and return xmm0 | 121 // Clean up FPU stack and exceptions and return xmm0 |
| 122 __ bind(&return_result); | 122 __ bind(&return_result); |
| 123 __ fstp(0); // Unload y. | 123 __ fstp(0); // Unload y. |
| 124 | 124 |
| 125 Label clear_exceptions; | 125 Label clear_exceptions; |
| 126 __ testb(rax, Immediate(0x3f /* Any Exception*/)); | 126 __ testb(rax, Immediate(0x3f /* Any Exception*/)); |
| 127 __ j(not_zero, &clear_exceptions); | 127 __ j(not_zero, &clear_exceptions); |
| 128 __ ret(0); | 128 __ ret(0); |
| 129 __ bind(&clear_exceptions); | 129 __ bind(&clear_exceptions); |
| 130 __ fnclex(); | 130 __ fnclex(); |
| 131 __ ret(0); | 131 __ ret(0); |
| 132 | 132 |
| 133 CodeDesc desc; | 133 CodeDesc desc; |
| 134 masm.GetCode(&desc); | 134 masm.GetCode(&desc); |
| 135 // Call the function from C++ through this pointer. | 135 // Call the function from C++ through this pointer. |
| 136 return FUNCTION_CAST<ModuloFunction>(buffer); | 136 return FUNCTION_CAST<ModuloFunction>(buffer); |
| 137 } | 137 } |
| 138 | 138 |
| 139 #endif | 139 #endif |
| 140 | 140 |
| 141 | 141 |
| 142 #undef __ | 142 #undef __ |
| 143 | 143 |
| 144 } } // namespace v8::internal | 144 } } // namespace v8::internal |
| 145 | 145 |
| 146 #endif // V8_TARGET_ARCH_X64 | 146 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |