Git Product home page Git Product logo

Comments (6)

bastien-roucaries avatar bastien-roucaries commented on June 26, 2024

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)
^^^^^^^^^

from long.js.

bastien-roucaries avatar bastien-roucaries commented on June 26, 2024

@dcodeIO Any news ?

from long.js.

bastien-roucaries avatar bastien-roucaries commented on June 26, 2024

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

from long.js.

dcodeIO avatar dcodeIO commented on June 26, 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.

from long.js.

bastien-roucaries avatar bastien-roucaries commented on June 26, 2024

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

from long.js.

bastien-roucaries avatar bastien-roucaries commented on June 26, 2024
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)
     )
   )
 )

from long.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.