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

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

Issue 9572009: Ensure consistent result of transcendental functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix compile errors for arm and mips. 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') | src/x64/code-stubs-x64.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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Platform specific code for Win32. 28 // Platform specific code for Win32.
29 29
30 #define V8_WIN32_HEADERS_FULL 30 #define V8_WIN32_HEADERS_FULL
31 #include "win32-headers.h" 31 #include "win32-headers.h"
32 32
33 #include "v8.h" 33 #include "v8.h"
34 34
35 #include "codegen.h"
35 #include "platform.h" 36 #include "platform.h"
36 #include "vm-state-inl.h" 37 #include "vm-state-inl.h"
37 38
38 #ifdef _MSC_VER 39 #ifdef _MSC_VER
39 40
40 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually 41 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually
41 // defined in strings.h. 42 // defined in strings.h.
42 int strncasecmp(const char* s1, const char* s2, int n) { 43 int strncasecmp(const char* s1, const char* s2, int n) {
43 return _strnicmp(s1, s2, n); 44 return _strnicmp(s1, s2, n);
44 } 45 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // dividend is a zero and divisor is nonzero finite => result equals dividend 195 // dividend is a zero and divisor is nonzero finite => result equals dividend
195 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) && 196 if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) &&
196 !(x == 0 && (y != 0 && isfinite(y)))) { 197 !(x == 0 && (y != 0 && isfinite(y)))) {
197 x = fmod(x, y); 198 x = fmod(x, y);
198 } 199 }
199 return x; 200 return x;
200 } 201 }
201 202
202 #endif // _WIN64 203 #endif // _WIN64
203 204
205
206 static Mutex* transcendental_function_mutex = OS::CreateMutex();
207
208 #define TRANSCENDENTAL_FUNCTION(name, type) \
209 static TranscendentalFunction fast_##name##_function = NULL; \
210 double fast_##name(double x) { \
211 if (fast_##name##_function == NULL) { \
212 ScopedLock lock(transcendental_function_mutex); \
213 TranscendentalFunction temp = \
214 CreateTranscendentalFunction(type); \
215 MemoryBarrier(); \
216 fast_##name##_function = temp; \
217 } \
218 return (*fast_##name##_function)(x); \
219 }
220
221 TRANSCENDENTAL_FUNCTION(sin, TranscendentalCache::SIN)
222 TRANSCENDENTAL_FUNCTION(cos, TranscendentalCache::COS)
223 TRANSCENDENTAL_FUNCTION(tan, TranscendentalCache::TAN)
224 TRANSCENDENTAL_FUNCTION(log, TranscendentalCache::LOG)
225
226 #undef TRANSCENDENTAL_FUNCTION
227
228
204 // ---------------------------------------------------------------------------- 229 // ----------------------------------------------------------------------------
205 // The Time class represents time on win32. A timestamp is represented as 230 // The Time class represents time on win32. A timestamp is represented as
206 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript 231 // a 64-bit integer in 100 nanoseconds since January 1, 1601 (UTC). JavaScript
207 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC, 232 // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC,
208 // January 1, 1970. 233 // January 1, 1970.
209 234
210 class Time { 235 class Time {
211 public: 236 public:
212 // Constructors. 237 // Constructors.
213 Time(); 238 Time();
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 2094
2070 2095
2071 void Sampler::Stop() { 2096 void Sampler::Stop() {
2072 ASSERT(IsActive()); 2097 ASSERT(IsActive());
2073 SamplerThread::RemoveActiveSampler(this); 2098 SamplerThread::RemoveActiveSampler(this);
2074 SetActive(false); 2099 SetActive(false);
2075 } 2100 }
2076 2101
2077 2102
2078 } } // namespace v8::internal 2103 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-posix.cc ('k') | src/x64/code-stubs-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698