diff options
Diffstat (limited to 'deps/v8/src/x64/codegen-x64.cc')
-rw-r--r-- | deps/v8/src/x64/codegen-x64.cc | 121 |
1 files changed, 17 insertions, 104 deletions
diff --git a/deps/v8/src/x64/codegen-x64.cc b/deps/v8/src/x64/codegen-x64.cc index 5c297f1a07..81c1a69aa8 100644 --- a/deps/v8/src/x64/codegen-x64.cc +++ b/deps/v8/src/x64/codegen-x64.cc @@ -32,15 +32,15 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { #define __ masm. -UnaryMathFunction CreateExpFunction() { - if (!FLAG_fast_math) return &std::exp; +UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { size_t actual_size; byte* buffer = static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); - if (buffer == NULL) return &std::exp; + if (buffer == nullptr) return nullptr; ExternalReference::InitializeMathExpData(); - MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); + MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), + CodeObjectRequired::kNo); // xmm0: raw double input. XMMRegister input = xmm0; XMMRegister result = xmm1; @@ -58,20 +58,21 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - Assembler::FlushICacheWithoutIsolate(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); - return FUNCTION_CAST<UnaryMathFunction>(buffer); + return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); } -UnaryMathFunction CreateSqrtFunction() { +UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { size_t actual_size; // Allocate buffer in executable space. byte* buffer = static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); - if (buffer == NULL) return &std::sqrt; + if (buffer == nullptr) return nullptr; - MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); + MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), + CodeObjectRequired::kNo); // xmm0: raw double input. // Move double input into registers. __ Sqrtsd(xmm0, xmm0); @@ -81,101 +82,11 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); DCHECK(!RelocInfo::RequiresRelocation(desc)); - Assembler::FlushICacheWithoutIsolate(buffer, actual_size); + Assembler::FlushICache(isolate, buffer, actual_size); base::OS::ProtectCode(buffer, actual_size); - return FUNCTION_CAST<UnaryMathFunction>(buffer); + return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); } - -#ifdef _WIN64 -typedef double (*ModuloFunction)(double, double); -// Define custom fmod implementation. -ModuloFunction CreateModuloFunction() { - size_t actual_size; - byte* buffer = static_cast<byte*>( - base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); - CHECK(buffer); - MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); - // Generated code is put into a fixed, unmovable, buffer, and not into - // the V8 heap. We can't, and don't, refer to any relocatable addresses - // (e.g. the JavaScript nan-object). - - // Windows 64 ABI passes double arguments in xmm0, xmm1 and - // returns result in xmm0. - // Argument backing space is allocated on the stack above - // the return address. - - // Compute x mod y. - // Load y and x (use argument backing store as temporary storage). - __ Movsd(Operand(rsp, kRegisterSize * 2), xmm1); - __ Movsd(Operand(rsp, kRegisterSize), xmm0); - __ fld_d(Operand(rsp, kRegisterSize * 2)); - __ fld_d(Operand(rsp, kRegisterSize)); - - // Clear exception flags before operation. - { - Label no_exceptions; - __ fwait(); - __ fnstsw_ax(); - // Clear if Illegal Operand or Zero Division exceptions are set. - __ testb(rax, Immediate(5)); - __ j(zero, &no_exceptions); - __ fnclex(); - __ bind(&no_exceptions); - } - - // Compute st(0) % st(1) - { - Label partial_remainder_loop; - __ bind(&partial_remainder_loop); - __ fprem(); - __ fwait(); - __ fnstsw_ax(); - __ testl(rax, Immediate(0x400 /* C2 */)); - // If C2 is set, computation only has partial result. Loop to - // continue computation. - __ j(not_zero, &partial_remainder_loop); - } - - Label valid_result; - Label return_result; - // If Invalid Operand or Zero Division exceptions are set, - // return NaN. - __ testb(rax, Immediate(5)); - __ j(zero, &valid_result); - __ fstp(0); // Drop result in st(0). - int64_t kNaNValue = V8_INT64_C(0x7ff8000000000000); - __ movq(rcx, kNaNValue); - __ movq(Operand(rsp, kRegisterSize), rcx); - __ Movsd(xmm0, Operand(rsp, kRegisterSize)); - __ jmp(&return_result); - - // If result is valid, return that. - __ bind(&valid_result); - __ fstp_d(Operand(rsp, kRegisterSize)); - __ Movsd(xmm0, Operand(rsp, kRegisterSize)); - - // Clean up FPU stack and exceptions and return xmm0 - __ bind(&return_result); - __ fstp(0); // Unload y. - - Label clear_exceptions; - __ testb(rax, Immediate(0x3f /* Any Exception*/)); - __ j(not_zero, &clear_exceptions); - __ ret(0); - __ bind(&clear_exceptions); - __ fnclex(); - __ ret(0); - - CodeDesc desc; - masm.GetCode(&desc); - base::OS::ProtectCode(buffer, actual_size); - // Call the function from C++ through this pointer. - return FUNCTION_CAST<ModuloFunction>(buffer); -} - -#endif - #undef __ // ------------------------------------------------------------------------- @@ -642,12 +553,14 @@ void MathExpGenerator::EmitMathExp(MacroAssembler* masm, #undef __ -CodeAgingHelper::CodeAgingHelper() { +CodeAgingHelper::CodeAgingHelper(Isolate* isolate) { + USE(isolate); DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength); // The sequence of instructions that is patched out for aging code is the // following boilerplate stack-building prologue that is found both in // FUNCTION and OPTIMIZED_FUNCTION code: - CodePatcher patcher(young_sequence_.start(), young_sequence_.length()); + CodePatcher patcher(isolate, young_sequence_.start(), + young_sequence_.length()); patcher.masm()->pushq(rbp); patcher.masm()->movp(rbp, rsp); patcher.masm()->Push(rsi); @@ -694,7 +607,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, Assembler::FlushICache(isolate, sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); - CodePatcher patcher(sequence, young_length); + CodePatcher patcher(isolate, sequence, young_length); patcher.masm()->call(stub->instruction_start()); patcher.masm()->Nop( kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength); |