Skip to content

fix: create objects without code generation when eval is forbidden, keep the host's gc, and reclaim per VM - #105

Merged
Project516 merged 2 commits into
p516/next-to-masterfrom
p516/review-fixes-020
Nov 29, 2026
Merged

Project516 merged 2 commits into
p516/next-to-masterfrom
p516/review-fixes-020

Conversation

@Project516

Copy link
Copy Markdown
Owner

What this changes

Fixes review findings on the 0.2.0 changes in #104, before they reach master.

  • Pages whose Content Security Policy forbids eval can create objects again. Object constructors and field accessors (src/runtime.ts) were built with new Function, which throws there. The first such error now switches them to closures with computed keys. With eval allowed, the generated code is unchanged.
  • A host's own globalThis.gc is left as the host set it. java-web keeps its job-ending wrapper internal (setGc, collector()), so gc({ execution: "async" }) still returns a Promise after a VM starts.
  • Each VM registers its own reclaim callback, and JVM.halt removes it. A second VM in the same process no longer replaces the first VM's, and a halted VM is no longer kept alive by it.
  • finalize() counts as a finalizer unless its body is a single return, as in HotSpot, so a native finalize() counts.
  • Restoring a snapshot restores references that turn up while referents are decoded.
  • docs/support.md says System.gc() needs a host collector under Node.
  • ObjectLayout, SoftRefs, RefsAfterGc and FinalizerCycles no longer depend on collection timing for their output.

Tests

  • New tests run Finalizers and UnsafeAtomics under node --disallow-code-generation-from-strings and compare them with HotSpot. Before this change, ctorFor threw an EvalError under that flag. ObjectLayout, VarHandles and MiscUnsafe also match HotSpot under it.
  • A host gc is the same function after runNode and still returns a Promise for gc({ execution: "async" }).
  • ObjectLayout, RefsAfterGc, FinalizerCycles, Refs, Finalizers and SoftRefs (-Xmx16m) match HotSpot 25.0.5.1.
  • pnpm typecheck and pnpm test pass. The Java2D tests pass only with no display set, as before.

…heck, restore late snapshot references, and make four ref tests deterministic
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 53b15b03-b2fd-4de2-8245-2c553938f675

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR fixes several issues from the 0.2.0 changes: adds eval-blocked fallbacks using closures for object constructors and field accessors, makes reclaim callbacks per-VM instead of global, leaves the host's globalThis.gc untouched while keeping an internal job-ending wrapper, fixes finalizable detection to match HotSpot (only a single return bytecode is empty), and makes snapshot restore handle references added during referent decoding. Tests are updated to not depend on collection timing and to run under --disallow-code-generation-from-strings.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve

@Project516
Project516 merged commit 306a403 into p516/next-to-master Nov 29, 2026
12 checks passed
@Project516
Project516 deleted the p516/review-fixes-020 branch November 29, 2026 17:31
Project516 added a commit that referenced this pull request Nov 29, 2026
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.

1 participant