Skip to content

Commit 06e9378

Browse files
committed
Improve robustness on free threaded builds and add a TODO
1 parent 3460ce5 commit 06e9378

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypyc/codegen/emitclass.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ def emit_reuse_dealloc(cl: ClassIR, emitter: Emitter) -> None:
855855
"""
856856
prefix = cl.name_prefix(emitter.names)
857857
emitter.emit_line(f"if ({prefix}_free_instance == NULL) {{")
858-
emitter.emit_line(f"{prefix}_free_instance = self;")
859858

860859
# Clear attributes and free referenced objects.
861860

@@ -865,6 +864,11 @@ def emit_reuse_dealloc(cl: ClassIR, emitter: Emitter) -> None:
865864
for attr, rtype in base.attributes.items():
866865
emitter.emit_reuse_clear(f"self->{emitter.attr(attr)}", rtype)
867866

867+
# TODO: Insert a memory barrier on free-threaded builds? This appears not to be
868+
# needed on x86-64 because of the memory model.
869+
870+
emitter.emit_line(f"{prefix}_free_instance = self;")
871+
868872
emitter.emit_line("return;")
869873
emitter.emit_line("}")
870874

0 commit comments

Comments
 (0)