Compare commits
357 Commits
Author | SHA1 | Date |
---|---|---|
|
01acb468de | 1 year ago |
|
693e633164 | 1 year ago |
|
0f758a7602 | 1 year ago |
|
7a534581c5 | 1 year ago |
|
8f1ea67df9 | 1 year ago |
|
6b0ba99e86 | 1 year ago |
|
4ae8b02413 | 1 year ago |
|
de22264f4d | 2 years ago |
|
bfc842924e | 2 years ago |
|
9f465e01fe | 2 years ago |
|
22860ba0d1 | 2 years ago |
|
4e1f67929e | 2 years ago |
|
23639915c4 | 2 years ago |
|
b85e13fb5f | 2 years ago |
|
ba8818e4f8 | 2 years ago |
|
90f9987c82 | 2 years ago |
|
8d1ba3d9b0 | 2 years ago |
|
5e2558048a | 3 years ago |
|
562e5d8623 | 3 years ago |
|
bc2c52165a | 3 years ago |
|
dac95d08f4 | 3 years ago |
|
be911e206c | 3 years ago |
|
6d7d815ee7 | 3 years ago |
|
a2188b8bae | 3 years ago |
|
f004d6c827 | 3 years ago |
|
beed67cea0 | 3 years ago |
|
7b9b28f5d8 | 3 years ago |
|
5f86707403 | 3 years ago |
|
50fd8c4853 | 3 years ago |
|
16f5095156 | 3 years ago |
|
2caf4de75a | 3 years ago |
|
2c76926e83 | 3 years ago |
|
0c3b661301 | 3 years ago |
|
56f32ec44b | 3 years ago |
|
92ac9b056f | 3 years ago |
|
0f9e01dad1 | 3 years ago |
|
38494da400 | 3 years ago |
|
63e38f0e7c | 3 years ago |
|
61baa40ba4 | 3 years ago |
|
199914d69d | 3 years ago |
|
1981c01338 | 3 years ago |
|
cd73d7d172 | 3 years ago |
|
66aa87a152 | 3 years ago |
|
cdca93f317 | 3 years ago |
|
9458c5ad7f | 3 years ago |
|
876634b87b | 3 years ago |
|
edf98efa51 | 3 years ago |
|
2b5957c394 | 3 years ago |
|
89fc0b26fd | 3 years ago |
|
1230e0bfd9 | 3 years ago |
|
69c2b4de29 | 3 years ago |
|
e011912bdf | 3 years ago |
|
f3cf117694 | 3 years ago |
|
5f2fff0db2 | 3 years ago |
|
40822191a4 | 3 years ago |
|
d9d149784d | 3 years ago |
|
6d1b2f8d50 | 3 years ago |
|
3a86893a57 | 3 years ago |
|
42a16bf2ee | 3 years ago |
|
2d35778c9c | 3 years ago |
|
2abf63618a | 3 years ago |
|
066876d491 | 3 years ago |
|
06d6d817ce | 3 years ago |
|
08e87492c0 | 3 years ago |
|
680221c1e2 | 3 years ago |
|
51b3f74b5e | 3 years ago |
|
cce8c1981e | 3 years ago |
|
4939ba32fb | 3 years ago |
|
d19820ac4a | 3 years ago |
|
dac3322b97 | 3 years ago |
|
8b2b26ffe0 | 3 years ago |
|
36edac7425 | 3 years ago |
|
e40d139536 | 3 years ago |
|
ccbee1a41e | 3 years ago |
|
71c99e91bb | 3 years ago |
|
34e8731854 | 3 years ago |
|
cb09ed51ea | 3 years ago |
|
9946f23eb7 | 3 years ago |
|
19eb58ad6a | 3 years ago |
|
f3d93b4b3a | 3 years ago |
|
dc9873c16d | 3 years ago |
|
5fa65d2f0b | 3 years ago |
|
1db1f9a396 | 3 years ago |
|
555215ab77 | 3 years ago |
|
9b7cc44fd1 | 3 years ago |
|
bfb280afb9 | 3 years ago |
|
c1df8e2fc3 | 3 years ago |
|
443f6c2c43 | 3 years ago |
|
f2517654e6 | 3 years ago |
|
ca8bb9c296 | 3 years ago |
|
9e200ee93a | 3 years ago |
|
78d07aa4bc | 3 years ago |
|
94fe156538 | 3 years ago |
|
244f9ecad6 | 3 years ago |
|
13ea7f1307 | 3 years ago |
|
76bc1b34f9 | 3 years ago |
|
8d6a2fb1fa | 3 years ago |
|
b803befa0a | 3 years ago |
|
32248f11be | 3 years ago |
|
e5b222d83d | 3 years ago |
|
04b7f4d2df | 3 years ago |
|
50c7413f00 | 3 years ago |
|
859b16d893 | 3 years ago |
|
9de83c5ac3 | 3 years ago |
|
b32503b350 | 3 years ago |
|
bca75a9dd4 | 3 years ago |
|
5b8a585e87 | 3 years ago |
|
211f04ae67 | 3 years ago |
|
b26f2ca597 | 3 years ago |
|
23d596066a | 3 years ago |
|
c0a375b7ee | 3 years ago |
|
768816934e | 3 years ago |
|
d0f8912c27 | 3 years ago |
|
013448c716 | 3 years ago |
|
13c8452f23 | 3 years ago |
|
10cf211007 | 3 years ago |
|
a97146a453 | 3 years ago |
|
352a019bd3 | 3 years ago |
|
17cbf3ce4f | 3 years ago |
|
7d7224a6a9 | 3 years ago |
|
130617f406 | 3 years ago |
|
fde4b8f3e6 | 3 years ago |
|
73a1a7eb43 | 3 years ago |
|
e20de0d18a | 3 years ago |
|
a529db3430 | 3 years ago |
|
41a087394e | 3 years ago |
|
32a099ceec | 3 years ago |
|
022510950f | 3 years ago |
|
4d0da84ffb | 3 years ago |
|
5325d82a40 | 3 years ago |
|
3d7ac99293 | 3 years ago |
|
2a8dd58a3c | 3 years ago |
|
c692746913 | 3 years ago |
|
1dd7c7991c | 3 years ago |
|
39aad94ae4 | 3 years ago |
|
98a12154fc | 3 years ago |
|
f4fdc4a501 | 3 years ago |
|
9c67a84b62 | 3 years ago |
|
f6154ae6d4 | 3 years ago |
|
89b1c07146 | 3 years ago |
|
bdfbff9adb | 3 years ago |
|
16e2613c05 | 3 years ago |
|
c1dcc7b176 | 3 years ago |
|
38532dec63 | 3 years ago |
|
516b1664f7 | 3 years ago |
|
c82e9dfb9e | 3 years ago |
|
e08cf72aa1 | 3 years ago |
|
828650e678 | 3 years ago |
|
dcc994b30e | 3 years ago |
|
9da38ba8ad | 3 years ago |
|
f656df5319 | 3 years ago |
|
8e840038de | 3 years ago |
|
d72f810567 | 3 years ago |
|
03c489498f | 3 years ago |
|
c3d0fe375a | 3 years ago |
|
576f65d846 | 3 years ago |
|
c559fc850d | 3 years ago |
|
099aed1be2 | 3 years ago |
|
b8732147a9 | 3 years ago |
|
308e6dd109 | 3 years ago |
|
ff0aafbd5e | 3 years ago |
|
1e7b95c25c | 3 years ago |
|
162cdcd4bf | 3 years ago |
|
625d9a7f32 | 3 years ago |
|
e87fe8ddcf | 3 years ago |
|
3b05fb647c | 3 years ago |
|
81b78fe395 | 3 years ago |
|
b346cd1cce | 3 years ago |
|
6a7d2c3c05 | 3 years ago |
|
3d1431316e | 3 years ago |
|
36ac367491 | 3 years ago |
|
a11136f899 | 3 years ago |
|
231096682a | 3 years ago |
|
05dde38ea2 | 3 years ago |
|
42b42e0f1c | 3 years ago |
|
69a6cbaa46 | 3 years ago |
|
01cca785f4 | 3 years ago |
|
7a62b154fc | 3 years ago |
|
35132ab2f2 | 3 years ago |
|
6965b2906d | 3 years ago |
|
eb2ba85760 | 3 years ago |
|
3c6477857e | 3 years ago |
|
160b38e4dd | 3 years ago |
|
80b4d0e99c | 3 years ago |
|
f27f75a108 | 3 years ago |
|
64d67185f6 | 3 years ago |
|
012c67457f | 3 years ago |
|
e6b4119652 | 3 years ago |
|
8f2f18722d | 3 years ago |
|
ed048e1219 | 3 years ago |
|
252ed746ed | 3 years ago |
|
c7758bbb00 | 3 years ago |
|
ee24d1f5b0 | 3 years ago |
|
423e11c036 | 3 years ago |
|
cbb004cae6 | 3 years ago |
|
4a301588bb | 3 years ago |
|
c9fc627375 | 3 years ago |
|
1457f6f2a8 | 3 years ago |
|
e4c063a209 | 3 years ago |
|
7f038f1269 | 3 years ago |
|
a07533bd2c | 3 years ago |
|
68bf915c02 | 3 years ago |
|
e27ffa5620 | 3 years ago |
|
b79eb44958 | 3 years ago |
|
438b7650ba | 3 years ago |
|
74a3270cb0 | 3 years ago |
|
087b984e54 | 3 years ago |
|
81c6c09862 | 3 years ago |
|
28fba59922 | 3 years ago |
|
e62fb9817f | 3 years ago |
|
77f63c15de | 3 years ago |
|
4b076e6798 | 3 years ago |
|
3aaa7737df | 3 years ago |
|
3b92963868 | 3 years ago |
|
8a170e1a64 | 3 years ago |
|
08a0f03cd5 | 3 years ago |
|
69bdf5b49b | 3 years ago |
|
823c46f6f8 | 3 years ago |
|
362bf39047 | 3 years ago |
|
ee760577ed | 3 years ago |
|
39b7209b6c | 3 years ago |
|
d93b224d4d | 3 years ago |
|
6eab1e7015 | 3 years ago |
|
d05a58af75 | 3 years ago |
|
255461198d | 3 years ago |
|
b101e8bcda | 3 years ago |
|
135ba6105f | 3 years ago |
|
ac374e72fd | 3 years ago |
|
47b94ac9ad | 3 years ago |
|
cac0b32520 | 3 years ago |
|
7a9b2ce938 | 3 years ago |
|
45fcaa9115 | 3 years ago |
|
a0474d34f2 | 3 years ago |
|
4cd34aa5aa | 3 years ago |
|
7ce17ffae1 | 3 years ago |
|
d1cc5885f7 | 3 years ago |
|
4b1aec0788 | 3 years ago |
|
37a203c774 | 3 years ago |
|
99b39de791 | 3 years ago |
|
62a8dafa7c | 3 years ago |
|
44d04f213a | 3 years ago |
|
492f61ae93 | 3 years ago |
|
434baa283f | 3 years ago |
|
bbe1305bcc | 3 years ago |
|
b551973cef | 3 years ago |
|
173a2c579d | 3 years ago |
|
3d40b656cb | 3 years ago |
|
6d3c0298e2 | 3 years ago |
|
5f0988df8c | 3 years ago |
|
f325c36183 | 3 years ago |
|
0fe40da3e5 | 3 years ago |
|
bee3df2801 | 3 years ago |
|
587615c465 | 3 years ago |
|
154c7e0627 | 3 years ago |
|
908cdefa3b | 3 years ago |
|
f351127dbb | 3 years ago |
|
aab2e614b1 | 3 years ago |
|
bae1fcd53e | 3 years ago |
|
af244fe5a2 | 3 years ago |
|
6776b53276 | 3 years ago |
|
5bee5bf6bd | 3 years ago |
|
02187fefc5 | 3 years ago |
|
85294ccd96 | 3 years ago |
|
156f5335bb | 3 years ago |
|
cf2d136c81 | 3 years ago |
|
15c6606353 | 3 years ago |
|
2be838b11e | 3 years ago |
|
d1009f4987 | 3 years ago |
|
2c64f7ed41 | 3 years ago |
|
bd94d0e645 | 3 years ago |
|
32469bf1ab | 3 years ago |
|
5f5d99952a | 3 years ago |
|
ba21a7f09c | 3 years ago |
|
9cef2280bc | 3 years ago |
|
ece929ebe9 | 3 years ago |
|
54f36f8471 | 3 years ago |
|
eb74a306ff | 3 years ago |
|
a35d749db9 | 3 years ago |
|
866c71f5e2 | 3 years ago |
|
2e75a3d7f0 | 3 years ago |
|
3fda8b8e3b | 3 years ago |
|
a15dffef51 | 3 years ago |
|
a257c9e485 | 3 years ago |
|
a5c8374b51 | 3 years ago |
|
f10ccd827e | 3 years ago |
|
1cb220f348 | 3 years ago |
|
20bc6cee86 | 3 years ago |
|
7cacac64c0 | 3 years ago |
|
5d19891e63 | 4 years ago |
|
bbaae33ce9 | 4 years ago |
|
010f454092 | 4 years ago |
|
22f33ad568 | 4 years ago |
|
f89c1d0018 | 4 years ago |
|
e4e3295111 | 4 years ago |
|
feb80243fe | 4 years ago |
|
f7ecc11a71 | 4 years ago |
|
f8c5bf6283 | 4 years ago |
|
4ba4cf4969 | 4 years ago |
|
06296d8996 | 4 years ago |
|
31226d5bdd | 4 years ago |
|
0e7d5286c4 | 4 years ago |
|
ffc7573ec9 | 4 years ago |
|
33d60fd936 | 4 years ago |
|
ea728b013b | 4 years ago |
|
03ed5c8133 | 4 years ago |
|
9cc448d3a2 | 4 years ago |
|
a058d1b2e4 | 4 years ago |
|
3167c99454 | 4 years ago |
|
3d051a2e53 | 4 years ago |
|
65434b15e5 | 4 years ago |
|
24fc351b02 | 4 years ago |
|
e89696d911 | 4 years ago |
|
9eec575e9e | 4 years ago |
|
d562a9315d | 4 years ago |
|
639fa953b6 | 4 years ago |
|
35b83ba090 | 4 years ago |
|
fdaff6c666 | 4 years ago |
|
7d91a9cfc0 | 4 years ago |
|
7f931c5ebb | 4 years ago |
|
a044f8ec37 | 4 years ago |
|
2a21db9a34 | 4 years ago |
|
ba05a924d3 | 4 years ago |
|
773dbf3f70 | 4 years ago |
|
af016f2a40 | 4 years ago |
|
b652613ece | 4 years ago |
|
e1cb478262 | 4 years ago |
|
a446ed077a | 4 years ago |
|
452db10284 | 4 years ago |
|
57d95388b1 | 4 years ago |
|
3cf4580b5d | 4 years ago |
|
4b1f9914f7 | 4 years ago |
|
ae48d1ace6 | 4 years ago |
|
acff35683a | 4 years ago |
|
569fdd39ea | 4 years ago |
|
b3dc7db31c | 4 years ago |
|
2311ec1ccf | 4 years ago |
|
f51da123e2 | 4 years ago |
|
332b492761 | 4 years ago |
|
13b123866f | 4 years ago |
|
22d3890e06 | 4 years ago |
|
f1e1e852ae | 4 years ago |
|
e888a14e51 | 4 years ago |
|
5e9c7d08d9 | 4 years ago |
|
f4ede43b52 | 4 years ago |
|
6b037e3667 | 4 years ago |
|
b841889846 | 4 years ago |
|
5efee76cae | 4 years ago |
|
13e8407884 | 4 years ago |
|
ded4717ed8 | 4 years ago |
|
93a7ed0017 | 4 years ago |
|
3259808b57 | 4 years ago |
|
1f25f3dbd1 | 4 years ago |
|
01bca00be4 | 4 years ago |
|
1a34f91cdd | 4 years ago |
|
bb41caeae0 | 4 years ago |
|
30c3d17a2c | 4 years ago |
|
9bc023bd1b | 4 years ago |
@ -1,33 +1,14 @@
|
||||
[submodule "awsm"]
|
||||
path = awsm
|
||||
url = https://github.com/gwsystems/aWsm
|
||||
ignore = dirty
|
||||
path = awsm
|
||||
url = https://github.com/gwsystems/aWsm
|
||||
ignore = dirty
|
||||
branch = master
|
||||
[submodule "http-parser"]
|
||||
path = runtime/thirdparty/http-parser
|
||||
url = https://github.com/gwsystems/http-parser.git
|
||||
path = runtime/thirdparty/http-parser
|
||||
url = https://github.com/gwsystems/http-parser.git
|
||||
[submodule "ck"]
|
||||
path = runtime/thirdparty/ck
|
||||
url = https://github.com/gwsystems/ck.git
|
||||
path = runtime/thirdparty/ck
|
||||
url = https://github.com/gwsystems/ck.git
|
||||
[submodule "jsmn"]
|
||||
path = runtime/thirdparty/jsmn
|
||||
url = https://github.com/gwsystems/jsmn.git
|
||||
[submodule "runtime/tests/gocr"]
|
||||
path = runtime/tests/gocr
|
||||
url = https://github.com/gwsystems/gocr.git
|
||||
branch = sledge
|
||||
[submodule "runtime/tests/TinyEKF"]
|
||||
path = runtime/tests/TinyEKF
|
||||
url = https://github.com/gwsystems/TinyEKF.git
|
||||
branch = sledge
|
||||
[submodule "runtime/tests/CMSIS_5_NN"]
|
||||
path = runtime/tests/CMSIS_5_NN
|
||||
url = https://github.com/gwsystems/CMSIS_5_NN.git
|
||||
branch = sledge
|
||||
[submodule "runtime/tests/sod"]
|
||||
path = runtime/tests/sod
|
||||
url = https://github.com/gwsystems/sod.git
|
||||
branch = sledge
|
||||
[submodule "runtime/tests/speechtotext"]
|
||||
path = runtime/tests/speechtotext
|
||||
url = https://github.com/gwsystems/speechtotext.git
|
||||
branch = sledge
|
||||
path = runtime/thirdparty/jsmn
|
||||
url = https://github.com/gwsystems/jsmn.git
|
||||
|
@ -1,22 +1,23 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"/usr/include/",
|
||||
"${workspaceFolder}/runtime/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/ck/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/http-parser/",
|
||||
"${workspaceFolder}/runtime/thirdparty/jsmn/"
|
||||
],
|
||||
"defines": [
|
||||
"x86_64",
|
||||
"_GNU_SOURCE"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"compilerPath": "/usr/bin/clang"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"includePath": [
|
||||
"/usr/include/",
|
||||
"${workspaceFolder}/runtime/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/ck/include/",
|
||||
"${workspaceFolder}/runtime/thirdparty/http-parser/",
|
||||
"${workspaceFolder}/runtime/thirdparty/jsmn/",
|
||||
"${workspaceFolder}/awsm/runtime/libc/wasi/include/",
|
||||
"${workspaceFolder}/libsledge/include"
|
||||
],
|
||||
"defines": [
|
||||
"x86_64",
|
||||
"_GNU_SOURCE"
|
||||
],
|
||||
"cStandard": "c17"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
@ -1,54 +1,60 @@
|
||||
SHELL:=/bin/bash
|
||||
ARCH:=$(shell arch)
|
||||
|
||||
COMPILER=awsm
|
||||
ROOT=${ROOT:-$(cd "$(dirname ${BASH_SOURCE:-$0})" && pwd)}
|
||||
WASMCEPTION_URL=https://github.com/gwsystems/wasmception/releases/download/v0.2.0/wasmception-linux-x86_64-0.2.0.tar.gz
|
||||
|
||||
# TODO: Add ARM release build
|
||||
.PHONY: build
|
||||
build:
|
||||
ifeq ($(ARCH),x86_64)
|
||||
cd ./awsm/wasmception && wget ${WASMCEPTION_URL} -O wasmception.tar.gz && tar xvfz wasmception.tar.gz && rm wasmception.tar.gz
|
||||
endif
|
||||
test -f ./${COMPILER}/wasmception/dist/bin/clang || make -C ${COMPILER}/wasmception
|
||||
@cd ${COMPILER} && RUSTUP_TOOLCHAIN=stable cargo build --release && cd ${ROOT}
|
||||
|
||||
# Sanity check that the aWsm compiler built and is in our PATH
|
||||
.PHONY: build-validate
|
||||
build-validate:
|
||||
which awsm
|
||||
awsm --version
|
||||
|
||||
.PHONY: build-dev
|
||||
build-dev:
|
||||
test -f ./${COMPILER}/wasmception/dist/bin/clang || make -C ${COMPILER}/wasmception
|
||||
@echo "Building aWsm compiler (default==debug)"
|
||||
@cd ${COMPILER} && cargo build && cd ${ROOT}
|
||||
|
||||
.PHONY: all
|
||||
all: awsm libsledge runtime applications
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "Cleaning aWsm compiler"
|
||||
@cd ${COMPILER} && cargo clean && cd ${ROOT}
|
||||
|
||||
# wasmception is too slow to recompile,
|
||||
# so lets not make that part of the "aWsm" cleanup
|
||||
.PHONY: wclean
|
||||
wclean:
|
||||
@echo "Cleaning wasmception toolchain"
|
||||
@cd ${COMPILER} && make -C wasmception clean && cd ${ROOT}
|
||||
|
||||
.PHONY: rtinit
|
||||
rtinit:
|
||||
@echo "Building runtime for the first time!"
|
||||
make -C runtime init
|
||||
clean: awsm.clean libsledge.clean runtime.clean applications.clean
|
||||
|
||||
.PHONY: submodules
|
||||
submodules:
|
||||
git submodule update --init --recursive
|
||||
|
||||
.PHONY: install
|
||||
install: submodules wasm_apps all
|
||||
|
||||
# aWsm: the WebAssembly to LLVM bitcode compiler
|
||||
.PHONY: awsm
|
||||
awsm:
|
||||
cd awsm && cargo build --release
|
||||
|
||||
.PHONY: awsm.clean
|
||||
awsm.clean:
|
||||
cd awsm && cargo clean
|
||||
|
||||
# libsledge: the support library linked with LLVM bitcode emitted by aWsm when building *.so modules
|
||||
.PHONY: libsledge
|
||||
libsledge:
|
||||
make -C libsledge dist/libsledge.a
|
||||
|
||||
.PHONY: libsledge.clean
|
||||
libsledge.clean:
|
||||
make -C libsledge clean
|
||||
|
||||
# sledgert: the runtime that executes *.so modules
|
||||
.PHONY: runtime
|
||||
runtime:
|
||||
@echo "Building runtime!"
|
||||
make -C runtime
|
||||
|
||||
.PHONY: install
|
||||
install: build rtinit
|
||||
@./install.sh wasmception
|
||||
|
||||
.PHONY: runtime.clean
|
||||
runtime.clean:
|
||||
make -C runtime clean
|
||||
|
||||
# SLEdge Applications
|
||||
.PHONY: applications
|
||||
applications:
|
||||
make -C applications all
|
||||
|
||||
.PHONY: applications.clean
|
||||
applications.clean:
|
||||
make -C applications clean
|
||||
|
||||
# Instead of having two copies of wasm_apps, just link to the awsm repo's copy
|
||||
wasm_apps:
|
||||
ln -sr awsm/applications/wasm_apps/ applications/
|
||||
|
||||
# Tests
|
||||
.PHONY: test
|
||||
test:
|
||||
make -f test.mk all
|
||||
|
@ -0,0 +1 @@
|
||||
dist/*
|
@ -0,0 +1,133 @@
|
||||
AWSMCC=../awsm/target/release/awsm
|
||||
CC=clang
|
||||
|
||||
# Used by aWsm when compiling the *.wasm to *.bc
|
||||
AWSMFLAGS= --inline-constant-globals --runtime-globals
|
||||
|
||||
# Used by clang when compiling the *.so module
|
||||
# --whole-archive causes the symbols in the listed static archive to be exported from the resulting *.so
|
||||
# https://stackoverflow.com/questions/805555/ld-linker-question-the-whole-archive-option
|
||||
CFLAGS=-O3 -flto
|
||||
LDFLAGS=-shared -fPIC -Wl,--export-dynamic,--whole-archive -L../libsledge/dist/ -lsledge -Wl,--no-whole-archive
|
||||
# LDFLAGS=-flto -fvisibility=hidden
|
||||
|
||||
# Strips out calls to assert() and disables debuglog
|
||||
CFLAGS+=-DNDEBUG
|
||||
|
||||
dist:
|
||||
mkdir -p dist
|
||||
|
||||
.PHONY: all
|
||||
all: \
|
||||
cifar10.install \
|
||||
empty.install \
|
||||
fibonacci.install \
|
||||
gocr.install \
|
||||
gps_ekf.install \
|
||||
license_plate_detection.install \
|
||||
resize_image.install \
|
||||
cnn_face_detection.install \
|
||||
get_jpeg_resolution.install \
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@make -C wasm_apps clean
|
||||
@rm -rf dist
|
||||
@rm -rf ../runtime/bin/*.so
|
||||
|
||||
wasm_apps/dist/%.wasm:
|
||||
make -C wasm_apps $(addprefix dist/,$(notdir $@))
|
||||
|
||||
../libsledge/dist/:
|
||||
mkdir ../libsledge/dist
|
||||
|
||||
../libsledge/dist/libsledge.a: ../libsledge/dist/
|
||||
make -C .. libsledge
|
||||
|
||||
PHONY: scratch_storage
|
||||
scratch_storage:
|
||||
make -C scratch_storage all
|
||||
|
||||
PHONY: scratch_storage.install
|
||||
scratch_storage.install: \
|
||||
scratch_storage_get.install \
|
||||
scratch_storage_set.install \
|
||||
scratch_storage_delete.install \
|
||||
scratch_storage_upsert.install
|
||||
|
||||
scratch_storage/scratch_storage_%.wasm:
|
||||
make -C scratch_storage all
|
||||
|
||||
dist/scratch_storage_%.bc: scratch_storage/scratch_storage_%.wasm dist
|
||||
${AWSMCC} ${AWSMFLAGS} $< -o $@
|
||||
|
||||
dist/%.bc: ./wasm_apps/dist/%.wasm dist
|
||||
${AWSMCC} ${AWSMFLAGS} $< -o $@
|
||||
|
||||
dist/%.ll: dist/%.bc
|
||||
llvm-dis $< -o $@
|
||||
|
||||
dist/%.wasm.so: dist/%.bc
|
||||
${CC} ${CFLAGS} ${LDFLAGS} $^ -o $@
|
||||
|
||||
../runtime/bin/%.wasm.so: dist/%.wasm.so
|
||||
cp $^ $@
|
||||
|
||||
.PHONY: cifar10.install
|
||||
cifar10.install: ../runtime/bin/cifar10.wasm.so
|
||||
|
||||
# Echo?
|
||||
|
||||
.PHONY: empty.install
|
||||
empty.install: ../runtime/bin/empty.wasm.so
|
||||
|
||||
.PHONY: exit.install
|
||||
exit.install: ../runtime/bin/exit.wasm.so
|
||||
|
||||
.PHONY: fibonacci.install
|
||||
fibonacci.install: ../runtime/bin/fibonacci.wasm.so
|
||||
|
||||
.PHONY: asc-fib.install
|
||||
asc-fib.install: ../runtime/bin/asc-fib.wasm.so
|
||||
|
||||
.PHONY: gocr.install
|
||||
gocr.install: ../runtime/bin/gocr.wasm.so
|
||||
|
||||
.PHONY: resize_image.install
|
||||
resize_image.install: ../runtime/bin/resize_image.wasm.so
|
||||
|
||||
.PHONY: gps_ekf.install
|
||||
gps_ekf.install: ../runtime/bin/gps_ekf.wasm.so
|
||||
|
||||
.PHONY: license_plate_detection.install
|
||||
license_plate_detection.install: ../runtime/bin/license_plate_detection.wasm.so
|
||||
|
||||
.PHONY: cnn_face_detection.install
|
||||
cnn_face_detection.install: ../runtime/bin/cnn_face_detection.wasm.so
|
||||
|
||||
.PHONY: get_jpeg_resolution.install
|
||||
get_jpeg_resolution.install: ../runtime/bin/get_jpeg_resolution.wasm.so
|
||||
|
||||
.PHONY: trap_divzero.install
|
||||
trap_divzero.install: ../runtime/bin/trap_divzero.wasm.so
|
||||
|
||||
.PHONY: stack_overflow.install
|
||||
stack_overflow.install: ../runtime/bin/stack_overflow.wasm.so
|
||||
|
||||
.PHONY: html.install
|
||||
html.install: ../runtime/bin/html.wasm.so
|
||||
|
||||
.PHONY: scratch_storage_get.install
|
||||
scratch_storage_get.install: ../runtime/bin/scratch_storage_get.wasm.so
|
||||
|
||||
.PHONY: scratch_storage_set.install
|
||||
scratch_storage_set.install: ../runtime/bin/scratch_storage_set.wasm.so
|
||||
|
||||
.PHONY: scratch_storage_delete.install
|
||||
scratch_storage_delete.install: ../runtime/bin/scratch_storage_delete.wasm.so
|
||||
|
||||
.PHONY: scratch_storage_upsert.install
|
||||
scratch_storage_upsert.install: ../runtime/bin/scratch_storage_upsert.wasm.so
|
||||
|
||||
.PHONY: depth_to_xyz.install
|
||||
depth_to_xyz.install: ../runtime/bin/depth_to_xyz.wasm.so
|
@ -0,0 +1 @@
|
||||
*.wasm
|
@ -0,0 +1,24 @@
|
||||
include ../wasm_apps/common.mk
|
||||
|
||||
.PHONY: all
|
||||
all: \
|
||||
scratch_storage_get.wasm \
|
||||
scratch_storage_set.wasm \
|
||||
scratch_storage_delete.wasm \
|
||||
scratch_storage_upsert.wasm \
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -f scratch_storage_set.wa* scratch_storage_get.wa* scratch_storage_delete.wa* scratch_storage_upsert.wa*
|
||||
|
||||
scratch_storage_set.wasm: scratch_storage_set.c
|
||||
@${WASMCC} ${WASMCFLAGS} ${WASMLDFLAGS} $^ -o $@
|
||||
|
||||
scratch_storage_get.wasm: scratch_storage_get.c
|
||||
@${WASMCC} ${WASMCFLAGS} ${WASMLDFLAGS} $^ -o $@
|
||||
|
||||
scratch_storage_delete.wasm: scratch_storage_delete.c
|
||||
@${WASMCC} ${WASMCFLAGS} ${WASMLDFLAGS} $^ -o $@
|
||||
|
||||
scratch_storage_upsert.wasm: scratch_storage_upsert.c
|
||||
@${WASMCC} ${WASMCFLAGS} ${WASMLDFLAGS} $^ -o $@
|
@ -0,0 +1,32 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int scratch_storage_delete(void *key, uint32_t key_len)
|
||||
__attribute__((__import_module__("scratch_storage"), __import_name__("delete")));
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "%s <key>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *key = argv[1];
|
||||
|
||||
if (key == NULL || strlen(key) < 0) {
|
||||
fprintf(stderr, "%s <key>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rc = scratch_storage_delete(key, strlen(key));
|
||||
if (rc == 1) {
|
||||
printf("Key '%s' not found\n", key);
|
||||
return 0;
|
||||
} else {
|
||||
printf("Key %s deleted\n", key);
|
||||
}
|
||||
};
|
@ -0,0 +1,38 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int scratch_storage_get(void *key, uint32_t key_len, void *buf, uint32_t buf_len)
|
||||
__attribute__((__import_module__("scratch_storage"), __import_name__("get")));
|
||||
|
||||
extern uint32_t scratch_storage_get_size(void *key, uint32_t key_len)
|
||||
__attribute__((__import_module__("scratch_storage"), __import_name__("get_size")));
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "%s <key>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *key = argv[1];
|
||||
|
||||
if (key == NULL || strlen(key) < 0) {
|
||||
fprintf(stderr, "%s <key>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t val_size = scratch_storage_get_size(key, strlen(key));
|
||||
char *buf = calloc(val_size + 1, sizeof(char));
|
||||
int rc = scratch_storage_get(key, strlen(key), buf, val_size);
|
||||
assert(rc != 2);
|
||||
if (rc == 1) {
|
||||
printf("Key '%s' not found\n", key);
|
||||
return 0;
|
||||
} else {
|
||||
printf("Key %s resolved to value of size %u with contents %s\n", key, val_size, buf);
|
||||
}
|
||||
};
|
@ -0,0 +1,35 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int scratch_storage_set(void *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
__attribute__((__import_module__("scratch_storage"), __import_name__("set")));
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "%s <key> <value>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *key = argv[1];
|
||||
char *value = argv[2];
|
||||
|
||||
if (key == NULL || strlen(key) < 0 || value == NULL || strlen(value) < 0) {
|
||||
fprintf(stderr, "%s <key> <value>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rc = scratch_storage_set(key, strlen(key), value, strlen(value));
|
||||
if (rc == 1) {
|
||||
printf("Key %s was already present\n", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(rc == 0);
|
||||
printf("Key %s set to value %s\n", key, value);
|
||||
return rc;
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int scratch_storage_upsert(void *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
__attribute__((__import_module__("scratch_storage"), __import_name__("upsert")));
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "%s <key> <value>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *key = argv[1];
|
||||
char *value = argv[2];
|
||||
|
||||
if (key == NULL || strlen(key) < 0 || value == NULL || strlen(value) < 0) {
|
||||
fprintf(stderr, "%s <key> <value>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
scratch_storage_upsert(key, strlen(key), value, strlen(value));
|
||||
printf("Key %s set to value %s\n", key, value);
|
||||
};
|
@ -1 +1 @@
|
||||
Subproject commit 84ad52b5c307ffdf9dc585bc40ae1122563a6857
|
||||
Subproject commit 272fcf42b6559ccb5c5213eb78edfc0f703520ab
|
@ -0,0 +1,59 @@
|
||||
SLEdge only implemented a subset of the WASI syscall interface
|
||||
|
||||
## Arguments
|
||||
|
||||
The WASI calls `args_sizes_get` and `args_get` are supported. HTTP query parameters are captured and passed as arguments.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
The WASI calls `environ_get` and `environ_sizes_get` are supported, but mostly unused. The current behavior is to to pass the runtime's environment variables into the sandbox. This is likely undesirable.
|
||||
|
||||
Presumably, the runtime should provide a standard set of environment variables and also allow the JSON spec to set additional function-specific environment variables.
|
||||
|
||||
See the reference of environment variables generated by WAGI for details: https://github.com/deislabs/wagi/blob/main/docs/environment_variables.md
|
||||
|
||||
## Clocks
|
||||
|
||||
`clock_time_get` is implemented but untested. `clock_res_get` is unimplemented.
|
||||
|
||||
## File System
|
||||
|
||||
SLEdge only supports `fd_read` from stdin and `fd_write` to stderr or stdout.
|
||||
|
||||
stdin is populated with the body of an HTTP POST request. stdout and stderr are both written in an interleaved fashion into a buffer and sent back to the client as the response body.
|
||||
|
||||
Actual access to the file system is unsupported, and sandboxes are not provided any preopened descriptors.
|
||||
|
||||
## Poll
|
||||
|
||||
`poll_oneoff` is unsupposed because SLEdge serverless functions are short lived. Sandboxed functions are assumed to make blocking reads/writes to stdin/stdout/stderr, and the serverless runtime is responsible for causing serverless functions to sleep and wake.
|
||||
|
||||
## Exit
|
||||
|
||||
`proc_exit` is supported and causes a sandbox to terminate execution.
|
||||
|
||||
## Signals
|
||||
|
||||
`proc_raise` is not supported. Signals are used by the runtime to provide preemption and context switching. It would be dangerous to trigger actual host signals from a sandbox.
|
||||
|
||||
However, the function could be implemented by creating a switch on the wasi signal and either ignoring or handling the signal within the `proc_raise` function itself.
|
||||
|
||||
`SIGABRT` could trigger the sandbox to exit in an abnormal condition.
|
||||
|
||||
The default ignore behavior could log the unexpected signal and return.
|
||||
|
||||
## Random
|
||||
|
||||
`random_get` is supported but largely untested.
|
||||
|
||||
## Yield
|
||||
|
||||
`sched_yield` is unsupported. This does not match with the run-to-completion nature of serverless.
|
||||
|
||||
In the case of EDF, a sandbox would always yield to itself. However, in the case of FIFO, we could enable this call to allow for a worker to "round robin" within a runqueue. However, it is unclear what the rationale would be to allow a serverless function to impact the scheduler.
|
||||
|
||||
## Sockets
|
||||
|
||||
All socket syscalls are unimplemented because the current logic around `sock_accept` and `sock_shutdown` seems to be focused on long-lived daemon nanoprocesses that handle multiple requests. The `poll_oneoff` call also seems to be based on this usecase.
|
||||
|
||||
Generally, a serverless function is expected to only make outbound network requests. However, this use case does not seem to be currently supported by WASI.
|
@ -1,147 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This script is responsible for copying, linking, and aliasing all of our build tools such that they are
|
||||
# in known paths that we can add to PATH and LD_LIBRARY_PATH. The binaries go into "${SYS_PREFIX}/bin" and
|
||||
# the libraries go into "${SYS_PREFIX}/lib". By default, SYS_PREFIX is `/opt/sledge/`, which means that this
|
||||
# script is assumed to be executed as root, as in our Docker build container. However, by by setting
|
||||
# SYS_PREFIX to a directory that the user has access to, this can be avoided.
|
||||
#
|
||||
# For example, in the GitHub Actions workflow, SYS_PREFIX is set to the topmost project directory and the
|
||||
# environment is updated as follows.
|
||||
#
|
||||
# SYS_PREFIX="$(pwd)" ./install.sh
|
||||
# PATH="$(pwd)/bin:$PATH"
|
||||
# LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH"
|
||||
#
|
||||
# This is currently executed
|
||||
# - Indirectly via `make install` in the root Makefile, typically when the sledge-dev build container is built
|
||||
# - Directly by the GitHub workflow
|
||||
#
|
||||
# The script takes either wasmception or wasi as the first argument to install either wasmception or WASI-SDK
|
||||
# If no argument is provided, wasmception is assumed
|
||||
# If either wasmception or wasi is provided, an additional `-d` or `--dry-run` flag can be provided to view the commands
|
||||
# and paths that would be generated. This is helpful for sanity checking when setting SYS_PREFIX and using in a new context
|
||||
|
||||
echo "Setting up toolchain environment"
|
||||
|
||||
for last_arg in "$@"; do :; done
|
||||
|
||||
if [[ $last_arg == "-d" ]] || [[ $last_arg == "--dry-run" ]]; then
|
||||
DRY_RUN=true
|
||||
else
|
||||
DRY_RUN=false
|
||||
fi
|
||||
|
||||
if $DRY_RUN; then
|
||||
DRY_RUN_PREFIX=echo
|
||||
else
|
||||
DRY_RUN_PREFIX=
|
||||
fi
|
||||
|
||||
# Get the absolute path of the topmost project directly
|
||||
# The use of dirname is particular. It seems unneccesary how this script is run
|
||||
SYS_SRC_PREFIX=${SYS_SRC_PREFIX:-"$(
|
||||
cd "$(dirname "$(dirname "${0}")")" || exit 1
|
||||
pwd -P
|
||||
)"}
|
||||
$DRY_RUN && echo SYS_SRC_PREFIX: "$SYS_SRC_PREFIX"
|
||||
|
||||
# And check for the presence of this script to make sure we got it right
|
||||
if [ ! -x "${SYS_SRC_PREFIX}/install.sh" ]; then
|
||||
echo "Unable to find the install script" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYS_NAME='sledge'
|
||||
COMPILER='awsm'
|
||||
COMPILER_EXECUTABLE=$COMPILER
|
||||
|
||||
# /opt/sledge
|
||||
SYS_PREFIX=${SYS_PREFIX:-"/opt/${SYS_NAME}"}
|
||||
$DRY_RUN && echo SYS_PREFIX: "$SYS_PREFIX"
|
||||
|
||||
# /sledge, where the sledge repo is mounted from the host
|
||||
SYS_SRC_PREFIX=${SYS_SRC_PREFIX:-"/${SYS_NAME}"}
|
||||
$DRY_RUN && echo SYS_SRC_PREFIX: "$SYS_SRC_PREFIX"
|
||||
|
||||
# The release directory containing the binary of the aWsm compiler
|
||||
SYS_COMPILER_REL_DIR=${SYS_COMPILER_REL_DIR:-"${SYS_SRC_PREFIX}/${COMPILER}/target/release"}
|
||||
$DRY_RUN && echo SYS_COMPILER_REL_DIR: "$SYS_COMPILER_REL_DIR"
|
||||
|
||||
# /opt/sledge/bin
|
||||
SYS_BIN_DIR=${SYS_BIN_DIR:-"${SYS_PREFIX}/bin"}
|
||||
$DRY_RUN && echo SYS_BIN_DIR: "$SYS_BIN_DIR"
|
||||
|
||||
# /opt/sledge/lib
|
||||
SYS_LIB_DIR=${SYS_LIB_DIR:-"${SYS_PREFIX}/lib"}
|
||||
$DRY_RUN && echo SYS_LIB_DIR: "$SYS_LIB_DIR"
|
||||
|
||||
# The first argument can be either wasi or wasmception. This determines the system interface used
|
||||
# The default is wasmception
|
||||
# Currently, WASI is not actually supported by the runtime.
|
||||
if [ $# -eq 0 ] || [ "$1" = "wasmception" ]; then
|
||||
echo "Setting up for wasmception"
|
||||
WASM_PREFIX=${WASM_PREFIX:-"${SYS_SRC_PREFIX}/${COMPILER}/wasmception"}
|
||||
WASM_BIN=${WASM_BIN:-"${WASM_PREFIX}/dist/bin"}
|
||||
WASM_SYSROOT=${WASM_SYSROOT:-"${WASM_PREFIX}/sysroot"}
|
||||
WASM_TARGET=${WASM_TARGET:-"wasm32-unknown-unknown-wasm"}
|
||||
WASM_BIN_PREFIX=${WASM_BIN_PREFIX:-"$WASM_TARGET"}
|
||||
WASM_TOOLS=(ar)
|
||||
elif [ "$1" = "wasi" ]; then
|
||||
echo "Setting up for wasi-sdk"
|
||||
WASM_PREFIX=${WASM_PREFIX:-${WASM_SDK:-"/opt/wasi-sdk"}}
|
||||
WASM_BIN=${WASM_BIN:-"${WASM_PREFIX}/bin"}
|
||||
WASM_SYSROOT=${WASM_SYSROOT:-"${WASM_PREFIX}/share/sysroot"}
|
||||
WASM_TARGET=${WASM_TARGET:-"wasm32-wasi"}
|
||||
WASM_BIN_PREFIX=${WASM_BIN_PREFIX:-"$WASM_TARGET"}
|
||||
WASM_TOOLS=(ar dwarfdump nm ranlib size)
|
||||
fi
|
||||
$DRY_RUN && echo WASM_PREFIX: "$WASM_PREFIX"
|
||||
$DRY_RUN && echo WASM_BIN: "$WASM_BIN"
|
||||
$DRY_RUN && echo WASM_SYSROOT: "$WASM_SYSROOT"
|
||||
$DRY_RUN && echo WASM_TARGET: "$WASM_TARGET"
|
||||
$DRY_RUN && echo WASM_BIN_PREFIX: "$WASM_BIN_PREFIX"
|
||||
$DRY_RUN && echo WASM_TOOLS: "${WASM_TOOLS[@]}"
|
||||
|
||||
# Delete all existing installations of the binaries
|
||||
$DRY_RUN_PREFIX rm -f "${SYS_BIN_DIR}"/*
|
||||
|
||||
# And reinstall
|
||||
$DRY_RUN_PREFIX install -d -v "$SYS_BIN_DIR" || exit 1
|
||||
|
||||
# Symbolically link the Awsm compiler
|
||||
# /sledge/awsm/target/release/silverfish /opt/sledge/bin/awsm
|
||||
$DRY_RUN_PREFIX ln -sfv "${SYS_COMPILER_REL_DIR}/${COMPILER_EXECUTABLE}" "${SYS_BIN_DIR}/${COMPILER_EXECUTABLE}"
|
||||
|
||||
# Generate shell script stubs that act as aliases that automatically set the approproiate target and sysroot
|
||||
# for either Wasmception or WASI-SDK
|
||||
# For example, when wasmception is set, calling `wasm32-unknown-unknown-wasm-clang` results in
|
||||
# `exec "/sledge/awsm/wasmception/dist/bin/clang" --target="wasm32-unknown-unknown-wasm" --sysroot="/sledge/awsm/wasmception/sysroot" "$@"`
|
||||
for file in clang clang++; do
|
||||
wrapper_file="$(mktemp)"
|
||||
cat > "$wrapper_file" << EOT
|
||||
#! /bin/sh
|
||||
|
||||
exec "${WASM_BIN}/${file}" --target="$WASM_TARGET" --sysroot="$WASM_SYSROOT" "\$@"
|
||||
EOT
|
||||
cat "$wrapper_file"
|
||||
$DRY_RUN_PREFIX install -p -v "$wrapper_file" "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-${file}"
|
||||
$DRY_RUN && echo rm -f "$wrapper_file"
|
||||
rm -f "$wrapper_file"
|
||||
done
|
||||
|
||||
# Link the LLVM Tools with the proper prefix
|
||||
for file in "${WASM_TOOLS[@]}"; do
|
||||
$DRY_RUN_PREFIX ln -sfv "${WASM_BIN}/llvm-${file}" "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-${file}"
|
||||
done
|
||||
|
||||
# Link any other tools with the proper prefix
|
||||
OTHER_TOOLS=(ld)
|
||||
for file in "${OTHER_TOOLS[@]}"; do
|
||||
$DRY_RUN_PREFIX ln -sfv "${WASM_BIN}/wasm-${file}" "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-${file}"
|
||||
done
|
||||
|
||||
# Link clang as gcc if needed
|
||||
$DRY_RUN_PREFIX ln -svf "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-clang" "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-gcc"
|
||||
$DRY_RUN_PREFIX ln -svf "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-clang++" "${SYS_BIN_DIR}/${WASM_BIN_PREFIX}-g++"
|
||||
|
||||
echo "Done!"
|
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Note, wasi-sdk versions do NOT match llvm versions, e.g. wasi-sdk-12 actually uses llvm-11
|
||||
LLVM_VERSION=13
|
||||
WASI_SDK_VERSION=12
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
if [[ $ARCH = "x86_64" ]]; then
|
||||
SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.4.3/shfmt_v3.4.3_linux_amd64
|
||||
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
|
||||
elif [[ $ARCH = "aarch64" ]]; then
|
||||
SHFMT_URL=https://github.com/patrickvane/shfmt/releases/download/master/shfmt_linux_arm
|
||||
echo "ARM64 support is still a work in progress!"
|
||||
exit 1
|
||||
else
|
||||
echo "This script only supports x86_64 and aarch64"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
|
||||
apt-utils \
|
||||
man-db \
|
||||
&& yes | unminimize
|
||||
|
||||
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
|
||||
automake \
|
||||
bc \
|
||||
bsdmainutils \
|
||||
build-essential \
|
||||
binutils-dev \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
curl \
|
||||
fonts-dejavu \
|
||||
fonts-cascadia-code \
|
||||
fonts-roboto \
|
||||
gdb \
|
||||
git \
|
||||
gpg-agent \
|
||||
gnuplot \
|
||||
hey \
|
||||
httpie \
|
||||
imagemagick \
|
||||
jq \
|
||||
less \
|
||||
libssl-dev \
|
||||
libtinfo5 \
|
||||
libtool \
|
||||
libz3-4 \
|
||||
lsb-release \
|
||||
make \
|
||||
netpbm \
|
||||
openssh-client \
|
||||
pango1.0-tools \
|
||||
pkg-config \
|
||||
shellcheck \
|
||||
software-properties-common \
|
||||
strace \
|
||||
valgrind \
|
||||
wabt \
|
||||
wamerican \
|
||||
wget
|
||||
|
||||
wget $SHFMT_URL -O shfmt && chmod +x shfmt && sudo mv shfmt /usr/local/bin/shfmt
|
||||
|
||||
sudo ./install_llvm.sh $LLVM_VERSION
|
||||
|
||||
curl -sS -L -O $WASI_SDK_URL && sudo dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
|
||||
|
||||
if [ -z "${WASI_SDK_PATH}" ]; then
|
||||
export WASI_SDK_PATH=/opt/wasi-sdk
|
||||
echo "export WASI_SDK_PATH=/opt/wasi-sdk" >> ~/.bashrc
|
||||
fi
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --component rustfmt --target wasm32-wasi -y
|
||||
|
||||
echo "Run 'source ~/.bashrc'"
|
@ -1,39 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Installs LLVM tooling, delegating the to the LLVM script as much as possible
|
||||
# We need to shim support for LLVM 8 because the LLVM script only supports 9-12
|
||||
|
||||
LLVM_VERSION=$1
|
||||
|
||||
echo "Installing LLVM $LLVM_VERSION"
|
||||
|
||||
# Script Installs clang, lldb, lld, and clangd
|
||||
if [[ "$LLVM_VERSION" -gt 8 ]]; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- "$LLVM_VERSION"
|
||||
else
|
||||
apt-get install -y --no-install-recommends \
|
||||
"clang-$LLVM_VERSION" \
|
||||
"lldb-$LLVM_VERSION" \
|
||||
"lld-$LLVM_VERSION" \
|
||||
"clangd-$LLVM_VERSION"
|
||||
fi
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | bash -s -- "$LLVM_VERSION"
|
||||
|
||||
# Installing "libc++-xx-dev" automagically installs "libc++1-xx", "libunwind-xx" and "libunwind-xx-dev"
|
||||
apt-get install -y --no-install-recommends \
|
||||
"libc++-$LLVM_VERSION-dev" \
|
||||
"libc++abi-$LLVM_VERSION-dev" \
|
||||
"libc++1-$LLVM_VERSION"
|
||||
"clang-tools-$LLVM_VERSION" \
|
||||
"clang-tidy-$LLVM_VERSION" \
|
||||
"clang-format-$LLVM_VERSION"
|
||||
|
||||
update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-$LLVM_VERSION" 100
|
||||
update-alternatives --remove-all wasm-ld
|
||||
update-alternatives --remove-all llvm-config
|
||||
update-alternatives --remove-all llvm-objdump
|
||||
update-alternatives --remove-all llvm-dis
|
||||
update-alternatives --remove-all clang-format
|
||||
update-alternatives --remove-all clang
|
||||
update-alternatives --remove-all clang++
|
||||
update-alternatives --remove-all clang-tidy
|
||||
|
||||
update-alternatives --install /usr/bin/wasm-ld wasm-ld "/usr/bin/wasm-ld-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/llvm-config llvm-config "/usr/bin/llvm-config-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/llvm-objdump llvm-objdump "/usr/bin/llvm-objdump-$LLVM_VERSION" 100
|
||||
|
||||
# Explicitly use at least clang-format-11 to format source because of changes between 10 and 11
|
||||
if [[ "$LLVM_VERSION" -ge 11 ]]; then
|
||||
apt-get install -y --no-install-recommends \
|
||||
"clang-format-$LLVM_VERSION"
|
||||
update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 100
|
||||
else
|
||||
apt-get install -y --no-install-recommends \
|
||||
"clang-format-11"
|
||||
update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-11" 100
|
||||
fi
|
||||
update-alternatives --install /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-$LLVM_VERSION 100
|
||||
update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-$LLVM_VERSION" 100
|
||||
update-alternatives --install /usr/bin/clang-tidy clang-tidy "/usr/bin/clang-tidy-$LLVM_VERSION" 100
|
||||
|
@ -0,0 +1,37 @@
|
||||
CFILES := src/*.c
|
||||
INCLUDES := -Iinclude/
|
||||
|
||||
# fPIC = Position Independent Code, necessary for linking to relative addresses.
|
||||
CFLAGS := -fPIC -O3 -flto -ftls-model=initial-exec
|
||||
|
||||
# Strips out calls to assert() and disables debuglog
|
||||
CFLAGS+=-DNDEBUG
|
||||
|
||||
# CFI Sanitizer
|
||||
# CFLAGS+=-fvisibility=default -fsanitize=cfi
|
||||
|
||||
# Undefined Sanitizer - https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
|
||||
# CFLAGS+=-fsanitize=undefined,float-divide-by-zero,unsigned-integer-overflow,implicit-conversion,local-bounds,nullability
|
||||
|
||||
# Address Sanitizer - "Fast Memory Error Detector" - https://clang.llvm.org/docs/AddressSanitizer.html
|
||||
# CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
|
||||
|
||||
# Clang SafeStack - https://clang.llvm.org/docs/SafeStack.html
|
||||
# CFLAGS+=-fsanitize=safe-stack
|
||||
|
||||
# Memory Sanitizer - https://clang.llvm.org/docs/MemorySanitizer.html
|
||||
# CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
|
||||
|
||||
all: dist/libsledge.a
|
||||
|
||||
dist:
|
||||
mkdir -p dist
|
||||
|
||||
dist/%.o: src/%.c dist
|
||||
clang ${CFLAGS} -c ${INCLUDES} -o $@ $<
|
||||
|
||||
dist/libsledge.a: dist/control_instructions.o dist/memory_instructions.o dist/numeric_instructions.o dist/table_instructions.o dist/variable_instructions.o dist/instantiation.o dist/wasi_snapshot_preview1.o dist/sledge_extensions.o
|
||||
ar rcs dist/libsledge.a $^
|
||||
|
||||
clean:
|
||||
rm -rf dist
|
@ -0,0 +1,156 @@
|
||||
---
|
||||
geometry: margin=2cm
|
||||
---
|
||||
|
||||
# libsledge Binary Interfaces
|
||||
|
||||
libsledge is a \*.a static library (archive) that is statically linked with a \*.bc file generated by the aWsm compiler when compiling to a \*.so Linux shared library that can be loaded and executed by the sledgert runtime.
|
||||
|
||||
The static library internally implements the aWsm ABI in order to link to the \*.bc file generated by the aWsm compiler. [See the relevant documentation for this ABI here](../awsm/doc/abi.md).
|
||||
|
||||
libsledge defines a ABI between the sledgert runtime and a \*.so shared library containing an executable serverless function. This is distinct from the aWsm ABI.
|
||||
|
||||
# SLEdge \*.so serverless module
|
||||
|
||||
A SLEdge \*.so serverless module is generated by the latter portion of the aWsm/SLEdge toolchain.
|
||||
|
||||
The first portion of the toolchain is responsible for compiling a source program into a WebAssembly module. This is handled by standard compilers capable of emitting WebAssembly.
|
||||
The second portion of the toolchain is the aWsm compiler, which generates a \*.bc file with a well defined ABI.
|
||||
The third portion of the toolchain is the LLVM compiler, which ingests a \*.bc file emitted by aWsm and the libsledge static library, and emits a SLEdge \*.so serverless module.
|
||||
|
||||
## Architecture
|
||||
|
||||
In order to reduce the overhead of calling sledgert functions, libsledge operates on global state of type `sledge_abi__wasm_module_instance` at `sledge_abi__current_wasm_module_instance`. This represents the global state of the wasm32 context executing on a sledgert worker core. The scheduler is responsible for populating these symbols before yielding execution to a serverless function.
|
||||
|
||||
The `sledge_abi__wasm_module_instance` structure includes the WebAssembly function table and the WebAssembly linear memory. This subset was selected because the author believes that use of function pointers and linear memory is frequent enough that LTO when compiling the \*.so file is beneficial.
|
||||
|
||||
## WebAssembly Instruction Implementation
|
||||
|
||||
Here is a list of WebAssembly instructions that depend on symbols from libsledge, libc, or sledgert (via the SLEdge ABI).
|
||||
|
||||
### [Control Instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#control-instructions)
|
||||
|
||||
| Instruction | aWsm ABI | libc Dependencies | SLEdge ABI |
|
||||
| ------------- | ------------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| call_indirect | `get_function_from_table` | `stderr`, `fprintf` | `sledge_abi__current_wasm_module_instance.table`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_INVALID_INDEX`, `WASM_TRAP_MISMATCHED_TYPE` |
|
||||
|
||||
### [Variable Instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#variable-instructions)
|
||||
|
||||
| Instruction | aWsm ABI | libc Dependencies | SLEdge ABI |
|
||||
| ----------- | ---------------------------------- | ----------------- | ---------------------------------------------------------------------- |
|
||||
| global.get | `get_global_i32`, `get_global_i64` | None | `sledge_abi__wasm_globals_get_i32`, `sledge_abi__wasm_globals_get_i64` |
|
||||
| global.set | `set_global_i32`, `set_global_i64` | None | `sledge_abi__wasm_globals_set_i32`, `sledge_abi__wasm_globals_set_i64` |
|
||||
|
||||
### [Numeric Instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#numeric-instructions)
|
||||
|
||||
| Instruction | aWsm ABI | libc Dependencies | SLEdge ABI |
|
||||
| --------------- | ---------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------------- |
|
||||
| i32.div_s | `i32_div` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.div_u | `u32_div` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.rem_s | `i32_rem` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.rem_u | `u32_rem` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.rotl | `rotl_u32` | None | None |
|
||||
| i32.rotr | `rotr_u32` | None | None |
|
||||
| i32.trunc_f32_s | `i32_trunc_f32` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.trunc_f32_u | `u32_trunc_f32` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.trunc_f64_s | `i32_trunc_f64` ("fast unsafe" disabled) | `INT32_MIN`, `INT32_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i32.trunc_f64_u | `u32_trunc_f64` ("fast unsafe" disabled) | `UINT32_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.div_s | `i64_div` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.div_u | `u64_div` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.rem_s | `i64_rem` ("fast unsafe" disabled) | `INT32_MIN`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.rem_u | `u64_rem` ("fast unsafe" disabled) | `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.rotl | `rotl_u64` | **NOT SUPPORTED** | **NOT SUPPORTED** |
|
||||
| i64.rotr | `rotr_u64` | **NOT SUPPORTED** | **NOT SUPPORTED** |
|
||||
| i64.trunc_f32_s | `i64_trunc_f32` | `INT64_MIN`, `INT64_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.trunc_f32_u | `u64_trunc_f32` | `UINT64_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.trunc_f64_s | `i64_trunc_f64` | `INT64_MIN`, `INT64_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| i64.trunc_f64_u | `u64_trunc_f64` | `UINT64_MAX`, `stderr`, `fprintf` | `sledge_abi__wasm_trap_raise`, `WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION` |
|
||||
| f32.ceil | `f32_ceil` | `ceilf` | `ceilf` |
|
||||
| f32.copysign | `f32_copysign` | `copysignf` | `copysignf` |
|
||||
| f32.floor | `f32_floor` | `floorf` | `floorf` |
|
||||
| f32.max | `f32_max` | None | None |
|
||||
| f32.min | `f32_min` | None | None |
|
||||
| f32.nearest | `f32_nearest` | `nearbyintf` | `nearbyintf` |
|
||||
| f32.trunc | `f32_trunc_f32` | `truncf` | `truncf` |
|
||||
| f64.ceil | `f64_ceil` | `ceil` | `ceil` |
|
||||
| f64.copysign | `f64_copysign` | `copysign` | `copysign` |
|
||||
| f64.floor | `f64_floor` | `floor` | `floor` |
|
||||
| f64.max | `f64_max` | None | None |
|
||||
| f64.min | `f64_min` | None | None |
|
||||
| f64.nearest | `f64_nearest` | `nearbyint` | `nearbyint` |
|
||||
| f64.trunc | `f64_trunc_f64` | `trunc` | `trunc` |
|
||||
|
||||
### [Memory Instructions](https://webassembly.github.io/spec/core/syntax/instructions.html#memory-instructions)
|
||||
|
||||
| instruction | aWsm ABI | libc Dependencies | SLEdge ABI |
|
||||
| ------------ | ------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| i32.load | `get_i32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.load8_s | `get_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.load8_u | `get_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.load16_s | `get_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.load16_u | `get_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.store | `set_i32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.store8 | `set_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i32.store16 | `set_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load | `get_i64` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load8_s | `get_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load8_u | `get_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load16_s | `get_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load16_u | `get_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load32_s | `get_i32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.load32_u | `get_i32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.store | `set_i64` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.store8 | `set_i8` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.store16 | `set_i16` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| i64.store32 | `set_i32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| f32.load | `get_f32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| f32.store | `set_f32` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| f64.load | `get_f64` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| f64.store | `set_f64` | `fprintf`, `stderr` | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_trap_raise`, `WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY` |
|
||||
| memory.grow | `instruction_memory_grow` | | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_memory_expand` |
|
||||
| memory.size | `instruction_memory_size` | | `sledge_abi__current_wasm_module_instance.memory` |
|
||||
| None | `initialize_region` | | `sledge_abi__current_wasm_module_instance.memory`, `sledge_abi__wasm_memory_initialize_region` |
|
||||
|
||||
|
||||
# SLEdge \*.so Module Loading / Initialization
|
||||
|
||||
The `sledgert` runtime is invoked with an argument containing the path to a JSON file defining serverless functions. The JSON format is a top level array containing 0..N JSON objects with the following keys:
|
||||
"name" - A Human friendly name identifying a serverless function. Is required.
|
||||
"path" - A path to a \*.so module containing the program to be executed
|
||||
"port" - The port which the serverless function is registered
|
||||
"relative-deadline-us"
|
||||
"expected-execution-us"
|
||||
"admissions-percentile"
|
||||
"http-resp-content-type"
|
||||
|
||||
The path to the JSON file is passed to `module_alloc_from_json`, which uses the Jasmine library to parse the JSON, performs validation, and passes the resulting specification to `module_alloc` for each module definition found. `module_alloc` allocated heap memory for a `struct module` and then calls `module_init`. `module_init` calls `sledge_abi_symbols_init`, which calls `dlopen` on the _.so file at the path specified in the JSON and then calls `dlsym` to resolve symbols within the _.so module.
|
||||
|
||||
- `module.abi.initialize_globals` -> `SLEDGE_ABI__INITIALIZE_GLOBALS` -> `populate_globals`
|
||||
- `module.abi.initialize_memory`-> `SLEDGE_ABI__INITIALIZE_MEMORY` -> `populate_memory`
|
||||
- `module.abi.initialize_table` -> `SLEDGE_ABI__INITIALIZE_TABLE` -> `populate_table`
|
||||
- `module.abi.entrypoint` -> `SLEDGE_ABI__ENTRYPOINT` -> `wasmf__start`
|
||||
- `module.abi.starting_pages` -> `SLEDGE_ABI__STARTING_PAGES` -> `starting_pages`
|
||||
- `module.abi.max_pages` -> `SLEDGE_ABI__MAX_PAGES` -> `max_pages`
|
||||
- `module.abi.globals_len` -> `SLEDGE_ABI__GLOBALS_LEN` -> `globals_len`
|
||||
|
||||
`module_init` then calls `module.abi.initialize_table`, which populates the indirect function table with the actual functions. This is performed once during module initialization because this table does not actually vary between instances of a module.
|
||||
|
||||
# SLEdge \*.so Module Instantiation
|
||||
|
||||
When `sledgert` receives a request at the registered port specified in the JSON, it performs allocation and initialization steps. The scheduler sets the expected ABI symbols and yields to `current_sandbox_start`, which immediately calls `current_sandbox_init`. This function initializes the associated runtime state and
|
||||
|
||||
1. calls `module.abi.initialize_globals` for the current sandbox if not NULL. This is optional because the module might not have been built with the `--runtime-globals`, in which case runtime globals are not used at all. If not NULL, the globals are set in the table.
|
||||
2. calls `module.abi.initialize_memory`, which copies segments into the linear memory
|
||||
|
||||
`current_sandbox_init` calls `wasi_context_init` to initialize the WASI context within the runtime.
|
||||
|
||||
`current_sandbox_init` returns to `current_sandbox_start`, which sets up wasm traps using `setjmp` and then calls `module.abi.entrypoint`
|
||||
|
||||
# Discussion (follow-up with Github issues):
|
||||
|
||||
- Should `sledge_abi__current_wasm_module_instance` be turned into a macro defined int the ABI header? That way it'll be easier to change the ABI symbols (change once, applied everywhere).
|
||||
- Should `instruction_memory_grow` be moved into sledgert? This would simplify the handling of the "cache" and generating a memory profile?
|
||||
- Rename `sledge_abi__wasm_globals_*` to `sledge_abi__wasm_global_*`
|
||||
- Implement Unsupported Numeric Instructions
|
||||
- Should the wasm global table be accessed directly instead of via a runtime function? If we expose the wasm global table to libsledge, then we have worse ABI stability, but better performance.
|
||||
- Should the Function Table be handled by the \*.so file or sledgert? Are function pointers really called that frequently?
|
@ -0,0 +1,258 @@
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <threads.h>
|
||||
|
||||
/* Do not include runtime headers here! */
|
||||
|
||||
/** ABI Types
|
||||
* Changes to these types breaks the contract between sledgert and the *.so modules that it runs. This means that all
|
||||
* modules must be recompiled. Avoid this!
|
||||
*/
|
||||
|
||||
struct sledge_abi__wasm_table_entry {
|
||||
uint32_t type_id;
|
||||
void *func_pointer;
|
||||
};
|
||||
|
||||
struct sledge_abi__wasm_table {
|
||||
uint32_t length;
|
||||
uint32_t capacity;
|
||||
struct sledge_abi__wasm_table_entry *buffer; /* Backing heap allocation */
|
||||
};
|
||||
|
||||
struct sledge_abi__wasm_memory {
|
||||
uint64_t size; /* Initial Size in bytes */
|
||||
uint64_t capacity; /* Size backed by actual pages */
|
||||
uint64_t max; /* Soft cap in bytes. Defaults to 4GB */
|
||||
uint8_t *buffer; /* Backing heap allocation. Different lifetime because realloc might move this */
|
||||
};
|
||||
|
||||
/* This structure is the runtime representation of the unique state of a module instance
|
||||
* Currently this is not spec-compliant, as it only supports a single table and a single memory and it excludes many
|
||||
* entities https://webassembly.github.io/spec/core/exec/runtime.html#module-instances
|
||||
*/
|
||||
struct sledge_abi__wasm_module_instance {
|
||||
uint64_t wasmg_0; /* Used to refer to the shadow stack */
|
||||
struct sledge_abi__wasm_table *table;
|
||||
/* Note: memory has an opaque type due to private state. Do not reorder members below this! */
|
||||
struct sledge_abi__wasm_memory memory;
|
||||
/* Private runtime state follows */
|
||||
};
|
||||
|
||||
/* Based on example traps listed at https://webassembly.org/docs/security/ */
|
||||
enum sledge_abi__wasm_trap
|
||||
{
|
||||
WASM_TRAP_INVALID_INDEX = 1,
|
||||
WASM_TRAP_MISMATCHED_TYPE = 2,
|
||||
WASM_TRAP_PROTECTED_CALL_STACK_OVERFLOW = 3,
|
||||
WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY = 4,
|
||||
WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION = 5,
|
||||
WASM_TRAP_UNREACHABLE = 6,
|
||||
WASM_TRAP_COUNT
|
||||
};
|
||||
|
||||
/* Symbols expected from sledgert */
|
||||
|
||||
extern void sledge_abi__wasm_trap_raise(enum sledge_abi__wasm_trap trapno);
|
||||
extern int32_t sledge_abi__wasm_memory_expand(struct sledge_abi__wasm_memory *wasm_memory, uint32_t page_count);
|
||||
void sledge_abi__wasm_memory_initialize_region(struct sledge_abi__wasm_memory *wasm_memory, uint32_t offset,
|
||||
uint32_t region_size, uint8_t region[]);
|
||||
|
||||
extern int32_t sledge_abi__wasm_globals_get_i32(uint32_t idx);
|
||||
extern int64_t sledge_abi__wasm_globals_get_i64(uint32_t idx);
|
||||
extern void sledge_abi__wasm_globals_set_i32(uint32_t idx, int32_t value, bool is_mutable);
|
||||
extern void sledge_abi__wasm_globals_set_i64(uint32_t idx, int64_t value, bool is_mutable);
|
||||
|
||||
/* Wasm initialization functions generated by the aWsm compiler */
|
||||
extern void sledge_abi__init_globals(void);
|
||||
extern void sledge_abi__init_mem(void);
|
||||
extern void sledge_abi__init_tbl(void);
|
||||
extern int32_t sledge_abi__entrypoint(void);
|
||||
extern uint32_t sledge_abi__wasm_memory_starting_pages(void);
|
||||
extern uint32_t sledge_abi__wasm_memory_max_pages(void);
|
||||
|
||||
typedef void (*sledge_abi__init_globals_fn_t)(void);
|
||||
#define SLEDGE_ABI__INITIALIZE_GLOBALS "sledge_abi__init_globals"
|
||||
|
||||
typedef void (*sledge_abi__init_mem_fn_t)(void);
|
||||
#define SLEDGE_ABI__INITIALIZE_MEMORY "sledge_abi__init_mem"
|
||||
|
||||
typedef void (*sledge_abi__init_tbl_fn_t)(void);
|
||||
#define SLEDGE_ABI__INITIALIZE_TABLE "sledge_abi__init_tbl"
|
||||
|
||||
typedef int32_t (*sledge_abi__entrypoint_fn_t)(void);
|
||||
#define SLEDGE_ABI__ENTRYPOINT "sledge_abi__entrypoint"
|
||||
|
||||
typedef uint32_t (*sledge_abi__wasm_memory_starting_pages_fn_t)(void);
|
||||
#define SLEDGE_ABI__STARTING_PAGES "sledge_abi__wasm_memory_starting_pages"
|
||||
|
||||
typedef uint32_t (*sledge_abi__wasm_memory_max_pages_fn_t)(void);
|
||||
#define SLEDGE_ABI__MAX_PAGES "sledge_abi__wasm_memory_max_pages"
|
||||
|
||||
typedef uint32_t (*sledge_abi__wasm_memory_globals_len_fn_t)(void);
|
||||
#define SLEDGE_ABI__GLOBALS_LEN "sledge_abi__wasm_globals_len"
|
||||
|
||||
typedef uint32_t __wasi_clockid_t;
|
||||
typedef uint64_t __wasi_dircookie_t;
|
||||
typedef uint32_t __wasi_exitcode_t;
|
||||
typedef int32_t __wasi_fd_t;
|
||||
typedef int64_t __wasi_filedelta_t;
|
||||
typedef uint64_t __wasi_filesize_t;
|
||||
typedef uint32_t __wasi_lookupflags_t;
|
||||
typedef uint64_t __wasi_rights_t;
|
||||
typedef uint32_t __wasi_size_t;
|
||||
typedef uint64_t __wasi_timestamp_t;
|
||||
|
||||
#ifndef unlikely
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#endif
|
||||
|
||||
#ifndef likely
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#endif
|
||||
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_args_get(__wasi_size_t argv_retoffset, __wasi_size_t argv_buf_retoffset);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_args_sizes_get(__wasi_size_t argc_retoffset, __wasi_size_t argv_buf_len_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_clock_res_get(__wasi_clockid_t id, __wasi_size_t resolution_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_clock_time_get(__wasi_clockid_t clock_id, __wasi_timestamp_t precision,
|
||||
__wasi_size_t time_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_environ_get(__wasi_size_t env_retoffset, __wasi_size_t env_buf_retoffset);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_environ_sizes_get(__wasi_size_t envc_retoffset, __wasi_size_t env_buf_len_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_advise(__wasi_fd_t fd, __wasi_filesize_t file_offset,
|
||||
__wasi_filesize_t len, uint32_t advice_extended);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_fd_allocate(__wasi_fd_t fd, __wasi_filesize_t offset, __wasi_filesize_t len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_close(__wasi_fd_t fd);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_datasync(__wasi_fd_t fd);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_fdstat_get(__wasi_fd_t fd, __wasi_size_t fdstat_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_fdstat_set_flags(__wasi_fd_t fd, uint32_t fdflags_extended);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_fdstat_set_rights(__wasi_fd_t fd, __wasi_rights_t fs_rights_base,
|
||||
__wasi_rights_t fs_rights_inheriting);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_filestat_get(__wasi_fd_t fd, __wasi_size_t filestat_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_filestat_set_size(__wasi_fd_t fd, __wasi_filesize_t size);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_filestat_set_times(__wasi_fd_t fd, __wasi_timestamp_t atim,
|
||||
__wasi_timestamp_t mtim, uint32_t fstflags_extended);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_fd_pread(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_filesize_t offset, __wasi_size_t nread_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_prestat_get(__wasi_fd_t fd, __wasi_size_t prestat_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_prestat_dir_name(__wasi_fd_t fd, __wasi_size_t dirname_retoffset,
|
||||
__wasi_size_t dirname_len);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_fd_pwrite(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_filesize_t file_offset, __wasi_size_t nwritten_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_read(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset,
|
||||
__wasi_size_t iovs_len, __wasi_size_t nread_retoffset);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_fd_readdir(__wasi_fd_t fd, __wasi_size_t buf_baseoffset, __wasi_size_t buf_len,
|
||||
__wasi_dircookie_t cookie, __wasi_size_t nread_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_renumber(__wasi_fd_t fd, __wasi_fd_t to);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_seek(__wasi_fd_t fd, __wasi_filedelta_t file_offset,
|
||||
uint32_t whence_extended, __wasi_size_t newoffset_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_sync(__wasi_fd_t fd);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_tell(__wasi_fd_t fd, __wasi_size_t fileoffset_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_fd_write(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset,
|
||||
__wasi_size_t iovs_len, __wasi_size_t nwritten_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_create_directory(__wasi_fd_t fd, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_filestat_get(__wasi_fd_t fd, __wasi_lookupflags_t flags,
|
||||
__wasi_size_t path_baseoffset, __wasi_size_t path_len,
|
||||
__wasi_size_t filestat_retoffset);
|
||||
|
||||
uint32_t
|
||||
sledge_abi__wasi_snapshot_preview1_path_filestat_set_times(__wasi_fd_t fd, __wasi_lookupflags_t flags,
|
||||
__wasi_size_t path_baseoffset, __wasi_size_t path_len,
|
||||
__wasi_timestamp_t atim, __wasi_timestamp_t mtim,
|
||||
uint32_t fstflags_extended);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_link(__wasi_fd_t old_fd, __wasi_lookupflags_t old_flags,
|
||||
__wasi_size_t old_path_baseoffset, __wasi_size_t old_path_len,
|
||||
__wasi_fd_t new_fd, __wasi_size_t new_path_baseoffset,
|
||||
__wasi_size_t new_path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_open(__wasi_fd_t dirfd, __wasi_lookupflags_t lookupflags,
|
||||
__wasi_size_t path_baseoffset, __wasi_size_t path_len,
|
||||
uint32_t oflags_extended, __wasi_rights_t fs_rights_base,
|
||||
__wasi_rights_t fs_rights_inheriting, uint32_t fdflags_extended,
|
||||
__wasi_size_t fd_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_readlink(__wasi_fd_t fd, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len, __wasi_size_t buf_baseretoffset,
|
||||
__wasi_size_t buf_len, __wasi_size_t nread_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_remove_directory(__wasi_fd_t fd, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_rename(__wasi_fd_t fd, __wasi_size_t old_path_baseoffset,
|
||||
__wasi_size_t old_path_len, __wasi_fd_t new_fd,
|
||||
__wasi_size_t new_path_baseoffset, __wasi_size_t new_path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_symlink(__wasi_size_t old_path_baseoffset, __wasi_size_t old_path_len,
|
||||
__wasi_fd_t fd, __wasi_size_t new_path_baseoffset,
|
||||
__wasi_size_t new_path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_path_unlink_file(__wasi_fd_t fd, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_poll_oneoff(__wasi_size_t in_baseoffset, __wasi_size_t out_baseoffset,
|
||||
__wasi_size_t nsubscriptions, __wasi_size_t nevents_retoffset);
|
||||
|
||||
void sledge_abi__wasi_snapshot_preview1_proc_exit(__wasi_exitcode_t exitcode);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_proc_raise(uint32_t sig_extended);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_random_get(__wasi_size_t buf_baseretoffset, __wasi_size_t buf_len);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_sched_yield(void);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_sock_recv(__wasi_fd_t fd, __wasi_size_t ri_data_baseretoffset,
|
||||
__wasi_size_t ri_data_len, uint32_t ri_flags_extended,
|
||||
__wasi_size_t ri_data_nbytes_retoffset,
|
||||
__wasi_size_t message_nbytes_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_sock_send(__wasi_fd_t fd, __wasi_size_t si_data_baseoffset,
|
||||
__wasi_size_t si_data_len, uint32_t si_flags_extended,
|
||||
__wasi_size_t nbytes_retoffset);
|
||||
|
||||
uint32_t sledge_abi__wasi_snapshot_preview1_sock_shutdown(__wasi_fd_t fd, uint32_t how);
|
||||
|
||||
uint32_t sledge_abi__scratch_storage_get_size(uint32_t key_offset, uint32_t key_len);
|
||||
int sledge_abi__scratch_storage_get(uint32_t key_offset, uint32_t key_size, uint32_t buf_offset, uint32_t buf_len);
|
||||
int sledge_abi__scratch_storage_set(uint32_t key_offset, uint32_t key_len, uint32_t value_offset, uint32_t value_len);
|
||||
int sledge_abi__scratch_storage_delete(uint32_t key_offset, uint32_t key_len);
|
||||
void
|
||||
sledge_abi__scratch_storage_upsert(uint32_t key_offset, uint32_t key_len, uint32_t value_offset, uint32_t value_len);
|
@ -0,0 +1,7 @@
|
||||
#include "sledge_abi.h"
|
||||
|
||||
void
|
||||
awsm_abi__trap_unreachable(void)
|
||||
{
|
||||
sledge_abi__wasm_trap_raise(WASM_TRAP_UNREACHABLE);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
#include "sledge_abi.h"
|
||||
|
||||
/* The visibility attribute is used to control the visibility of a symbol across C translation units. The default
|
||||
* argument forces "external" linkage. This originated in gcc, but had been adopted by LLVM.
|
||||
* Reference: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html */
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
|
||||
/* The weak attribute is used to provide a weak symbol that can be overridden by later linking to a "strong" symbol.
|
||||
* This is useful for defining a default or no-op implementation of a symbol that might or might not be present in a
|
||||
* binary. This applies to populate_globals() below, which is only generated by aWsm when a module is compiled with the
|
||||
* "--runtime-globals" argument. We need to provide a weak symbol that does nothing to prevent unresolved symbols from
|
||||
* triggering linker errors. */
|
||||
#define WEAK __attribute__((weak))
|
||||
|
||||
/* aWsm ABI Symbols */
|
||||
extern void populate_globals(void);
|
||||
extern void populate_memory(void);
|
||||
extern void populate_table(void);
|
||||
extern void populate_table(void);
|
||||
extern int32_t wasmf__start(void);
|
||||
extern uint32_t starting_pages;
|
||||
extern uint32_t max_pages;
|
||||
extern uint32_t globals_len;
|
||||
|
||||
WEAK void populate_globals(){};
|
||||
|
||||
EXPORT void
|
||||
sledge_abi__init_globals(void)
|
||||
{
|
||||
populate_globals();
|
||||
}
|
||||
|
||||
void
|
||||
sledge_abi__init_mem(void)
|
||||
{
|
||||
populate_memory();
|
||||
}
|
||||
|
||||
EXPORT void
|
||||
sledge_abi__init_tbl(void)
|
||||
{
|
||||
populate_table();
|
||||
}
|
||||
|
||||
EXPORT int32_t
|
||||
sledge_abi__entrypoint(void)
|
||||
{
|
||||
return wasmf__start();
|
||||
}
|
||||
|
||||
EXPORT uint32_t
|
||||
sledge_abi__wasm_memory_starting_pages(void)
|
||||
{
|
||||
return starting_pages;
|
||||
}
|
||||
|
||||
EXPORT uint32_t
|
||||
sledge_abi__wasm_memory_max_pages(void)
|
||||
{
|
||||
return max_pages;
|
||||
}
|
||||
|
||||
EXPORT uint32_t
|
||||
sledge_abi__wasm_globals_len(void)
|
||||
{
|
||||
return globals_len;
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
#include "sledge_abi.h"
|
||||
|
||||
#define INLINE __attribute__((always_inline))
|
||||
#define WASM_PAGE_SIZE (1024 * 64) /* 64KB */
|
||||
|
||||
/* This is private and NOT in the sledge_abi.h header because the runtime uses an overlay struct that extends this
|
||||
* symbol with private members */
|
||||
extern thread_local struct sledge_abi__wasm_module_instance sledge_abi__current_wasm_module_instance;
|
||||
|
||||
INLINE uint32_t
|
||||
instruction_memory_size()
|
||||
{
|
||||
return (uint32_t)(sledge_abi__current_wasm_module_instance.memory.size / (uint64_t)WASM_PAGE_SIZE);
|
||||
}
|
||||
|
||||
// These functions are equivalent to those in wasm_memory.h, but they minimize pointer dereferencing
|
||||
INLINE float
|
||||
get_f32(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(float *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
INLINE double
|
||||
get_f64(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(double *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
INLINE int8_t
|
||||
get_i8(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(int8_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
INLINE int16_t
|
||||
get_i16(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(int16_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
INLINE int32_t
|
||||
get_i32(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(int32_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
INLINE int64_t
|
||||
get_i64(uint32_t offset)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
return *(int64_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset];
|
||||
}
|
||||
|
||||
// Now setting routines
|
||||
INLINE void
|
||||
set_f32(uint32_t offset, float value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(float *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_f64(uint32_t offset, double value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(double *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i8(uint32_t offset, int8_t value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(int8_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i16(uint32_t offset, int16_t value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(int16_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i32(uint32_t offset, int32_t value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(int32_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i64(uint32_t offset, int64_t value)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.memory.buffer != NULL);
|
||||
|
||||
*(int64_t *)&sledge_abi__current_wasm_module_instance.memory.buffer[offset] = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Stub that implements the WebAssembly memory.grow instruction
|
||||
*
|
||||
* @param count number of pages to grow the WebAssembly linear memory by
|
||||
* @return The previous size of the linear memory in pages or -1 if enough memory cannot be allocated
|
||||
*/
|
||||
INLINE int32_t
|
||||
instruction_memory_grow(uint32_t count)
|
||||
{
|
||||
return sledge_abi__wasm_memory_expand(&sledge_abi__current_wasm_module_instance.memory, count);
|
||||
}
|
||||
|
||||
|
||||
INLINE void
|
||||
initialize_region(uint32_t offset, uint32_t region_size, uint8_t region[region_size])
|
||||
{
|
||||
sledge_abi__wasm_memory_initialize_region(&sledge_abi__current_wasm_module_instance.memory, offset, region_size,
|
||||
region);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
#include <stdint.h>
|
||||
#include "sledge_abi.h"
|
||||
|
||||
#define INLINE __attribute__((always_inline))
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param key_len
|
||||
* @returns value_size at key or 0 if key not present
|
||||
*/
|
||||
INLINE uint32_t
|
||||
scratch_storage_get_size(uint32_t key_offset, uint32_t key_len)
|
||||
{
|
||||
return sledge_abi__scratch_storage_get_size(key_offset, key_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key_offset
|
||||
* @param key_len
|
||||
* @param buf_offset linear memory offset to buffer where value should be copied.
|
||||
* @param buf_len Size of buffer. Assumed to be size returned by sledge_kv_get_value_size.
|
||||
* @returns 0 on success, 1 if key missing, 2 if buffer too small
|
||||
*/
|
||||
INLINE int
|
||||
scratch_storage_get(uint32_t key_offset, uint32_t key_len, uint32_t buf_offset, uint32_t buf_len)
|
||||
{
|
||||
return sledge_abi__scratch_storage_get(key_offset, key_len, buf_offset, buf_len);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param key_offset
|
||||
* @param key_len
|
||||
* @param value_offset
|
||||
* @param value_len
|
||||
* @returns 0 on success, 1 if already present,
|
||||
*/
|
||||
INLINE int
|
||||
scratch_storage_set(uint32_t key_offset, uint32_t key_len, uint32_t value_offset, uint32_t value_len)
|
||||
{
|
||||
return sledge_abi__scratch_storage_set(key_offset, key_len, value_offset, value_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key_offset
|
||||
* @param key_len
|
||||
* @returns 0 on success, 1 if not present
|
||||
*/
|
||||
INLINE int
|
||||
scratch_storage_delete(uint32_t key_offset, uint32_t key_len)
|
||||
{
|
||||
return sledge_abi__scratch_storage_delete(key_offset, key_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key_offset
|
||||
* @param key_len
|
||||
* @param value_offset
|
||||
* @param value_len
|
||||
* @returns 0 on success, 1 if already present,
|
||||
*/
|
||||
INLINE void
|
||||
scratch_storage_upsert(uint32_t key_offset, uint32_t key_len, uint32_t value_offset, uint32_t value_len)
|
||||
{
|
||||
sledge_abi__scratch_storage_upsert(key_offset, key_len, value_offset, value_len);
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
#include "sledge_abi.h"
|
||||
|
||||
#define INDIRECT_TABLE_SIZE (1 << 10)
|
||||
#define INLINE __attribute__((always_inline))
|
||||
|
||||
/* This is private and NOT in the sledge_abi.h header because the runtime uses an overlay struct that extends this
|
||||
* symbol with private members */
|
||||
extern thread_local struct sledge_abi__wasm_module_instance sledge_abi__current_wasm_module_instance;
|
||||
|
||||
static INLINE void *
|
||||
wasm_table_get(struct sledge_abi__wasm_table *wasm_table, uint32_t idx, uint32_t type_id)
|
||||
{
|
||||
assert(wasm_table != NULL);
|
||||
|
||||
if (unlikely(idx >= wasm_table->capacity)) { sledge_abi__wasm_trap_raise(WASM_TRAP_INVALID_INDEX); }
|
||||
|
||||
struct sledge_abi__wasm_table_entry f = wasm_table->buffer[idx];
|
||||
|
||||
if (unlikely(f.type_id != type_id)) { sledge_abi__wasm_trap_raise(WASM_TRAP_MISMATCHED_TYPE); }
|
||||
|
||||
if (unlikely(f.func_pointer == NULL)) { sledge_abi__wasm_trap_raise(WASM_TRAP_MISMATCHED_TYPE); }
|
||||
|
||||
return f.func_pointer;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
wasm_table_set(struct sledge_abi__wasm_table *wasm_table, uint32_t idx, uint32_t type_id, char *pointer)
|
||||
{
|
||||
assert(wasm_table != NULL);
|
||||
assert(idx < wasm_table->capacity);
|
||||
assert(pointer != NULL);
|
||||
|
||||
if (wasm_table->buffer[idx].type_id == type_id && wasm_table->buffer[idx].func_pointer == pointer) return;
|
||||
wasm_table->buffer[idx] = (struct sledge_abi__wasm_table_entry){ .type_id = type_id, .func_pointer = pointer };
|
||||
}
|
||||
|
||||
INLINE void
|
||||
add_function_to_table(uint32_t idx, uint32_t type_id, char *pointer)
|
||||
{
|
||||
wasm_table_set(sledge_abi__current_wasm_module_instance.table, idx, type_id, pointer);
|
||||
}
|
||||
|
||||
/* char * is used as a generic pointer to a function pointer */
|
||||
INLINE char *
|
||||
get_function_from_table(uint32_t idx, uint32_t type_id)
|
||||
{
|
||||
assert(sledge_abi__current_wasm_module_instance.table != NULL);
|
||||
|
||||
if (unlikely(idx >= sledge_abi__current_wasm_module_instance.table->capacity)) {
|
||||
sledge_abi__wasm_trap_raise(WASM_TRAP_INVALID_INDEX);
|
||||
}
|
||||
|
||||
struct sledge_abi__wasm_table_entry f = sledge_abi__current_wasm_module_instance.table->buffer[idx];
|
||||
|
||||
if (unlikely(f.type_id != type_id)) { sledge_abi__wasm_trap_raise(WASM_TRAP_MISMATCHED_TYPE); }
|
||||
|
||||
if (unlikely(f.func_pointer == NULL)) { sledge_abi__wasm_trap_raise(WASM_TRAP_MISMATCHED_TYPE); }
|
||||
|
||||
return f.func_pointer;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "sledge_abi.h"
|
||||
|
||||
/* This is private and NOT in the sledge_abi.h header because the runtime uses an overlay struct that extends this
|
||||
* symbol with private members */
|
||||
extern thread_local struct sledge_abi__wasm_module_instance sledge_abi__current_wasm_module_instance;
|
||||
|
||||
int32_t
|
||||
get_global_i32(uint32_t idx)
|
||||
{
|
||||
if (idx == 0) {
|
||||
return (int32_t)sledge_abi__current_wasm_module_instance.wasmg_0;
|
||||
} else {
|
||||
return sledge_abi__wasm_globals_get_i32(idx);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t
|
||||
get_global_i64(uint32_t idx)
|
||||
{
|
||||
if (idx == 0) {
|
||||
return (int64_t)sledge_abi__current_wasm_module_instance.wasmg_0;
|
||||
} else {
|
||||
return sledge_abi__wasm_globals_get_i64(idx);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_global_i32(uint32_t idx, int32_t value)
|
||||
{
|
||||
if (idx == 0) {
|
||||
sledge_abi__current_wasm_module_instance.wasmg_0 = (uint64_t)value;
|
||||
} else {
|
||||
/* aWsm does not currently pass the is_mutable flag, so all runtime globals are assumed to be mutable.
|
||||
This is true if aWsm uses the flags to inline constant globals */
|
||||
sledge_abi__wasm_globals_set_i32(idx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
set_global_i64(uint32_t idx, int64_t value)
|
||||
{
|
||||
if (idx == 0) {
|
||||
sledge_abi__current_wasm_module_instance.wasmg_0 = (uint64_t)value;
|
||||
} else {
|
||||
/* aWsm does not currently pass the is_mutable flag, so all runtime globals are assumed to be mutable.
|
||||
This is true if aWsm uses the flags to inline constant globals */
|
||||
sledge_abi__wasm_globals_set_i64(idx, value, true);
|
||||
}
|
||||
}
|
@ -0,0 +1,311 @@
|
||||
#include <stdint.h>
|
||||
#include "sledge_abi.h"
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_args_get(__wasi_size_t argv_retoffset, __wasi_size_t argv_buf_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_args_get(argv_retoffset, argv_buf_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_args_sizes_get(__wasi_size_t argc_retoffset, __wasi_size_t argv_buf_len_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_args_sizes_get(argc_retoffset, argv_buf_len_retoffset);
|
||||
};
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_clock_res_get(__wasi_clockid_t id, __wasi_size_t resolution_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_clock_res_get(id, resolution_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_clock_time_get(__wasi_clockid_t clock_id, __wasi_timestamp_t precision,
|
||||
__wasi_size_t time_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_clock_time_get(clock_id, precision, time_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_environ_get(__wasi_size_t env_retoffset, __wasi_size_t env_buf_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_environ_get(env_retoffset, env_buf_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_environ_sizes_get(__wasi_size_t envc_retoffset, __wasi_size_t env_buf_len_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_environ_sizes_get(envc_retoffset, env_buf_len_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_advise(__wasi_fd_t fd, __wasi_filesize_t file_offset, __wasi_filesize_t len,
|
||||
uint32_t advice_extended)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_advise(fd, file_offset, len, advice_extended);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_allocate(__wasi_fd_t fd, __wasi_filesize_t offset, __wasi_filesize_t len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_allocate(fd, offset, len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_close(__wasi_fd_t fd)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_close(fd);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_datasync(__wasi_fd_t fd)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_datasync(fd);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_fdstat_get(__wasi_fd_t fd, __wasi_size_t fdstat_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_fdstat_get(fd, fdstat_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_fdstat_set_flags(__wasi_fd_t fd, uint32_t fdflags_extended)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_fdstat_set_flags(fd, fdflags_extended);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_fdstat_set_rights(__wasi_fd_t fd, __wasi_rights_t fs_rights_base,
|
||||
__wasi_rights_t fs_rights_inheriting)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_fdstat_set_rights(fd, fs_rights_base, fs_rights_inheriting);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_filestat_get(__wasi_fd_t fd, __wasi_size_t filestat_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_filestat_get(fd, filestat_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_filestat_set_size(__wasi_fd_t fd, __wasi_filesize_t size)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_filestat_set_size(fd, size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_filestat_set_times(__wasi_fd_t fd, __wasi_timestamp_t atim, __wasi_timestamp_t mtim,
|
||||
uint32_t fstflags_extended)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_filestat_set_times(fd, atim, mtim, fstflags_extended);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_pread(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_filesize_t offset, __wasi_size_t nread_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_pread(fd, iovs_baseoffset, iovs_len, offset, nread_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_prestat_get(__wasi_fd_t fd, __wasi_size_t prestat_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_prestat_get(fd, prestat_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_prestat_dir_name(__wasi_fd_t fd, __wasi_size_t dirname_retoffset, __wasi_size_t dirname_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_prestat_dir_name(fd, dirname_retoffset, dirname_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_pwrite(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_filesize_t file_offset, __wasi_size_t nwritten_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_pwrite(fd, iovs_baseoffset, iovs_len, file_offset,
|
||||
nwritten_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_read(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_size_t nread_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_read(fd, iovs_baseoffset, iovs_len, nread_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_readdir(__wasi_fd_t fd, __wasi_size_t buf_baseoffset, __wasi_size_t buf_len,
|
||||
__wasi_dircookie_t cookie, __wasi_size_t nread_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_readdir(fd, buf_baseoffset, buf_len, cookie, nread_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_renumber(__wasi_fd_t fd, __wasi_fd_t to)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_renumber(fd, to);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_seek(__wasi_fd_t fd, __wasi_filedelta_t file_offset, uint32_t whence_extended,
|
||||
__wasi_size_t newoffset_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_seek(fd, file_offset, whence_extended, newoffset_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_sync(__wasi_fd_t fd)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_sync(fd);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_tell(__wasi_fd_t fd, __wasi_size_t fileoffset_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_tell(fd, fileoffset_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_fd_write(__wasi_fd_t fd, __wasi_size_t iovs_baseoffset, __wasi_size_t iovs_len,
|
||||
__wasi_size_t nwritten_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_fd_write(fd, iovs_baseoffset, iovs_len, nwritten_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_create_directory(__wasi_fd_t fd, __wasi_size_t path_baseoffset, __wasi_size_t path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_create_directory(fd, path_baseoffset, path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_filestat_get(__wasi_fd_t fd, __wasi_lookupflags_t flags, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len, __wasi_size_t filestat_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_filestat_get(fd, flags, path_baseoffset, path_len,
|
||||
filestat_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_filestat_set_times(__wasi_fd_t fd, __wasi_lookupflags_t flags,
|
||||
__wasi_size_t path_baseoffset, __wasi_size_t path_len,
|
||||
__wasi_timestamp_t atim, __wasi_timestamp_t mtim,
|
||||
uint32_t fstflags_extended)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_filestat_set_times(fd, flags, path_baseoffset, path_len, atim,
|
||||
mtim, fstflags_extended);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_link(__wasi_fd_t old_fd, __wasi_lookupflags_t old_flags, __wasi_size_t old_path_baseoffset,
|
||||
__wasi_size_t old_path_len, __wasi_fd_t new_fd, __wasi_size_t new_path_baseoffset,
|
||||
__wasi_size_t new_path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_link(old_fd, old_flags, old_path_baseoffset, old_path_len,
|
||||
new_fd, new_path_baseoffset, new_path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_open(__wasi_fd_t dirfd, __wasi_lookupflags_t lookupflags, __wasi_size_t path_baseoffset,
|
||||
__wasi_size_t path_len, uint32_t oflags_extended, __wasi_rights_t fs_rights_base,
|
||||
__wasi_rights_t fs_rights_inheriting, uint32_t fdflags_extended,
|
||||
__wasi_size_t fd_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_open(dirfd, lookupflags, path_baseoffset, path_len,
|
||||
oflags_extended, fs_rights_base, fs_rights_inheriting,
|
||||
fdflags_extended, fd_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_readlink(__wasi_fd_t fd, __wasi_size_t path_baseoffset, __wasi_size_t path_len,
|
||||
__wasi_size_t buf_baseretoffset, __wasi_size_t buf_len,
|
||||
__wasi_size_t nread_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_readlink(fd, path_baseoffset, path_len, buf_baseretoffset,
|
||||
buf_len, nread_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_remove_directory(__wasi_fd_t fd, __wasi_size_t path_baseoffset, __wasi_size_t path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_remove_directory(fd, path_baseoffset, path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_rename(__wasi_fd_t fd, __wasi_size_t old_path_baseoffset, __wasi_size_t old_path_len,
|
||||
__wasi_fd_t new_fd, __wasi_size_t new_path_baseoffset, __wasi_size_t new_path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_rename(fd, old_path_baseoffset, old_path_len, new_fd,
|
||||
new_path_baseoffset, new_path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_symlink(__wasi_size_t old_path_baseoffset, __wasi_size_t old_path_len, __wasi_fd_t fd,
|
||||
__wasi_size_t new_path_baseoffset, __wasi_size_t new_path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_symlink(old_path_baseoffset, old_path_len, fd,
|
||||
new_path_baseoffset, new_path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_path_unlink_file(__wasi_fd_t fd, __wasi_size_t path_baseoffset, __wasi_size_t path_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_path_unlink_file(fd, path_baseoffset, path_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_poll_oneoff(__wasi_size_t in_baseoffset, __wasi_size_t out_baseoffset,
|
||||
__wasi_size_t nsubscriptions, __wasi_size_t nevents_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_poll_oneoff(in_baseoffset, out_baseoffset, nsubscriptions,
|
||||
nevents_retoffset);
|
||||
}
|
||||
|
||||
void
|
||||
wasi_snapshot_preview1_proc_exit(__wasi_exitcode_t exitcode)
|
||||
{
|
||||
sledge_abi__wasi_snapshot_preview1_proc_exit(exitcode);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_proc_raise(uint32_t sig_extended)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_proc_raise(sig_extended);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_random_get(__wasi_size_t buf_baseretoffset, __wasi_size_t buf_len)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_random_get(buf_baseretoffset, buf_len);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_sched_yield(void)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_sched_yield();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_sock_recv(__wasi_fd_t fd, __wasi_size_t ri_data_baseretoffset, __wasi_size_t ri_data_len,
|
||||
uint32_t ri_flags_extended, __wasi_size_t ri_data_nbytes_retoffset,
|
||||
__wasi_size_t message_nbytes_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_sock_recv(fd, ri_data_baseretoffset, ri_data_len, ri_flags_extended,
|
||||
ri_data_nbytes_retoffset, message_nbytes_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_sock_send(__wasi_fd_t fd, __wasi_size_t si_data_baseoffset, __wasi_size_t si_data_len,
|
||||
uint32_t si_flags_extended, __wasi_size_t nbytes_retoffset)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_sock_send(fd, si_data_baseoffset, si_data_len, si_flags_extended,
|
||||
nbytes_retoffset);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
wasi_snapshot_preview1_sock_shutdown(__wasi_fd_t fd, uint32_t how)
|
||||
{
|
||||
return sledge_abi__wasi_snapshot_preview1_sock_shutdown(fd, how);
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
|
||||
uint32_t
|
||||
instruction_memory_size()
|
||||
{
|
||||
return local_sandbox_context_cache.memory.size / WASM_PAGE_SIZE;
|
||||
}
|
||||
|
||||
// All of these are pretty generic
|
||||
INLINE float
|
||||
get_f32(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(float) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(float *)address;
|
||||
}
|
||||
|
||||
INLINE double
|
||||
get_f64(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(double) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(double *)address;
|
||||
}
|
||||
|
||||
INLINE int8_t
|
||||
get_i8(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(int8_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(int8_t *)address;
|
||||
}
|
||||
|
||||
INLINE int16_t
|
||||
get_i16(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(int16_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(int16_t *)address;
|
||||
}
|
||||
|
||||
INLINE int32_t
|
||||
get_i32(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(int32_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(int32_t *)address;
|
||||
}
|
||||
|
||||
INLINE int64_t
|
||||
get_i64(uint32_t offset)
|
||||
{
|
||||
assert(offset + sizeof(int64_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
return *(int64_t *)address;
|
||||
}
|
||||
|
||||
INLINE int32_t
|
||||
get_global_i32(uint32_t offset)
|
||||
{
|
||||
return get_i32(offset);
|
||||
}
|
||||
|
||||
INLINE int64_t
|
||||
get_global_i64(uint32_t offset)
|
||||
{
|
||||
return get_i64(offset);
|
||||
}
|
||||
|
||||
// Now setting routines
|
||||
INLINE void
|
||||
set_f32(uint32_t offset, float v)
|
||||
{
|
||||
assert(offset + sizeof(float) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(float *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_f64(uint32_t offset, double v)
|
||||
{
|
||||
assert(offset + sizeof(double) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(double *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i8(uint32_t offset, int8_t v)
|
||||
{
|
||||
assert(offset + sizeof(int8_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(int8_t *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i16(uint32_t offset, int16_t v)
|
||||
{
|
||||
assert(offset + sizeof(int16_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(int16_t *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i32(uint32_t offset, int32_t v)
|
||||
{
|
||||
assert(offset + sizeof(int32_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(int32_t *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_i64(uint32_t offset, int64_t v)
|
||||
{
|
||||
assert(offset + sizeof(int64_t) <= local_sandbox_context_cache.memory.size);
|
||||
|
||||
char *mem_as_chars = (char *)local_sandbox_context_cache.memory.start;
|
||||
void *address = &mem_as_chars[offset];
|
||||
|
||||
*(int64_t *)address = v;
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_global_i32(uint32_t offset, int32_t v)
|
||||
{
|
||||
set_i32(offset, v);
|
||||
}
|
||||
|
||||
INLINE void
|
||||
set_global_i64(uint32_t offset, int64_t v)
|
||||
{
|
||||
set_i64(offset, v);
|
||||
}
|
||||
|
||||
// Table handling functionality
|
||||
// INLINE char *
|
||||
// get_function_from_table(uint32_t idx, uint32_t type_id)
|
||||
// {
|
||||
// assert(idx < INDIRECT_TABLE_SIZE);
|
||||
|
||||
// struct indirect_table_entry f = local_sandbox_context_cache.module_indirect_table[idx];
|
||||
|
||||
// // FIXME: Commented out function type check because of gocr
|
||||
// // assert(f.type_id == type_id);
|
||||
|
||||
// assert(f.func_pointer);
|
||||
|
||||
// return f.func_pointer;
|
||||
// }
|
@ -1,4 +0,0 @@
|
||||
*res.dat
|
||||
rt.log
|
||||
log.csv
|
||||
res/*
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "ekf_first_iter",
|
||||
"path": "ekf_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "application/octet-stream"
|
||||
},
|
||||
{
|
||||
"name": "ekf_second_iter",
|
||||
"path": "ekf_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "application/octet-stream"
|
||||
},
|
||||
{
|
||||
"name": "ekf_third_iter",
|
||||
"path": "ekf_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "application/octet-stream"
|
||||
}
|
||||
]
|
@ -1,2 +0,0 @@
|
||||
result.dat
|
||||
res/*
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "ekf",
|
||||
"path": "ekf_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "application/octet-stream"
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
log.csv
|
||||
res/*
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "cifar10_rand",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 4096,
|
||||
"http-resp-size": 128,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "cifar10_same",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 4096,
|
||||
"http-resp-size": 128,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
@ -1,2 +0,0 @@
|
||||
log.csv
|
||||
res/*
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
command -v imagemagick && {
|
||||
echo "imagemagick is already installed."
|
||||
return 0
|
||||
}
|
||||
|
||||
# Installs the deps needed for run.sh
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
apt-get install imagemagick
|
||||
else
|
||||
sudo apt-get install imagemagick
|
||||
fi
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "resize_small",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
{
|
||||
"name": "resize_medium",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
{
|
||||
"name": "resize_large",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1524000,
|
||||
"http-resp-size": 1524000,
|
||||
"http-resp-content-type": "image/png"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
res/*
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
command -v imagemagick && {
|
||||
echo "imagemagick is already installed."
|
||||
return 0
|
||||
}
|
||||
|
||||
# Installs the deps needed for run.sh
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
apt-get install imagemagick
|
||||
else
|
||||
sudo apt-get install imagemagick
|
||||
fi
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "resize",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
flower.jpg
|
||||
log.csv
|
||||
res/*
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "lpd1",
|
||||
"path": "lpd_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1002400,
|
||||
"http-resp-size": 1048576,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "lpd2",
|
||||
"path": "lpd_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1002400,
|
||||
"http-resp-size": 1048576,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "lpd4",
|
||||
"path": "lpd_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 50000,
|
||||
"http-req-size": 1002400,
|
||||
"http-resp-size": 1048576,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Installs the deps needed for run.sh
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
apt-get install netpbm pango1.0-tools wamerican
|
||||
else
|
||||
sudo apt-get install netpbm pango1.0-tools wamerican
|
||||
fi
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "gocr_72_dpi",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_108_dpi",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_144_dpi",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Installs the deps needed for run.sh
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
apt-get install netpbm pango1.0-tools wamerican fonts-roboto fonts-cascadia-code fonts-dejavu
|
||||
else
|
||||
sudo apt-get install netpbm pango1.0-tools wamerican fonts-roboto fonts-cascadia-code fonts-dejavu
|
||||
fi
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "gocr_mono",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_urw_gothic",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_lobster_2",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Installs the deps needed for run.sh
|
||||
if [ "$(whoami)" == "root" ]; then
|
||||
apt-get install netpbm pango1.0-tools wamerican
|
||||
else
|
||||
sudo apt-get install netpbm pango1.0-tools wamerican
|
||||
fi
|
@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "gocr_1_word",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10000,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_10_words",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10001,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"name": "gocr_100_words",
|
||||
"path": "gocr_wasm.so",
|
||||
"port": 10002,
|
||||
"expected-execution-us": 5000,
|
||||
"relative-deadline-us": 36000,
|
||||
"http-req-size": 5335057,
|
||||
"http-resp-size": 5335057,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
res/*
|
File diff suppressed because one or more lines are too long
@ -1,2 +0,0 @@
|
||||
pnm file was generated as follows
|
||||
`pngtopnm 5x8.png >5x8.pnm`
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,3 +0,0 @@
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
||||
SLEDGE_SIGALRM_HANDLER=TRIAGED
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=true
|
@ -1,2 +0,0 @@
|
||||
SLEDGE_SCHEDULER=FIFO
|
||||
SLEDGE_DISABLE_PREEMPTION=false
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue