Context
Phase 1 of #573 migrated Map<K, V> to the heap-wrap-as-ADT scheme. This issue tracks the parallel migration for Decimal, which still uses raw i32 handles into _decimal_store and therefore still leaks per execute().
Decimal differs slightly from Map and Set: there are many more host helpers (decimal_from_int, decimal_from_string, decimal_from_float, decimal_add, decimal_sub, decimal_mul, decimal_div, decimal_round, ...) and most return new handles, so the wrap migration touches every arithmetic call-site.
Scope
vera/wasm/calls_containers.py — wrap on every Decimal-returning op (≈10 sites covering construction + binary ops + round); unwrap on every Decimal-consuming op (decimal_eq, decimal_compare, decimal_to_string, decimal_to_float).
vera/wasm/helpers.py — remove "Decimal" from _HOST_HANDLE_TYPES.
vera/codegen/api.py::host_decref_handle — add kind == 3 branch popping _decimal_store.
vera/browser/runtime.mjs::host_decref_handle — same kind === 3 branch popping decimalStore.
- Define
_WRAP_KIND_DECIMAL = 3 and _DECIMAL_HANDLE_TAG = 0xFEEDC003 constants alongside the Map equivalents (already reserved in the phase-1 PR).
- Regression test for a heavy Decimal arithmetic loop showing
_decimal_store stays bounded.
- Update
TestOpaqueHandleParamRooting347::test_decimal_param_not_shadow_pushed for the post-migration expectation.
Acceptance
- 5 000-iteration
decimal_add chain: _decimal_store size at exit < 100.
- All existing Decimal tests still pass.
- Browser parity tests pass.
Decimal is removed from _HOST_HANDLE_TYPES.
Notes for the implementor
array_fold over Decimal accumulators is the natural stress shape (mirrors TestArrayFoldHandleRooting490 with the post-migration expectation flipped — accumulators ARE rooted now).
- Watch for
decimal_round which has a different signature than the other binary ops (takes a precision arg as i64).
Context
Phase 1 of #573 migrated
Map<K, V>to the heap-wrap-as-ADT scheme. This issue tracks the parallel migration forDecimal, which still uses raw i32 handles into_decimal_storeand therefore still leaks perexecute().Decimal differs slightly from Map and Set: there are many more host helpers (
decimal_from_int,decimal_from_string,decimal_from_float,decimal_add,decimal_sub,decimal_mul,decimal_div,decimal_round, ...) and most return new handles, so the wrap migration touches every arithmetic call-site.Scope
vera/wasm/calls_containers.py— wrap on every Decimal-returning op (≈10 sites covering construction + binary ops + round); unwrap on every Decimal-consuming op (decimal_eq,decimal_compare,decimal_to_string,decimal_to_float).vera/wasm/helpers.py— remove"Decimal"from_HOST_HANDLE_TYPES.vera/codegen/api.py::host_decref_handle— addkind == 3branch popping_decimal_store.vera/browser/runtime.mjs::host_decref_handle— samekind === 3branch poppingdecimalStore._WRAP_KIND_DECIMAL = 3and_DECIMAL_HANDLE_TAG = 0xFEEDC003constants alongside the Map equivalents (already reserved in the phase-1 PR)._decimal_storestays bounded.TestOpaqueHandleParamRooting347::test_decimal_param_not_shadow_pushedfor the post-migration expectation.Acceptance
decimal_addchain:_decimal_storesize at exit < 100.Decimalis removed from_HOST_HANDLE_TYPES.Notes for the implementor
array_foldover Decimal accumulators is the natural stress shape (mirrorsTestArrayFoldHandleRooting490with the post-migration expectation flipped — accumulators ARE rooted now).decimal_roundwhich has a different signature than the other binary ops (takes a precision arg as i64).