WebAssembly/Goto: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: WebAssembly/Goto
| Old | New | Line | |
|---|---|---|---|
| 1 | + | This article is about the implementation of Goto for the WebAssembly target in FPC. | |
| 2 | + | ||
| 3 | + | ## The problem | |
| 4 | + | ||
| 5 | + | Goto is difficult to implement, due to WebAssembly's lack of labels and jumps. It requires all gotos to be converted to structured flow, such as loops and break/continue. This requires implementing a complex algorithm, such as Relooper or Stackifier. Useful read: [1](https://medium.com/leaningtech/solving-the-structured-control-flow-problem-once-and-for-all-5123117b1ee2) | |
| 6 | + | ||
| 7 | + | ## FPC's implementation | |
| 8 | + | ||
| 9 | + | Goto support was added in commit 376de92a50259f77e0dc0e1fc3f7d07135547bbc. The current implementation resolves goto and branches, using a state machine, which is correct, but not very good in terms of speed. In the future, we might implement a faster algorithm (Stackifier). | |
| 10 | + | ||
| 11 | + | ## See Also | |
| 12 | + | ||
| 13 | + | - [[WebAssembly]] | |
| 14 | + | ||
| 15 | + | --- | |
| 16 | + | *From the Free Pascal wiki, page "WebAssembly/Goto", as it stood on 2023-10-25 after a change by Nickysn, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 17 | + | Category: WebAssembly |
