OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ppc/codegen-ppc.h" | 5 #include "src/ppc/codegen-ppc.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
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/ppc/simulator-ppc.h" | 11 #include "src/ppc/simulator-ppc.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_ppc_machine_code = NULL; | 21 byte* fast_exp_ppc_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()) | 23 return Simulator::current(isolate) |
24 ->CallFPReturnsDouble(fast_exp_ppc_machine_code, x, 0); | 24 ->CallFPReturnsDouble(fast_exp_ppc_machine_code, x, 0); |
25 } | 25 } |
26 #endif | 26 #endif |
27 | 27 |
28 | 28 |
29 UnaryMathFunction CreateExpFunction() { | 29 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { |
30 if (!FLAG_fast_math) return &std::exp; | |
31 size_t actual_size; | 30 size_t actual_size; |
32 byte* buffer = | 31 byte* buffer = |
33 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 32 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
34 if (buffer == NULL) return &std::exp; | 33 if (buffer == nullptr) return nullptr; |
35 ExternalReference::InitializeMathExpData(); | 34 ExternalReference::InitializeMathExpData(); |
36 | 35 |
37 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 36 MacroAssembler masm(nullptr, buffer, static_cast<int>(actual_size)); |
38 | 37 |
39 { | 38 { |
40 DoubleRegister input = d1; | 39 DoubleRegister input = d1; |
41 DoubleRegister result = d2; | 40 DoubleRegister result = d2; |
42 DoubleRegister double_scratch1 = d3; | 41 DoubleRegister double_scratch1 = d3; |
43 DoubleRegister double_scratch2 = d4; | 42 DoubleRegister double_scratch2 = d4; |
44 Register temp1 = r7; | 43 Register temp1 = r7; |
45 Register temp2 = r8; | 44 Register temp2 = r8; |
46 Register temp3 = r9; | 45 Register temp3 = r9; |
47 | 46 |
48 // Called from C | 47 // Called from C |
49 __ function_descriptor(); | 48 __ function_descriptor(); |
50 | 49 |
51 __ Push(temp3, temp2, temp1); | 50 __ Push(temp3, temp2, temp1); |
52 MathExpGenerator::EmitMathExp(&masm, input, result, double_scratch1, | 51 MathExpGenerator::EmitMathExp(&masm, input, result, double_scratch1, |
53 double_scratch2, temp1, temp2, temp3); | 52 double_scratch2, temp1, temp2, temp3); |
54 __ Pop(temp3, temp2, temp1); | 53 __ Pop(temp3, temp2, temp1); |
55 __ fmr(d1, result); | 54 __ fmr(d1, result); |
56 __ Ret(); | 55 __ Ret(); |
57 } | 56 } |
58 | 57 |
59 CodeDesc desc; | 58 CodeDesc desc; |
60 masm.GetCode(&desc); | 59 masm.GetCode(&desc); |
61 #if !ABI_USES_FUNCTION_DESCRIPTORS | 60 #if !ABI_USES_FUNCTION_DESCRIPTORS |
62 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 61 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
63 #endif | 62 #endif |
64 | 63 |
65 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); | 64 Assembler::FlushICache(isolate, buffer, actual_size); |
66 base::OS::ProtectCode(buffer, actual_size); | 65 base::OS::ProtectCode(buffer, actual_size); |
67 | 66 |
68 #if !defined(USE_SIMULATOR) | 67 #if !defined(USE_SIMULATOR) |
69 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 68 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
70 #else | 69 #else |
71 fast_exp_ppc_machine_code = buffer; | 70 fast_exp_ppc_machine_code = buffer; |
72 return &fast_exp_simulator; | 71 return &fast_exp_simulator; |
73 #endif | 72 #endif |
74 } | 73 } |
75 | 74 |
76 | 75 |
77 UnaryMathFunction CreateSqrtFunction() { | 76 UnaryMathFunction CreateSqrtFunction() { |
78 #if defined(USE_SIMULATOR) | 77 #if defined(USE_SIMULATOR) |
79 return &std::sqrt; | 78 return &std::sqrt; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 patcher.masm()->Jump(r3); | 673 patcher.masm()->Jump(r3); |
675 for (int i = 0; i < kCodeAgingSequenceNops; i++) { | 674 for (int i = 0; i < kCodeAgingSequenceNops; i++) { |
676 patcher.masm()->nop(); | 675 patcher.masm()->nop(); |
677 } | 676 } |
678 } | 677 } |
679 } | 678 } |
680 } // namespace internal | 679 } // namespace internal |
681 } // namespace v8 | 680 } // namespace v8 |
682 | 681 |
683 #endif // V8_TARGET_ARCH_PPC | 682 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |