scripts/image-fixes/20-OCArrayLiteralTest.stOCASTTranslator>>visitArrayNode:, OCASTTranslator>>stackDepthOfBraceArrayElement:, OCArrayLiteralTest>>testLiteralArrayLongHavingAnotherArrayLongThe test was skipped for pharo issue 19058. A brace array of up to 32 elements is compiled with push-cons-array, which needs one stack slot per element. A 32-element brace array as the last element of a 32-element brace array needs 31+32=63 slots. A method frame has 56 (LargeFrame), so compilation failed with 'Cannot compile -- stack including temps is too deep'. The failure is identical on both VMs, so the defect is in the image compiler (OCASTTranslator>>visitArrayNode:). The old workaround only tested statements size > 32. The fix adds OCASTTranslator>>stackDepthOfBraceArrayElement:, a conservative recursive estimate of the stack depth of a brace array including nested brace arrays. visitArrayNode: now takes the existing at:put: path (visitLargeArrayNode:) when the size is over 32 or the estimate is over 32. The test entry removes the self flag: and self skip lines and keeps every assertion unchanged.
| Test | Defect in | State | Cause |
|---|---|---|---|
OCArrayLiteralTest>>testLiteralArrayLongHavingAnotherArrayLong |
image-code | repaired | OCASTTranslator>>visitArrayNode: emits push-cons-array for nested brace arrays whose combined depth (63) exceeds the 56-slot frame; the skip hid this (pharo issue 19058). |
Regression check: Ran each class on our VM (JIT) and on Cog, on the base image and on the fixed image. Pass counts were identical before and after, with 0 FAIL/ERROR/TIMEOUT, on both VMs. OCArrayLiteralTest went from 8 to 9 passes, the test that was skipped now passing. The other classes: OCASTTranslatorTest 4, OCCompilerTest 16, OCBytecodeGeneratorTest 2, OCASTBasicTranslatorTest 3, OCClosureTest 21, OCIRBuilderTest 34, OCLiteralTest 14, OpalCompilerTest 16, OCEvaluatorTest 4, OCDoitTest 13, OCClosureCompilerTest 18, OCASTBlockTranslatorTest 17. I also compiled and ran the nested 32x32 brace array directly with evalfile on both fixed images (size 32, elements correct). I did not run ours-nojit, and I did not run the whole OpalCompiler-Tests package; only the classes listed above.
Upstream note: Title: Opal: compile nested large brace arrays without overflowing the frame (fixes #19058, re-enables OCArrayLiteralTest>>testLiteralArrayLongHavingAnotherArrayLong). Description: OCASTTranslator>>visitArrayNode: used push-cons-array for any brace array of 32 or fewer elements, so a 32-element array whose last element is another 32-element array needs 63 stack slots, more than the 56-slot LargeFrame, and fails with 'stack including temps is too deep'. The translator now estimates the stack depth of the array including nested brace arrays (stackDepthOfBraceArrayElement:) and uses the at:put: path (visitLargeArrayNode:) when the estimate is over 32. The skip in the test is removed. This is a conservative estimate, not a track of the real stack depth at the emit point; a stack-aware check (the commented-out stackLimit line in visitArrayNode:) would be more exact. No PR has been made; the owner must review first.
Last full sweeps of 2026-11-17: iospharo (sweep14-new14) and stock Cog with the Cog changes (sweepcogp14-new10), with all image fixes. "Before" is the state of the test before the repairs. The Stock Cog column has a value only where the record measured stock Cog: "PASS 3 of 3 (repair run)" is the check of each repair on stock Cog v12.0.6 with the fix entry; "-" is not measured separately.
| Test | Before | State | iospharo VM | Patched Cog | Stock Cog |
|---|---|---|---|---|---|
OCArrayLiteralTest>>testLiteralArrayLongHavingAnotherArrayLong | SKIP | repaired | PASS | PASS | PASS 3 of 3 (repair run) |
Run the tests in a Pharo 14 image (build 791). Before the fix they skip, fail or carry the expected-failure mark.
"Run in a Playground of a Pharo 14 image (Do it and print each line)." ((OCArrayLiteralTest selector: #testLiteralArrayLongHavingAnotherArrayLong) run) printString.
testLiteralArrayLongHavingAnotherArrayLong
| method array elements |
self flag: 'Skipped in Pharo14 because of github.com/pharo-project/pharo/issues/19058. Fix should come on P15'.
self skip.
elements := ((1 to: 32) inject: ' ' into: [ :r :e | r , ' . ' , e asString ]).
array := ' { ' , elements , ' }'.
array := array copyReplaceAll: '32' with: array.
method := self compile: 'array ^' , array.
array := method valueWithReceiver: #().
self assert: ( array isKindOf: Array).
self assert: array size equals: 32.
1 to: 31 do: [ :index | self assert: (array at: index) equals: index ].
1 to: 32 do: [ :index | self assert: ((array at: 32) at: index) equals: index ].How to apply an entries file: file in 00-header.st and the entries file as one chunk (the iospharo script scripts/gen-image-fixes.py makes that chunk). Each entry checks for the defect first and prints FIXED, ADDED or SKIP. Download 00-header.st.
"OCArrayLiteralTest>>testLiteralArrayLongHavingAnotherArrayLong (pharo issue 19058):
a brace array of up to 32 elements is compiled with push-cons-array, so it needs one stack slot
per element. A 32-element brace array as last element of a 32-element brace array needs
31 + 32 = 63 slots, but a method frame has 56 slots (CompiledCode class>>fullFrameSize), and the
compiler fails with 'stack including temps is too deep'. The translator now takes the at:put:
path when the estimated stack depth of the array, nested brace arrays included, is over 32."
add value: #OCASTTranslator value: #stackDepthOfBraceArrayElement: value: 'private' value: 'stackDepthOfBraceArrayElement: aNode
"Conservative estimate of the stack slots that the push-cons-array code of aNode needs. Blocks run in their own frame."
| deepest |
aNode isBlock ifTrue: [ ^ 1 ].
deepest := 0.
aNode isDynamicArray
ifTrue: [
aNode children withIndexDo: [ :each :index |
deepest := deepest max: index - 1 + (self stackDepthOfBraceArrayElement: each) ].
^ deepest max: aNode children size ].
aNode children do: [ :each | deepest := deepest max: (self stackDepthOfBraceArrayElement: each) ].
^ deepest + 1'.
fix value: #OCASTTranslator value: #visitArrayNode: value: [ :s | (s includesSubstring: 'statements size > 32') and: [ (s includesSubstring: 'stackDepthOfBraceArrayElement:') not ] ] value: 'visitArrayNode: anArrayNode
| elementNodes |
"A brace array that needs more stack than the frame has is built with at:put: (pharo issue 19058)."
(anArrayNode statements size > 32 or: [ (self stackDepthOfBraceArrayElement: anArrayNode) > 32 ]) ifTrue: [ ^ self visitLargeArrayNode: anArrayNode ].
elementNodes := anArrayNode children.
elementNodes do: [ :node | self visitNode: node ].
methodBuilder pushConsArray: elementNodes size'.
fix value: #OCArrayLiteralTest value: #testLiteralArrayLongHavingAnotherArrayLong value: [ :s | s includesSubstring: 'self skip' ] value: 'testLiteralArrayLongHavingAnotherArrayLong
| method array elements |
elements := ((1 to: 32) inject: '' '' into: [ :r :e | r , '' . '' , e asString ]).
array := '' { '' , elements , '' }''.
array := array copyReplaceAll: ''32'' with: array.
method := self compile: ''array ^'' , array.
array := method valueWithReceiver: #().
self assert: ( array isKindOf: Array).
self assert: array size equals: 32.
1 to: 31 do: [ :index | self assert: (array at: index) equals: index ].
1 to: 32 do: [ :index | self assert: ((array at: 32) at: index) equals: index ]'.
State of 2026-11-20. Made from the test records of the iospharo project (a second Pharo VM). The fixes are proposals for review.