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/ia32/codegen-ia32.h" | 5 #include "src/ia32/codegen-ia32.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { | 27 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { |
28 masm->LeaveFrame(StackFrame::INTERNAL); | 28 masm->LeaveFrame(StackFrame::INTERNAL); |
29 DCHECK(masm->has_frame()); | 29 DCHECK(masm->has_frame()); |
30 masm->set_has_frame(false); | 30 masm->set_has_frame(false); |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 #define __ masm. | 34 #define __ masm. |
35 | 35 |
36 | 36 |
37 UnaryMathFunction CreateExpFunction() { | 37 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { |
38 if (!FLAG_fast_math) return &std::exp; | |
39 size_t actual_size; | 38 size_t actual_size; |
40 byte* buffer = | 39 byte* buffer = |
41 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 40 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
42 if (buffer == NULL) return &std::exp; | 41 if (buffer == nullptr) return nullptr; |
43 ExternalReference::InitializeMathExpData(); | 42 ExternalReference::InitializeMathExpData(); |
44 | 43 |
45 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 44 MacroAssembler masm(nullptr, buffer, static_cast<int>(actual_size)); |
46 // esp[1 * kPointerSize]: raw double input | 45 // esp[1 * kPointerSize]: raw double input |
47 // esp[0 * kPointerSize]: return address | 46 // esp[0 * kPointerSize]: return address |
48 { | 47 { |
49 XMMRegister input = xmm1; | 48 XMMRegister input = xmm1; |
50 XMMRegister result = xmm2; | 49 XMMRegister result = xmm2; |
51 __ movsd(input, Operand(esp, 1 * kPointerSize)); | 50 __ movsd(input, Operand(esp, 1 * kPointerSize)); |
52 __ push(eax); | 51 __ push(eax); |
53 __ push(ebx); | 52 __ push(ebx); |
54 | 53 |
55 MathExpGenerator::EmitMathExp(&masm, input, result, xmm0, eax, ebx); | 54 MathExpGenerator::EmitMathExp(&masm, input, result, xmm0, eax, ebx); |
56 | 55 |
57 __ pop(ebx); | 56 __ pop(ebx); |
58 __ pop(eax); | 57 __ pop(eax); |
59 __ movsd(Operand(esp, 1 * kPointerSize), result); | 58 __ movsd(Operand(esp, 1 * kPointerSize), result); |
60 __ fld_d(Operand(esp, 1 * kPointerSize)); | 59 __ fld_d(Operand(esp, 1 * kPointerSize)); |
61 __ Ret(); | 60 __ Ret(); |
62 } | 61 } |
63 | 62 |
64 CodeDesc desc; | 63 CodeDesc desc; |
65 masm.GetCode(&desc); | 64 masm.GetCode(&desc); |
66 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 65 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
67 | 66 |
68 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); | 67 Assembler::FlushICache(isolate, buffer, actual_size); |
69 base::OS::ProtectCode(buffer, actual_size); | 68 base::OS::ProtectCode(buffer, actual_size); |
70 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 69 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
71 } | 70 } |
72 | 71 |
73 | 72 |
74 UnaryMathFunction CreateSqrtFunction() { | 73 UnaryMathFunction CreateSqrtFunction() { |
75 size_t actual_size; | 74 size_t actual_size; |
76 // Allocate buffer in executable space. | 75 // Allocate buffer in executable space. |
77 byte* buffer = | 76 byte* buffer = |
78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 77 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
79 if (buffer == NULL) return &std::sqrt; | 78 if (buffer == NULL) return &std::sqrt; |
80 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 79 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 CodePatcher patcher(sequence, young_length); | 1037 CodePatcher patcher(sequence, young_length); |
1039 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 1038 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
1040 } | 1039 } |
1041 } | 1040 } |
1042 | 1041 |
1043 | 1042 |
1044 } // namespace internal | 1043 } // namespace internal |
1045 } // namespace v8 | 1044 } // namespace v8 |
1046 | 1045 |
1047 #endif // V8_TARGET_ARCH_IA32 | 1046 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |