OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/x64/codegen-x64.h" | 5 #include "src/x64/codegen-x64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #define __ masm. | 32 #define __ masm. |
33 | 33 |
34 | 34 |
35 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { | 35 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { |
36 size_t actual_size; | 36 size_t actual_size; |
37 byte* buffer = | 37 byte* buffer = |
38 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 38 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
39 if (buffer == nullptr) return nullptr; | 39 if (buffer == nullptr) return nullptr; |
40 ExternalReference::InitializeMathExpData(); | 40 ExternalReference::InitializeMathExpData(); |
41 | 41 |
42 MacroAssembler masm(nullptr, buffer, static_cast<int>(actual_size)); | 42 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), false); |
43 // xmm0: raw double input. | 43 // xmm0: raw double input. |
44 XMMRegister input = xmm0; | 44 XMMRegister input = xmm0; |
45 XMMRegister result = xmm1; | 45 XMMRegister result = xmm1; |
46 __ pushq(rax); | 46 __ pushq(rax); |
47 __ pushq(rbx); | 47 __ pushq(rbx); |
48 | 48 |
49 MathExpGenerator::EmitMathExp(&masm, input, result, xmm2, rax, rbx); | 49 MathExpGenerator::EmitMathExp(&masm, input, result, xmm2, rax, rbx); |
50 | 50 |
51 __ popq(rbx); | 51 __ popq(rbx); |
52 __ popq(rax); | 52 __ popq(rax); |
(...skipping 10 matching lines...) Expand all Loading... |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 UnaryMathFunction CreateSqrtFunction() { | 66 UnaryMathFunction CreateSqrtFunction() { |
67 size_t actual_size; | 67 size_t actual_size; |
68 // Allocate buffer in executable space. | 68 // Allocate buffer in executable space. |
69 byte* buffer = | 69 byte* buffer = |
70 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 70 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
71 if (buffer == NULL) return &std::sqrt; | 71 if (buffer == NULL) return &std::sqrt; |
72 | 72 |
73 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 73 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), false); |
74 // xmm0: raw double input. | 74 // xmm0: raw double input. |
75 // Move double input into registers. | 75 // Move double input into registers. |
76 __ Sqrtsd(xmm0, xmm0); | 76 __ Sqrtsd(xmm0, xmm0); |
77 __ Ret(); | 77 __ Ret(); |
78 | 78 |
79 CodeDesc desc; | 79 CodeDesc desc; |
80 masm.GetCode(&desc); | 80 masm.GetCode(&desc); |
81 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 81 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
82 | 82 |
83 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); | 83 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); |
84 base::OS::ProtectCode(buffer, actual_size); | 84 base::OS::ProtectCode(buffer, actual_size); |
85 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 85 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 #ifdef _WIN64 | 89 #ifdef _WIN64 |
90 typedef double (*ModuloFunction)(double, double); | 90 typedef double (*ModuloFunction)(double, double); |
91 // Define custom fmod implementation. | 91 // Define custom fmod implementation. |
92 ModuloFunction CreateModuloFunction() { | 92 ModuloFunction CreateModuloFunction() { |
93 size_t actual_size; | 93 size_t actual_size; |
94 byte* buffer = static_cast<byte*>( | 94 byte* buffer = static_cast<byte*>( |
95 base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); | 95 base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); |
96 CHECK(buffer); | 96 CHECK(buffer); |
97 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 97 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), false); |
98 // Generated code is put into a fixed, unmovable, buffer, and not into | 98 // Generated code is put into a fixed, unmovable, buffer, and not into |
99 // the V8 heap. We can't, and don't, refer to any relocatable addresses | 99 // the V8 heap. We can't, and don't, refer to any relocatable addresses |
100 // (e.g. the JavaScript nan-object). | 100 // (e.g. the JavaScript nan-object). |
101 | 101 |
102 // Windows 64 ABI passes double arguments in xmm0, xmm1 and | 102 // Windows 64 ABI passes double arguments in xmm0, xmm1 and |
103 // returns result in xmm0. | 103 // returns result in xmm0. |
104 // Argument backing space is allocated on the stack above | 104 // Argument backing space is allocated on the stack above |
105 // the return address. | 105 // the return address. |
106 | 106 |
107 // Compute x mod y. | 107 // Compute x mod y. |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 719 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
720 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 720 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
721 } | 721 } |
722 } | 722 } |
723 | 723 |
724 | 724 |
725 } // namespace internal | 725 } // namespace internal |
726 } // namespace v8 | 726 } // namespace v8 |
727 | 727 |
728 #endif // V8_TARGET_ARCH_X64 | 728 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |