HaxeFoundation / HaxeFoundation/haxe

Emscripten/ASM.js Style Type Hints

Open
#10,179 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Emscripten has a funky way of annotating JS that enables the JIT to skip dynamic type checking:

```
function increment(int) {
int = int|0;
return (int + 1)|0;
}
```

This style evolved organically in response to benchmarking and was later formalized into [ASM.js](https://en.wikipedia.org/wiki/Asm.js) and then WASM. There is [a prior ticket](https://github.com/HaxeFoundation/haxe/issues/1649) proposing an ASM.js target, which was closed because ASM.js forbids the use of garbage collection. However, I'm not suggesting adopting the full ASM.js standard, just an option to add these type hints to the JS target's output.

The suggestion to [add ASM.js type hints](https://github.com/HaxeFoundation/haxe/issues/5763#issuecomment-557702367) has been brought up before in another ticket, but didn't go anywhere because they weren't sure if there would be a speed boost. However, it _should_ help: Chrome initially declined to add an ASM.js specific pass in part because their engine was already pretty good at leveraging the annotations directly (and I think they were busy building TurboFan). These types of annotations might also benefit other targets as well....

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.