We were able to run EYE on swipl.wasm
What we did for Ubuntu is available at josd.github.io/temp/eye-wasm at master · josd/josd.github.io · GitHub
sudo apt install cmake
sudo apt install ninja-build
cd ~
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ~
wget https://zlib.net/zlib-1.2.11.tar.gz -O "$HOME/zlib-1.2.11.tar.gz"
tar -xf "$HOME/zlib-1.2.11.tar.gz" -C "$HOME"
cd "$HOME/zlib-1.2.11"
emconfigure ./configure
emmake make
cd ~/github.com/SWI-Prolog/swipl-devel
mkdir build.wasm
cd build.wasm
source ~/emsdk/emsdk_env.sh
export EMSCRIPTEN=~/emsdk/upstream/emscripten/
ALLOW_MEMORY_GROWTH=1")
cmake -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1" \
-DZLIB_LIBRARY=$HOME/zlib-1.2.11/libz.a \
-DZLIB_INCLUDE_DIR=$HOME/zlib-1.2.11 \
-DMULTI_THREADED=OFF \
-DUSE_SIGNALS=OFF \
-DUSE_GMP=OFF \
-DBUILD_SWIPL_LD=OFF \
-DSWIPL_PACKAGES=OFF \
-DINSTALL_DOCUMENTATION=OFF \
-DSWIPL_NATIVE_FRIEND=build \
-G Ninja ..
ninja
cd ~/github.com/josd/josd.github.io/temp/eye-wasm
node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope socrates.n3 --query socrates-query.n3
node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope gps-plugin.n3 gps-example1.n3 --query gps-query1.n3
node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope test-dt.n3 test-facts.n3 --query test-query.n3
The first test which is about socrates runs fine
$ node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope socrates.n3 --query socrates-query.n3
eye --nope socrates.n3 --query socrates-query.n3
EYE v22.0203.1955 josd
SWI-Prolog version 8.5.7-26-g4a0a2091e-DIRTY
starting 0 [msec cputime] 434 [msec walltime]
#Processed by EYE v22.0203.1955 josd
#eye --nope socrates.n3 --query socrates-query.n3
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/socrates.n3 SC=3
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/socrates-query.n3 SC=1
networking 0 [msec cputime] 49 [msec walltime]
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/socrates#>
:Socrates a :Human.
:Socrates a :Mortal.
reasoning 0 [msec cputime] 2 [msec walltime]
#2022-02-18T13:04:30.742Z in=4 out=2 ent=3 step=6 brake=2 inf=624805 sec=0.000 inf/sec=
#ENDS
2022-02-18T13:04:30.742Z in=4 out=2 ent=3 step=6 brake=2 inf=624805 sec=0.000 inf/sec=
The second test which is about GPS4IntegratedCare also runs fine
$ node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope gps-plugin.n3 gps-example1.n3 --query gps-query1.n3
eye --nope gps-plugin.n3 gps-example1.n3 --query gps-query1.n3
EYE v22.0203.1955 josd
SWI-Prolog version 8.5.7-26-g4a0a2091e-DIRTY
starting 0 [msec cputime] 426 [msec walltime]
#Processed by EYE v22.0203.1955 josd
#eye --nope gps-plugin.n3 gps-example1.n3 --query gps-query1.n3
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/gps-plugin.n3 SC=7
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/gps-example1.n3 SC=5
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/gps-query1.n3 SC=1
networking 0 [msec cputime] 70 [msec walltime]
PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX list: <http://www.w3.org/2000/10/swap/list#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
PREFIX gps: <http://josd.github.io/eye/reasoning/gps/gps-schema#>
PREFIX : <http://josd.github.io/eye/reasoning#>
:i1 gps:path ((:drive_gent_brugge :drive_brugge_oostende) 2400.0 0.01 0.9408 0.99).
:i1 gps:path ((:drive_gent_kortrijk :drive_kortrijk_brugge :drive_brugge_oostende) 4100.0 0.018000000000000002 0.903168 0.9801).
reasoning 0 [msec cputime] 10 [msec walltime]
#2022-02-18T13:04:48.052Z in=13 out=2 ent=2 step=2 brake=2 inf=685808 sec=0.000 inf/sec=
#ENDS
2022-02-18T13:04:48.052Z in=13 out=2 ent=2 step=2 brake=2 inf=685808 sec=0.000 inf/sec=
The last test which is the 100000 deep taxonomy benchmark runs out of memory
$ node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -f eye.pl -g main -- --nope test-dt.n3 test-facts.n3 --query test-query.n3
eye --nope test-dt.n3 test-facts.n3 --query test-query.n3
EYE v22.0203.1955 josd
SWI-Prolog version 8.5.7-26-g4a0a2091e-DIRTY
starting 0 [msec cputime] 420 [msec walltime]
#Processed by EYE v22.0203.1955 josd
#eye --nope test-dt.n3 test-facts.n3 --query test-query.n3
GET file:///home/jdroo/github.com/josd/josd.github.io/temp/eye-wasm/test-dt.n3 [FATAL ERROR: at Fri Feb 18 11:42:28 2022
Cannot report error: no memory]
Aborted(native code called abort())
exiting due to exception: RuntimeError: Aborted(native code called abort()),RuntimeError: Aborted(native code called abort())
at abort (/home/jdroo/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js:1:21763)
at _abort (/home/jdroo/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js:1:101328)
at <anonymous>:wasm-function[1497]:0xc7d51
at <anonymous>:wasm-function[988]:0x9c2f9
at <anonymous>:wasm-function[472]:0x30a56
at <anonymous>:wasm-function[70]:0x3e4d
at <anonymous>:wasm-function[1602]:0xcd05f
at <anonymous>:wasm-function[1601]:0xccfc7
at invoke_iiii (/home/jdroo/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js:1:122082)
at <anonymous>:wasm-function[732]:0x5c2e3
but when running the same benchmark with webeye it works fine
$ /usr/bin/time -f "sec=%e0 kB=%M cpu=%P" node ~/github.com/SWI-Prolog/swipl-devel/build.wasm/src/swipl.js -g run,halt webeye.pl dt.pl
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'('http://example.org/ns#z','http://example.org/ns#N100000') => true.
sec=29.830 kB=504168 cpu=108%
When compared with the native swipl
$ /usr/bin/time -f "sec=%e0 kB=%M cpu=%P" swipl -g run,halt webeye.pl dt.pl
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'('http://example.org/ns#z','http://example.org/ns#N100000') => true.
sec=8.380 kB=190200 cpu=114%
we see that swipl.js is about 3.5 times slower and uses about 2.5 times more memory, but that really looks nice when compared with https://twitter.com/josderoo/status/1494097945767161862