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

Unified 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 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/common-operator.cc
diff --git a/src/compiler/common-operator.cc b/src/compiler/common-operator.cc
index 321528c46425cb830e15fc7fddac02ef4a4e4887..f732375a68cb52c1a09d90a9ff50126779115bc5 100644
--- a/src/compiler/common-operator.cc
+++ b/src/compiler/common-operator.cc
@@ -274,6 +274,30 @@ std::ostream& operator<<(std::ostream& os,
V(7) \
V(8)
+#define CACHED_DEOPTIMIZE_LIST(V) \
+ V(Eager, MinusZero) \
+ V(Eager, NoReason) \
+ V(Eager, WrongMap) \
+ V(Soft, InsufficientTypeFeedbackForGenericKeyedAccess) \
+ V(Soft, InsufficientTypeFeedbackForGenericNamedAccess)
+
+#define CACHED_DEOPTIMIZE_IF_LIST(V) \
+ V(DivisionByZero) \
+ V(Hole) \
+ V(MinusZero) \
+ V(Overflow) \
+ V(Smi)
+
+#define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \
+ V(LostPrecision) \
+ V(LostPrecisionOrNaN) \
+ V(NoReason) \
+ V(NotAHeapNumber) \
+ V(NotAHeapNumberUndefinedBoolean) \
+ V(NotASmi) \
+ V(OutOfBounds) \
+ V(WrongInstanceType) \
+ V(WrongMap)
#define CACHED_PARAMETER_LIST(V) \
V(0) \
@@ -426,6 +450,54 @@ struct CommonOperatorGlobalCache final {
CACHED_MERGE_LIST(CACHED_MERGE)
#undef CACHED_MERGE
+ template <DeoptimizeKind kKind, DeoptimizeReason kReason>
+ struct DeoptimizeOperator final : public Operator1<DeoptimizeParameters> {
+ DeoptimizeOperator()
+ : Operator1<DeoptimizeParameters>( // --
+ IrOpcode::kDeoptimize, // opcode
+ Operator::kFoldable | Operator::kNoThrow, // properties
+ "Deoptimize", // name
+ 1, 1, 1, 0, 0, 1, // counts
+ DeoptimizeParameters(kKind, kReason)) {} // parameter
+ };
+#define CACHED_DEOPTIMIZE(Kind, Reason) \
+ DeoptimizeOperator<DeoptimizeKind::k##Kind, DeoptimizeReason::k##Reason> \
+ kDeoptimize##Kind##Reason##Operator;
+ CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
+#undef CACHED_DEOPTIMIZE
+
+ template <DeoptimizeReason kReason>
+ struct DeoptimizeIfOperator final : public Operator1<DeoptimizeReason> {
+ DeoptimizeIfOperator()
+ : Operator1<DeoptimizeReason>( // --
+ IrOpcode::kDeoptimizeIf, // opcode
+ Operator::kFoldable | Operator::kNoThrow, // properties
+ "DeoptimizeIf", // name
+ 2, 1, 1, 0, 1, 1, // counts
+ kReason) {} // parameter
+ };
+#define CACHED_DEOPTIMIZE_IF(Reason) \
+ DeoptimizeIfOperator<DeoptimizeReason::k##Reason> \
+ kDeoptimizeIf##Reason##Operator;
+ CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
+#undef CACHED_DEOPTIMIZE_IF
+
+ template <DeoptimizeReason kReason>
+ struct DeoptimizeUnlessOperator final : public Operator1<DeoptimizeReason> {
+ DeoptimizeUnlessOperator()
+ : Operator1<DeoptimizeReason>( // --
+ IrOpcode::kDeoptimizeUnless, // opcode
+ Operator::kFoldable | Operator::kNoThrow, // properties
+ "DeoptimizeUnless", // name
+ 2, 1, 1, 0, 1, 1, // counts
+ kReason) {} // parameter
+ };
+#define CACHED_DEOPTIMIZE_UNLESS(Reason) \
+ DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \
+ kDeoptimizeUnless##Reason##Operator;
+ CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
+#undef CACHED_DEOPTIMIZE_UNLESS
+
template <MachineRepresentation kRep, int kInputCount>
struct PhiOperator final : public Operator1<MachineRepresentation> {
PhiOperator()
@@ -569,7 +641,14 @@ const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
const Operator* CommonOperatorBuilder::Deoptimize(DeoptimizeKind kind,
DeoptimizeReason reason) {
- // TODO(turbofan): Cache the most common versions of this.
+#define CACHED_DEOPTIMIZE(Kind, Reason) \
+ if (kind == DeoptimizeKind::k##Kind && \
+ reason == DeoptimizeReason::k##Reason) { \
+ return &cache_.kDeoptimize##Kind##Reason##Operator; \
+ }
+ CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
+#undef CACHED_DEOPTIMIZE
+ // Uncached
DeoptimizeParameters parameter(kind, reason);
return new (zone()) Operator1<DeoptimizeParameters>( // --
IrOpcode::kDeoptimize, // opcodes
@@ -580,7 +659,16 @@ const Operator* CommonOperatorBuilder::Deoptimize(DeoptimizeKind kind,
}
const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeReason reason) {
- // TODO(turbofan): Cache the most common versions of this.
+ switch (reason) {
+#define CACHED_DEOPTIMIZE_IF(Reason) \
+ case DeoptimizeReason::k##Reason: \
+ return &cache_.kDeoptimizeIf##Reason##Operator;
+ CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
+#undef CACHED_DEOPTIMIZE_IF
+ default:
+ break;
+ }
+ // Uncached
return new (zone()) Operator1<DeoptimizeReason>( // --
IrOpcode::kDeoptimizeIf, // opcode
Operator::kFoldable | Operator::kNoThrow, // properties
@@ -591,7 +679,16 @@ const Operator* CommonOperatorBuilder::DeoptimizeIf(DeoptimizeReason reason) {
const Operator* CommonOperatorBuilder::DeoptimizeUnless(
DeoptimizeReason reason) {
- // TODO(turbofan): Cache the most common versions of this.
+ switch (reason) {
+#define CACHED_DEOPTIMIZE_UNLESS(Reason) \
+ case DeoptimizeReason::k##Reason: \
+ return &cache_.kDeoptimizeUnless##Reason##Operator;
+ CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
+#undef CACHED_DEOPTIMIZE_UNLESS
+ default:
+ break;
+ }
+ // Uncached
return new (zone()) Operator1<DeoptimizeReason>( // --
IrOpcode::kDeoptimizeUnless, // opcode
Operator::kFoldable | Operator::kNoThrow, // properties
« 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