|
|
Subscribe / Log in / New account

Portable low-level *compiled* code

Portable low-level *compiled* code

Posted Nov 18, 2019 15:16 UTC (Mon) by ballombe (subscriber, #9523)
In reply to: Portable low-level *compiled* code by Cyberax
Parent article: Announcing the Bytecode Alliance

Does it have break; and continue; ?


to post comments

Portable low-level *compiled* code

Posted Nov 18, 2019 16:35 UTC (Mon) by excors (subscriber, #95769) [Link] (2 responses)

According to https://webassembly.github.io/spec/core/syntax/instructio... a program consists of well-nested block..end/loop..end/if..end instructions. The br instruction can refer to any block/loop/if that it's nested under; for block/if it behaves like C's break (jumping to the end of the block), for loop it behaves like C's continue (jumping back to the start). If you want to compile a C loop that contains both break and continue, I guess you'd need a "(block (loop (...)))" to allow br in both directions. It looks like switch statements get implemented as a nested stack of blocks (roughly one per case), and then a br_table instruction that dynamically chooses which level of block to break out of, so that it's still nesting-based control flow.

Portable low-level *compiled* code

Posted Nov 18, 2019 22:50 UTC (Mon) by ballombe (subscriber, #9523) [Link] (1 responses)

And yet arbitrary setjmp/longjmp work (yes I tested).

Portable low-level *compiled* code

Posted Nov 19, 2019 5:49 UTC (Tue) by eru (subscriber, #2753) [Link]

There does not appear to be any dedicated exception handling, so implementing that (or throw...catch) must be quite kludgy.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds