Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Jan 22, 2026

This started out as just a bit of cleanup and documentation, but with help from @andreaTP it became a large update of how we use Chicory to run Prism.

The original cleanup items:

  • prism.org already exists and we don't own it, so moved Maven groupID to org.jruby.
  • As this is a chicory-based binding for prism, renamed artifact to chicory-prism.
  • Added JRuby dependency, as the only current consumer of chicory-prism is JRuby and the parser will usually reference RubySymbol.
  • Moved make target java-wasm build output to java-wasm/src/main/resources.
  • Added a README with basic instructions for bootstrapping and building the artifact.

After that, the functional updates:

  • update chicory to latest (1.6.1)
  • proper memory management for data entering and leaving the WASM engine
  • reduce allocation for buffers that can be used repeatedly
  • start preparing to publish a maven artifact

kddnewton and others added 30 commits November 5, 2025 13:02
See ruby/ruby@6d81969

It leaves the old variant around. RuboCop for examples accesses `Prism::Translation::Parser35`
to test against ruby-head. For now I left these simply as an alias
While the latter creates an intermediate array of all method names
including all ancestors, the former just traverse the inheritance
chain and can stop if found once.
Use `method_defined?` instead of `instance_methods.include?`
Bumps the java-deps group in /java-wasm with 3 updates: [com.dylibso.chicory:bom](https://github.com/dylibso/chicory), com.dylibso.chicory:annotations-processor and [com.dylibso.chicory:chicory-compiler-maven-plugin](https://github.com/dylibso/chicory).


Updates `com.dylibso.chicory:bom` from 1.5.3 to 1.6.0
- [Release notes](https://github.com/dylibso/chicory/releases)
- [Commits](dylibso/chicory@1.5.3...1.6.0)

Updates `com.dylibso.chicory:annotations-processor` from 1.5.3 to 1.6.0

Updates `com.dylibso.chicory:chicory-compiler-maven-plugin` from 1.5.3 to 1.6.0
- [Release notes](https://github.com/dylibso/chicory/releases)
- [Commits](dylibso/chicory@1.5.3...1.6.0)

Updates `com.dylibso.chicory:annotations-processor` from 1.5.3 to 1.6.0

Updates `com.dylibso.chicory:chicory-compiler-maven-plugin` from 1.5.3 to 1.6.0
- [Release notes](https://github.com/dylibso/chicory/releases)
- [Commits](dylibso/chicory@1.5.3...1.6.0)

---
updated-dependencies:
- dependency-name: com.dylibso.chicory:bom
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: java-deps
- dependency-name: com.dylibso.chicory:annotations-processor
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: java-deps
- dependency-name: com.dylibso.chicory:chicory-compiler-maven-plugin
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: java-deps
- dependency-name: com.dylibso.chicory:annotations-processor
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: java-deps
- dependency-name: com.dylibso.chicory:chicory-compiler-maven-plugin
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: java-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
…a-deps-48b38cc957

Bump the java-deps group in /java-wasm with 3 updates
`gemfiles/3.5/Gemfile` has been updated to `gemfiles/4.0/Gemfile` by ruby#3715.
Reject endless method as a block parameter default
Reenable windows CI that were disabled because of fiddle
When we know we are in an alternation, and we know we have captured
variables, add a syntax error by visiting the pattern subtree and
finding the local variable target nodes and adding an error.
Revisit variable capture syntax error
eregon and others added 15 commits January 20, 2026 00:54
…:Ripper

* Handle line continuations.
* Handle space at the end of file in LexCompat.

Co-authored-by: Earlopain <14981592+Earlopain@users.noreply.github.com>
Add Ripper :on_sp events for Prism.lex_compat and Prism::Translation::Ripper
You're supposed to return the first argument.
```rb
# Before
[[:stmts_new], [:rescue_mod, nil, nil], [:stmts_add, nil, nil], [:program, nil]]
# After
[[:stmts_new], [:rescue_mod, "1", "2"], [:stmts_add, nil, "1"], [:program, nil]]
```

The correct result would be:
`[[:rescue_mod, "1", "2"], [:stmts_new], [:stmts_add, nil, "1"], [:program, nil]]`

But the order depends on the prism AST so it seems very difficult to match.
Fix `on_*` return value of ripper translator
… translator

* We don't know what `on_*` events might return so we cannot assume it's an Array.
* See ruby#3838 (comment)
We should touch these as little as possible and just pass them along
Add `license` identifier to Rust crates
…g-any

Check using Prism nodes if a command call has any arguments in Ripper translator
Nodes need access to RubySymbol and support APIs at least.
* It is a resource used as source code (in wasm) that is compiled
  for the project artifact.
* Added to Rake CLOBBER
with:
name: prism.wasm
path: java-wasm/src/test/resources/prism.wasm
path: java-wasm/src/main/resources/prism.wasm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prism.wasm file was very intentionally placed in test so that it doesn't get included in the resulting jar (it's redundant).

The Chicory compiler already generates a org/prism/PrismParser.meta file that is smaller and contains everything needed for execution.

instance = Instance.builder(module)
.withMemoryFactory(limits -> new ByteArrayMemory(new MemoryLimits(10, MemoryLimits.MAX_PAGES)))
.withMachineFactory(PrismModule::create)
.withMachineFactory(parser.machineFactory())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: .withMachineFactory(PrismParser::create)

@@ -1,11 +1,12 @@
package org.prism;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but you might want to align the package name to the new groupId.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah working on that now.

Allow the buffer functions to manage the internal pointer and use
consistent argument order for calloc.
headius referenced this pull request in headius/jruby-prism-gem Jan 25, 2026
We need to free the current_block_exits in parse_program when we're done
with it to prevent memory leaks. This fixes the following memory leak detected
when running Ruby using `RUBY_FREE_AT_EXIT=1 ruby -nc -e "break"`:

    Direct leak of 32 byte(s) in 1 object(s) allocated from:
        #0 0x5bd3c5bc66c8 in realloc (miniruby+0x616c8) (BuildId: ba6a96e5a060aec6fd9f05ed7e95d9627e1dbd74)
        #1 0x5bd3c5f91fd9 in pm_node_list_grow prism/templates/src/node.c.erb:35:40
        #2 0x5bd3c5f91e9d in pm_node_list_append prism/templates/src/node.c.erb:48:9
        ruby#3 0x5bd3c6001fa0 in parse_block_exit prism/prism.c:15788:17
        ruby#4 0x5bd3c5fee155 in parse_expression_prefix prism/prism.c:19221:50
        ruby#5 0x5bd3c5fe9970 in parse_expression prism/prism.c:22235:23
        ruby#6 0x5bd3c5fe0586 in parse_statements prism/prism.c:13976:27
        ruby#7 0x5bd3c5fd6792 in parse_program prism/prism.c:22508:40
headius and others added 7 commits January 26, 2026 12:31
Primarily for testing purposes.
This is not all of the boot files but is sufficient to demonstrate
a memory fault in the AOT WASM parser.
@headius headius merged commit ed09e78 into jruby:topic/javawasm_changes Feb 3, 2026
62 of 65 checks passed
@headius headius deleted the jruby-prism-wasm-updates branch February 3, 2026 19:28
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.