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

For packaging for debian => need source information #129

Open
bastien-roucaries opened this issue Nov 12, 2023 · 6 comments
Open

For packaging for debian => need source information #129

bastien-roucaries opened this issue Nov 12, 2023 · 6 comments

Comments

@bastien-roucaries
Copy link

How did you build the wasm included in the js file ?

Where does come from test/goog ?

Thanks

@bastien-roucaries
Copy link
Author

Moreover I can not compile the wasm:
wasm.wat:10:6: error: unexpected token "get_global", expected an instr.
(get_global $high)
^^^^^^^^^^
wasm.wat:14:6: error: unexpected token "set_local", expected an instr.
(set_local $result
^^^^^^^^^
wasm.wat:17:12: error: unexpected token i64.extend_u/i32.
(i64.extend_u/i32
^^^^^^^^^^^^^^^^
wasm.wat:18:14: error: unexpected token get_local.
(get_local $xl)
^^^^^^^^^

@bastien-roucaries
Copy link
Author

@dcodeIO Any news ?

@bastien-roucaries
Copy link
Author

@dcodeIO
Copy link
Owner

dcodeIO commented Feb 11, 2024

The .wasm was built from the .wat file using WABT, at a time when local_get / global_get were still named get_local / get_global. Some basic instruction names changed since, but it should trivially build when updated.

The test/goog files come from Google's closure library.

@bastien-roucaries
Copy link
Author

@dcodeIO If you could give me the exact command or step used for recompiling it will be really helful. I fail

@bastien-roucaries
Copy link
Author

commit 121318aa4e9e8fe7f5c4bf82271abfa4d0f9f9b7
Author: Bastien Roucariès <rouca@debian.org>
Date:   Fri Feb 16 20:15:57 2024 +0000

    Convert to modern wasm
    
    forwarded: https://github.com/dcodeIO/long.js/issues/129

diff --git a/wasm.wat b/wasm.wat
index 983fcdf..d1bfeb4 100644
--- a/wasm.wat
+++ b/wasm.wat
@@ -7,206 +7,206 @@
   (export "get_high" (func $get_high))
   (global $high (mut i32) (i32.const 0))
   (func $get_high (result i32)
-    (get_global $high)
+    (global.get $high)
   )
   (func $mul (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (result i32)
     (local $result i64)
-    (set_local $result
+    (local.set $result
       (i64.mul
         (i64.or
-          (i64.extend_u/i32
-            (get_local $xl)
+          (i64.extend_i32_u
+            (local.get $xl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $xh)
+            (i64.extend_i32_u
+              (local.get $xh)
             )
             (i64.const 32)
           )
         )
         (i64.or
-          (i64.extend_u/i32
-            (get_local $yl)
+          (i64.extend_i32_u
+            (local.get $yl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $yh)
+            (i64.extend_i32_u
+              (local.get $yh)
             )
             (i64.const 32)
           )
         )
       )
     )
-    (set_global $high
-      (i32.wrap/i64
+    (global.set $high
+      (i32.wrap_i64
         (i64.shr_s
-          (get_local $result)
+          (local.get $result)
           (i64.const 32)
         )
       )
     )
-    (i32.wrap/i64
-      (get_local $result)
+    (i32.wrap_i64
+      (local.get $result)
     )
   )
   (func $div_s (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (result i32)
     (local $result i64)
-    (set_local $result
+    (local.set $result
       (i64.div_s
         (i64.or
-          (i64.extend_u/i32
-            (get_local $xl)
+          (i64.extend_i32_u
+            (local.get $xl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $xh)
+            (i64.extend_i32_u
+              (local.get $xh)
             )
             (i64.const 32)
           )
         )
         (i64.or
-          (i64.extend_u/i32
-            (get_local $yl)
+          (i64.extend_i32_u
+            (local.get $yl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $yh)
+            (i64.extend_i32_u
+              (local.get $yh)
             )
             (i64.const 32)
           )
         )
       )
     )
-    (set_global $high
-      (i32.wrap/i64
+    (global.set $high
+      (i32.wrap_i64
         (i64.shr_s
-          (get_local $result)
+          (local.get $result)
           (i64.const 32)
         )
       )
     )
-    (i32.wrap/i64
-      (get_local $result)
+    (i32.wrap_i64
+      (local.get $result)
     )
   )
   (func $div_u (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (result i32)
     (local $result i64)
-    (set_local $result
+    (local.set $result
       (i64.div_u
         (i64.or
-          (i64.extend_u/i32
-            (get_local $xl)
+          (i64.extend_i32_u
+            (local.get $xl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $xh)
+            (i64.extend_i32_u
+              (local.get $xh)
             )
             (i64.const 32)
           )
         )
         (i64.or
-          (i64.extend_u/i32
-            (get_local $yl)
+          (i64.extend_i32_u
+            (local.get $yl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $yh)
+            (i64.extend_i32_u
+              (local.get $yh)
             )
             (i64.const 32)
           )
         )
       )
     )
-    (set_global $high
-      (i32.wrap/i64
+    (global.set $high
+      (i32.wrap_i64
         (i64.shr_s
-          (get_local $result)
+          (local.get $result)
           (i64.const 32)
         )
       )
     )
-    (i32.wrap/i64
-      (get_local $result)
+    (i32.wrap_i64
+      (local.get $result)
     )
   )
   (func $rem_s (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (result i32)
     (local $result i64)
-    (set_local $result
+    (local.set $result
       (i64.rem_s
         (i64.or
-          (i64.extend_u/i32
-            (get_local $xl)
+          (i64.extend_i32_u
+            (local.get $xl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $xh)
+            (i64.extend_i32_u
+              (local.get $xh)
             )
             (i64.const 32)
           )
         )
         (i64.or
-          (i64.extend_u/i32
-            (get_local $yl)
+          (i64.extend_i32_u
+            (local.get $yl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $yh)
+            (i64.extend_i32_u
+              (local.get $yh)
             )
             (i64.const 32)
           )
         )
       )
     )
-    (set_global $high
-      (i32.wrap/i64
+    (global.set $high
+      (i32.wrap_i64
         (i64.shr_s
-          (get_local $result)
+          (local.get $result)
           (i64.const 32)
         )
       )
     )
-    (i32.wrap/i64
-      (get_local $result)
+    (i32.wrap_i64
+      (local.get $result)
     )
   )
   (func $rem_u (param $xl i32) (param $xh i32) (param $yl i32) (param $yh i32) (result i32)
     (local $result i64)
-    (set_local $result
+    (local.set $result
       (i64.rem_u
         (i64.or
-          (i64.extend_u/i32
-            (get_local $xl)
+          (i64.extend_i32_u
+            (local.get $xl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $xh)
+            (i64.extend_i32_u
+              (local.get $xh)
             )
             (i64.const 32)
           )
         )
         (i64.or
-          (i64.extend_u/i32
-            (get_local $yl)
+          (i64.extend_i32_u
+            (local.get $yl)
           )
           (i64.shl
-            (i64.extend_u/i32
-              (get_local $yh)
+            (i64.extend_i32_u
+              (local.get $yh)
             )
             (i64.const 32)
           )
         )
       )
     )
-    (set_global $high
-      (i32.wrap/i64
+    (global.set $high
+      (i32.wrap_i64
         (i64.shr_s
-          (get_local $result)
+          (local.get $result)
           (i64.const 32)
         )
       )
     )
-    (i32.wrap/i64
-      (get_local $result)
+    (i32.wrap_i64
+      (local.get $result)
     )
   )
 )

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

2 participants