| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 double ceiling(double x) { | 132 double ceiling(double x) { |
| 133 return ceil(x); | 133 return ceil(x); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 static Mutex* limit_mutex = NULL; | 137 static Mutex* limit_mutex = NULL; |
| 138 | 138 |
| 139 #if defined(V8_TARGET_ARCH_IA32) | 139 #if defined(V8_TARGET_ARCH_IA32) |
| 140 static OS::MemCopyFunction memcopy_function = NULL; | 140 static OS::MemCopyFunction memcopy_function = NULL; |
| 141 static Mutex* memcopy_function_mutex = OS::CreateMutex(); | 141 static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER; |
| 142 // Defined in codegen-ia32.cc. | 142 // Defined in codegen-ia32.cc. |
| 143 OS::MemCopyFunction CreateMemCopyFunction(); | 143 OS::MemCopyFunction CreateMemCopyFunction(); |
| 144 | 144 |
| 145 // Copy memory area to disjoint memory area. | 145 // Copy memory area to disjoint memory area. |
| 146 void OS::MemCopy(void* dest, const void* src, size_t size) { | 146 void OS::MemCopy(void* dest, const void* src, size_t size) { |
| 147 if (memcopy_function == NULL) { | 147 if (memcopy_function == NULL) { |
| 148 ScopedLock lock(memcopy_function_mutex); | 148 ScopedLock lock(memcopy_function_mutex.Pointer()); |
| 149 if (memcopy_function == NULL) { | 149 if (memcopy_function == NULL) { |
| 150 OS::MemCopyFunction temp = CreateMemCopyFunction(); | 150 OS::MemCopyFunction temp = CreateMemCopyFunction(); |
| 151 MemoryBarrier(); | 151 MemoryBarrier(); |
| 152 memcopy_function = temp; | 152 memcopy_function = temp; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 // Note: here we rely on dependent reads being ordered. This is true | 155 // Note: here we rely on dependent reads being ordered. This is true |
| 156 // on all architectures we currently support. | 156 // on all architectures we currently support. |
| 157 (*memcopy_function)(dest, src, size); | 157 (*memcopy_function)(dest, src, size); |
| 158 #ifdef DEBUG | 158 #ifdef DEBUG |
| 159 CHECK_EQ(0, memcmp(dest, src, size)); | 159 CHECK_EQ(0, memcmp(dest, src, size)); |
| 160 #endif | 160 #endif |
| 161 } | 161 } |
| 162 #endif // V8_TARGET_ARCH_IA32 | 162 #endif // V8_TARGET_ARCH_IA32 |
| 163 | 163 |
| 164 #ifdef _WIN64 | 164 #ifdef _WIN64 |
| 165 typedef double (*ModuloFunction)(double, double); | 165 typedef double (*ModuloFunction)(double, double); |
| 166 static ModuloFunction modulo_function = NULL; | 166 static ModuloFunction modulo_function = NULL; |
| 167 static Mutex* modulo_function_mutex = OS::CreateMutex(); | 167 static LazyMutex modulo_function_mutex = LAZY_MUTEX_INITIALIZER; |
| 168 // Defined in codegen-x64.cc. | 168 // Defined in codegen-x64.cc. |
| 169 ModuloFunction CreateModuloFunction(); | 169 ModuloFunction CreateModuloFunction(); |
| 170 | 170 |
| 171 double modulo(double x, double y) { | 171 double modulo(double x, double y) { |
| 172 if (modulo_function == NULL) { | 172 if (modulo_function == NULL) { |
| 173 ScopedLock lock(modulo_function_mutex); | 173 ScopedLock lock(modulo_function_mutex.Pointer()); |
| 174 if (modulo_function == NULL) { | 174 if (modulo_function == NULL) { |
| 175 ModuloFunction temp = CreateModuloFunction(); | 175 ModuloFunction temp = CreateModuloFunction(); |
| 176 MemoryBarrier(); | 176 MemoryBarrier(); |
| 177 modulo_function = temp; | 177 modulo_function = temp; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 // Note: here we rely on dependent reads being ordered. This is true | 180 // Note: here we rely on dependent reads being ordered. This is true |
| 181 // on all architectures we currently support. | 181 // on all architectures we currently support. |
| 182 return (*modulo_function)(x, y); | 182 return (*modulo_function)(x, y); |
| 183 } | 183 } |
| (...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 sampler->SampleStack(sample); | 1991 sampler->SampleStack(sample); |
| 1992 sampler->Tick(sample); | 1992 sampler->Tick(sample); |
| 1993 } | 1993 } |
| 1994 ResumeThread(profiled_thread); | 1994 ResumeThread(profiled_thread); |
| 1995 } | 1995 } |
| 1996 | 1996 |
| 1997 const int interval_; | 1997 const int interval_; |
| 1998 RuntimeProfilerRateLimiter rate_limiter_; | 1998 RuntimeProfilerRateLimiter rate_limiter_; |
| 1999 | 1999 |
| 2000 // Protects the process wide state below. | 2000 // Protects the process wide state below. |
| 2001 static Mutex* mutex_; | 2001 static LazyMutex mutex_; |
| 2002 static SamplerThread* instance_; | 2002 static SamplerThread* instance_; |
| 2003 | 2003 |
| 2004 private: | 2004 private: |
| 2005 DISALLOW_COPY_AND_ASSIGN(SamplerThread); | 2005 DISALLOW_COPY_AND_ASSIGN(SamplerThread); |
| 2006 }; | 2006 }; |
| 2007 | 2007 |
| 2008 | 2008 |
| 2009 Mutex* SamplerThread::mutex_ = OS::CreateMutex(); | 2009 LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER; |
| 2010 SamplerThread* SamplerThread::instance_ = NULL; | 2010 SamplerThread* SamplerThread::instance_ = NULL; |
| 2011 | 2011 |
| 2012 | 2012 |
| 2013 Sampler::Sampler(Isolate* isolate, int interval) | 2013 Sampler::Sampler(Isolate* isolate, int interval) |
| 2014 : isolate_(isolate), | 2014 : isolate_(isolate), |
| 2015 interval_(interval), | 2015 interval_(interval), |
| 2016 profiling_(false), | 2016 profiling_(false), |
| 2017 active_(false), | 2017 active_(false), |
| 2018 samples_taken_(0) { | 2018 samples_taken_(0) { |
| 2019 data_ = new PlatformData; | 2019 data_ = new PlatformData; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2034 | 2034 |
| 2035 | 2035 |
| 2036 void Sampler::Stop() { | 2036 void Sampler::Stop() { |
| 2037 ASSERT(IsActive()); | 2037 ASSERT(IsActive()); |
| 2038 SamplerThread::RemoveActiveSampler(this); | 2038 SamplerThread::RemoveActiveSampler(this); |
| 2039 SetActive(false); | 2039 SetActive(false); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 | 2042 |
| 2043 } } // namespace v8::internal | 2043 } } // namespace v8::internal |
| OLD | NEW |