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/mips/codegen-mips.h" | 5 #include "src/mips/codegen-mips.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
11 #include "src/mips/simulator-mips.h" | 11 #include "src/mips/simulator-mips.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 | 16 |
17 #define __ masm. | 17 #define __ masm. |
18 | 18 |
19 | 19 |
20 #if defined(USE_SIMULATOR) | 20 #if defined(USE_SIMULATOR) |
21 byte* fast_exp_mips_machine_code = NULL; | 21 byte* fast_exp_mips_machine_code = nullptr; |
22 double fast_exp_simulator(double x) { | 22 double fast_exp_simulator(double x, Isolate* isolate) { |
23 return Simulator::current(Isolate::Current())->CallFP( | 23 return Simulator::current(isolate)->CallFP(fast_exp_mips_machine_code, x, 0); |
24 fast_exp_mips_machine_code, x, 0); | |
25 } | 24 } |
26 #endif | 25 #endif |
27 | 26 |
28 | 27 |
29 UnaryMathFunction CreateExpFunction() { | 28 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { |
30 if (!FLAG_fast_math) return &std::exp; | |
31 size_t actual_size; | 29 size_t actual_size; |
32 byte* buffer = | 30 byte* buffer = |
33 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 31 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
34 if (buffer == NULL) return &std::exp; | 32 if (buffer == nullptr) return nullptr; |
35 ExternalReference::InitializeMathExpData(); | 33 ExternalReference::InitializeMathExpData(); |
36 | 34 |
37 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 35 MacroAssembler masm(nullptr, buffer, static_cast<int>(actual_size)); |
38 | 36 |
39 { | 37 { |
40 DoubleRegister input = f12; | 38 DoubleRegister input = f12; |
41 DoubleRegister result = f0; | 39 DoubleRegister result = f0; |
42 DoubleRegister double_scratch1 = f4; | 40 DoubleRegister double_scratch1 = f4; |
43 DoubleRegister double_scratch2 = f6; | 41 DoubleRegister double_scratch2 = f6; |
44 Register temp1 = t0; | 42 Register temp1 = t0; |
45 Register temp2 = t1; | 43 Register temp2 = t1; |
46 Register temp3 = t2; | 44 Register temp3 = t2; |
47 | 45 |
48 __ MovFromFloatParameter(input); | 46 __ MovFromFloatParameter(input); |
49 __ Push(temp3, temp2, temp1); | 47 __ Push(temp3, temp2, temp1); |
50 MathExpGenerator::EmitMathExp( | 48 MathExpGenerator::EmitMathExp( |
51 &masm, input, result, double_scratch1, double_scratch2, | 49 &masm, input, result, double_scratch1, double_scratch2, |
52 temp1, temp2, temp3); | 50 temp1, temp2, temp3); |
53 __ Pop(temp3, temp2, temp1); | 51 __ Pop(temp3, temp2, temp1); |
54 __ MovToFloatResult(result); | 52 __ MovToFloatResult(result); |
55 __ Ret(); | 53 __ Ret(); |
56 } | 54 } |
57 | 55 |
58 CodeDesc desc; | 56 CodeDesc desc; |
59 masm.GetCode(&desc); | 57 masm.GetCode(&desc); |
60 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 58 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
61 | 59 |
62 CpuFeatures::FlushICache(buffer, actual_size); | 60 CpuFeatures::FlushICache(buffer, actual_size); |
63 base::OS::ProtectCode(buffer, actual_size); | 61 base::OS::ProtectCode(buffer, actual_size); |
64 | 62 |
65 #if !defined(USE_SIMULATOR) | 63 #if !defined(USE_SIMULATOR) |
66 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 64 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
67 #else | 65 #else |
68 fast_exp_mips_machine_code = buffer; | 66 fast_exp_mips_machine_code = buffer; |
69 return &fast_exp_simulator; | 67 return &fast_exp_simulator; |
70 #endif | 68 #endif |
71 } | 69 } |
72 | 70 |
73 | 71 |
74 #if defined(V8_HOST_ARCH_MIPS) | 72 #if defined(V8_HOST_ARCH_MIPS) |
75 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { | 73 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { |
76 #if defined(USE_SIMULATOR) || defined(_MIPS_ARCH_MIPS32R6) || \ | 74 #if defined(USE_SIMULATOR) || defined(_MIPS_ARCH_MIPS32R6) || \ |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 } | 1256 } |
1259 } | 1257 } |
1260 | 1258 |
1261 | 1259 |
1262 #undef __ | 1260 #undef __ |
1263 | 1261 |
1264 } // namespace internal | 1262 } // namespace internal |
1265 } // namespace v8 | 1263 } // namespace v8 |
1266 | 1264 |
1267 #endif // V8_TARGET_ARCH_MIPS | 1265 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |