Skip to content
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

Unit test on high bit shifts #10752

Open
ncannasse opened this issue Jul 13, 2022 · 3 comments
Open

Unit test on high bit shifts #10752

ncannasse opened this issue Jul 13, 2022 · 3 comments
Assignees
Labels
platform-eval Everything related to the Haxe 4 eval macro interpreter
Milestone

Comments

@ncannasse
Copy link
Member

The following tests might give different results depending on platforms:

function shl( x, y ) return x << y;
shl(1,33); // can be 0 or 2, depending if native CPU opcode is used (which does &31 on shift value)

https://c9x.me/x86/html/file_module_x86_id_285.html

I think we should make it platform agnostic, but I'm curious to know if the issue is HL specific or if some other platforms are affected.

@Simn
Copy link
Member

Simn commented Jul 13, 2022

This gives me 2 an all targets (that I tested) except Eval.

@ncannasse
Copy link
Member Author

Oh so OCaml is indeed doing something very specific regarding to bit shifting.
This explains why the compiled version of 1 << 33 (using compiler optimisation) differs from 1 << 33 at runtime.
I guess we should add a "land 31" to all bit shifts (both optimizer and eval) to match other targets.

@Simn Simn self-assigned this Jul 13, 2022
@Simn Simn added the platform-eval Everything related to the Haxe 4 eval macro interpreter label Jul 13, 2022
@Simn Simn closed this as completed in 45db4d9 Aug 1, 2022
Simn added a commit that referenced this issue Aug 1, 2022
@Simn
Copy link
Member

Simn commented Aug 1, 2022

This also fails on PHP and python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-eval Everything related to the Haxe 4 eval macro interpreter
Projects
None yet
Development

No branches or pull requests

2 participants