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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 CodeDesc desc; | 57 CodeDesc desc; |
58 masm.GetCode(&desc); | 58 masm.GetCode(&desc); |
59 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 59 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
60 | 60 |
61 Assembler::FlushICache(isolate, buffer, actual_size); | 61 Assembler::FlushICache(isolate, buffer, actual_size); |
62 base::OS::ProtectCode(buffer, actual_size); | 62 base::OS::ProtectCode(buffer, actual_size); |
63 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); | 63 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 UnaryMathFunction CreateSqrtFunction() { | 67 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { |
68 size_t actual_size; | 68 size_t actual_size; |
69 // Allocate buffer in executable space. | 69 // Allocate buffer in executable space. |
70 byte* buffer = | 70 byte* buffer = |
71 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 71 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
72 if (buffer == NULL) return &std::sqrt; | 72 if (buffer == nullptr) return nullptr; |
73 | 73 |
74 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), | 74 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), |
75 CodeObjectRequired::kNo); | 75 CodeObjectRequired::kNo); |
76 // xmm0: raw double input. | 76 // xmm0: raw double input. |
77 // Move double input into registers. | 77 // Move double input into registers. |
78 __ Sqrtsd(xmm0, xmm0); | 78 __ Sqrtsd(xmm0, xmm0); |
79 __ Ret(); | 79 __ Ret(); |
80 | 80 |
81 CodeDesc desc; | 81 CodeDesc desc; |
82 masm.GetCode(&desc); | 82 masm.GetCode(&desc); |
83 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 83 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
84 | 84 |
85 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); | 85 Assembler::FlushICache(isolate, buffer, actual_size); |
86 base::OS::ProtectCode(buffer, actual_size); | 86 base::OS::ProtectCode(buffer, actual_size); |
87 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 87 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 #ifdef _WIN64 | 91 #ifdef _WIN64 |
92 typedef double (*ModuloFunction)(double, double); | 92 typedef double (*ModuloFunction)(double, double); |
93 // Define custom fmod implementation. | 93 // Define custom fmod implementation. |
94 ModuloFunction CreateModuloFunction() { | 94 ModuloFunction CreateModuloFunction() { |
95 size_t actual_size; | 95 size_t actual_size; |
96 byte* buffer = static_cast<byte*>( | 96 byte* buffer = static_cast<byte*>( |
97 base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); | 97 base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 722 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
723 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 723 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
724 } | 724 } |
725 } | 725 } |
726 | 726 |
727 | 727 |
728 } // namespace internal | 728 } // namespace internal |
729 } // namespace v8 | 729 } // namespace v8 |
730 | 730 |
731 #endif // V8_TARGET_ARCH_X64 | 731 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |