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

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

Issue 9690010: Ensure consistency of Math.sqrt on Intel platforms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed suggestions. 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 121
122 // ---------------------------------------------------------------------------- 122 // ----------------------------------------------------------------------------
123 // Math functions 123 // Math functions
124 124
125 double modulo(double x, double y) { 125 double modulo(double x, double y) {
126 return fmod(x, y); 126 return fmod(x, y);
127 } 127 }
128 128
129 129
130 static Mutex* transcendental_function_mutex = OS::CreateMutex(); 130 static Mutex* math_function_mutex = OS::CreateMutex();
131 131
132 #define TRANSCENDENTAL_FUNCTION(name, type) \ 132 #define UNARY_MATH_FUNCTION(name, generator) \
133 static TranscendentalFunction fast_##name##_function = NULL; \ 133 static UnaryMathFunction fast_##name##_function = NULL; \
134 double fast_##name(double x) { \ 134 double fast_##name(double x) { \
135 if (fast_##name##_function == NULL) { \ 135 if (fast_##name##_function == NULL) { \
136 ScopedLock lock(transcendental_function_mutex); \ 136 ScopedLock lock(math_function_mutex); \
137 TranscendentalFunction temp = \ 137 UnaryMathFunction temp = generator; \
138 CreateTranscendentalFunction(type); \ 138 MemoryBarrier(); \
139 MemoryBarrier(); \ 139 fast_##name##_function = temp; \
140 fast_##name##_function = temp; \ 140 } \
141 } \ 141 return (*fast_##name##_function)(x); \
142 return (*fast_##name##_function)(x); \
143 } 142 }
144 143
145 TRANSCENDENTAL_FUNCTION(sin, TranscendentalCache::SIN) 144 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN))
146 TRANSCENDENTAL_FUNCTION(cos, TranscendentalCache::COS) 145 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS))
147 TRANSCENDENTAL_FUNCTION(tan, TranscendentalCache::TAN) 146 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN))
148 TRANSCENDENTAL_FUNCTION(log, TranscendentalCache::LOG) 147 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG))
148 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
149 149
150 #undef TRANSCENDENTAL_FUNCTION 150 #undef MATH_FUNCTION
151 151
152 152
153 double OS::nan_value() { 153 double OS::nan_value() {
154 // NAN from math.h is defined in C99 and not in POSIX. 154 // NAN from math.h is defined in C99 and not in POSIX.
155 return NAN; 155 return NAN;
156 } 156 }
157 157
158 158
159 // ---------------------------------------------------------------------------- 159 // ----------------------------------------------------------------------------
160 // POSIX date/time support. 160 // POSIX date/time support.
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return ntohl(value); 515 return ntohl(value);
516 } 516 }
517 517
518 518
519 Socket* OS::CreateSocket() { 519 Socket* OS::CreateSocket() {
520 return new POSIXSocket(); 520 return new POSIXSocket();
521 } 521 }
522 522
523 523
524 } } // namespace v8::internal 524 } } // namespace v8::internal
OLDNEW
« src/ia32/codegen-ia32.cc ('K') | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698