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

Side by Side Diff: src/platform-win32.cc

Issue 9455088: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Florian's comments. Created 8 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-solaris.cc ('k') | src/runtime-profiler.h » ('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 // 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 double ceiling(double x) { 137 double ceiling(double x) {
138 return ceil(x); 138 return ceil(x);
139 } 139 }
140 140
141 141
142 static Mutex* limit_mutex = NULL; 142 static Mutex* limit_mutex = NULL;
143 143
144 #if defined(V8_TARGET_ARCH_IA32) 144 #if defined(V8_TARGET_ARCH_IA32)
145 static OS::MemCopyFunction memcopy_function = NULL; 145 static OS::MemCopyFunction memcopy_function = NULL;
146 static Mutex* memcopy_function_mutex = OS::CreateMutex(); 146 static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER;
147 // Defined in codegen-ia32.cc. 147 // Defined in codegen-ia32.cc.
148 OS::MemCopyFunction CreateMemCopyFunction(); 148 OS::MemCopyFunction CreateMemCopyFunction();
149 149
150 // Copy memory area to disjoint memory area. 150 // Copy memory area to disjoint memory area.
151 void OS::MemCopy(void* dest, const void* src, size_t size) { 151 void OS::MemCopy(void* dest, const void* src, size_t size) {
152 if (memcopy_function == NULL) { 152 if (memcopy_function == NULL) {
153 ScopedLock lock(memcopy_function_mutex); 153 ScopedLock lock(memcopy_function_mutex.Pointer());
154 if (memcopy_function == NULL) { 154 if (memcopy_function == NULL) {
155 OS::MemCopyFunction temp = CreateMemCopyFunction(); 155 OS::MemCopyFunction temp = CreateMemCopyFunction();
156 MemoryBarrier(); 156 MemoryBarrier();
157 memcopy_function = temp; 157 memcopy_function = temp;
158 } 158 }
159 } 159 }
160 // Note: here we rely on dependent reads being ordered. This is true 160 // Note: here we rely on dependent reads being ordered. This is true
161 // on all architectures we currently support. 161 // on all architectures we currently support.
162 (*memcopy_function)(dest, src, size); 162 (*memcopy_function)(dest, src, size);
163 #ifdef DEBUG 163 #ifdef DEBUG
164 CHECK_EQ(0, memcmp(dest, src, size)); 164 CHECK_EQ(0, memcmp(dest, src, size));
165 #endif 165 #endif
166 } 166 }
167 #endif // V8_TARGET_ARCH_IA32 167 #endif // V8_TARGET_ARCH_IA32
168 168
169 #ifdef _WIN64 169 #ifdef _WIN64
170 typedef double (*ModuloFunction)(double, double); 170 typedef double (*ModuloFunction)(double, double);
171 static ModuloFunction modulo_function = NULL; 171 static ModuloFunction modulo_function = NULL;
172 static Mutex* modulo_function_mutex = OS::CreateMutex(); 172 static LazyMutex modulo_function_mutex = LAZY_MUTEX_INITIALIZER;
173 // Defined in codegen-x64.cc. 173 // Defined in codegen-x64.cc.
174 ModuloFunction CreateModuloFunction(); 174 ModuloFunction CreateModuloFunction();
175 175
176 double modulo(double x, double y) { 176 double modulo(double x, double y) {
177 if (modulo_function == NULL) { 177 if (modulo_function == NULL) {
178 ScopedLock lock(modulo_function_mutex); 178 ScopedLock lock(modulo_function_mutex.Pointer());
179 if (modulo_function == NULL) { 179 if (modulo_function == NULL) {
180 ModuloFunction temp = CreateModuloFunction(); 180 ModuloFunction temp = CreateModuloFunction();
181 MemoryBarrier(); 181 MemoryBarrier();
182 modulo_function = temp; 182 modulo_function = temp;
183 } 183 }
184 } 184 }
185 // Note: here we rely on dependent reads being ordered. This is true 185 // Note: here we rely on dependent reads being ordered. This is true
186 // on all architectures we currently support. 186 // on all architectures we currently support.
187 return (*modulo_function)(x, y); 187 return (*modulo_function)(x, y);
188 } 188 }
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 sampler->SampleStack(sample); 2026 sampler->SampleStack(sample);
2027 sampler->Tick(sample); 2027 sampler->Tick(sample);
2028 } 2028 }
2029 ResumeThread(profiled_thread); 2029 ResumeThread(profiled_thread);
2030 } 2030 }
2031 2031
2032 const int interval_; 2032 const int interval_;
2033 RuntimeProfilerRateLimiter rate_limiter_; 2033 RuntimeProfilerRateLimiter rate_limiter_;
2034 2034
2035 // Protects the process wide state below. 2035 // Protects the process wide state below.
2036 static Mutex* mutex_; 2036 static LazyMutex mutex_;
2037 static SamplerThread* instance_; 2037 static SamplerThread* instance_;
2038 2038
2039 private: 2039 private:
2040 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 2040 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
2041 }; 2041 };
2042 2042
2043 2043
2044 Mutex* SamplerThread::mutex_ = OS::CreateMutex(); 2044 LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER;
2045 SamplerThread* SamplerThread::instance_ = NULL; 2045 SamplerThread* SamplerThread::instance_ = NULL;
2046 2046
2047 2047
2048 Sampler::Sampler(Isolate* isolate, int interval) 2048 Sampler::Sampler(Isolate* isolate, int interval)
2049 : isolate_(isolate), 2049 : isolate_(isolate),
2050 interval_(interval), 2050 interval_(interval),
2051 profiling_(false), 2051 profiling_(false),
2052 active_(false), 2052 active_(false),
2053 samples_taken_(0) { 2053 samples_taken_(0) {
2054 data_ = new PlatformData; 2054 data_ = new PlatformData;
(...skipping 14 matching lines...) Expand all
2069 2069
2070 2070
2071 void Sampler::Stop() { 2071 void Sampler::Stop() {
2072 ASSERT(IsActive()); 2072 ASSERT(IsActive());
2073 SamplerThread::RemoveActiveSampler(this); 2073 SamplerThread::RemoveActiveSampler(this);
2074 SetActive(false); 2074 SetActive(false);
2075 } 2075 }
2076 2076
2077 2077
2078 } } // namespace v8::internal 2078 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | src/runtime-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698