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

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

Issue 922623002: [turbofan] Avoid ToNumber conversions if they could deoptimize. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment tweaks Created 5 years, 10 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 | test/mjsunit/compiler/regress-to-number-binop-deopt.js » ('j') | 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 3c79ea1e1d7d2d44163410d9e6e2e58ce1bc2b02..282848064a4a8b0a8338886dab61055f9e613f9a 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -272,13 +272,15 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
Reduction JSTypedLowering::ReduceJSBitwiseOr(Node* node) {
JSBinopReduction r(this, node);
- if (r.BothInputsAre(Type::Primitive()) || r.OneInputIs(zero_range_)) {
- // TODO(jarin): Propagate frame state input from non-primitive input node to
- // JSToNumber node.
+
+ // We can only reduce to Word32Or if we are sure the to-number conversions
+ // cannot lazily deoptimize.
+ bool shortcut_or_zero =
+ !FLAG_turbo_deoptimization && r.OneInputIs(zero_range_);
+ if (r.BothInputsAre(Type::Primitive()) || shortcut_or_zero) {
// TODO(titzer): some Smi bitwise operations don't really require going
// all the way to int32, which can save tagging/untagging for some
- // operations
- // on some platforms.
+ // operations on some platforms.
// TODO(turbofan): make this heuristic configurable for code size.
r.ConvertInputsToUI32(kSigned, kSigned);
return r.ChangeToPureOperator(machine()->Word32Or(), Type::Integral32());
@@ -289,9 +291,13 @@ Reduction JSTypedLowering::ReduceJSBitwiseOr(Node* node) {
Reduction JSTypedLowering::ReduceJSMultiply(Node* node) {
JSBinopReduction r(this, node);
- if (r.BothInputsAre(Type::Primitive()) || r.OneInputIs(one_range_)) {
- // TODO(jarin): Propagate frame state input from non-primitive input node to
- // JSToNumber node.
+
+ // We can only reduce to NumberMultiply if we are sure the to-number
+ // conversions cannot lazily deoptimize.
+ bool shortcut_multiply_one =
+ !FLAG_turbo_deoptimization && r.OneInputIs(one_range_);
+
+ if (r.BothInputsAre(Type::Primitive()) || shortcut_multiply_one) {
r.ConvertInputsToNumber();
return r.ChangeToPureOperator(simplified()->NumberMultiply(),
Type::Number());
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-to-number-binop-deopt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698