Skip to content

Commit 80580d6

Browse files
committed
Remove registry check from EmitBlock to fix op/pack.t regression
The registry check in EmitBlock (lines 104-138) was causing op/pack.t to stop at test 245 instead of running 14579 tests, a regression of -14334 tests. Root cause: The check was too aggressive and interfered with normal control flow in labeled blocks, particularly SKIP blocks in test files. Solution: Remove the registry check from EmitBlock entirely. Real loops (for/while/foreach) have their own registry checks in EmitForeach.java and EmitStatement.java that work correctly. Changes: - EmitBlock.java: Removed registry check (lines 104-138) - Kept conditional registry clearing at block exit (works correctly) Results: - op/pack.t: restored to baseline - uni/variables.t: 66683/66880 (baseline maintained) - skip_control_flow.t: tests 2,5,8 still fail (scalar context issue remains)
1 parent e94a91a commit 80580d6

1 file changed

Lines changed: 3 additions & 41 deletions

File tree

src/main/java/org/perlonjava/codegen/EmitBlock.java

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,51 +99,13 @@ public static void emitBlock(EmitterVisitor emitterVisitor, BlockNode node) {
9999
element.accept(voidVisitor);
100100
}
101101

102-
// Check for non-local control flow after each statement in labeled blocks
103-
// Only for simple blocks to avoid ASM VerifyError
104-
if (node.isLoop && node.labelName != null && i < list.size() - 1 && list.size() <= 3) {
105-
// Check if block contains loop constructs (they handle their own control flow)
106-
boolean hasLoopConstruct = false;
107-
for (Node elem : list) {
108-
if (elem instanceof For1Node || elem instanceof For3Node) {
109-
hasLoopConstruct = true;
110-
break;
111-
}
112-
}
113-
114-
if (!hasLoopConstruct) {
115-
Label continueBlock = new Label();
116-
117-
// if (!RuntimeControlFlowRegistry.hasMarker()) continue
118-
mv.visitMethodInsn(Opcodes.INVOKESTATIC,
119-
"org/perlonjava/runtime/RuntimeControlFlowRegistry",
120-
"hasMarker",
121-
"()Z",
122-
false);
123-
mv.visitJumpInsn(Opcodes.IFEQ, continueBlock);
124-
125-
// Has marker: check if it matches this loop
126-
mv.visitLdcInsn(node.labelName);
127-
mv.visitMethodInsn(Opcodes.INVOKESTATIC,
128-
"org/perlonjava/runtime/RuntimeControlFlowRegistry",
129-
"checkLoopAndGetAction",
130-
"(Ljava/lang/String;)I",
131-
false);
132-
133-
// If action != 0, jump to nextLabel (exit block)
134-
mv.visitJumpInsn(Opcodes.IFNE, nextLabel);
135-
136-
mv.visitLabel(continueBlock);
137-
}
138-
}
139-
140102
// NOTE: Registry checks are DISABLED in EmitBlock because:
141-
// 1. They cause ASM frame computation errors in nested/refactored code
142-
// 2. Bare labeled blocks (like TODO:) don't need non-local control flow
103+
// 1. They cause regressions in op/pack.t (stops at test 245 instead of 14579)
104+
// 2. Bare labeled blocks don't need non-local control flow checks
143105
// 3. Real loops (for/while/foreach) have their own registry checks in
144106
// EmitForeach.java and EmitStatement.java that work correctly
145107
//
146-
// This means non-local control flow (next LABEL from closures) works for
108+
// This means non-local control flow (last LABEL from closures) works for
147109
// actual loop constructs but NOT for bare labeled blocks, which is correct
148110
// Perl behavior anyway.
149111
}

0 commit comments

Comments
 (0)