Commit 87086a1f authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[gasm] Add Effect/Control/FrameState wrapper classes

These node/edge kinds don't fit into the heap object type system; add
wrapper classes for them instead. The wrapper class must be explicitly
created, but is implicitly convertible to Node*.

Bug: v8:9972
Change-Id: Ic6c253a95bb5705fb946ee3f35508ea70c9f0070
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1940255
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65244}
parent 39b9b263
...@@ -579,12 +579,12 @@ Node* GraphAssembler::TypeGuard(Type type, Node* value) { ...@@ -579,12 +579,12 @@ Node* GraphAssembler::TypeGuard(Type type, Node* value) {
graph()->NewNode(common()->TypeGuard(type), value, effect(), control())); graph()->NewNode(common()->TypeGuard(type), value, effect(), control()));
} }
Node* GraphAssembler::Checkpoint(Node* frame_state) { Node* GraphAssembler::Checkpoint(FrameState frame_state) {
return AddNode(graph()->NewNode(common()->Checkpoint(), frame_state, effect(), return AddNode(graph()->NewNode(common()->Checkpoint(), frame_state, effect(),
control())); control()));
} }
Node* GraphAssembler::LoopExit(Node* loop_header) { Node* GraphAssembler::LoopExit(Control loop_header) {
return AddNode( return AddNode(
graph()->NewNode(common()->LoopExit(), control(), loop_header)); graph()->NewNode(common()->LoopExit(), control(), loop_header));
} }
......
...@@ -126,6 +126,46 @@ class BasicBlock; ...@@ -126,6 +126,46 @@ class BasicBlock;
class GraphAssembler; class GraphAssembler;
// Wrapper classes for special node/edge types (effect, control, frame states)
// that otherwise don't fit into the type system.
class NodeWrapper {
public:
explicit constexpr NodeWrapper(Node* node) : node_(node) {}
operator Node*() const { return node_; }
Node* operator->() const { return node_; }
private:
Node* const node_;
};
class Effect : public NodeWrapper {
public:
explicit constexpr Effect(Node* node) : NodeWrapper(node) {
// TODO(jgruber): Remove the End/Dead special case.
SLOW_DCHECK(node == nullptr || node->op()->opcode() == IrOpcode::kEnd ||
node->op()->opcode() == IrOpcode::kDead ||
node->op()->EffectOutputCount() > 0);
}
};
class Control : public NodeWrapper {
public:
explicit constexpr Control(Node* node) : NodeWrapper(node) {
// TODO(jgruber): Remove the End/Dead special case.
SLOW_DCHECK(node == nullptr || node->op()->opcode() == IrOpcode::kEnd ||
node->op()->opcode() == IrOpcode::kDead ||
node->op()->ControlOutputCount() > 0);
}
};
class FrameState : public NodeWrapper {
public:
explicit constexpr FrameState(Node* node) : NodeWrapper(node) {
SLOW_DCHECK(node->op()->opcode() == IrOpcode::kFrameState);
}
};
enum class GraphAssemblerLabelType { kDeferred, kNonDeferred, kLoop }; enum class GraphAssemblerLabelType { kDeferred, kNonDeferred, kLoop };
// Label with statically known count of incoming branches and phis. // Label with statically known count of incoming branches and phis.
...@@ -304,8 +344,8 @@ class V8_EXPORT_PRIVATE GraphAssembler { ...@@ -304,8 +344,8 @@ class V8_EXPORT_PRIVATE GraphAssembler {
TNode<Boolean> NumberIsFloat64Hole(TNode<Number> value); TNode<Boolean> NumberIsFloat64Hole(TNode<Number> value);
Node* TypeGuard(Type type, Node* value); Node* TypeGuard(Type type, Node* value);
Node* Checkpoint(Node* frame_state); Node* Checkpoint(FrameState frame_state);
Node* LoopExit(Node* loop_header); Node* LoopExit(Control loop_header);
Node* LoopExitEffect(); Node* LoopExitEffect();
Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value); Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value);
...@@ -392,8 +432,8 @@ class V8_EXPORT_PRIVATE GraphAssembler { ...@@ -392,8 +432,8 @@ class V8_EXPORT_PRIVATE GraphAssembler {
void ConnectUnreachableToEnd(); void ConnectUnreachableToEnd();
Node* control() { return control_; } Control control() { return Control(control_); }
Node* effect() { return effect_; } Effect effect() { return Effect(effect_); }
protected: protected:
class BasicBlockUpdater; class BasicBlockUpdater;
......
This diff is collapsed.
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