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

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

Issue 9664067: Use lazy instance initializer to remove static initializers in two places. (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-posix.cc ('k') | no next file » | 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && 201 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) &&
202 !(x == 0 && (y != 0 && isfinite(y)))) { 202 !(x == 0 && (y != 0 && isfinite(y)))) {
203 x = fmod(x, y); 203 x = fmod(x, y);
204 } 204 }
205 return x; 205 return x;
206 } 206 }
207 207
208 #endif // _WIN64 208 #endif // _WIN64
209 209
210 210
211 static Mutex* math_function_mutex = OS::CreateMutex(); 211 static LazyMutex math_function_mutex = LAZY_MUTEX_INITIALIZER;
212 212
213 #define UNARY_MATH_FUNCTION(name, generator) \ 213 #define UNARY_MATH_FUNCTION(name, generator) \
214 static UnaryMathFunction fast_##name##_function = NULL; \ 214 static UnaryMathFunction fast_##name##_function = NULL; \
215 double fast_##name(double x) { \ 215 double fast_##name(double x) { \
216 if (fast_##name##_function == NULL) { \ 216 if (fast_##name##_function == NULL) { \
217 ScopedLock lock(math_function_mutex); \ 217 ScopedLock lock(math_function_mutex.Pointer()); \
218 UnaryMathFunction temp = generator; \ 218 UnaryMathFunction temp = generator; \
219 MemoryBarrier(); \ 219 MemoryBarrier(); \
220 fast_##name##_function = temp; \ 220 fast_##name##_function = temp; \
221 } \ 221 } \
222 return (*fast_##name##_function)(x); \ 222 return (*fast_##name##_function)(x); \
223 } 223 }
224 224
225 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) 225 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN))
226 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) 226 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS))
227 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) 227 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN))
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
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-posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698