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

Unified Diff: src/compiler/js-builtin-reducer.cc

Issue 2125583002: [turbofan] Recognize fast path for Number.parseInt. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/compiler/js-builtin-reducer.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-builtin-reducer.cc
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc
index 75eccb72647cf5a75316841c70d1c5e1e01773b7..21f51c1661a88153b80eaf93a8b97b71044aa046 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -521,6 +521,23 @@ Reduction JSBuiltinReducer::ReduceMathTrunc(Node* node) {
return NoChange();
}
+// ES6 section 20.1.2.13 Number.parseInt ( string, radix )
+Reduction JSBuiltinReducer::ReduceNumberParseInt(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(type_cache_.kSafeInteger) ||
+ r.InputsMatchTwo(type_cache_.kSafeInteger,
+ type_cache_.kZeroOrUndefined) ||
+ r.InputsMatchTwo(type_cache_.kSafeInteger, type_cache_.kTenOrUndefined)) {
+ // Number.parseInt(a:safe-integer) -> NumberToInt32(a)
+ // Number.parseInt(a:safe-integer,b:#0\/undefined) -> NumberToInt32(a)
+ // Number.parseInt(a:safe-integer,b:#10\/undefined) -> NumberToInt32(a)
+ Node* input = r.GetJSCallInput(0);
+ Node* value = graph()->NewNode(simplified()->NumberToInt32(), input);
+ return Replace(value);
+ }
+ return NoChange();
+}
+
// ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) {
JSCallReduction r(node);
@@ -639,6 +656,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
case kMathTrunc:
reduction = ReduceMathTrunc(node);
break;
+ case kNumberParseInt:
+ reduction = ReduceNumberParseInt(node);
+ break;
case kStringFromCharCode:
reduction = ReduceStringFromCharCode(node);
break;
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698