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

Side by Side Diff: src/codegen.cc

Issue 269823006: Move generated math methods from platform to codegen (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/codegen.h ('k') | src/platform.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "bootstrapper.h" 7 #include "bootstrapper.h"
8 #include "codegen.h" 8 #include "codegen.h"
9 #include "compiler.h" 9 #include "compiler.h"
10 #include "cpu-profiler.h" 10 #include "cpu-profiler.h"
11 #include "debug.h" 11 #include "debug.h"
12 #include "prettyprinter.h" 12 #include "prettyprinter.h"
13 #include "rewriter.h" 13 #include "rewriter.h"
14 #include "runtime.h" 14 #include "runtime.h"
15 #include "stub-cache.h" 15 #include "stub-cache.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20
21 #if defined(_WIN64)
22 typedef double (*ModuloFunction)(double, double);
23 static ModuloFunction modulo_function = NULL;
24 // Defined in codegen-x64.cc.
25 ModuloFunction CreateModuloFunction();
26
27 void init_modulo_function() {
28 modulo_function = CreateModuloFunction();
29 }
30
31
32 double modulo(double x, double y) {
33 // Note: here we rely on dependent reads being ordered. This is true
34 // on all architectures we currently support.
35 return (*modulo_function)(x, y);
36 }
37 #elif defined(_WIN32)
38
39 double modulo(double x, double y) {
40 // Workaround MS fmod bugs. ECMA-262 says:
41 // dividend is finite and divisor is an infinity => result equals dividend
42 // dividend is a zero and divisor is nonzero finite => result equals dividend
43 if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) &&
44 !(x == 0 && (y != 0 && std::isfinite(y)))) {
45 x = fmod(x, y);
46 }
47 return x;
48 }
49 #else // POSIX
50
51 double modulo(double x, double y) {
52 return std::fmod(x, y);
53 }
54 #endif // defined(_WIN64)
55
56
57 #define UNARY_MATH_FUNCTION(name, generator) \
58 static UnaryMathFunction fast_##name##_function = NULL; \
59 void init_fast_##name##_function() { \
60 fast_##name##_function = generator; \
61 } \
62 double fast_##name(double x) { \
63 return (*fast_##name##_function)(x); \
64 }
65
66 UNARY_MATH_FUNCTION(exp, CreateExpFunction())
67 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
68
69 #undef UNARY_MATH_FUNCTION
70
71
72 void lazily_initialize_fast_exp() {
73 if (fast_exp_function == NULL) {
74 init_fast_exp_function();
75 }
76 }
77
78
20 #define __ ACCESS_MASM(masm_) 79 #define __ ACCESS_MASM(masm_)
21 80
22 #ifdef DEBUG 81 #ifdef DEBUG
23 82
24 Comment::Comment(MacroAssembler* masm, const char* msg) 83 Comment::Comment(MacroAssembler* masm, const char* msg)
25 : masm_(masm), msg_(msg) { 84 : masm_(masm), msg_(msg) {
26 __ RecordComment(msg); 85 __ RecordComment(msg);
27 } 86 }
28 87
29 88
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ASSERT(result_size_ == 1 || result_size_ == 2); 276 ASSERT(result_size_ == 1 || result_size_ == 2);
218 #ifdef _WIN64 277 #ifdef _WIN64
219 return result | ((result_size_ == 1) ? 0 : 2); 278 return result | ((result_size_ == 1) ? 0 : 2);
220 #else 279 #else
221 return result; 280 return result;
222 #endif 281 #endif
223 } 282 }
224 283
225 284
226 } } // namespace v8::internal 285 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698