[maglev] Update checkpoint state in AddNewNode
Instead of manually ensuring checkpoints and marking that operations had side effects, do this in AddNewNode based on OpProperties. Bug: v8:7700 Change-Id: I1e2699af537056d066e7f919abe5e7479bd3af91 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3545174 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/main@{#79578}
This commit is contained in:
parent
b35964839c
commit
ae153a7141
@ -128,7 +128,6 @@ void MaglevGraphBuilder::BuildGenericUnaryOperationNode() {
|
||||
ValueNode* node = AddNewOperationNode<kOperation>(
|
||||
{value}, compiler::FeedbackSource{feedback(), slot_index});
|
||||
SetAccumulator(node);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
|
||||
template <Operation kOperation>
|
||||
@ -139,7 +138,6 @@ void MaglevGraphBuilder::BuildGenericBinaryOperationNode() {
|
||||
ValueNode* node = AddNewOperationNode<kOperation>(
|
||||
{left, right}, compiler::FeedbackSource{feedback(), slot_index});
|
||||
SetAccumulator(node);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
|
||||
template <Operation kOperation>
|
||||
@ -213,7 +211,6 @@ void MaglevGraphBuilder::VisitLdaGlobal() {
|
||||
USE(slot_index); // TODO(v8:7700): Use the feedback info.
|
||||
|
||||
SetAccumulator(AddNewNode<LoadGlobal>({context}, name));
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaGlobalInsideTypeof)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(StaGlobal)
|
||||
@ -232,7 +229,6 @@ void MaglevGraphBuilder::VisitGetNamedProperty() {
|
||||
FeedbackNexus nexus = feedback_nexus(2);
|
||||
|
||||
if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) {
|
||||
EnsureCheckpoint();
|
||||
AddNewNode<SoftDeopt>({});
|
||||
} else if (nexus.ic_state() == InlineCacheState::MONOMORPHIC) {
|
||||
std::vector<MapAndHandler> maps_and_handlers;
|
||||
@ -244,7 +240,6 @@ void MaglevGraphBuilder::VisitGetNamedProperty() {
|
||||
LoadHandler::Kind kind = LoadHandler::KindBits::decode(handler);
|
||||
if (kind == LoadHandler::Kind::kField &&
|
||||
!LoadHandler::IsWasmStructBits::decode(handler)) {
|
||||
EnsureCheckpoint();
|
||||
AddNewNode<CheckMaps>({object},
|
||||
MakeRef(broker(), map_and_handler.first));
|
||||
SetAccumulator(AddNewNode<LoadField>({object}, handler));
|
||||
@ -256,7 +251,6 @@ void MaglevGraphBuilder::VisitGetNamedProperty() {
|
||||
ValueNode* context = GetContext();
|
||||
compiler::NameRef name = GetRefOperand<Name>(1);
|
||||
SetAccumulator(AddNewNode<LoadNamedGeneric>({context, object}, name));
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(GetNamedPropertyFromSuper)
|
||||
@ -270,7 +264,6 @@ void MaglevGraphBuilder::VisitSetNamedProperty() {
|
||||
FeedbackNexus nexus = feedback_nexus(2);
|
||||
|
||||
if (nexus.ic_state() == InlineCacheState::UNINITIALIZED) {
|
||||
EnsureCheckpoint();
|
||||
AddNewNode<SoftDeopt>({});
|
||||
} else if (nexus.ic_state() == InlineCacheState::MONOMORPHIC) {
|
||||
std::vector<MapAndHandler> maps_and_handlers;
|
||||
@ -281,7 +274,6 @@ void MaglevGraphBuilder::VisitSetNamedProperty() {
|
||||
int handler = map_and_handler.second->ToSmi().value();
|
||||
StoreHandler::Kind kind = StoreHandler::KindBits::decode(handler);
|
||||
if (kind == StoreHandler::Kind::kField) {
|
||||
EnsureCheckpoint();
|
||||
AddNewNode<CheckMaps>({object},
|
||||
MakeRef(broker(), map_and_handler.first));
|
||||
ValueNode* value = GetAccumulator();
|
||||
@ -389,7 +381,6 @@ void MaglevGraphBuilder::VisitCallProperty() {
|
||||
call_property->set_arg(i, current_interpreter_frame_.get(args[i]));
|
||||
}
|
||||
SetAccumulator(call_property);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
void MaglevGraphBuilder::VisitCallProperty0() {
|
||||
ValueNode* function = LoadRegister(0);
|
||||
@ -398,7 +389,6 @@ void MaglevGraphBuilder::VisitCallProperty0() {
|
||||
CallProperty* call_property =
|
||||
AddNewNode<CallProperty>({function, context, LoadRegister(1)});
|
||||
SetAccumulator(call_property);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
void MaglevGraphBuilder::VisitCallProperty1() {
|
||||
ValueNode* function = LoadRegister(0);
|
||||
@ -407,7 +397,6 @@ void MaglevGraphBuilder::VisitCallProperty1() {
|
||||
CallProperty* call_property = AddNewNode<CallProperty>(
|
||||
{function, context, LoadRegister(1), LoadRegister(2)});
|
||||
SetAccumulator(call_property);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
void MaglevGraphBuilder::VisitCallProperty2() {
|
||||
ValueNode* function = LoadRegister(0);
|
||||
@ -416,7 +405,6 @@ void MaglevGraphBuilder::VisitCallProperty2() {
|
||||
CallProperty* call_property = AddNewNode<CallProperty>(
|
||||
{function, context, LoadRegister(1), LoadRegister(2), LoadRegister(3)});
|
||||
SetAccumulator(call_property);
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver0)
|
||||
|
@ -125,14 +125,13 @@ class MaglevGraphBuilder {
|
||||
|
||||
template <typename NodeT>
|
||||
NodeT* AddNode(NodeT* node) {
|
||||
if (node->properties().can_deopt()) {
|
||||
EnsureCheckpoint();
|
||||
}
|
||||
if (node->properties().is_required_when_unused()) {
|
||||
MarkPossibleSideEffect();
|
||||
}
|
||||
current_block_->nodes().Add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
template <typename NodeT, typename... Args>
|
||||
NodeT* NewNode(size_t input_count, Args&&... args) {
|
||||
NodeT* node =
|
||||
Node::New<NodeT>(zone(), input_count, std::forward<Args>(args)...);
|
||||
if (has_graph_labeller()) graph_labeller()->RegisterNode(node);
|
||||
return node;
|
||||
}
|
||||
@ -143,19 +142,14 @@ class MaglevGraphBuilder {
|
||||
|
||||
template <typename NodeT, typename... Args>
|
||||
NodeT* AddNewNode(size_t input_count, Args&&... args) {
|
||||
return AddNode(NewNode<NodeT>(input_count, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename NodeT, typename... Args>
|
||||
NodeT* NewNode(std::initializer_list<ValueNode*> inputs, Args&&... args) {
|
||||
NodeT* node = Node::New<NodeT>(zone(), inputs, std::forward<Args>(args)...);
|
||||
if (has_graph_labeller()) graph_labeller()->RegisterNode(node);
|
||||
return node;
|
||||
return AddNode(
|
||||
Node::New<NodeT>(zone(), input_count, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename NodeT, typename... Args>
|
||||
NodeT* AddNewNode(std::initializer_list<ValueNode*> inputs, Args&&... args) {
|
||||
return AddNode(NewNode<NodeT>(inputs, std::forward<Args>(args)...));
|
||||
return AddNode(
|
||||
Node::New<NodeT>(zone(), inputs, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
ValueNode* GetContext() const {
|
||||
|
@ -189,6 +189,10 @@ class OpProperties {
|
||||
static constexpr OpProperties Call() {
|
||||
return OpProperties(kIsCallBit::encode(true));
|
||||
}
|
||||
static constexpr OpProperties JSCall() {
|
||||
return OpProperties(kIsCallBit::encode(true) |
|
||||
kNonMemorySideEffectsBit::encode(true));
|
||||
}
|
||||
static constexpr OpProperties Deopt() {
|
||||
return OpProperties(kCanDeoptBit::encode(true));
|
||||
}
|
||||
@ -712,7 +716,7 @@ class UnaryWithFeedbackNode : public FixedInputValueNodeT<1, Derived> {
|
||||
|
||||
public:
|
||||
// The implementation currently calls runtime.
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
static constexpr int kOperandIndex = 0;
|
||||
Input& operand_input() { return Node::input(kOperandIndex); }
|
||||
@ -736,7 +740,7 @@ class BinaryWithFeedbackNode : public FixedInputValueNodeT<2, Derived> {
|
||||
|
||||
public:
|
||||
// The implementation currently calls runtime.
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
static constexpr int kLeftIndex = 0;
|
||||
static constexpr int kRightIndex = 1;
|
||||
@ -933,8 +937,7 @@ class LoadField : public FixedInputValueNodeT<1, LoadField> {
|
||||
explicit LoadField(size_t input_count, int handler)
|
||||
: Base(input_count), handler_(handler) {}
|
||||
|
||||
// The implementation currently calls runtime.
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::Reading();
|
||||
|
||||
int handler() const { return handler_; }
|
||||
|
||||
@ -956,6 +959,8 @@ class StoreField : public FixedInputNodeT<2, StoreField> {
|
||||
explicit StoreField(size_t input_count, int handler)
|
||||
: Base(input_count), handler_(handler) {}
|
||||
|
||||
static constexpr OpProperties kProperties = OpProperties::Writing();
|
||||
|
||||
int handler() const { return handler_; }
|
||||
|
||||
static constexpr int kObjectIndex = 0;
|
||||
@ -979,7 +984,7 @@ class LoadGlobal : public FixedInputValueNodeT<1, LoadGlobal> {
|
||||
: Base(input_count), name_(name) {}
|
||||
|
||||
// The implementation currently calls runtime.
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
Input& context() { return input(0); }
|
||||
const compiler::NameRef& name() const { return name_; }
|
||||
@ -1000,7 +1005,7 @@ class LoadNamedGeneric : public FixedInputValueNodeT<2, LoadNamedGeneric> {
|
||||
: Base(input_count), name_(name) {}
|
||||
|
||||
// The implementation currently calls runtime.
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
compiler::NameRef name() const { return name_; }
|
||||
|
||||
@ -1104,7 +1109,7 @@ class CallProperty : public ValueNodeT<CallProperty> {
|
||||
set_input(1, context);
|
||||
}
|
||||
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
Input& function() { return input(0); }
|
||||
const Input& function() const { return input(0); }
|
||||
@ -1125,7 +1130,7 @@ class CallUndefinedReceiver : public ValueNodeT<CallUndefinedReceiver> {
|
||||
public:
|
||||
explicit CallUndefinedReceiver(size_t input_count) : Base(input_count) {}
|
||||
|
||||
static constexpr OpProperties kProperties = OpProperties::Call();
|
||||
static constexpr OpProperties kProperties = OpProperties::JSCall();
|
||||
|
||||
Input& function() { return input(0); }
|
||||
const Input& function() const { return input(0); }
|
||||
|
Loading…
Reference in New Issue
Block a user