8000 Improve `Invoke*`: explicit catch types · Issue #1565 · qbicc/qbicc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve Invoke*: explicit catch types #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmlloyd opened this issue Nov 8, 2022 · 0 comments
Open

Improve Invoke*: explicit catch types #1565

dmlloyd opened this issue Nov 8, 2022 · 0 comments
Labels
kind: enhancement ✨ A new feature or use case

Comments

@dmlloyd
Copy link
Collaborator
dmlloyd commented Nov 8, 2022

The structure of Invoke, with its separate catch and resume labels, mirrors LLVM. In order to translate Java's catch list to a catch label, we employ an algorithm which generates if+instanceof trees for each potential throw site. This is done at the front end as the method is parsed.

However one downside to this approach is that we may end up generating multiple identical if trees if many call sites exist within range of the same catch handler list. It also makes the IR somewhat more complex to read since one must trace the catch execution through several blocks.

It might be worth trying to modify Invoke* to instead accept a list of (type, label) pairs, somewhat like a type switch.

On the front end, the method parser (or a BBB like today) would be able to determine the catch list fairly easily for a given call site and carry out the automatic promotion of Call* to Invoke*. The interpreter can perform the requisite type checks and dispatches fairly easily as well.

For LLVM, during lowering we would transform Invoke* so that it only has a single catch of type Throwable by generating an if tree much like today. However, the if tree which is generated can be reused by every call site with the same list; furthermore, the if tree for a given list of n items (where n > 1) can delegate to the if tree for the corresponding tail list of n - 1 items much like the original catch generator did. This would be simpler to do on the back end than on the front end.

Once this transformation has occurred, from the perspective of LLVM, Invoke* is identical to what it was before.

It might be necessary to add a catch list to Throw as well. This would prevent the necessity of translating Throw to Goto on the front end (this can be done during lower instead).

By using an ordered catch list, lowering to WASM might become simpler as well (see WASM exception handling for more info).

@dmlloyd dmlloyd added the kind: enhancement ✨ A new feature or use case label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement ✨ A new feature or use case
Projects
None yet
Development

No branches or pull requests

1 participant
0