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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-numbers.cc
diff --git a/src/runtime/runtime-numbers.cc b/src/runtime/runtime-numbers.cc
index 9f43c0acfceeeff5bfec4d3fca72ebbf41830f2d..1c8c91d126a6356f56335fd9b6301100b635ae09 100644
--- a/src/runtime/runtime-numbers.cc
+++ b/src/runtime/runtime-numbers.cc
@@ -74,10 +74,21 @@ RUNTIME_FUNCTION(Runtime_StringParseFloat) {
RUNTIME_FUNCTION(Runtime_NumberToString) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0);
-
- return *isolate->factory()->NumberToString(number);
+ DCHECK_LE(1, args.length());
+ DCHECK_GE(2, args.length());
+ CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 0);
+ if (args.length() == 1) return *isolate->factory()->NumberToString(value);
+ double value_number = value->Number();
+ CONVERT_INT32_ARG_CHECKED(radix, 1);
+ if (std::isnan(value_number)) return isolate->heap()->nan_string();
+ if (std::isinf(value_number)) {
+ return (value_number < 0.0) ? isolate->heap()->minus_infinity_string()
+ : isolate->heap()->infinity_string();
+ }
+ char* const str = DoubleToRadixCString(value_number, radix);
+ Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
+ DeleteArray(str);
+ return *result;
}
« 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