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

Hashlink null comparison #11416

Closed
ncannasse opened this issue Nov 27, 2023 · 2 comments
Closed

Hashlink null comparison #11416

ncannasse opened this issue Nov 27, 2023 · 2 comments
Assignees

Comments

@ncannasse
Copy link
Member

When comparing Null<Int> with Int, HL will allocate instead of doing two checks, one for null and one for the integer.

For example:

class Main {

	public var x : Null<Int>;
	
	static function main() {
		var m = new Main();
		var b = m.x == 3;
		trace(b);
	}

}

This produces:

	.10    @1 call 1, Main.new(0)
	.11    @2 field 3,0[6]
	.11    @3 int 4,@7
	.11    @4 todyn 5,4
	.11    @5 jeq 3,5,2

Instead of

	.10    @0 new 0
	.10    @1 call 1, Main.new(0)
	.11    @2 field 3,0[6]
	.11    @3 jnull 3,6
	.11    @5 safecast 4,3
	.11    @6 int 5,@7
	.11    @7 jnoteq 4,5,2
@Simn
Copy link
Member

Simn commented Nov 27, 2023

Note that #8426 was never merged, and I don't remember if HL ever fully passed these tests (our conversation there suggests that it didn't).

@yuxiaomao
Copy link
Contributor

Fixed by #11612

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

No branches or pull requests

3 participants