Skip to content

[java-wasm] Allow serialize to be called separately from serializeParse.#3537

Merged
enebo merged 1 commit into
ruby:mainfrom
enebo:topic/javawasm_changes
Apr 2, 2025
Merged

[java-wasm] Allow serialize to be called separately from serializeParse.#3537
enebo merged 1 commit into
ruby:mainfrom
enebo:topic/javawasm_changes

Conversation

@enebo

@enebo enebo commented Apr 1, 2025

Copy link
Copy Markdown
Collaborator

JRuby internally uses loader differently and also encodes options differently.

Also added MemoryPages options since in testing one file complained about memory usage.

Lastly, original method was making a String from bytes so allow serialize to accept bytes and
sourceLength since sometimes you have source smaller than the byte[] backing store.

JRuby internally uses loader differently and also encodes options
differently.

Also added MemoryPages options since in testing one file complained about
memory usage.

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks @enebo !

wasi = WasiPreview1.builder().withOptions(wasiOpts).build();
instance = Instance.builder(PrismModule.load())
.withMemoryFactory(ByteArrayMemory::new)
.withMemoryFactory(limits -> new ByteArrayMemory(new MemoryLimits(10, MemoryLimits.MAX_PAGES)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • nitpick - it will be good if the memory limits can be tuned when creating the object.

Maybe in the next iteration we can make use of a Builder to lock the constructor down.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@andreaTP yeah I think we definitely need to be able to configure. This just allowed basic parsing in JRuby to not warn for now.

@enebo

enebo commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator Author

@eregon Any chance for an approval on this? We are working towards pure-Java webasm build for platforms where foreign call access does not exist (this is WIP). This likely will be expanded beyond serialization to general gem as well.

@enebo
enebo merged commit a3326c0 into ruby:main Apr 2, 2025
@enebo
enebo deleted the topic/javawasm_changes branch April 2, 2025 21:48
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.

3 participants