Skip to content

Commit 7248b03

Browse files
committed
.
1 parent 4a38926 commit 7248b03

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

zjit/mini_zjit.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def to_s = "(read: #{Eff.name_of(read)}, write: #{Eff.name_of(write)})"
266266
# ═══════════════════════════════════════════════════════════════════
267267

268268
class Insn
269-
attr_accessor :id, :type, :block
269+
attr_accessor :id, :type, :block, :forwarded
270270

271271
def initialize(type = Types::Any)
272272
@id = nil # assigned by Function#push_insn
@@ -279,24 +279,26 @@ def to_s = "v#{find.id}"
279279

280280
# ── Union-Find (per-instruction) ──
281281
# Each insn carries its own forwarding pointer. find() follows the
282-
# chain with path compression. Fixpoint: insn.@forwarded == insn.
282+
# chain with path compression. Fixpoint: insn.forwarded == insn.
283283

284284
def find
285-
# Path compression: flatten chain as we walk
285+
# Walk to root
286286
root = self
287-
root = root.instance_variable_get(:@forwarded) until root.instance_variable_get(:@forwarded).equal?(root)
288-
# Compress
287+
while !root.forwarded.equal?(root)
288+
root = root.forwarded
289+
end
290+
# Path compression
289291
current = self
290-
until current.equal?(root)
291-
nxt = current.instance_variable_get(:@forwarded)
292-
current.instance_variable_set(:@forwarded, root)
292+
while !current.equal?(root)
293+
nxt = current.forwarded
294+
current.forwarded = root
293295
current = nxt
294296
end
295297
root
296298
end
297299

298300
def make_equal_to(other)
299-
find.instance_variable_set(:@forwarded, other.find)
301+
find.forwarded = other.find
300302
end
301303

302304
# Override in subclasses

0 commit comments

Comments
 (0)