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
{{ message }}
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
I might be totally wrong here, but it seems to me that wasm is an intermediate representation of compiler output. As such, it will be used to combine separately compiled entities from different compilers. Therefore, it would seem better provide to the notion of finally as a primitive so the semantics of the finally clause can be unambiguously communicated.
@winksaville, not quite, Wasm is an abstraction defining a virtual ISA. Automatic interoperability between different compilers is explicitly a non-goal (they would need to collaboratively define a common ABI).
@rossberg-chromium, it seems to me that finally has very definite semantics that is intertwined with the try/catch/else implementation and semantics. So defining it as @KarlSchimpf proposes above or some other way would be beneficial even within a system that's built by a single compilation.
Would it be ok to consider a try inst* finally' inst* end (as I suggested above) to be a future feature? Or, do you feel that this must be baked in this initial, minimal proposal?
IMHO it should be in the MVP as try finally is integral to several languages, but it's your call.
Question, are you sure try/finally can be implemented in terms of try/catch since wasm is limited to structured control flow?
Also, reading exception handing on wikipedia there seems to be at least a implementation schemes, dynamic registration and table driven. Have you implemented anything yet?
@bartwe, in Wasm, return is just a special case of a br, where the same applies. The same semantics exists in e.g. C++, yet, compilers like clang on LLVM compile away finally.
Activity
rossberg commentedon May 11, 2017
Finally can be expressed with catch and (re)throw, so isn't required as a primitive. Compilers tend to compile it away (e.g. LLVM, AFAIK).
KarlSchimpf commentedon May 11, 2017
I agree with @rossberg-chromium that one can implement the concept, but it requires an "artificial" throw in the try body.
I think a better solution is to define a second
block that always evaluates the finally instructions. This cleanly separates the two types of semantics, keeping things simple.
winksaville commentedon May 11, 2017
I might be totally wrong here, but it seems to me that
wasmis an intermediate representation of compiler output. As such, it will be used to combine separately compiled entities from different compilers. Therefore, it would seem better provide to the notion offinallyas a primitive so the semantics of thefinallyclause can be unambiguously communicated.rossberg commentedon May 11, 2017
@winksaville, not quite, Wasm is an abstraction defining a virtual ISA. Automatic interoperability between different compilers is explicitly a non-goal (they would need to collaboratively define a common ABI).
winksaville commentedon May 11, 2017
@rossberg-chromium, it seems to me that
finallyhas very definite semantics that is intertwined with the try/catch/else implementation and semantics. So defining it as @KarlSchimpf proposes above or some other way would be beneficial even within a system that's built by a single compilation.KarlSchimpf commentedon May 12, 2017
Would it be ok to consider a
try inst* finally' inst* end(as I suggested above) to be a future feature? Or, do you feel that this must be baked in this initial, minimal proposal?winksaville commentedon May 12, 2017
IMHO it should be in the MVP as
try finallyis integral to several languages, but it's your call.Question, are you sure
try/finallycan be implemented in terms oftry/catchsincewasmis limited to structured control flow?Also, reading exception handing on wikipedia there seems to be at least a implementation schemes, dynamic registration and table driven. Have you implemented anything yet?
winksaville commentedon May 12, 2017
SG and I think your suggestion of separating
try finallyfromtry catchis a good one.KarlSchimpf commentedon May 15, 2017
Marked as (future) enhancement to this proposal.
Abion47 commentedon May 15, 2017
Out of curiosity, I looked at the IL generated from compiling the following C# script:
The IL byte code that the compiler generated looked like this (ish):
So it seems like there may be something to this idea of separating the
try catchand thetry finallyblocks.bartwe commentedon Jun 2, 2017
One additional issue with finally is that it gets called also when within the try block a 'return' call is made.
rossberg commentedon Jun 2, 2017
@bartwe, in Wasm,
returnis just a special case of abr, where the same applies. The same semantics exists in e.g. C++, yet, compilers like clang on LLVM compile awayfinally.osa1 commentedon Oct 9, 2022
Should this be closed in favor of #158?
aheejin commentedon Oct 9, 2022
Yeah I think this can be closed. I don't think we will have
finallyin the current version of the EH proposal anyway though.