Skip to content

Fix returning newly instantiated arrays#197

Open
rafael226 wants to merge 2 commits into
Syncleus:masterfrom
rafael226:bounty/return-new-array-directly
Open

Fix returning newly instantiated arrays#197
rafael226 wants to merge 2 commits into
Syncleus:masterfrom
rafael226:bounty/return-new-array-directly

Conversation

@rafael226
Copy link
Copy Markdown

Fixes #66.

This changes code generation for return new <primitive>[size] so it emits the newly-created array as a local temporary and returns that temporary, matching the workaround pattern that already compiled.

What changed:

  • handle I_NEWARRAY under Return without throwing CodeGenException
  • add primitive newarray descriptor mapping for local array declarations
  • update primitive direct-array-return codegen tests from expected exception to expected OpenCL
  • unignore the existing runtime regression test

Validated locally with:

mvn -q -Djacoco.skip=true -Dtest='ReturnInstantiatedArrayDirectlyTest,Return*ArrayNewTest,Return*ArrayVarTest' test

Local note: the project POM contains -XX:MaxPermSize=512m, which JDK 17 rejects, so I removed that flag only for the local validation run and restored pom.xml afterward.

@rafael226
Copy link
Copy Markdown
Author

Expanded the fix to cover direct returns for all primitive array types, including boolean. The implementation now derives the emitted return-array type from the method return type and the tests share a common expected-OpenCL helper to keep coverage consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOUNTY $25] Can not directly return an instantiated array.

1 participant