Commit 0571adf1 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[compiler] Remove frame state combine pushing

With FCG no longer able to deoptimize, we can remove the "push" version
of output frame state combine, as deoptimisation to bytecode is always
the PokeAt variant.

Bug: v8:6409
Change-Id: I9b6d38a7441ca834835615c238228fa8a75a027b
Reviewed-on: https://chromium-review.googlesource.com/557866
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46355}
parent 3bef2af6
......@@ -33,13 +33,6 @@ class AstGraphBuilder::AstContext BASE_EMBEDDED {
bool IsValue() const { return kind_ == Expression::kValue; }
bool IsTest() const { return kind_ == Expression::kTest; }
// Determines how to combine the frame state with the value
// that is about to be plugged into this AstContext.
OutputFrameStateCombine GetStateCombine() {
return IsEffect() ? OutputFrameStateCombine::Ignore()
: OutputFrameStateCombine::Push();
}
// Plug a node into this expression context. Call this function in tail
// position in the Visit functions for expressions.
virtual void ProduceValue(Expression* expr, Node* value) = 0;
......
......@@ -736,12 +736,11 @@ void CodeGenerator::TranslateFrameStateDescriptorOperands(
for (StateValueList::iterator it = values->begin(); it != values->end();
++it, ++index) {
StateValueDescriptor* value_desc = (*it).desc;
if (combine.kind() == OutputFrameStateCombine::kPokeAt) {
if (!combine.IsOutputIgnored()) {
// The result of the call should be placed at position
// [index_from_top] in the stack (overwriting whatever was
// previously there).
size_t index_from_top =
desc->GetSize(combine) - 1 - combine.GetOffsetToPokeAt();
size_t index_from_top = desc->GetSize() - 1 - combine.GetOffsetToPokeAt();
if (index >= index_from_top &&
index < index_from_top + iter->instruction()->OutputCount()) {
DCHECK_NOT_NULL(translation);
......@@ -756,17 +755,7 @@ void CodeGenerator::TranslateFrameStateDescriptorOperands(
}
TranslateStateValueDescriptor(value_desc, (*it).nested, translation, iter);
}
DCHECK_EQ(desc->GetSize(OutputFrameStateCombine::Ignore()), index);
if (combine.kind() == OutputFrameStateCombine::kPushOutput) {
DCHECK(combine.GetPushCount() <= iter->instruction()->OutputCount());
for (size_t output = 0; output < combine.GetPushCount(); output++) {
// Materialize the result of the call instruction in this slot.
AddTranslationForOperand(translation, iter->instruction(),
iter->instruction()->OutputAt(output),
MachineType::AnyTagged());
}
}
DCHECK_EQ(desc->GetSize(), index);
}
......
......@@ -17,19 +17,14 @@ namespace internal {
namespace compiler {
size_t hash_value(OutputFrameStateCombine const& sc) {
return base::hash_combine(sc.kind_, sc.parameter_);
return base::hash_value(sc.parameter_);
}
std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) {
switch (sc.kind_) {
case OutputFrameStateCombine::kPushOutput:
if (sc.parameter_ == 0) return os << "Ignore";
return os << "Push(" << sc.parameter_ << ")";
case OutputFrameStateCombine::kPokeAt:
return os << "PokeAt(" << sc.parameter_ << ")";
}
UNREACHABLE();
if (sc.parameter_ == OutputFrameStateCombine::kInvalidIndex)
return os << "Ignore";
return os << "PokeAt(" << sc.parameter_ << ")";
}
......
......@@ -22,42 +22,26 @@ class Node;
// the output of a node to obtain a framestate for lazy bailout.
class OutputFrameStateCombine {
public:
enum Kind {
kPushOutput, // Push the output on the expression stack.
kPokeAt // Poke at the given environment location,
// counting from the top of the stack.
};
static const size_t kInvalidIndex = SIZE_MAX;
static OutputFrameStateCombine Ignore() {
return OutputFrameStateCombine(kPushOutput, 0);
}
static OutputFrameStateCombine Push(size_t count = 1) {
return OutputFrameStateCombine(kPushOutput, count);
return OutputFrameStateCombine(kInvalidIndex);
}
static OutputFrameStateCombine PokeAt(size_t index) {
return OutputFrameStateCombine(kPokeAt, index);
return OutputFrameStateCombine(index);
}
Kind kind() const { return kind_; }
size_t GetPushCount() const {
DCHECK_EQ(kPushOutput, kind());
return parameter_;
}
size_t GetOffsetToPokeAt() const {
DCHECK_EQ(kPokeAt, kind());
DCHECK_NE(parameter_, kInvalidIndex);
return parameter_;
}
bool IsOutputIgnored() const {
return kind_ == kPushOutput && parameter_ == 0;
}
bool IsOutputIgnored() const { return parameter_ == kInvalidIndex; }
size_t ConsumedOutputCount() const {
return kind_ == kPushOutput ? GetPushCount() : 1;
}
size_t ConsumedOutputCount() const { return IsOutputIgnored() ? 0 : 1; }
bool operator==(OutputFrameStateCombine const& other) const {
return kind_ == other.kind_ && parameter_ == other.parameter_;
return parameter_ == other.parameter_;
}
bool operator!=(OutputFrameStateCombine const& other) const {
return !(*this == other);
......@@ -68,10 +52,8 @@ class OutputFrameStateCombine {
OutputFrameStateCombine const&);
private:
OutputFrameStateCombine(Kind kind, size_t parameter)
: kind_(kind), parameter_(parameter) {}
explicit OutputFrameStateCombine(size_t parameter) : parameter_(parameter) {}
Kind const kind_;
size_t const parameter_;
};
......
......@@ -597,8 +597,7 @@ size_t InstructionSelector::AddInputsToFrameStateDescriptor(
StateValueList* values_descriptor = descriptor->GetStateValueDescriptors();
DCHECK_EQ(values_descriptor->size(), 0u);
values_descriptor->ReserveSize(
descriptor->GetSize(OutputFrameStateCombine::Ignore()));
values_descriptor->ReserveSize(descriptor->GetSize());
entries += AddOperandToStateValueDescriptor(
values_descriptor, inputs, g, deduplicator, function,
......
......@@ -1013,18 +1013,9 @@ FrameStateDescriptor::FrameStateDescriptor(
shared_info_(shared_info),
outer_state_(outer_state) {}
size_t FrameStateDescriptor::GetSize(OutputFrameStateCombine combine) const {
size_t size = 1 + parameters_count() + locals_count() + stack_count() +
(HasContext() ? 1 : 0);
switch (combine.kind()) {
case OutputFrameStateCombine::kPushOutput:
size += combine.GetPushCount();
break;
case OutputFrameStateCombine::kPokeAt:
break;
}
return size;
size_t FrameStateDescriptor::GetSize() const {
return 1 + parameters_count() + locals_count() + stack_count() +
(HasContext() ? 1 : 0);
}
......
......@@ -1300,8 +1300,7 @@ class FrameStateDescriptor : public ZoneObject {
type_ == FrameStateType::kBuiltinContinuation;
}
size_t GetSize(OutputFrameStateCombine combine =
OutputFrameStateCombine::Ignore()) const;
size_t GetSize() const;
size_t GetTotalSize() const;
size_t GetFrameCount() const;
size_t GetJSFrameCount() const;
......
......@@ -374,7 +374,7 @@ TARGET_TEST_F(InstructionSelectorTest, CallJSFunctionWithDeopt) {
m.common()->TypedStateValues(&empty_types, SparseInputMask::Dense()));
Node* context_sentinel = m.Int32Constant(0);
Node* state_node = m.AddNode(
m.common()->FrameState(bailout_id, OutputFrameStateCombine::Push(),
m.common()->FrameState(bailout_id, OutputFrameStateCombine::PokeAt(0),
m.GetFrameStateFunctionInfo(1, 0)),
parameters, locals, stack, context_sentinel, function_node,
m.UndefinedConstant());
......@@ -433,11 +433,12 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) {
m.common()->TypedStateValues(&tagged_type, SparseInputMask::Dense()),
m.UndefinedConstant());
Node* context_sentinel = m.Int32Constant(0);
Node* state_node = m.AddNode(
m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
m.GetFrameStateFunctionInfo(1, 1)),
parameters, locals, stack, context_sentinel, function_node,
m.UndefinedConstant());
Node* state_node =
m.AddNode(m.common()->FrameState(bailout_id_before,
OutputFrameStateCombine::PokeAt(0),
m.GetFrameStateFunctionInfo(1, 1)),
parameters, locals, stack, context_sentinel, function_node,
m.UndefinedConstant());
// Build the call.
Node* stub_code = m.HeapConstant(callable.code());
......@@ -474,8 +475,6 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeopt) {
FrameStateDescriptor* desc_before =
s.GetFrameStateDescriptor(deopt_id_before);
EXPECT_EQ(bailout_id_before, desc_before->bailout_id());
EXPECT_EQ(OutputFrameStateCombine::kPushOutput,
desc_before->state_combine().kind());
EXPECT_EQ(1u, desc_before->parameters_count());
EXPECT_EQ(1u, desc_before->locals_count());
EXPECT_EQ(1u, desc_before->stack_count());
......@@ -543,11 +542,12 @@ TARGET_TEST_F(InstructionSelectorTest, CallStubWithDeoptRecursiveFrameState) {
Node* stack2 = m.AddNode(
m.common()->TypedStateValues(&int32x2_type, SparseInputMask::Dense()),
m.Int32Constant(44), m.Int32Constant(45));
Node* state_node = m.AddNode(
m.common()->FrameState(bailout_id_before, OutputFrameStateCombine::Push(),
m.GetFrameStateFunctionInfo(1, 1)),
parameters2, locals2, stack2, context2, function_node,
frame_state_parent);
Node* state_node =
m.AddNode(m.common()->FrameState(bailout_id_before,
OutputFrameStateCombine::PokeAt(0),
m.GetFrameStateFunctionInfo(1, 1)),
parameters2, locals2, stack2, context2, function_node,
frame_state_parent);
// Build the call.
Node* stub_code = m.HeapConstant(callable.code());
......
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