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