Skip to content

feat: Add HBC versions 90, 94, 96 support#50

Open
devsphere-apps wants to merge 2 commits into
bongtrop:mainfrom
devsphere-apps:feat/add-hbc-90-94-96-support
Open

feat: Add HBC versions 90, 94, 96 support#50
devsphere-apps wants to merge 2 commits into
bongtrop:mainfrom
devsphere-apps:feat/add-hbc-90-94-96-support

Conversation

@devsphere-apps

@devsphere-apps devsphere-apps commented Apr 25, 2026

Copy link
Copy Markdown

Summary

Adds support for Hermes Bytecode 90, 94, and 96: updated file header layout, parser segments (BigInt table/storage, function source table, segmentID, etc.), and registered HBC90 / HBC94 / HBC96.

Opcode tables for v90+ are aligned with facebook/hermes BytecodeList.def (including the HERMES_RUN_WASM block) so real-world index.android.bundle files from current React Native / Hermes builds disassemble successfully.

Changes

  • hbc90 — Header fields: bigIntCount, bigIntStorageSize, segmentID (replaces cjsModuleOffset), functionSourceCount, padding 31→19; BigInt + function-source segments; updated opcodes.
  • hbc94 / hbc96 — Same bytecode file layout as v90; v96 documents hasAsync in BytecodeOptions (single-byte options field, per Hermes).
  • Opcode / translator — Regenerate data/opcode.json from upstream BytecodeList.def; v90/v94/v96 translators handle operand suffixes (:S, :B, :F).
  • Project — Python ^3.8, version 0.2.0 (pyproject.toml, metadata.py).
  • Docs — README (supported versions, changelog, troubleshooting, venv / install), CONTRIBUTING.md, VERSION_HISTORY.md.
  • Teststest_new_versions.py (12 tests); root test.py runs 23 legacy unittests from the repo root.
  • UX — Lazy docopt import; python -m hbctool via __main__.py.

Fixes

Fixes #39
Fixes #40
Fixes #47
Fixes #48

How to test

cd hbctool
python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
python3 -m pip install -e .
python3 -m pytest test_new_versions.py -v
python3 test.py

Result: all 12 test_new_versions tests passed; legacy suite 23 tests passed (OK).

- Add hbc90: BigInt support (LoadConstBigInt, LoadConstBigIntLongIndex),
  segmentID (renamed from cjsModuleOffset), bigIntCount, bigIntStorageSize,
  functionSourceCount header fields, BigInt table/storage parsing,
  FunctionSource table parsing, padding reduced 31→19 bytes
- Add hbc94: BytecodeOptions refinements (same binary layout as v90)
- Add hbc96: hasAsync flag in BytecodeOptions
- Update hbctool/hbc/__init__.py to register versions 90, 94, 96
- Bump version to 0.2.0 in metadata.py and pyproject.toml
- Update Python requirement to ^3.8, add classifiers for 3.8–3.12
- Update README.md with supported version table, changelog, troubleshooting
- Add CONTRIBUTING.md with guide for adding new HBC versions
- Add VERSION_HISTORY.md documenting format changes per version
- Add test_new_versions.py validation tests

Fixes bongtrop#39 (v90)
Fixes bongtrop#40 (v94)
Fixes bongtrop#47 (v96)
Fixes bongtrop#48 (v96)
Fixes bongtrop#41 (v85 - already existed)

Made-with: Cursor
Regenerate data/opcode.json from facebook/hermes main BytecodeList.def via the updated opcode_generator (includes HERMES_RUN_WASM block for real React Native bundles).

Strip :B and :F operand suffixes in translators before operand_type lookup; accept UInt16:B/UInt32:B in tests.

Developer experience: lazy-import docopt in main(); add hbctool/__main__.py for python -m hbctool; add repo-root test.py runner for legacy unittests.

Docs: README venv/Pip install, externally-managed-environment, disasm outputs (instruction.hasm); CONTRIBUTING test commands; VERSION_HISTORY opcode regeneration note; gitignore kapanya_output and hermes_out-style paths.
Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant