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

Side by Side Diff: src/runtime/runtime-maths.cc

Issue 2065503002: [builtins] Introduce proper Float64Atan and Float64Atan2 operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [WIP] Fix GCC/Win32. Created 4 years, 6 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
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/compiler/test-run-machops.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DCHECK(args.length() == 2); 52 DCHECK(args.length() == 2);
53 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 53 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
54 CONVERT_ARG_CHECKED(JSTypedArray, result, 1); 54 CONVERT_ARG_CHECKED(JSTypedArray, result, 1);
55 CHECK(result->byte_length() == Smi::FromInt(2 * sizeof(double))); 55 CHECK(result->byte_length() == Smi::FromInt(2 * sizeof(double)));
56 FixedFloat64Array* array = FixedFloat64Array::cast(result->elements()); 56 FixedFloat64Array* array = FixedFloat64Array::cast(result->elements());
57 double* y = static_cast<double*>(array->DataPtr()); 57 double* y = static_cast<double*>(array->DataPtr());
58 return Smi::FromInt(fdlibm::rempio2(x, y)); 58 return Smi::FromInt(fdlibm::rempio2(x, y));
59 } 59 }
60 60
61 61
62 static const double kPiDividedBy4 = 0.78539816339744830962;
63
64
65 RUNTIME_FUNCTION(Runtime_MathAtan2) {
66 HandleScope scope(isolate);
67 DCHECK(args.length() == 2);
68 isolate->counters()->math_atan2_runtime()->Increment();
69 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
70 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
71 double result;
72 if (std::isinf(x) && std::isinf(y)) {
73 // Make sure that the result in case of two infinite arguments
74 // is a multiple of Pi / 4. The sign of the result is determined
75 // by the first argument (x) and the sign of the second argument
76 // determines the multiplier: one or three.
77 int multiplier = (x < 0) ? -1 : 1;
78 if (y < 0) multiplier *= 3;
79 result = multiplier * kPiDividedBy4;
80 } else {
81 result = std::atan2(x, y);
82 }
83 return *isolate->factory()->NewNumber(result);
84 }
85
86
87 RUNTIME_FUNCTION(Runtime_MathExpRT) { 62 RUNTIME_FUNCTION(Runtime_MathExpRT) {
88 HandleScope scope(isolate); 63 HandleScope scope(isolate);
89 DCHECK(args.length() == 1); 64 DCHECK(args.length() == 1);
90 isolate->counters()->math_exp_runtime()->Increment(); 65 isolate->counters()->math_exp_runtime()->Increment();
91 66
92 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 67 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
93 lazily_initialize_fast_exp(isolate); 68 lazily_initialize_fast_exp(isolate);
94 return *isolate->factory()->NewNumber(fast_exp(x, isolate)); 69 return *isolate->factory()->NewNumber(fast_exp(x, isolate));
95 } 70 }
96 71
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 base::RandomNumberGenerator::XorShift128(&state0, &state1); 162 base::RandomNumberGenerator::XorShift128(&state0, &state1);
188 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); 163 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1);
189 } 164 }
190 // Persist current state. 165 // Persist current state.
191 array[kState0Offset] = uint64_to_double(state0); 166 array[kState0Offset] = uint64_to_double(state0);
192 array[kState1Offset] = uint64_to_double(state1); 167 array[kState1Offset] = uint64_to_double(state1);
193 return *typed_array; 168 return *typed_array;
194 } 169 }
195 } // namespace internal 170 } // namespace internal
196 } // namespace v8 171 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698