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

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

Issue 9666052: Landing for pliard@chromium.org: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 double ceiling(double x) { 143 double ceiling(double x) {
144 return ceil(x); 144 return ceil(x);
145 } 145 }
146 146
147 147
148 static Mutex* limit_mutex = NULL; 148 static Mutex* limit_mutex = NULL;
149 149
150 #if defined(V8_TARGET_ARCH_IA32) 150 #if defined(V8_TARGET_ARCH_IA32)
151 static OS::MemCopyFunction memcopy_function = NULL; 151 static OS::MemCopyFunction memcopy_function = NULL;
152 static Mutex* memcopy_function_mutex = OS::CreateMutex(); 152 static LazyMutex memcopy_function_mutex = LAZY_MUTEX_INITIALIZER;
153 // Defined in codegen-ia32.cc. 153 // Defined in codegen-ia32.cc.
154 OS::MemCopyFunction CreateMemCopyFunction(); 154 OS::MemCopyFunction CreateMemCopyFunction();
155 155
156 // Copy memory area to disjoint memory area. 156 // Copy memory area to disjoint memory area.
157 void OS::MemCopy(void* dest, const void* src, size_t size) { 157 void OS::MemCopy(void* dest, const void* src, size_t size) {
158 if (memcopy_function == NULL) { 158 if (memcopy_function == NULL) {
159 ScopedLock lock(memcopy_function_mutex); 159 ScopedLock lock(memcopy_function_mutex.Pointer());
160 if (memcopy_function == NULL) { 160 if (memcopy_function == NULL) {
161 OS::MemCopyFunction temp = CreateMemCopyFunction(); 161 OS::MemCopyFunction temp = CreateMemCopyFunction();
162 MemoryBarrier(); 162 MemoryBarrier();
163 memcopy_function = temp; 163 memcopy_function = temp;
164 } 164 }
165 } 165 }
166 // Note: here we rely on dependent reads being ordered. This is true 166 // Note: here we rely on dependent reads being ordered. This is true
167 // on all architectures we currently support. 167 // on all architectures we currently support.
168 (*memcopy_function)(dest, src, size); 168 (*memcopy_function)(dest, src, size);
169 #ifdef DEBUG 169 #ifdef DEBUG
170 CHECK_EQ(0, memcmp(dest, src, size)); 170 CHECK_EQ(0, memcmp(dest, src, size));
171 #endif 171 #endif
172 } 172 }
173 #endif // V8_TARGET_ARCH_IA32 173 #endif // V8_TARGET_ARCH_IA32
174 174
175 #ifdef _WIN64 175 #ifdef _WIN64
176 typedef double (*ModuloFunction)(double, double); 176 typedef double (*ModuloFunction)(double, double);
177 static ModuloFunction modulo_function = NULL; 177 static ModuloFunction modulo_function = NULL;
178 static Mutex* modulo_function_mutex = OS::CreateMutex(); 178 static LazyMutex modulo_function_mutex = LAZY_MUTEX_INITIALIZER;
179 // Defined in codegen-x64.cc. 179 // Defined in codegen-x64.cc.
180 ModuloFunction CreateModuloFunction(); 180 ModuloFunction CreateModuloFunction();
181 181
182 double modulo(double x, double y) { 182 double modulo(double x, double y) {
183 if (modulo_function == NULL) { 183 if (modulo_function == NULL) {
184 ScopedLock lock(modulo_function_mutex); 184 ScopedLock lock(modulo_function_mutex.Pointer());
185 if (modulo_function == NULL) { 185 if (modulo_function == NULL) {
186 ModuloFunction temp = CreateModuloFunction(); 186 ModuloFunction temp = CreateModuloFunction();
187 MemoryBarrier(); 187 MemoryBarrier();
188 modulo_function = temp; 188 modulo_function = temp;
189 } 189 }
190 } 190 }
191 // Note: here we rely on dependent reads being ordered. This is true 191 // Note: here we rely on dependent reads being ordered. This is true
192 // on all architectures we currently support. 192 // on all architectures we currently support.
193 return (*modulo_function)(x, y); 193 return (*modulo_function)(x, y);
194 } 194 }
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 sampler->SampleStack(sample); 2051 sampler->SampleStack(sample);
2052 sampler->Tick(sample); 2052 sampler->Tick(sample);
2053 } 2053 }
2054 ResumeThread(profiled_thread); 2054 ResumeThread(profiled_thread);
2055 } 2055 }
2056 2056
2057 const int interval_; 2057 const int interval_;
2058 RuntimeProfilerRateLimiter rate_limiter_; 2058 RuntimeProfilerRateLimiter rate_limiter_;
2059 2059
2060 // Protects the process wide state below. 2060 // Protects the process wide state below.
2061 static Mutex* mutex_; 2061 static LazyMutex mutex_;
2062 static SamplerThread* instance_; 2062 static SamplerThread* instance_;
2063 2063
2064 private: 2064 private:
2065 DISALLOW_COPY_AND_ASSIGN(SamplerThread); 2065 DISALLOW_COPY_AND_ASSIGN(SamplerThread);
2066 }; 2066 };
2067 2067
2068 2068
2069 Mutex* SamplerThread::mutex_ = OS::CreateMutex(); 2069 LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER;
2070 SamplerThread* SamplerThread::instance_ = NULL; 2070 SamplerThread* SamplerThread::instance_ = NULL;
2071 2071
2072 2072
2073 Sampler::Sampler(Isolate* isolate, int interval) 2073 Sampler::Sampler(Isolate* isolate, int interval)
2074 : isolate_(isolate), 2074 : isolate_(isolate),
2075 interval_(interval), 2075 interval_(interval),
2076 profiling_(false), 2076 profiling_(false),
2077 active_(false), 2077 active_(false),
2078 samples_taken_(0) { 2078 samples_taken_(0) {
2079 data_ = new PlatformData; 2079 data_ = new PlatformData;
(...skipping 14 matching lines...) Expand all
2094 2094
2095 2095
2096 void Sampler::Stop() { 2096 void Sampler::Stop() {
2097 ASSERT(IsActive()); 2097 ASSERT(IsActive());
2098 SamplerThread::RemoveActiveSampler(this); 2098 SamplerThread::RemoveActiveSampler(this);
2099 SetActive(false); 2099 SetActive(false);
2100 } 2100 }
2101 2101
2102 2102
2103 } } // namespace v8::internal 2103 } } // 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