| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 #if defined(V8_TARGET_ARCH_IA32) | 179 #if defined(V8_TARGET_ARCH_IA32) |
| 180 static OS::MemCopyFunction memcopy_function = NULL; | 180 static OS::MemCopyFunction memcopy_function = NULL; |
| 181 static Mutex* memcopy_function_mutex = OS::CreateMutex(); | 181 static Mutex* memcopy_function_mutex = OS::CreateMutex(); |
| 182 // Defined in codegen-ia32.cc. | 182 // Defined in codegen-ia32.cc. |
| 183 OS::MemCopyFunction CreateMemCopyFunction(); | 183 OS::MemCopyFunction CreateMemCopyFunction(); |
| 184 | 184 |
| 185 // Copy memory area to disjoint memory area. | 185 // Copy memory area to disjoint memory area. |
| 186 void OS::MemCopy(void* dest, const void* src, size_t size) { | 186 void OS::MemCopy(void* dest, const void* src, size_t size) { |
| 187 if (memcopy_function == NULL) { | 187 if (memcopy_function == NULL) { |
| 188 ScopedLock lock(memcopy_function_mutex); | 188 ScopedLock lock(memcopy_function_mutex); |
| 189 Isolate::EnsureDefaultIsolate(); | |
| 190 if (memcopy_function == NULL) { | 189 if (memcopy_function == NULL) { |
| 191 OS::MemCopyFunction temp = CreateMemCopyFunction(); | 190 OS::MemCopyFunction temp = CreateMemCopyFunction(); |
| 192 MemoryBarrier(); | 191 MemoryBarrier(); |
| 193 memcopy_function = temp; | 192 memcopy_function = temp; |
| 194 } | 193 } |
| 195 } | 194 } |
| 195 // Note: here we rely on dependent reads being ordered. This is true |
| 196 // on all architectures we currently support. |
| 196 (*memcopy_function)(dest, src, size); | 197 (*memcopy_function)(dest, src, size); |
| 197 #ifdef DEBUG | 198 #ifdef DEBUG |
| 198 CHECK_EQ(0, memcmp(dest, src, size)); | 199 CHECK_EQ(0, memcmp(dest, src, size)); |
| 199 #endif | 200 #endif |
| 200 } | 201 } |
| 201 #endif // V8_TARGET_ARCH_IA32 | 202 #endif // V8_TARGET_ARCH_IA32 |
| 202 | 203 |
| 203 #ifdef _WIN64 | 204 #ifdef _WIN64 |
| 204 typedef double (*ModuloFunction)(double, double); | 205 typedef double (*ModuloFunction)(double, double); |
| 205 static ModuloFunction modulo_function = NULL; | 206 static ModuloFunction modulo_function = NULL; |
| 206 static Mutex* modulo_function_mutex = OS::CreateMutex(); | 207 static Mutex* modulo_function_mutex = OS::CreateMutex(); |
| 207 // Defined in codegen-x64.cc. | 208 // Defined in codegen-x64.cc. |
| 208 ModuloFunction CreateModuloFunction(); | 209 ModuloFunction CreateModuloFunction(); |
| 209 | 210 |
| 210 double modulo(double x, double y) { | 211 double modulo(double x, double y) { |
| 211 if (modulo_function == NULL) { | 212 if (modulo_function == NULL) { |
| 212 ScopedLock lock(modulo_function_mutex); | 213 ScopedLock lock(modulo_function_mutex); |
| 213 Isolate::EnsureDefaultIsolate(); | |
| 214 if (modulo_function == NULL) { | 214 if (modulo_function == NULL) { |
| 215 ModuloFunction temp = CreateModuloFunction(); | 215 ModuloFunction temp = CreateModuloFunction(); |
| 216 MemoryBarrier(); | 216 MemoryBarrier(); |
| 217 modulo_function = temp; | 217 modulo_function = temp; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 // Note: here we rely on dependent reads being ordered. This is true |
| 221 // on all architectures we currently support. |
| 220 return (*modulo_function)(x, y); | 222 return (*modulo_function)(x, y); |
| 221 } | 223 } |
| 222 #else // Win32 | 224 #else // Win32 |
| 223 | 225 |
| 224 double modulo(double x, double y) { | 226 double modulo(double x, double y) { |
| 225 // Workaround MS fmod bugs. ECMA-262 says: | 227 // Workaround MS fmod bugs. ECMA-262 says: |
| 226 // dividend is finite and divisor is an infinity => result equals dividend | 228 // dividend is finite and divisor is an infinity => result equals dividend |
| 227 // dividend is a zero and divisor is nonzero finite => result equals dividend | 229 // dividend is a zero and divisor is nonzero finite => result equals dividend |
| 228 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && | 230 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && |
| 229 !(x == 0 && (y != 0 && isfinite(y)))) { | 231 !(x == 0 && (y != 0 && isfinite(y)))) { |
| (...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 | 2063 |
| 2062 void Sampler::Stop() { | 2064 void Sampler::Stop() { |
| 2063 ASSERT(IsActive()); | 2065 ASSERT(IsActive()); |
| 2064 SamplerThread::RemoveActiveSampler(this); | 2066 SamplerThread::RemoveActiveSampler(this); |
| 2065 SetActive(false); | 2067 SetActive(false); |
| 2066 } | 2068 } |
| 2067 | 2069 |
| 2068 #endif // ENABLE_LOGGING_AND_PROFILING | 2070 #endif // ENABLE_LOGGING_AND_PROFILING |
| 2069 | 2071 |
| 2070 } } // namespace v8::internal | 2072 } } // namespace v8::internal |
| OLD | NEW |