-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support for native methods #2
Comments
Annotation @WasmBinaryCode Set the final binary bytes directly via a annotation to a method.
Pro
Conta
|
Annotation @WasmCodeBuilder Use the the API for the intermediate code that also use the JWebAssembly compiler.
Pro
Contra
|
Annotation @WasmTextCode Write a WebAssembly text notation code as annotation to a function.
Pro
Contra
|
There is an annotation @WasmTextCode. And some native APIs was implement with it. |
Just curious. In the @Replace( "java/lang/Double.doubleToRawLongBits(D)J" )
@WasmTextCode( "local.get 0 i64.reinterpret_f64 return" )
static long doubleToRawLongBits(double value) {
return 0; // for Java compiler
} do this? @Replace( "java/lang/Double.doubleToRawLongBits(D)J" )
@WasmTextCode( "local.get 0 i64.reinterpret_f64 return" )
static native long doubleToRawLongBits(double value); Seems like this is exactly what |
You are right. Can be historian reasons or a simple mistake. You should make a pull request for it. |
Oops, I see now that the code I was looking at is obsolete In diff --git a/test/de/inetsoftware/jwebassembly/runtime/CallFunctions.java b/test/de/inetsoftware/jwebassembly/runtime/CallFunctions.java
index 4d7d453..2d0c329 100644
--- a/test/de/inetsoftware/jwebassembly/runtime/CallFunctions.java
+++ b/test/de/inetsoftware/jwebassembly/runtime/CallFunctions.java
@@ -86,8 +86,6 @@ static float nativeCall() {
+ "local.get 1 " //
+ "f32.max " //
+ "return" )
- private static float nativeMax( float a, float b) {
- return Math.max( a, b );
- }
+ private static native float nativeMax( float a, float b);
}
} Not sure if that's there for a special reason or not... kindof looks like it. |
I does not understand what you means. First you referenced to https://github.com/i-net-software/JWebAssembly-API/blob/master/src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForDouble.java There it is possible to change to a native method. Now you referenced to a unit test which test @WasmTextCode annotation. I can also not find the change set which you referenced. The method nativeMax was never native. |
Yes I am confused too... :) OK duh, I checked out the wrong project (JWebAssembly instead of JWebAssembly-API). That patch above applies to the JWebAssembly project (if correct). I will create a separate pull request for the JWebAssembly-API project. Thanks. |
FYI, PR#1. |
Sorry for the confusion. The first project is the compiler. And the second one is the runtime API (one of several possible APIs). What can I improve to avoid such confusion in the future? |
Hah - nothing. My fault, not yours :) |
WebAssembly supports many features that can not handle directly via Java syntax. To support this we need a syntax extension. This can be important for writing a library.
Please write suggestions and comments to this issue.
The text was updated successfully, but these errors were encountered: