Skip to content

Compiler: keep Int32 and Nativeint in the IR for the js backend #1915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 11, 2025

Conversation

hhugo
Copy link
Member

@hhugo hhugo commented Apr 3, 2025

Previously, primitives taking float arguments
could receive Int/Int32/NativeInt/Float arg

@hhugo
Copy link
Member Author

hhugo commented Apr 3, 2025

Experimentation based on this comment #1649 (comment)

@hhugo
Copy link
Member Author

hhugo commented Apr 4, 2025

With the current PR, compiling ocamlc result in the following diff. Two 4 become 4.

$ diff master.js pr.js 
35587c35587
<          Math.floor(v14535 * 4 / v14534 * 1000. + 0.5) / 1000.),
---
>          Math.floor(v14535 * 4. / v14534 * 1000. + 0.5) / 1000.),
35595c35595
<     var v14543 = [0, v14542.length - 2 | 0], v14545 = v14544 * 4;
---
>     var v14543 = [0, v14542.length - 2 | 0], v14545 = v14544 * 4.;

@hhugo hhugo force-pushed the no-identity branch 2 times, most recently from f4b9dab to b4dc100 Compare April 4, 2025 21:35
@hhugo
Copy link
Member Author

hhugo commented Apr 7, 2025

The issue now is that wasmoo uses information from the js runtime but some //Alias: annotations are not wasmoo compatible. @vouillon, do you have any plan for another mechanism to keep "purity" information for the wasm runtime ?

@vouillon
Copy link
Member

vouillon commented Apr 7, 2025

The issue now is that wasmoo uses information from the js runtime but some //Alias: annotations are not wasmoo compatible. @vouillon, do you have any plan for another mechanism to keep "purity" information for the wasm runtime ?

I did not plan to do that. One issue is that if we start duplicating this information, we will have to make sure to keep things in sync. The other issue is that I don't know where else to put this information.

@hhugo hhugo force-pushed the no-identity branch 2 times, most recently from 49f4cac to e780e71 Compare April 9, 2025 09:25
@hhugo
Copy link
Member Author

hhugo commented Apr 9, 2025

This PR is now includes

With this PR, wasmoo no longer resolves aliases during codegen. Aliases are still used to compute purity though.

I think there is still an issue with #1922, can you take a look ?

@hhugo hhugo changed the title Don't noop conversion between ints/float with the same runtime repr. Remove noop conversion between ints/float with the same runtime repr. Apr 10, 2025
@hhugo hhugo marked this pull request as ready for review April 10, 2025 09:11
@hhugo hhugo changed the title Remove noop conversion between ints/float with the same runtime repr. Compiler: keep Int32 and Nativeint in the IR for the js backend Apr 10, 2025
@hhugo hhugo merged commit d8a731f into master Apr 11, 2025
25 of 26 checks passed
@hhugo hhugo deleted the no-identity branch April 11, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants