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

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

Issue 9959093: Merged r11194, r11198, r11201, r11214 into trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 8 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/v8.cc » ('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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 (*memcopy_function)(dest, src, size); 160 (*memcopy_function)(dest, src, size);
161 #ifdef DEBUG 161 #ifdef DEBUG
162 CHECK_EQ(0, memcmp(dest, src, size)); 162 CHECK_EQ(0, memcmp(dest, src, size));
163 #endif 163 #endif
164 } 164 }
165 #endif // V8_TARGET_ARCH_IA32 165 #endif // V8_TARGET_ARCH_IA32
166 166
167 #ifdef _WIN64 167 #ifdef _WIN64
168 typedef double (*ModuloFunction)(double, double); 168 typedef double (*ModuloFunction)(double, double);
169 static ModuloFunction modulo_function = NULL; 169 static ModuloFunction modulo_function = NULL;
170 V8_DECLARE_ONCE(modulo_function_init_once);
171 // Defined in codegen-x64.cc. 170 // Defined in codegen-x64.cc.
172 ModuloFunction CreateModuloFunction(); 171 ModuloFunction CreateModuloFunction();
173 172
174 void init_modulo_function() { 173 void init_modulo_function() {
175 modulo_function = CreateModuloFunction(); 174 modulo_function = CreateModuloFunction();
176 } 175 }
177 176
178 double modulo(double x, double y) { 177 double modulo(double x, double y) {
179 CallOnce(&modulo_function_init_once, &init_modulo_function);
180 // Note: here we rely on dependent reads being ordered. This is true 178 // Note: here we rely on dependent reads being ordered. This is true
181 // on all architectures we currently support. 179 // on all architectures we currently support.
182 return (*modulo_function)(x, y); 180 return (*modulo_function)(x, y);
183 } 181 }
184 #else // Win32 182 #else // Win32
185 183
186 double modulo(double x, double y) { 184 double modulo(double x, double y) {
187 // Workaround MS fmod bugs. ECMA-262 says: 185 // Workaround MS fmod bugs. ECMA-262 says:
188 // dividend is finite and divisor is an infinity => result equals dividend 186 // dividend is finite and divisor is an infinity => result equals dividend
189 // dividend is a zero and divisor is nonzero finite => result equals dividend 187 // dividend is a zero and divisor is nonzero finite => result equals dividend
190 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && 188 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) &&
191 !(x == 0 && (y != 0 && isfinite(y)))) { 189 !(x == 0 && (y != 0 && isfinite(y)))) {
192 x = fmod(x, y); 190 x = fmod(x, y);
193 } 191 }
194 return x; 192 return x;
195 } 193 }
196 194
197 #endif // _WIN64 195 #endif // _WIN64
198 196
199 197
200 #define UNARY_MATH_FUNCTION(name, generator) \ 198 #define UNARY_MATH_FUNCTION(name, generator) \
201 static UnaryMathFunction fast_##name##_function = NULL; \ 199 static UnaryMathFunction fast_##name##_function = NULL; \
202 V8_DECLARE_ONCE(fast_##name##_init_once); \
203 void init_fast_##name##_function() { \ 200 void init_fast_##name##_function() { \
204 fast_##name##_function = generator; \ 201 fast_##name##_function = generator; \
205 } \ 202 } \
206 double fast_##name(double x) { \ 203 double fast_##name(double x) { \
207 CallOnce(&fast_##name##_init_once, \
208 &init_fast_##name##_function); \
209 return (*fast_##name##_function)(x); \ 204 return (*fast_##name##_function)(x); \
210 } 205 }
211 206
212 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) 207 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN))
213 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) 208 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS))
214 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) 209 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN))
215 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) 210 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG))
216 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) 211 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
217 212
218 #undef MATH_FUNCTION 213 #undef MATH_FUNCTION
219 214
220 215
216 void MathSetup() {
217 #ifdef _WIN64
218 init_modulo_function();
219 #endif
220 init_fast_sin_function();
221 init_fast_cos_function();
222 init_fast_tan_function();
223 init_fast_log_function();
224 init_fast_sqrt_function();
225 }
226
227
221 // ---------------------------------------------------------------------------- 228 // ----------------------------------------------------------------------------
222 // The Time class represents time on win32. A timestamp is represented as 229 // The Time class represents time on win32. A timestamp is represented as
223 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript 230 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript
224 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, 231 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC,
225 // January 1, 1970. 232 // January 1, 1970.
226 233
227 class Time { 234 class Time {
228 public: 235 public:
229 // Constructors. 236 // Constructors.
230 Time(); 237 Time();
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // Convert the current time to a 64-bit integer first, before converting it 568 // Convert the current time to a 64-bit integer first, before converting it
562 // to an unsigned. Going directly can cause an overflow and the seed to be 569 // to an unsigned. Going directly can cause an overflow and the seed to be
563 // set to all ones. The seed will be identical for different instances that 570 // set to all ones. The seed will be identical for different instances that
564 // call this setup code within the same millisecond. 571 // call this setup code within the same millisecond.
565 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 572 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
566 srand(static_cast<unsigned int>(seed)); 573 srand(static_cast<unsigned int>(seed));
567 limit_mutex = CreateMutex(); 574 limit_mutex = CreateMutex();
568 } 575 }
569 576
570 577
578 void OS::PostSetUp() {
579 // Math functions depend on CPU features therefore they are initialized after
580 // CPU.
581 MathSetup();
582 }
583
584
571 // Returns the accumulated user time for thread. 585 // Returns the accumulated user time for thread.
572 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 586 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
573 FILETIME dummy; 587 FILETIME dummy;
574 uint64_t usertime; 588 uint64_t usertime;
575 589
576 // Get the amount of time that the thread has executed in user mode. 590 // Get the amount of time that the thread has executed in user mode.
577 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy, 591 if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
578 reinterpret_cast<FILETIME*>(&usertime))) return -1; 592 reinterpret_cast<FILETIME*>(&usertime))) return -1;
579 593
580 // Adjust the resolution to micro-seconds. 594 // Adjust the resolution to micro-seconds.
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 2101
2088 2102
2089 void Sampler::Stop() { 2103 void Sampler::Stop() {
2090 ASSERT(IsActive()); 2104 ASSERT(IsActive());
2091 SamplerThread::RemoveActiveSampler(this); 2105 SamplerThread::RemoveActiveSampler(this);
2092 SetActive(false); 2106 SetActive(false);
2093 } 2107 }
2094 2108
2095 2109
2096 } } // namespace v8::internal 2110 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698