| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // The return value is expected to be in xmm0. | 84 // The return value is expected to be in xmm0. |
| 85 __ fstp_d(Operand(rsp, 0)); | 85 __ fstp_d(Operand(rsp, 0)); |
| 86 __ pop(rbx); | 86 __ pop(rbx); |
| 87 __ movq(xmm0, rbx); | 87 __ movq(xmm0, rbx); |
| 88 __ pop(rdi); | 88 __ pop(rdi); |
| 89 __ pop(rbx); | 89 __ pop(rbx); |
| 90 __ Ret(); | 90 __ Ret(); |
| 91 | 91 |
| 92 CodeDesc desc; | 92 CodeDesc desc; |
| 93 masm.GetCode(&desc); | 93 masm.GetCode(&desc); |
| 94 ASSERT(desc.reloc_size == 0); | 94 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
| 95 | 95 |
| 96 CPU::FlushICache(buffer, actual_size); | 96 CPU::FlushICache(buffer, actual_size); |
| 97 OS::ProtectCode(buffer, actual_size); | 97 OS::ProtectCode(buffer, actual_size); |
| 98 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 98 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 UnaryMathFunction CreateExpFunction() { | 102 UnaryMathFunction CreateExpFunction() { |
| 103 if (!FLAG_fast_math) return &exp; | 103 if (!FLAG_fast_math) return &exp; |
| 104 size_t actual_size; | 104 size_t actual_size; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 | 115 |
| 116 MathExpGenerator::EmitMathExp(&masm, input, result, xmm2, rax, rbx); | 116 MathExpGenerator::EmitMathExp(&masm, input, result, xmm2, rax, rbx); |
| 117 | 117 |
| 118 __ pop(rbx); | 118 __ pop(rbx); |
| 119 __ pop(rax); | 119 __ pop(rax); |
| 120 __ movsd(xmm0, result); | 120 __ movsd(xmm0, result); |
| 121 __ Ret(); | 121 __ Ret(); |
| 122 | 122 |
| 123 CodeDesc desc; | 123 CodeDesc desc; |
| 124 masm.GetCode(&desc); | 124 masm.GetCode(&desc); |
| 125 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
| 125 | 126 |
| 126 CPU::FlushICache(buffer, actual_size); | 127 CPU::FlushICache(buffer, actual_size); |
| 127 OS::ProtectCode(buffer, actual_size); | 128 OS::ProtectCode(buffer, actual_size); |
| 128 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 129 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 129 } | 130 } |
| 130 | 131 |
| 131 | 132 |
| 132 UnaryMathFunction CreateSqrtFunction() { | 133 UnaryMathFunction CreateSqrtFunction() { |
| 133 size_t actual_size; | 134 size_t actual_size; |
| 134 // Allocate buffer in executable space. | 135 // Allocate buffer in executable space. |
| 135 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | 136 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
| 136 &actual_size, | 137 &actual_size, |
| 137 true)); | 138 true)); |
| 138 if (buffer == NULL) return &sqrt; | 139 if (buffer == NULL) return &sqrt; |
| 139 | 140 |
| 140 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 141 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
| 141 // xmm0: raw double input. | 142 // xmm0: raw double input. |
| 142 // Move double input into registers. | 143 // Move double input into registers. |
| 143 __ sqrtsd(xmm0, xmm0); | 144 __ sqrtsd(xmm0, xmm0); |
| 144 __ Ret(); | 145 __ Ret(); |
| 145 | 146 |
| 146 CodeDesc desc; | 147 CodeDesc desc; |
| 147 masm.GetCode(&desc); | 148 masm.GetCode(&desc); |
| 148 ASSERT(desc.reloc_size == 0); | 149 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
| 149 | 150 |
| 150 CPU::FlushICache(buffer, actual_size); | 151 CPU::FlushICache(buffer, actual_size); |
| 151 OS::ProtectCode(buffer, actual_size); | 152 OS::ProtectCode(buffer, actual_size); |
| 152 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 153 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 153 } | 154 } |
| 154 | 155 |
| 155 | 156 |
| 156 #ifdef _WIN64 | 157 #ifdef _WIN64 |
| 157 typedef double (*ModuloFunction)(double, double); | 158 typedef double (*ModuloFunction)(double, double); |
| 158 // Define custom fmod implementation. | 159 // Define custom fmod implementation. |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 CodePatcher patcher(sequence, young_length); | 776 CodePatcher patcher(sequence, young_length); |
| 776 patcher.masm()->call(stub->instruction_start()); | 777 patcher.masm()->call(stub->instruction_start()); |
| 777 patcher.masm()->nop(); | 778 patcher.masm()->nop(); |
| 778 } | 779 } |
| 779 } | 780 } |
| 780 | 781 |
| 781 | 782 |
| 782 } } // namespace v8::internal | 783 } } // namespace v8::internal |
| 783 | 784 |
| 784 #endif // V8_TARGET_ARCH_X64 | 785 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |