Commit 661768cf authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbofan] Add deopt feedback to CheckIf

Bug: v8:7779
Change-Id: I97d7a46039d9063e4169fa215f7f6857c80eb3b9
Reviewed-on: https://chromium-review.googlesource.com/1076087Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53404}
parent 02a51d7f
......@@ -1529,8 +1529,8 @@ Node* EffectControlLinearizer::LowerCheckInternalizedString(Node* node,
void EffectControlLinearizer::LowerCheckIf(Node* node, Node* frame_state) {
Node* value = node->InputAt(0);
__ DeoptimizeIfNot(DeoptimizeReasonOf(node->op()), VectorSlotPair(), value,
frame_state);
const CheckIfParameters& p = CheckIfParametersOf(node->op());
__ DeoptimizeIfNot(p.reason(), p.feedback(), value, frame_state);
}
Node* EffectControlLinearizer::LowerCheckedInt32Add(Node* node,
......
......@@ -581,11 +581,6 @@ AbortReason AbortReasonOf(const Operator* op) {
return static_cast<AbortReason>(OpParameter<int>(op));
}
DeoptimizeReason DeoptimizeReasonOf(const Operator* op) {
DCHECK_EQ(IrOpcode::kCheckIf, op->opcode());
return OpParameter<DeoptimizeReason>(op);
}
const CheckTaggedInputParameters& CheckTaggedInputParametersOf(
const Operator* op) {
DCHECK(op->opcode() == IrOpcode::kCheckedTruncateTaggedToWord32 ||
......@@ -834,11 +829,12 @@ struct SimplifiedOperatorGlobalCache final {
#undef CHECKED_WITH_FEEDBACK
template <DeoptimizeReason kDeoptimizeReason>
struct CheckIfOperator final : public Operator1<DeoptimizeReason> {
struct CheckIfOperator final : public Operator1<CheckIfParameters> {
CheckIfOperator()
: Operator1<DeoptimizeReason>(
: Operator1<CheckIfParameters>(
IrOpcode::kCheckIf, Operator::kFoldable | Operator::kNoThrow,
"CheckIf", 1, 1, 1, 0, 1, 0, kDeoptimizeReason) {}
"CheckIf", 1, 1, 1, 0, 1, 0,
CheckIfParameters(kDeoptimizeReason, VectorSlotPair())) {}
};
#define CHECK_IF(Name, message) \
CheckIfOperator<DeoptimizeReason::k##Name> kCheckIf##Name;
......@@ -1144,15 +1140,20 @@ const Operator* SimplifiedOperatorBuilder::RuntimeAbort(AbortReason reason) {
static_cast<int>(reason)); // parameter
}
const Operator* SimplifiedOperatorBuilder::CheckIf(DeoptimizeReason reason) {
switch (reason) {
const Operator* SimplifiedOperatorBuilder::CheckIf(
DeoptimizeReason reason, const VectorSlotPair& feedback) {
if (!feedback.IsValid()) {
switch (reason) {
#define CHECK_IF(Name, message) \
case DeoptimizeReason::k##Name: \
return &cache_.kCheckIf##Name;
DEOPTIMIZE_REASON_LIST(CHECK_IF)
#undef CHECK_IF
}
}
UNREACHABLE();
return new (zone()) Operator1<CheckIfParameters>(
IrOpcode::kCheckIf, Operator::kFoldable | Operator::kNoThrow, "CheckIf",
1, 1, 1, 0, 1, 0, CheckIfParameters(reason, feedback));
}
const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged(
......@@ -1412,6 +1413,23 @@ CheckParameters const& CheckParametersOf(Operator const* op) {
return OpParameter<CheckParameters>(op);
}
bool operator==(CheckIfParameters const& lhs, CheckIfParameters const& rhs) {
return lhs.reason() == rhs.reason() && lhs.feedback() == rhs.feedback();
}
size_t hash_value(CheckIfParameters const& p) {
return base::hash_combine(p.reason(), p.feedback());
}
std::ostream& operator<<(std::ostream& os, CheckIfParameters const& p) {
return os << p.reason() << p.feedback();
}
CheckIfParameters const& CheckIfParametersOf(Operator const* op) {
CHECK(op->opcode() == IrOpcode::kCheckIf);
return OpParameter<CheckIfParameters>(op);
}
const Operator* SimplifiedOperatorBuilder::NewDoubleElements(
PretenureFlag pretenure) {
return new (zone()) Operator1<PretenureFlag>( // --
......
......@@ -162,6 +162,29 @@ std::ostream& operator<<(std::ostream&, CheckParameters const&);
CheckParameters const& CheckParametersOf(Operator const*) V8_WARN_UNUSED_RESULT;
class CheckIfParameters final {
public:
explicit CheckIfParameters(DeoptimizeReason reason,
const VectorSlotPair& feedback)
: reason_(reason), feedback_(feedback) {}
VectorSlotPair const& feedback() const { return feedback_; }
DeoptimizeReason reason() const { return reason_; }
private:
DeoptimizeReason reason_;
VectorSlotPair feedback_;
};
bool operator==(CheckIfParameters const&, CheckIfParameters const&);
size_t hash_value(CheckIfParameters const&);
std::ostream& operator<<(std::ostream&, CheckIfParameters const&);
CheckIfParameters const& CheckIfParametersOf(Operator const*)
V8_WARN_UNUSED_RESULT;
enum class CheckFloat64HoleMode : uint8_t {
kNeverReturnHole, // Never return the hole (deoptimize instead).
kAllowReturnHole // Allow to return the hole (signaling NaN).
......@@ -619,7 +642,8 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* CheckEqualsSymbol();
const Operator* CheckFloat64Hole(CheckFloat64HoleMode);
const Operator* CheckHeapObject();
const Operator* CheckIf(DeoptimizeReason deoptimize_reason);
const Operator* CheckIf(DeoptimizeReason deoptimize_reason,
const VectorSlotPair& feedback = VectorSlotPair());
const Operator* CheckInternalizedString();
const Operator* CheckMaps(CheckMapsFlags, ZoneHandleSet<Map>,
const VectorSlotPair& = VectorSlotPair());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment