Skip to content

Conversation

@lum1n0us
Copy link
Contributor

Since basic_block_else is NULL, it meets a crash if there is a
IF block without a else branch. Like:

(func (export "params-id") (param i32) (result i32)
  (i32.const 1)
  (if (param i32) (result i32) (local.get 0)
    (then)
  )
)

Consider the ELSE block will be created lazily, focus on
`basic_block_entry" here.

goto fail;
}
if (!push_jit_block_to_stack_and_pass_params(
cc, block, block->basic_block_entry, value))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also modify L195, change if (basic_block == block->basic_block_entry) to:
if (block->wasm_code_else), if has else branch, we should generate BNE cond, basic_block_entry, basic_block_else, if no, we should generate BNE cond, basic_block_entry, basic_block_end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the part I am not sure about it yet. Let me take more time to dig into it.

Since `basic_block_else` is NULL, it meets a crash if there is a
IF block without a else branch. Like:

``` wat
(func (export "params-id") (param i32) (result i32)
  (i32.const 1)
  (if (param i32) (result i32) (local.get 0)
    (then)
  )
)
```

Consider the ELSE block will be created lazily, focus on
`basic_block_entry" here.
@lum1n0us
Copy link
Contributor Author

And there is another problem: after load_block_params(), shall we also push return values from the previous block ?

@wenyongh
Copy link
Collaborator

And there is another problem: after load_block_params(), shall we also push return values from the previous block ?

Yes, that's really an issue, I have tried to fix it in another PR:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1050/files#diff-16c33ead1da22f9948b953ef64d866ef0996bd1e82286d0cb4dee785c98d07aa

See load_block_results added, and the handle_op_end which calls load_block_results. Have tested some cases, but normally we should carefully check the codes and test more cases.

@wenyongh wenyongh merged commit 0f2885c into bytecodealliance:dev/fast_jit Mar 21, 2022
@lum1n0us lum1n0us deleted the fix_null_else_bb branch May 10, 2022 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants