long.js icon indicating copy to clipboard operation
long.js copied to clipboard

For packaging for debian => need source information

Open bastien-roucaries opened this issue 2 years ago • 6 comments

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

Where does come from test/goog ?

Thanks

bastien-roucaries avatar Nov 12 '23 00:11 bastien-roucaries

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 avatar Nov 12 '23 00:11 bastien-roucaries

@dcodeIO Any news ?

bastien-roucaries avatar Feb 10 '24 22:02 bastien-roucaries

It block https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1063508

bastien-roucaries avatar Feb 10 '24 22:02 bastien-roucaries

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.

dcodeIO avatar Feb 11 '24 11:02 dcodeIO

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

bastien-roucaries avatar Feb 12 '24 09:02 bastien-roucaries

commit 121318aa4e9e8fe7f5c4bf82271abfa4d0f9f9b7
Author: Bastien Roucariès <[email protected]>
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)
     )
   )
 )

bastien-roucaries avatar Feb 16 '24 20:02 bastien-roucaries