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

Side by Side 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 unified diff | 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 »
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/compiler/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-typed-lowering.h" 7 #include "src/compiler/js-typed-lowering.h"
8 #include "src/compiler/node-aux-data-inl.h" 8 #include "src/compiler/node-aux-data-inl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 r.ConvertInputsToString(); 265 r.ConvertInputsToString();
266 return r.ChangeToPureOperator(simplified()->StringAdd()); 266 return r.ChangeToPureOperator(simplified()->StringAdd());
267 } 267 }
268 #endif 268 #endif
269 return NoChange(); 269 return NoChange();
270 } 270 }
271 271
272 272
273 Reduction JSTypedLowering::ReduceJSBitwiseOr(Node* node) { 273 Reduction JSTypedLowering::ReduceJSBitwiseOr(Node* node) {
274 JSBinopReduction r(this, node); 274 JSBinopReduction r(this, node);
275 if (r.BothInputsAre(Type::Primitive()) || r.OneInputIs(zero_range_)) { 275
276 // TODO(jarin): Propagate frame state input from non-primitive input node to 276 // We can only reduce to Word32Or if we are sure the to-number conversions
277 // JSToNumber node. 277 // cannot lazily deoptimize.
278 bool shortcut_or_zero =
279 !FLAG_turbo_deoptimization && r.OneInputIs(zero_range_);
280 if (r.BothInputsAre(Type::Primitive()) || shortcut_or_zero) {
278 // TODO(titzer): some Smi bitwise operations don't really require going 281 // TODO(titzer): some Smi bitwise operations don't really require going
279 // all the way to int32, which can save tagging/untagging for some 282 // all the way to int32, which can save tagging/untagging for some
280 // operations 283 // operations on some platforms.
281 // on some platforms.
282 // TODO(turbofan): make this heuristic configurable for code size. 284 // TODO(turbofan): make this heuristic configurable for code size.
283 r.ConvertInputsToUI32(kSigned, kSigned); 285 r.ConvertInputsToUI32(kSigned, kSigned);
284 return r.ChangeToPureOperator(machine()->Word32Or(), Type::Integral32()); 286 return r.ChangeToPureOperator(machine()->Word32Or(), Type::Integral32());
285 } 287 }
286 return NoChange(); 288 return NoChange();
287 } 289 }
288 290
289 291
290 Reduction JSTypedLowering::ReduceJSMultiply(Node* node) { 292 Reduction JSTypedLowering::ReduceJSMultiply(Node* node) {
291 JSBinopReduction r(this, node); 293 JSBinopReduction r(this, node);
292 if (r.BothInputsAre(Type::Primitive()) || r.OneInputIs(one_range_)) { 294
293 // TODO(jarin): Propagate frame state input from non-primitive input node to 295 // We can only reduce to NumberMultiply if we are sure the to-number
294 // JSToNumber node. 296 // conversions cannot lazily deoptimize.
297 bool shortcut_multiply_one =
298 !FLAG_turbo_deoptimization && r.OneInputIs(one_range_);
299
300 if (r.BothInputsAre(Type::Primitive()) || shortcut_multiply_one) {
295 r.ConvertInputsToNumber(); 301 r.ConvertInputsToNumber();
296 return r.ChangeToPureOperator(simplified()->NumberMultiply(), 302 return r.ChangeToPureOperator(simplified()->NumberMultiply(),
297 Type::Number()); 303 Type::Number());
298 } 304 }
299 // TODO(turbofan): relax/remove the effects of this operator in other cases. 305 // TODO(turbofan): relax/remove the effects of this operator in other cases.
300 return NoChange(); 306 return NoChange();
301 } 307 }
302 308
303 309
304 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, 310 Reduction JSTypedLowering::ReduceNumberBinop(Node* node,
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 } 1015 }
1010 1016
1011 1017
1012 MachineOperatorBuilder* JSTypedLowering::machine() const { 1018 MachineOperatorBuilder* JSTypedLowering::machine() const {
1013 return jsgraph()->machine(); 1019 return jsgraph()->machine();
1014 } 1020 }
1015 1021
1016 } // namespace compiler 1022 } // namespace compiler
1017 } // namespace internal 1023 } // namespace internal
1018 } // namespace v8 1024 } // namespace v8
OLDNEW
« 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