instruction-level block types declaration #420
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
binary_encoder.ml
, we acquiesce block types should not have index. These indices are removed by functionbt_some_to_raw
in the rewriting phase, which checks inline types' correspondence with the type section.This would make the encoding of inline function-like block types invalid. For example :
Here,
block (param i32) (result i32)
is encoded as0x02
(forblock
)0x01 0x7F
(forparam i32
, but I think it should be0x7F
for representing the inline value typei32
). And in reality, the first0x01
would be parsed as type index, and the second0x7F
parsed as the instructioni64.div_s
, making arraying indexing out of bounds.In contrast, function types are added in the grouping phase by
declare_func_type
, and rewrited in the rewriting phase byrewrite_block_type
, to assign them a type index. I think we should do the same thing to inline block types.(In the reference interpreter, block types are also added to the types section :
)