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

Side by Side Diff: src/compiler/common-operator.cc

Issue 2266743002: [turbofan] Cache the most common Deoptimize operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 #define CACHED_MERGE_LIST(V) \ 267 #define CACHED_MERGE_LIST(V) \
268 V(1) \ 268 V(1) \
269 V(2) \ 269 V(2) \
270 V(3) \ 270 V(3) \
271 V(4) \ 271 V(4) \
272 V(5) \ 272 V(5) \
273 V(6) \ 273 V(6) \
274 V(7) \ 274 V(7) \
275 V(8) 275 V(8)
276 276
277 #define CACHED_DEOPTIMIZE_LIST(V) \
278 V(Eager, MinusZero) \
279 V(Eager, NoReason) \
280 V(Eager, WrongMap) \
281 V(Soft, InsufficientTypeFeedbackForGenericKeyedAccess) \
282 V(Soft, InsufficientTypeFeedbackForGenericNamedAccess)
283
284 #define CACHED_DEOPTIMIZE_IF_LIST(V) \
285 V(DivisionByZero) \
286 V(Hole) \
287 V(MinusZero) \
288 V(Overflow) \
289 V(Smi)
290
291 #define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \
292 V(LostPrecision) \
293 V(LostPrecisionOrNaN) \
294 V(NoReason) \
295 V(NotAHeapNumber) \
296 V(NotAHeapNumberUndefinedBoolean) \
297 V(NotASmi) \
298 V(OutOfBounds) \
299 V(WrongInstanceType) \
300 V(WrongMap)
277 301
278 #define CACHED_PARAMETER_LIST(V) \ 302 #define CACHED_PARAMETER_LIST(V) \
279 V(0) \ 303 V(0) \
280 V(1) \ 304 V(1) \
281 V(2) \ 305 V(2) \
282 V(3) \ 306 V(3) \
283 V(4) \ 307 V(4) \
284 V(5) \ 308 V(5) \
285 V(6) 309 V(6)
286 310
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 : Operator( // -- 443 : Operator( // --
420 IrOpcode::kMerge, Operator::kKontrol, // opcode 444 IrOpcode::kMerge, Operator::kKontrol, // opcode
421 "Merge", // name 445 "Merge", // name
422 0, 0, kInputCount, 0, 0, 1) {} // counts 446 0, 0, kInputCount, 0, 0, 1) {} // counts
423 }; 447 };
424 #define CACHED_MERGE(input_count) \ 448 #define CACHED_MERGE(input_count) \
425 MergeOperator<input_count> kMerge##input_count##Operator; 449 MergeOperator<input_count> kMerge##input_count##Operator;
426 CACHED_MERGE_LIST(CACHED_MERGE) 450 CACHED_MERGE_LIST(CACHED_MERGE)
427 #undef CACHED_MERGE 451 #undef CACHED_MERGE
428 452
453 template <DeoptimizeKind kKind, DeoptimizeReason kReason>
454 struct DeoptimizeOperator final : public Operator1<DeoptimizeParameters> {
455 DeoptimizeOperator()
456 : Operator1<DeoptimizeParameters>( // --
457 IrOpcode::kDeoptimize, // opcode
458 Operator::kFoldable | Operator::kNoThrow, // properties
459 "Deoptimize", // name
460 1, 1, 1, 0, 0, 1, // counts
461 DeoptimizeParameters(kKind, kReason)) {} // parameter
462 };
463 #define CACHED_DEOPTIMIZE(Kind, Reason) \
464 DeoptimizeOperator<DeoptimizeKind::k##Kind, DeoptimizeReason::k##Reason> \
465 kDeoptimize##Kind##Reason##Operator;
466 CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
467 #undef CACHED_DEOPTIMIZE
468
469 template <DeoptimizeReason kReason>
470 struct DeoptimizeIfOperator final : public Operator1<DeoptimizeReason> {
471 DeoptimizeIfOperator()
472 : Operator1<DeoptimizeReason>( // --
473 IrOpcode::kDeoptimizeIf, // opcode
474 Operator::kFoldable | Operator::kNoThrow, // properties
475 "DeoptimizeIf", // name
476 2, 1, 1, 0, 1, 1, // counts
477 kReason) {} // parameter
478 };
479 #define CACHED_DEOPTIMIZE_IF(Reason) \
480 DeoptimizeIfOperator<DeoptimizeReason::k##Reason> \
481 kDeoptimizeIf##Reason##Operator;
482 CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
483 #undef CACHED_DEOPTIMIZE_IF
484
485 template <DeoptimizeReason kReason>
486 struct DeoptimizeUnlessOperator final : public Operator1<DeoptimizeReason> {
487 DeoptimizeUnlessOperator()
488 : Operator1<DeoptimizeReason>( // --
489 IrOpcode::kDeoptimizeUnless, // opcode
490 Operator::kFoldable | Operator::kNoThrow, // properties
491 "DeoptimizeUnless", // name
492 2, 1, 1, 0, 1, 1, // counts
493 kReason) {} // parameter
494 };
495 #define CACHED_DEOPTIMIZE_UNLESS(Reason) \
496 DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \
497 kDeoptimizeUnless##Reason##Operator;
498 CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
499 #undef CACHED_DEOPTIMIZE_UNLESS
500
429 template <MachineRepresentation kRep, int kInputCount> 501 template <MachineRepresentation kRep, int kInputCount>
430 struct PhiOperator final : public Operator1<MachineRepresentation> { 502 struct PhiOperator final : public Operator1<MachineRepresentation> {
431 PhiOperator() 503 PhiOperator()
432 : Operator1<MachineRepresentation>( //-- 504 : Operator1<MachineRepresentation>( //--
433 IrOpcode::kPhi, Operator::kPure, // opcode 505 IrOpcode::kPhi, Operator::kPure, // opcode
434 "Phi", // name 506 "Phi", // name
435 kInputCount, 0, 1, 1, 0, 0, // counts 507 kInputCount, 0, 1, 1, 0, 0, // counts
436 kRep) {} // parameter 508 kRep) {} // parameter
437 }; 509 };
438 #define CACHED_PHI(rep, input_count) \ 510 #define CACHED_PHI(rep, input_count) \
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 return &cache_.kBranchTrueOperator; 634 return &cache_.kBranchTrueOperator;
563 case BranchHint::kFalse: 635 case BranchHint::kFalse:
564 return &cache_.kBranchFalseOperator; 636 return &cache_.kBranchFalseOperator;
565 } 637 }
566 UNREACHABLE(); 638 UNREACHABLE();
567 return nullptr; 639 return nullptr;
568 } 640 }
569 641
570 const Operator* CommonOperatorBuilder::Deoptimize(DeoptimizeKind kind, 642 const Operator* CommonOperatorBuilder::Deoptimize(DeoptimizeKind kind,
571 DeoptimizeReason reason) { 643 DeoptimizeReason reason) {
572 // TODO(turbofan): Cache the most common versions of this. 644 #define CACHED_DEOPTIMIZE(Kind, Reason) \
645 if (kind == DeoptimizeKind::k##Kind && \
646 reason == DeoptimizeReason::k##Reason) { \
647 return &cache_.kDeoptimize##Kind##Reason##Operator; \
648 }
649 CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
650 #undef CACHED_DEOPTIMIZE
651 // Uncached
573 DeoptimizeParameters parameter(kind, reason); 652 DeoptimizeParameters parameter(kind, reason);
574 return new (zone()) Operator1<DeoptimizeParameters>( // -- 653 return new (zone()) Operator1<DeoptimizeParameters>( // --
575 IrOpcode::kDeoptimize, // opcodes 654 IrOpcode::kDeoptimize, // opcodes
576 Operator::kFoldable | Operator::kNoThrow, // properties 655 Operator::kFoldable | Operator::kNoThrow, // properties
577 "Deoptimize", // name 656 "Deoptimize", // name
578 1, 1, 1, 0, 0, 1, // counts 657 1, 1, 1, 0, 0, 1, // counts
579 parameter); // parameter 658 parameter); // parameter
580 } 659 }
581 660
582 const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeReason reason) { 661 const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeReason reason) {
583 // TODO(turbofan): Cache the most common versions of this. 662 switch (reason) {
663 #define CACHED_DEOPTIMIZE_IF(Reason) \
664 case DeoptimizeReason::k##Reason: \
665 return &cache_.kDeoptimizeIf##Reason##Operator;
666 CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
667 #undef CACHED_DEOPTIMIZE_IF
668 default:
669 break;
670 }
671 // Uncached
584 return new (zone()) Operator1<DeoptimizeReason>( // -- 672 return new (zone()) Operator1<DeoptimizeReason>( // --
585 IrOpcode::kDeoptimizeIf, // opcode 673 IrOpcode::kDeoptimizeIf, // opcode
586 Operator::kFoldable | Operator::kNoThrow, // properties 674 Operator::kFoldable | Operator::kNoThrow, // properties
587 "DeoptimizeIf", // name 675 "DeoptimizeIf", // name
588 2, 1, 1, 0, 1, 1, // counts 676 2, 1, 1, 0, 1, 1, // counts
589 reason); // parameter 677 reason); // parameter
590 } 678 }
591 679
592 const Operator* CommonOperatorBuilder::DeoptimizeUnless( 680 const Operator* CommonOperatorBuilder::DeoptimizeUnless(
593 DeoptimizeReason reason) { 681 DeoptimizeReason reason) {
594 // TODO(turbofan): Cache the most common versions of this. 682 switch (reason) {
683 #define CACHED_DEOPTIMIZE_UNLESS(Reason) \
684 case DeoptimizeReason::k##Reason: \
685 return &cache_.kDeoptimizeUnless##Reason##Operator;
686 CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
687 #undef CACHED_DEOPTIMIZE_UNLESS
688 default:
689 break;
690 }
691 // Uncached
595 return new (zone()) Operator1<DeoptimizeReason>( // -- 692 return new (zone()) Operator1<DeoptimizeReason>( // --
596 IrOpcode::kDeoptimizeUnless, // opcode 693 IrOpcode::kDeoptimizeUnless, // opcode
597 Operator::kFoldable | Operator::kNoThrow, // properties 694 Operator::kFoldable | Operator::kNoThrow, // properties
598 "DeoptimizeUnless", // name 695 "DeoptimizeUnless", // name
599 2, 1, 1, 0, 1, 1, // counts 696 2, 1, 1, 0, 1, 1, // counts
600 reason); // parameter 697 reason); // parameter
601 } 698 }
602 699
603 700
604 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) { 701 const Operator* CommonOperatorBuilder::Switch(size_t control_output_count) {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 CommonOperatorBuilder::CreateFrameStateFunctionInfo( 1085 CommonOperatorBuilder::CreateFrameStateFunctionInfo(
989 FrameStateType type, int parameter_count, int local_count, 1086 FrameStateType type, int parameter_count, int local_count,
990 Handle<SharedFunctionInfo> shared_info) { 1087 Handle<SharedFunctionInfo> shared_info) {
991 return new (zone()->New(sizeof(FrameStateFunctionInfo))) 1088 return new (zone()->New(sizeof(FrameStateFunctionInfo)))
992 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info); 1089 FrameStateFunctionInfo(type, parameter_count, local_count, shared_info);
993 } 1090 }
994 1091
995 } // namespace compiler 1092 } // namespace compiler
996 } // namespace internal 1093 } // namespace internal
997 } // namespace v8 1094 } // namespace v8
OLDNEW
« 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