OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 namespace v8 { | 169 namespace v8 { |
170 namespace internal { | 170 namespace internal { |
171 | 171 |
172 double ceiling(double x) { | 172 double ceiling(double x) { |
173 return ceil(x); | 173 return ceil(x); |
174 } | 174 } |
175 | 175 |
176 | 176 |
177 static Mutex* limit_mutex = NULL; | 177 static Mutex* limit_mutex = NULL; |
178 | 178 |
| 179 #if defined(V8_TARGET_ARCH_IA32) |
| 180 static OS::MemCopyFunction memcopy_function = NULL; |
| 181 static Mutex* memcopy_function_mutex = OS::CreateMutex(); |
| 182 // Defined in codegen-ia32.cc. |
| 183 OS::MemCopyFunction CreateMemCopyFunction(); |
| 184 |
| 185 // Copy memory area to disjoint memory area. |
| 186 void OS::MemCopy(void* dest, const void* src, size_t size) { |
| 187 if (memcopy_function == NULL) { |
| 188 ScopedLock lock(memcopy_function_mutex); |
| 189 Isolate::EnsureDefaultIsolate(); |
| 190 if (memcopy_function == NULL) { |
| 191 memcopy_function = CreateMemCopyFunction(); |
| 192 } |
| 193 } |
| 194 (*memcopy_function)(dest, src, size); |
| 195 #ifdef DEBUG |
| 196 CHECK_EQ(0, memcmp(dest, src, size)); |
| 197 #endif |
| 198 } |
| 199 #endif // V8_TARGET_ARCH_IA32 |
179 | 200 |
180 #ifdef _WIN64 | 201 #ifdef _WIN64 |
181 typedef double (*ModuloFunction)(double, double); | 202 typedef double (*ModuloFunction)(double, double); |
182 | 203 static ModuloFunction modulo_function = NULL; |
| 204 static Mutex* modulo_function_mutex = OS::CreateMutex(); |
183 // Defined in codegen-x64.cc. | 205 // Defined in codegen-x64.cc. |
184 ModuloFunction CreateModuloFunction(); | 206 ModuloFunction CreateModuloFunction(); |
185 | 207 |
186 double modulo(double x, double y) { | 208 double modulo(double x, double y) { |
187 static ModuloFunction function = CreateModuloFunction(); | 209 if (modulo_function == NULL) { |
188 return function(x, y); | 210 ScopedLock lock(modulo_function_mutex); |
| 211 Isolate::EnsureDefaultIsolate(); |
| 212 if (modulo_function == NULL) { |
| 213 Release_Store(reinterpret_cast<AtomicWord*>(&modulo_function), |
| 214 reinterpret_cast<AtomicWord>(CreateModuloFunction())); |
| 215 } |
| 216 } |
| 217 return (*modulo_function)(x, y); |
189 } | 218 } |
190 #else // Win32 | 219 #else // Win32 |
191 | 220 |
192 double modulo(double x, double y) { | 221 double modulo(double x, double y) { |
193 // Workaround MS fmod bugs. ECMA-262 says: | 222 // Workaround MS fmod bugs. ECMA-262 says: |
194 // dividend is finite and divisor is an infinity => result equals dividend | 223 // dividend is finite and divisor is an infinity => result equals dividend |
195 // dividend is a zero and divisor is nonzero finite => result equals dividend | 224 // dividend is a zero and divisor is nonzero finite => result equals dividend |
196 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && | 225 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && |
197 !(x == 0 && (y != 0 && isfinite(y)))) { | 226 !(x == 0 && (y != 0 && isfinite(y)))) { |
198 x = fmod(x, y); | 227 x = fmod(x, y); |
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 | 2058 |
2030 void Sampler::Stop() { | 2059 void Sampler::Stop() { |
2031 ASSERT(IsActive()); | 2060 ASSERT(IsActive()); |
2032 SamplerThread::RemoveActiveSampler(this); | 2061 SamplerThread::RemoveActiveSampler(this); |
2033 SetActive(false); | 2062 SetActive(false); |
2034 } | 2063 } |
2035 | 2064 |
2036 #endif // ENABLE_LOGGING_AND_PROFILING | 2065 #endif // ENABLE_LOGGING_AND_PROFILING |
2037 | 2066 |
2038 } } // namespace v8::internal | 2067 } } // namespace v8::internal |
OLD | NEW |