Repository navigation
Store UTF-8 constants in the constant pool as plain strings - #41
Conversation
…an object per entry
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
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. |
There was a problem hiding this comment.
This PR changes UTF-8 constant pool entries from objects to plain strings, reducing memory usage by ~10% (4 MB per VM). All constant pool readers now go through cpEntry() (which wraps strings on demand) or utf8() (which reads strings directly). The change is applied consistently across the interpreter, JIT, invokedynamic, reflection, and NPE message generation. Tests pass including boot snapshot restore and browser self-tests.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
There was a problem hiding this comment.
This PR changes the constant pool representation to store UTF-8 entries as plain strings instead of {tag, value, a, b} objects, reducing VM heap by ~10%. A new cpEntry(cp, i) function wraps a string in a CpEntry object when callers need one, while utf8(cp, i) reads the string directly. All constant pool readers across the interpreter, JIT, invokedynamic, reflection, and NPE message builder have been updated to use these two functions. Tests pass including boot snapshot restore.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
There was a problem hiding this comment.
This PR changes UTF-8 constant pool entries to be stored as plain strings instead of objects, reducing memory usage by ~10% (4 MB per VM). All constant pool access sites across the interpreter, JIT, indy, reflection, and NPE message builder are updated to use the new cpEntry() helper which wraps strings on demand. Tests and typecheck pass.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
Every constant pool entry was a
{ tag, value, a, b }object, and most entries are UTF-8 strings: names, descriptors, signatures and attribute names. A live VM restored from a boot snapshot held about 128,000 of these objects.UTF-8 entries are now stored as the string itself.
cpEntry(cp, i)returns an entry object for the other kinds and wraps a string when a caller needs one.utf8(cp, i)reads the string directly. Every reader of the constant pool goes through one of the two: the interpreter's resolution insrc/jvm.ts, the JIT, invokedynamic and condy, reflection, and the helpful NullPointerException messages.Measured on a small ARM board, median of eight alternating runs:
The times are within noise. The memory is not: about 4 MB (10%) less heap per VM.
Checks:
test/classfile.test.tscases for UTF-8 entries stored as strings and wrapped bycpEntry.pnpm typecheckandpnpm testpass (145 tests), boot snapshot restore included.Noticed, not fixed:
{ image, at }offsets, are the next largest groups of small objects. Their savings were not measured.