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

JVM Target Crash (Same code does not crash in Java or other targets) #10965

Closed
onehundredfeet opened this issue Feb 13, 2023 · 6 comments
Closed
Assignees
Labels
platform-jvm Everything related to JVM

Comments

@onehundredfeet
Copy link
Contributor

onehundredfeet commented Feb 13, 2023

Hi,

I'm trying to get a relatively simple math example running in the jam target and I'm getting this:

Error: Unable to initialize main class haxe.root.Error
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    haxe/root/Error.main()V @52: invokestatic
  Reason:
    Type float (current frame, stack[0]) is not assignable to 'java/lang/Object'
  Current Frame:
    bci: @52
    flags: { }
    locals: { float, float, float, float, float, float, float, float, float, float }
    stack: { float }

And the code is just a matrix inverse:

class Error {
	
	static public function main() {
        var m = new Mat3(1, 0, 0, 0, 1, 0, 0, 0, 1);
        var n = m.inverse();
        trace(n);
	}
}

I've included the code in case it's helpful. Again it works for hash link and java targets.

Code.zip

@onehundredfeet
Copy link
Contributor Author

I've reduced the inverse down to just this and can still repro the same crash:

    static public function inverse(_this : Mat3): Mat3 {
		var m:Mat3Data = _this;
        var a = m.c2.z;
        var b = 2.;
        var c = -a * b; // this fails? why? can not assign a float to an object?

        return new Mat3(c, 0.0, 0.0, c, 0.0, 0.0, c, 0.0, 0.0);
	}

@Simn Simn self-assigned this Feb 13, 2023
@Simn Simn added the platform-jvm Everything related to JVM label Feb 13, 2023
@Simn
Copy link
Member

Simn commented Feb 13, 2023

class Main {
	static public function main() {
		var a:Single = 0;
		var c = -a;
	}
}

Looks like it's just the minus Single. I guess I didn't pay much attention to singles.

@onehundredfeet
Copy link
Contributor Author

well, that was a much simpler issue than I was expecting.

@Simn Simn closed this as completed in 29a318d Feb 13, 2023
@Simn
Copy link
Member

Simn commented Feb 13, 2023

Yeah single-precision floats aren't used a whole lot. Out of curiosity, why are you using them for a math library?

@onehundredfeet
Copy link
Contributor Author

onehundredfeet commented Feb 13, 2023

Because it's styled after shader math, it's intended to support different precisions for speed purposes. It supports both singles and doubles.

The irony is that I've been doing some benchmarks, and on my apple m1, the doubles are faster than singles.

I'm not sure the same is true of x86 though.

@onehundredfeet
Copy link
Contributor Author

Thanks for fixing this so quickly Simon!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-jvm Everything related to JVM
Projects
None yet
Development

No branches or pull requests

2 participants