Why define beginToTierEntry_ as a uint8_t in CodeRange?

I’m porting SpiderMonkey into risc-v.
Recently, i encounter a problem about CodeRange.

0x00005555589b4864 in js::wasm::CodeRange::CodeRange (this=0x7fffffff6870, funcIndex=30, funcLineOrBytecode=514, offsets=...)
    at /home/luyahan/source/gecko/js/src/wasm/WasmCodegenTypes.cpp:136
136	  MOZ_ASSERT(offsets.tierEntry - begin_ <= UINT8_MAX);`

Because beginToTierEntry_ is a uint8_t, offsets.tierEntry - begin_ must less than UINT8_MAX.
But in risc-v, it exceeds 255

(gdb) p begin_
$1 = 3488
(gdb) p offsets.tierEntry
$2 = 3984
(gdb) p offsets.tierEntry - begin_
$3 = 496
(gdb) bt

What can i do to fix it?


Hi LuYahan,

It looks like this field is uint8_t to make CodeRange smaller, and we’ve never needed a larger range. It’s okay to increase the field size to uint16_t if that’s required by a platform.

1 Like