Skip to content

Commit

Permalink
Cheerp Docs: clarify usage of __asm__ keyword (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri91 authored Sep 15, 2023
1 parent a225a9c commit 6f90abf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/docs/cheerp/reference/javascript-interop/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ There are some Cheerp specific limitations at this time:
A working example/tutorial is here: [example of _ asmjs _ and namespace client on Github](https://gist.github.com/carlopi/c36e9b8f0eaf72c569491fadac331707)
Code inside `__asm__` tag should never throw to the external scope.
Code inside `__asm__` tag should never throw to the external scope, and should consist of a single JS expression or statement without the final `;`.
## Clobbering names
Cheerp minifies the output by default (unless the `-cheerp-pretty-code` option is used). This happens by assigning the smallest possible symbols to the most used local or global variables. If you need to use temporary variables in inline asm code you need to declare those variables in the clobber list, for example
```
__asm__("var jsTemp1=%0; var jsTemp2=jsTemp+1; console.log(jsTemp2);" : /*No output*/ : "r"(42) : /*Clobber list*/ "jsTemp1","jsTemp2"); // This will print out "43"
__asm__("(function(){var jsTemp1=%0; var jsTemp2=jsTemp+1; console.log(jsTemp2);})()" : /*No output*/ : "r"(42) : /*Clobber list*/ "jsTemp1","jsTemp2"); // This will print out "43"
```
All names declared as clobbered will be globally excluded from the list of symbol that are used for minification. The effect is the same as marking those names as reserved using the `-cheerp-reserved-names` command line option. For best results we recommend to choose temporary names while keeping the following into account:
Expand Down

0 comments on commit 6f90abf

Please sign in to comment.