Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 1473683004: Lazily initialize fast_sqrt() and pass an Isolate parameter to it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/crankshaft/hydrogen-instructions.cc ('k') | src/mips/codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 CodeDesc desc; 64 CodeDesc desc;
65 masm.GetCode(&desc); 65 masm.GetCode(&desc);
66 DCHECK(!RelocInfo::RequiresRelocation(desc)); 66 DCHECK(!RelocInfo::RequiresRelocation(desc));
67 67
68 Assembler::FlushICache(isolate, buffer, actual_size); 68 Assembler::FlushICache(isolate, buffer, actual_size);
69 base::OS::ProtectCode(buffer, actual_size); 69 base::OS::ProtectCode(buffer, actual_size);
70 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); 70 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer);
71 } 71 }
72 72
73 73
74 UnaryMathFunction CreateSqrtFunction() { 74 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) {
75 size_t actual_size; 75 size_t actual_size;
76 // Allocate buffer in executable space. 76 // Allocate buffer in executable space.
77 byte* buffer = 77 byte* buffer =
78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); 78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
79 if (buffer == NULL) return &std::sqrt; 79 if (buffer == nullptr) return nullptr;
80 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size), 80 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
81 CodeObjectRequired::kNo); 81 CodeObjectRequired::kNo);
82 // esp[1 * kPointerSize]: raw double input 82 // esp[1 * kPointerSize]: raw double input
83 // esp[0 * kPointerSize]: return address 83 // esp[0 * kPointerSize]: return address
84 // Move double input into registers. 84 // Move double input into registers.
85 { 85 {
86 __ movsd(xmm0, Operand(esp, 1 * kPointerSize)); 86 __ movsd(xmm0, Operand(esp, 1 * kPointerSize));
87 __ sqrtsd(xmm0, xmm0); 87 __ sqrtsd(xmm0, xmm0);
88 __ movsd(Operand(esp, 1 * kPointerSize), xmm0); 88 __ movsd(Operand(esp, 1 * kPointerSize), xmm0);
89 // Load result into floating point register as return value. 89 // Load result into floating point register as return value.
90 __ fld_d(Operand(esp, 1 * kPointerSize)); 90 __ fld_d(Operand(esp, 1 * kPointerSize));
91 __ Ret(); 91 __ Ret();
92 } 92 }
93 93
94 CodeDesc desc; 94 CodeDesc desc;
95 masm.GetCode(&desc); 95 masm.GetCode(&desc);
96 DCHECK(!RelocInfo::RequiresRelocation(desc)); 96 DCHECK(!RelocInfo::RequiresRelocation(desc));
97 97
98 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); 98 Assembler::FlushICache(isolate, buffer, actual_size);
99 base::OS::ProtectCode(buffer, actual_size); 99 base::OS::ProtectCode(buffer, actual_size);
100 return FUNCTION_CAST<UnaryMathFunction>(buffer); 100 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer);
101 } 101 }
102 102
103 103
104 // Helper functions for CreateMemMoveFunction. 104 // Helper functions for CreateMemMoveFunction.
105 #undef __ 105 #undef __
106 #define __ ACCESS_MASM(masm) 106 #define __ ACCESS_MASM(masm)
107 107
108 enum Direction { FORWARD, BACKWARD }; 108 enum Direction { FORWARD, BACKWARD };
109 enum Alignment { MOVE_ALIGNED, MOVE_UNALIGNED }; 109 enum Alignment { MOVE_ALIGNED, MOVE_UNALIGNED };
110 110
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 CodePatcher patcher(sequence, young_length); 1040 CodePatcher patcher(sequence, young_length);
1041 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); 1041 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
1042 } 1042 }
1043 } 1043 }
1044 1044
1045 1045
1046 } // namespace internal 1046 } // namespace internal
1047 } // namespace v8 1047 } // namespace v8
1048 1048
1049 #endif // V8_TARGET_ARCH_IA32 1049 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen-instructions.cc ('k') | src/mips/codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698