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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2063073004: [turbofan] Lower to NumberAdd / NumberSubtract if type feedback is Number. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_UnboxHoleyDouble
Patch Set: REBASE and fix. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 6991363a3e297f0930a705eca9e72e66aa5dafd2..572a0aed2e501c32eba94fb02f69fb94059b30d1 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -404,6 +404,14 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
JSBinopReduction r(this, node);
BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
+ if (feedback == BinaryOperationHints::kNumberOrUndefined &&
+ r.BothInputsAre(Type::PlainPrimitive()) &&
+ r.NeitherInputCanBe(Type::StringOrReceiver())) {
+ // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y))
+ Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
+ r.ConvertInputsToNumber(frame_state);
+ return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
+ }
if (feedback != BinaryOperationHints::kAny) {
// Lower to the optimistic number binop.
return r.ChangeToSpeculativeOperator(
@@ -462,6 +470,15 @@ Reduction JSTypedLowering::ReduceJSSubtract(Node* node) {
if (flags() & kDisableBinaryOpReduction) return NoChange();
JSBinopReduction r(this, node);
BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
+ if (feedback == BinaryOperationHints::kNumberOrUndefined &&
+ r.BothInputsAre(Type::PlainPrimitive())) {
+ // JSSubtract(x:plain-primitive, y:plain-primitive)
+ // => NumberSubtract(ToNumber(x), ToNumber(y))
+ Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
+ r.ConvertInputsToNumber(frame_state);
+ return r.ChangeToPureOperator(simplified()->NumberSubtract(),
+ Type::Number());
+ }
if (feedback != BinaryOperationHints::kAny) {
// Lower to the optimistic number binop.
return r.ChangeToSpeculativeOperator(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698