You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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 generatesif
+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*
toInvoke*
. 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 typeThrowable
by generating anif
tree much like today. However, theif
tree which is generated can be reused by every call site with the same list; furthermore, theif
tree for a given list ofn
items (wheren > 1
) can delegate to theif
tree for the corresponding tail list ofn - 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 translatingThrow
toGoto
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).
The text was updated successfully, but these errors were encountered: