Commit 574b5611 authored by Nico Hartmann's avatar Nico Hartmann Committed by V8 LUCI CQ

[turboshaft] Blocks store graph generation for debug checks

Bug: v8:12783
Change-Id: Icf9e5b29863a1d4bfc8924ea34476d2a9998c391
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3683322
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80936}
parent efadd2d0
...@@ -228,7 +228,7 @@ class Block { ...@@ -228,7 +228,7 @@ class Block {
// used for translating phi nodes from the previous graph. // used for translating phi nodes from the previous graph.
void SetOrigin(const Block* origin) { void SetOrigin(const Block* origin) {
DCHECK_NULL(origin_); DCHECK_NULL(origin_);
DCHECK_NE(origin->graph_, graph_); DCHECK_EQ(origin->graph_generation_ + 1, graph_generation_);
origin_ = origin; origin_ = origin;
} }
const Block* Origin() const { return origin_; } const Block* Origin() const { return origin_; }
...@@ -256,7 +256,7 @@ class Block { ...@@ -256,7 +256,7 @@ class Block {
Block* neighboring_predecessor_ = nullptr; Block* neighboring_predecessor_ = nullptr;
const Block* origin_ = nullptr; const Block* origin_ = nullptr;
#ifdef DEBUG #ifdef DEBUG
Graph* graph_ = nullptr; size_t graph_generation_ = 0;
#endif #endif
}; };
...@@ -349,13 +349,13 @@ class Graph { ...@@ -349,13 +349,13 @@ class Graph {
Block* result = all_blocks_[next_block_++]; Block* result = all_blocks_[next_block_++];
*result = Block(kind); *result = Block(kind);
#ifdef DEBUG #ifdef DEBUG
result->graph_ = this; result->graph_generation_ = generation_;
#endif #endif
return result; return result;
} }
V8_INLINE bool Add(Block* block) { V8_INLINE bool Add(Block* block) {
DCHECK_EQ(block->graph_, this); DCHECK_EQ(block->graph_generation_, generation_);
if (!bound_blocks_.empty() && !block->HasPredecessors()) return false; if (!bound_blocks_.empty() && !block->HasPredecessors()) return false;
bool deferred = true; bool deferred = true;
for (Block* pred = block->last_predecessor_; pred != nullptr; for (Block* pred = block->last_predecessor_; pred != nullptr;
...@@ -477,6 +477,9 @@ class Graph { ...@@ -477,6 +477,9 @@ class Graph {
Graph& GetOrCreateCompanion() { Graph& GetOrCreateCompanion() {
if (!companion_) { if (!companion_) {
companion_ = std::make_unique<Graph>(graph_zone_, operations_.size()); companion_ = std::make_unique<Graph>(graph_zone_, operations_.size());
#ifdef DEBUG
companion_->generation_ = generation_ + 1;
#endif // DEBUG
} }
return *companion_; return *companion_;
} }
...@@ -490,6 +493,11 @@ class Graph { ...@@ -490,6 +493,11 @@ class Graph {
std::swap(all_blocks_, companion.all_blocks_); std::swap(all_blocks_, companion.all_blocks_);
std::swap(next_block_, companion.next_block_); std::swap(next_block_, companion.next_block_);
std::swap(graph_zone_, companion.graph_zone_); std::swap(graph_zone_, companion.graph_zone_);
#ifdef DEBUG
// Update generation index.
DCHECK_EQ(generation_ + 1, companion.generation_);
generation_ = companion.generation_++;
#endif // DEBUG
} }
private: private:
...@@ -506,6 +514,9 @@ class Graph { ...@@ -506,6 +514,9 @@ class Graph {
size_t next_block_ = 0; size_t next_block_ = 0;
Zone* graph_zone_; Zone* graph_zone_;
std::unique_ptr<Graph> companion_ = {}; std::unique_ptr<Graph> companion_ = {};
#ifdef DEBUG
size_t generation_ = 1;
#endif // DEBUG
}; };
V8_INLINE OperationStorageSlot* AllocateOpStorage(Graph* graph, V8_INLINE OperationStorageSlot* AllocateOpStorage(Graph* graph,
......
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