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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 2074903002: [turbofan] Numeric type feedback for mul, div and mod. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler/opcodes.h » ('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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 jsgraph()->HeapConstant(callable.code())); 466 jsgraph()->HeapConstant(callable.code()));
467 NodeProperties::ChangeOp(node, common()->Call(desc)); 467 NodeProperties::ChangeOp(node, common()->Call(desc));
468 return Changed(node); 468 return Changed(node);
469 } 469 }
470 return NoChange(); 470 return NoChange();
471 } 471 }
472 472
473 473
474 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { 474 Reduction JSTypedLowering::ReduceJSModulus(Node* node) {
475 if (flags() & kDisableBinaryOpReduction) return NoChange(); 475 if (flags() & kDisableBinaryOpReduction) return NoChange();
476
477 JSBinopReduction r(this, node); 476 JSBinopReduction r(this, node);
478 if (r.BothInputsAre(Type::Number())) { 477 if (r.BothInputsAre(Type::Number())) {
479 // JSModulus(x:number, x:number) => NumberModulus(x, y) 478 // JSModulus(x:number, x:number) => NumberModulus(x, y)
480 return r.ChangeToPureOperator(simplified()->NumberModulus(), 479 return r.ChangeToPureOperator(simplified()->NumberModulus(),
481 Type::Number()); 480 Type::Number());
482 } 481 }
482 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback();
483 if (feedback != BinaryOperationHints::kAny) {
484 return r.ChangeToSpeculativeOperator(
485 simplified()->SpeculativeNumberModulus(feedback), Type::Number());
486 }
483 return NoChange(); 487 return NoChange();
484 } 488 }
485 489
486 Reduction JSTypedLowering::ReduceJSSubtract(Node* node) { 490 Reduction JSTypedLowering::ReduceJSSubtract(Node* node) {
487 if (flags() & kDisableBinaryOpReduction) return NoChange(); 491 if (flags() & kDisableBinaryOpReduction) return NoChange();
488 JSBinopReduction r(this, node); 492 JSBinopReduction r(this, node);
489 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback(); 493 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback();
490 if (feedback == BinaryOperationHints::kNumberOrUndefined && 494 if (feedback == BinaryOperationHints::kNumberOrUndefined &&
491 r.BothInputsAre(Type::PlainPrimitive())) { 495 r.BothInputsAre(Type::PlainPrimitive())) {
492 // JSSubtract(x:plain-primitive, y:plain-primitive) 496 // JSSubtract(x:plain-primitive, y:plain-primitive)
493 // => NumberSubtract(ToNumber(x), ToNumber(y)) 497 // => NumberSubtract(ToNumber(x), ToNumber(y))
494 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 498 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
495 r.ConvertInputsToNumber(frame_state); 499 r.ConvertInputsToNumber(frame_state);
496 return r.ChangeToPureOperator(simplified()->NumberSubtract(), 500 return r.ChangeToPureOperator(simplified()->NumberSubtract(),
497 Type::Number()); 501 Type::Number());
498 } 502 }
499 if (feedback != BinaryOperationHints::kAny) { 503 if (feedback != BinaryOperationHints::kAny) {
500 // Lower to the optimistic number binop. 504 // Lower to the optimistic number binop.
501 return r.ChangeToSpeculativeOperator( 505 return r.ChangeToSpeculativeOperator(
502 simplified()->SpeculativeNumberSubtract(feedback), Type::Number()); 506 simplified()->SpeculativeNumberSubtract(feedback), Type::Number());
503 } 507 }
504 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 508 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
505 r.ConvertInputsToNumber(frame_state); 509 r.ConvertInputsToNumber(frame_state);
506 return r.ChangeToPureOperator(simplified()->NumberSubtract(), Type::Number()); 510 return r.ChangeToPureOperator(simplified()->NumberSubtract(), Type::Number());
507 } 511 }
508 512
509 Reduction JSTypedLowering::ReduceJSMultiply(Node* node) { 513 Reduction JSTypedLowering::ReduceJSMultiply(Node* node) {
510 if (flags() & kDisableBinaryOpReduction) return NoChange(); 514 if (flags() & kDisableBinaryOpReduction) return NoChange();
511 JSBinopReduction r(this, node); 515 JSBinopReduction r(this, node);
516
517 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback();
518 if (feedback != BinaryOperationHints::kAny) {
519 return r.ChangeToSpeculativeOperator(
520 simplified()->SpeculativeNumberMultiply(feedback), Type::Number());
521 }
522
512 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 523 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
513 r.ConvertInputsToNumber(frame_state); 524 r.ConvertInputsToNumber(frame_state);
514 return r.ChangeToPureOperator(simplified()->NumberMultiply(), Type::Number()); 525 return r.ChangeToPureOperator(simplified()->NumberMultiply(), Type::Number());
515 } 526 }
516 527
517 Reduction JSTypedLowering::ReduceJSDivide(Node* node) { 528 Reduction JSTypedLowering::ReduceJSDivide(Node* node) {
518 if (flags() & kDisableBinaryOpReduction) return NoChange(); 529 if (flags() & kDisableBinaryOpReduction) return NoChange();
519 JSBinopReduction r(this, node); 530 JSBinopReduction r(this, node);
531 BinaryOperationHints::Hint feedback = r.GetNumberBinaryOperationFeedback();
532 if (feedback != BinaryOperationHints::kAny) {
533 return r.ChangeToSpeculativeOperator(
534 simplified()->SpeculativeNumberDivide(feedback), Type::Number());
535 }
520 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 536 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
521 r.ConvertInputsToNumber(frame_state); 537 r.ConvertInputsToNumber(frame_state);
522 return r.ChangeToPureOperator(simplified()->NumberDivide(), Type::Number()); 538 return r.ChangeToPureOperator(simplified()->NumberDivide(), Type::Number());
523 } 539 }
524 540
525 541
526 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) { 542 Reduction JSTypedLowering::ReduceInt32Binop(Node* node, const Operator* intOp) {
527 if (flags() & kDisableBinaryOpReduction) return NoChange(); 543 if (flags() & kDisableBinaryOpReduction) return NoChange();
528 544
529 JSBinopReduction r(this, node); 545 JSBinopReduction r(this, node);
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 } 2007 }
1992 2008
1993 2009
1994 CompilationDependencies* JSTypedLowering::dependencies() const { 2010 CompilationDependencies* JSTypedLowering::dependencies() const {
1995 return dependencies_; 2011 return dependencies_;
1996 } 2012 }
1997 2013
1998 } // namespace compiler 2014 } // namespace compiler
1999 } // namespace internal 2015 } // namespace internal
2000 } // namespace v8 2016 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698