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

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

Issue 2227463003: [WIP] NumberToString operator in TF. Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_BuiltinTypingRules
Patch Set: Created 4 years, 4 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') | no next file » | 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/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 double value = 67 double value =
68 StringToDouble(isolate->unicode_cache(), subject, ALLOW_TRAILING_JUNK, 68 StringToDouble(isolate->unicode_cache(), subject, ALLOW_TRAILING_JUNK,
69 std::numeric_limits<double>::quiet_NaN()); 69 std::numeric_limits<double>::quiet_NaN());
70 70
71 return *isolate->factory()->NewNumber(value); 71 return *isolate->factory()->NewNumber(value);
72 } 72 }
73 73
74 74
75 RUNTIME_FUNCTION(Runtime_NumberToString) { 75 RUNTIME_FUNCTION(Runtime_NumberToString) {
76 HandleScope scope(isolate); 76 HandleScope scope(isolate);
77 DCHECK(args.length() == 1); 77 DCHECK_LE(1, args.length());
78 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); 78 DCHECK_GE(2, args.length());
79 79 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 0);
80 return *isolate->factory()->NumberToString(number); 80 if (args.length() == 1) return *isolate->factory()->NumberToString(value);
81 double value_number = value->Number();
82 CONVERT_INT32_ARG_CHECKED(radix, 1);
83 if (std::isnan(value_number)) return isolate->heap()->nan_string();
84 if (std::isinf(value_number)) {
85 return (value_number < 0.0) ? isolate->heap()->minus_infinity_string()
86 : isolate->heap()->infinity_string();
87 }
88 char* const str = DoubleToRadixCString(value_number, radix);
89 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
90 DeleteArray(str);
91 return *result;
81 } 92 }
82 93
83 94
84 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { 95 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) {
85 HandleScope scope(isolate); 96 HandleScope scope(isolate);
86 DCHECK(args.length() == 1); 97 DCHECK(args.length() == 1);
87 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); 98 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0);
88 99
89 return *isolate->factory()->NumberToString(number, false); 100 return *isolate->factory()->NumberToString(number, false);
90 } 101 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 228
218 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) { 229 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) {
219 HandleScope scope(isolate); 230 HandleScope scope(isolate);
220 DCHECK(args.length() == 0); 231 DCHECK(args.length() == 0);
221 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32); 232 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32);
222 } 233 }
223 234
224 235
225 } // namespace internal 236 } // namespace internal
226 } // namespace v8 237 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698