Compare commits

...

357 Commits

Author SHA1 Message Date
emil 01acb468de feat: added logging instrumentation for tenant preprocessing param
1 year ago
Emil Abbasov 693e633164 Removed all the PNMs from the testbenchs
1 year ago
Emil Abbasov 0f758a7602 fix: Update multi-tenancy-tests for GOCR to accept PNGs
1 year ago
Emil Abbasov 7a534581c5 fix: Update gocr tests to send PNGs instead of PNMs
1 year ago
Emil Abbasov 8f1ea67df9 feat: GOCR now suports PNG input (no conversion, no pnm at all)
1 year ago
Emil 6b0ba99e86
feature: added SJF scheduler and Regression based prediction (#385)
1 year ago
Emil 4ae8b02413
Enhanced Bash scripts (#384)
1 year ago
Emil de22264f4d
Merge pull request #383 from gwsystems/mt-dbf
2 years ago
Emil Abbasov bfc842924e feat: added new test for cnn_face_detection app
2 years ago
Emil Abbasov 9f465e01fe Merge branch 'mt-dbf' of https://github.com/gwsystems/sledge-serverless-framework into mt-dbf
2 years ago
Emil Abbasov 22860ba0d1 Merge pull request #380 from gwsystems/mt-dbf
2 years ago
Emil 4e1f67929e
Merge pull request #381 from mzpqnxow/portable-uname-arch
2 years ago
AG 23639915c4
Update install_deb.sh
2 years ago
Emil b85e13fb5f
Merge pull request #380 from gwsystems/mt-dbf
2 years ago
Emil Abbasov ba8818e4f8 added multi-tenancy testbed
2 years ago
Emil Abbasov 90f9987c82 Fix: temporary fix (by Xiaosu) that introduces locks that prevent scalability
2 years ago
emil 8d1ba3d9b0 cleanup
2 years ago
Emil 5e2558048a
Fix: Change the TLS-model for the libsledge to init-exec (#370)
3 years ago
emil 562e5d8623 Fix: Change the TLS-model for the libsledge to init-exec
3 years ago
emil bc2c52165a update cmu-sod tests
3 years ago
Emil dac95d08f4
Remove wasm_apps submodule from Sledge repo (#368)
3 years ago
emil be911e206c updated README to reflect latest changes
3 years ago
lyuxiaosu 6d7d815ee7
remove sending duplicate http response header (#367)
3 years ago
Emil a2188b8bae
Retrieve more accurate CPU frequency for runtime (#366)
3 years ago
emil f004d6c827 update awsm sobmodule head
3 years ago
Emil beed67cea0
remove epoll from workers (#365)
3 years ago
emil 7b9b28f5d8 update aWsm submodule
3 years ago
emil 5f86707403 fixed make of libsledge (add flto support)
3 years ago
emil 50fd8c4853 update awsm submodule
3 years ago
emil 16f5095156 update awsm submodule to its head
3 years ago
emil 2caf4de75a cleanup zombie code left after removing vectors for request buf
3 years ago
emil 2c76926e83 fix: epoll_wait causing crash on client pipe break
3 years ago
Sean McBride 0c3b661301
feat: Latency perflog (#364)
3 years ago
Sean McBride 56f32ec44b
refactor: HTTP memstreams (#363)
3 years ago
Sean McBride 92ac9b056f
Merge pull request #355 from gwsystems/feat-prometheus
3 years ago
Sean McBride 0f9e01dad1 refactor: deref tag
3 years ago
Sean McBride 38494da400 feat: epoll tags
3 years ago
Sean McBride 63e38f0e7c chore: PERF_WINDOW_CAPACITY scripts
3 years ago
Sean McBride 61baa40ba4 refactor: zombie comment
3 years ago
Sean McBride 199914d69d refactor: log procfs metrics status
3 years ago
Sean McBride 1981c01338 refactor: PERF_WINDOW_CAPACITY
3 years ago
Sean McBride cd73d7d172 refactor: reorder metrics
3 years ago
Sean McBride 66aa87a152 refactor: Metrics server port
3 years ago
Sean McBride cdca93f317 chore: log HTTP Route Total Counters status
3 years ago
Sean McBride 9458c5ad7f refactor: http route total counters
3 years ago
Sean McBride 876634b87b refactor: admissions control flags
3 years ago
Sean McBride edf98efa51 refactor: http total counters Makefile
3 years ago
Sean McBride 2b5957c394 refactor: HTTP total counters
3 years ago
Sean McBride 89fc0b26fd fix: HTTP header truncation
3 years ago
Sean McBride 1230e0bfd9 fix: merge conflicts from pulling master
3 years ago
Sean McBride 69c2b4de29 Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into feat-prometheus
3 years ago
Sean McBride e011912bdf
Merge pull request #360 from gwsystems/359-perf-window
3 years ago
Sean McBride f3cf117694
Merge pull request #362 from gwsystems/cmu-sod
3 years ago
Sean McBride 5f2fff0db2 chore: add expected_result
3 years ago
Sean McBride 40822191a4 refactor: Remove add from pulling master
3 years ago
Sean McBride d9d149784d Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into cmu-sod
3 years ago
Sean McBride 6d1b2f8d50 feat: Add cmu-sod app
3 years ago
Sean McBride 3a86893a57 refactor: target simplified cmu-sod
3 years ago
Sean McBride 42a16bf2ee refactor: perf_window
3 years ago
Sean McBride 2d35778c9c
Merge pull request #358 from gwsystems/fix-http-session-state-machine
3 years ago
Sean McBride 2abf63618a fix: correct HTTP session state machine
3 years ago
Sean McBride 066876d491 fix: HTTP session state machine
3 years ago
Sean McBride 06d6d817ce
Merge pull request #357 from gwsystems/82-fix-lock-tracking
3 years ago
Sean McBride 08e87492c0 feat: port cmu-sod app
3 years ago
Sean McBride 680221c1e2 feat: Reimplement spinlocks for better tracking
3 years ago
Sean McBride 51b3f74b5e refactor: Remove LOG_LOCK_OVERHEAD reporting
3 years ago
Sean McBride cce8c1981e fix: lock tracking
3 years ago
Sean McBride 4939ba32fb fix: Correct admissions control prometheus keys
3 years ago
Sean McBride d19820ac4a fix: HTTP nits
3 years ago
Sean McBride dac3322b97 fix: skip route accounting on no match
3 years ago
Sean McBride 8b2b26ffe0 fix: Correct routes and URLs to please prometheus
3 years ago
Sean McBride 36edac7425 feat: route level metrics
3 years ago
Sean McBride e40d139536 feat: metrics thread and proc stat
3 years ago
Sean McBride ccbee1a41e feat: Additional counters and gauges
3 years ago
Sean McBride 71c99e91bb feat: Initial metrics server
3 years ago
Emil 34e8731854
HTTP Log Tool and More Script Automations (#354)
3 years ago
Emil cb09ed51ea
Updated deferable server (#352)
3 years ago
Emil 9946f23eb7
General Cleanup (#351)
3 years ago
Sean McBride 19eb58ad6a
Merge pull request #343 from gwsystems/writeback-on-block
3 years ago
Sean McBride f3d93b4b3a
Merge pull request #350 from gwsystems/349-docker-fix
3 years ago
Sean McBride dc9873c16d fix: dockerfile issues
3 years ago
Sean McBride 5fa65d2f0b fix: correct flush when zero blocking
3 years ago
Sean McBride 1db1f9a396 refactor: Address Emil feedback
3 years ago
Sean McBride 555215ab77
Merge pull request #344 from gwsystems/hashmap
3 years ago
Sean McBride 9b7cc44fd1 chore: clang-format nit
3 years ago
Sean McBride bfb280afb9 chore: Add gitignore scratch_storage
3 years ago
Sean McBride c1df8e2fc3 fix: Address Gabe feedback
3 years ago
Sean McBride 443f6c2c43 fix: reorder map_node to improve alignment
3 years ago
Sean McBride f2517654e6
Merge pull request #348 from gwsystems/347-fix-sandbox-alloc
3 years ago
Sean McBride ca8bb9c296 fix: sandbox_alloc size
3 years ago
Sean McBride 9e200ee93a fix: strip logs on http_session eagain
3 years ago
Sean McBride 78d07aa4bc Merge branch 'master' into writeback-on-block
3 years ago
Sean McBride 94fe156538
Merge pull request #346 from gwsystems/fix-parsing-err-handler
3 years ago
Sean McBride 244f9ecad6 fix: correct http_parser error handling
3 years ago
Sean McBride 13ea7f1307 refactor: remove unused header include
3 years ago
Sean McBride 76bc1b34f9 fix: Add missing header guard
3 years ago
Sean McBride 8d6a2fb1fa docs: Remove zombie param tags
3 years ago
Sean McBride b803befa0a test: test concurrent access to key
3 years ago
Sean McBride 32248f11be fix: Correct upsert bug
3 years ago
Sean McBride e5b222d83d feat: Initial scratch storage implementation
3 years ago
Sean McBride 04b7f4d2df refactor: Remove zombie http-session variable
3 years ago
Sean McBride 50c7413f00 fix: Remove merge conflict mistake
3 years ago
Sean McBride 859b16d893
Merge branch 'master' into writeback-on-block
3 years ago
Sean McBride 9de83c5ac3 refactor: restore content-length and content-type in response
3 years ago
Sean McBride b32503b350 refactor: tcp_session_recv
3 years ago
Sean McBride bca75a9dd4 refactor: no http_session in sandbox lifetime.
3 years ago
Sean McBride 5b8a585e87
Merge pull request #342 from gwsystems/341-cleanup-queue-rename
3 years ago
Sean McBride 211f04ae67 refactor: rename to local_cleanup_queue
3 years ago
Sean McBride b26f2ca597
Merge pull request #335 from gwsystems/http-parsing-listener
3 years ago
Sean McBride 23d596066a fix: Remove incorrect assertion
3 years ago
Sean McBride c0a375b7ee refactor: http cleanup
3 years ago
Sean McBride 768816934e chore: clang-format
3 years ago
Sean McBride d0f8912c27 fix: parse_uint64_t overflow handling
3 years ago
Sean McBride 013448c716 chore: Update awsm
3 years ago
Sean McBride 13c8452f23 fix: completion queue alignment
3 years ago
Sean McBride 10cf211007 doc: Replace IN with parameter-level doc block
3 years ago
Sean McBride a97146a453 refactor: Remove unused defines
3 years ago
Sean McBride 352a019bd3 chore: clang-format json.h
3 years ago
Sean McBride 17cbf3ce4f refactor: Remove extraneous assert
3 years ago
Sean McBride 7d7224a6a9 refactor: module pools
3 years ago
Sean McBride 130617f406 fix: double free on error
3 years ago
Sean McBride fde4b8f3e6 docs: Remove zombie parameters
3 years ago
Sean McBride 73a1a7eb43 refactor: make module_add more explicit
3 years ago
Sean McBride e20de0d18a refactor: use vec for dynamically-size router
3 years ago
Sean McBride a529db3430 refactor: RUNTIME_MAX_TENANT_COUNT
3 years ago
Sean McBride 41a087394e refactor: Increase buffer by explicit size
3 years ago
Sean McBride 32a099ceec refactor: http_session_receive_request asserts
3 years ago
Sean McBride 022510950f refactor: panic on full router
3 years ago
Sean McBride 4d0da84ffb fix: Correct type of strtoimax call
3 years ago
Sean McBride 5325d82a40 refactor: rename json parser
3 years ago
Sean McBride 3d7ac99293 refactor: Remove redundant cast
3 years ago
Sean McBride 2a8dd58a3c doc: remove extraneous comment
3 years ago
Sean McBride c692746913 refactor: Remove duplicate total_time calc
3 years ago
Sean McBride 1dd7c7991c doc: fix typo
3 years ago
Sean McBride 39aad94ae4 refactor: Better handle non-null terminated string
3 years ago
Sean McBride 98a12154fc docs: Better explain http session buffer logic
3 years ago
Sean McBride f4fdc4a501 fix: Handle STDIN reads without a body
3 years ago
Sean McBride 9c67a84b62 fix: calloc incorrect args order
3 years ago
Sean McBride f6154ae6d4 fix: memset struct http_request
3 years ago
Sean McBride 89b1c07146 feat: LOG_TENANT_LOADING
3 years ago
Sean McBride bdfbff9adb fix: wasi context leak htt
3 years ago
Sean McBride 16e2613c05 fix: global_request_scheduler_add err handling
3 years ago
Sean McBride c1dcc7b176 chore: alignment debugging
3 years ago
Sean McBride 38532dec63 Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into http-parsing-listener
3 years ago
Sean McBride 516b1664f7
Merge pull request #340 from gwsystems/emil-test-nits
3 years ago
Sean McBride c82e9dfb9e
Merge pull request #339 from gwsystems/sandbox-state-hooks
3 years ago
Sean McBride e08cf72aa1 chore: Assorted bash experiment cleanup
3 years ago
Sean McBride 828650e678 feat: sandbox state hooks
3 years ago
Sean McBride dcc994b30e
Merge pull request #338 from gwsystems/runtime-runqueue-size
3 years ago
Sean McBride 9da38ba8ad
Merge pull request #337 from gwsystems/emil-docker-fixes
3 years ago
Sean McBride f656df5319 refactor: runtime-runqueue-size
3 years ago
Sean McBride 8e840038de chore: docker fixes
3 years ago
Sean McBride d72f810567 feat: nonblocking request reads
3 years ago
Sean McBride 03c489498f refactor: small nits
3 years ago
Sean McBride c3d0fe375a refactor: parsing and validation
3 years ago
Sean McBride 576f65d846 refactor: http_router and session
3 years ago
Sean McBride c559fc850d test: image classification
3 years ago
Sean McBride 099aed1be2 test: other tests
3 years ago
Sean McBride b8732147a9 test: lpd by plate count
3 years ago
Sean McBride 308e6dd109 test: image_resize
3 years ago
Sean McBride ff0aafbd5e test: html
3 years ago
Sean McBride 1e7b95c25c test: gocr by_word
3 years ago
Sean McBride 162cdcd4bf refactor: Remove debuglogs
3 years ago
Sean McBride 625d9a7f32 test: gocr by font
3 years ago
Sean McBride e87fe8ddcf test: gocr by_dpi
3 years ago
Sean McBride 3b05fb647c test: empty
3 years ago
Sean McBride 81b78fe395 test: deadline description
3 years ago
Sean McBride b346cd1cce test: fivebyeight
3 years ago
Sean McBride 6a7d2c3c05 test: handwriting
3 years ago
Sean McBride 3d1431316e chore: clang-format nit 2
3 years ago
Sean McBride 36ac367491 chore: clang-format nit
3 years ago
Sean McBride a11136f899 test: hyde
3 years ago
Sean McBride 231096682a test: fib bimodal spec
3 years ago
Sean McBride 05dde38ea2 feat: dynamic http buffers
3 years ago
Sean McBride 42b42e0f1c test: imageclassification tenant
3 years ago
Sean McBride 69a6cbaa46 fix: Correct tenant listen bug
3 years ago
Sean McBride 01cca785f4 feat: partial tenant implementation
3 years ago
Sean McBride 7a62b154fc refactor: refactor TCP into module
3 years ago
Sean McBride 35132ab2f2 chore: query param fib
3 years ago
Sean McBride 6965b2906d feat: Preliminary routes
3 years ago
Sean McBride eb2ba85760 Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into http-parsing-listener
3 years ago
Sean McBride 3c6477857e feat: Parse HTTP request on listener core
3 years ago
Sean McBride 160b38e4dd refactor: Allocate http_session on listener
3 years ago
Sean McBride 80b4d0e99c refactor: http_session
3 years ago
Sean McBride f27f75a108
Merge pull request #334 from gwsystems/json-refactor
3 years ago
Sean McBride 64d67185f6 refactor: keys global const array
3 years ago
Sean McBride 012c67457f refactor: Resize back to original size
3 years ago
Sean McBride e6b4119652 refactor: JSON_TOKENS_CAPACITY
3 years ago
Sean McBride 8f2f18722d refactor: change load_file_into_buffer err
3 years ago
Sean McBride ed048e1219 refactor: Remove extraneous assertion
3 years ago
Sean McBride 252ed746ed fix: has_valid_size use expected_size
3 years ago
Sean McBride c7758bbb00 refactor: Abstract sandbox from http-parser
3 years ago
Sean McBride ee24d1f5b0 refactor: http-session
3 years ago
Sean McBride 423e11c036 Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into json-refactor
3 years ago
Sean McBride cbb004cae6
Merge pull request #325 from gwsystems/fix-scheduler-types
3 years ago
Sean McBride 4a301588bb fix: json_buf memory leak
3 years ago
Sean McBride c9fc627375 fix: double free
3 years ago
Sean McBride 1457f6f2a8 refactor: init with module_config
3 years ago
Sean McBride e4c063a209 fix: extern module_listen
3 years ago
Sean McBride 7f038f1269 refactor: jsonint parsing and module validation
3 years ago
Sean McBride a07533bd2c refactor: move tok advance and add assumption
3 years ago
Sean McBride 68bf915c02 refactor: Improve JSON validation logs
3 years ago
Sean McBride e27ffa5620 refactor: break JSON parsing out from module.c
3 years ago
Sean McBride b79eb44958 refactor: move JSON file loading from module
3 years ago
Sean McBride 438b7650ba refactor: Move validation to module_alloc
3 years ago
Sean McBride 74a3270cb0 refactor: load_file_into_buffer
3 years ago
Sean McBride 087b984e54
Merge pull request #332 from gwsystems/validate-socket-err-handler
3 years ago
Sean McBride 81c6c09862
Merge pull request #333 from gwsystems/wasi-networking-docs
3 years ago
Sean McBride 28fba59922 docs: Document WASI support level
3 years ago
Sean McBride e62fb9817f fix: correct type nit
3 years ago
Sean McBride 77f63c15de feat: stub for sock_accept
3 years ago
Sean McBride 4b076e6798 doc: Remove TODO comment
3 years ago
Sean McBride 3aaa7737df fix: handle NULL from realloc
3 years ago
Sean McBride 3b92963868 refactor: priority_queue_grow_nolock
3 years ago
Sean McBride 8a170e1a64 refactor: Move grow logic into PQ API
3 years ago
Sean McBride 08a0f03cd5 refactor: change PQ capacity to exclude 0th elem
3 years ago
Sean McBride 69bdf5b49b feat: grow local runqueue if full
3 years ago
Sean McBride 823c46f6f8 feat: return 429 if request queue full
3 years ago
Sean McBride 362bf39047 refactor: sandbox struct in req queue
3 years ago
Sean McBride ee760577ed
Merge pull request #324 from gwsystems/update-wasm-apps-5
3 years ago
Sean McBride 39b7209b6c chore: Cleanup html makefile
3 years ago
Sean McBride d93b224d4d chore: cleanup args logic
3 years ago
Sean McBride 6eab1e7015 feat: query params to wasi args
3 years ago
Sean McBride d05a58af75 feat: module name as first argument
3 years ago
Sean McBride 255461198d fix: wasi args
3 years ago
Sean McBride b101e8bcda feat: Remove exit trap
3 years ago
Sean McBride 135ba6105f chore: update wasm apps
3 years ago
Sean McBride ac374e72fd feat: unreachable trap support
3 years ago
Sean McBride 47b94ac9ad chore: update wasm apps and awsm compiler
3 years ago
Sean McBride cac0b32520
Merge pull request #318 from gwsystems/sigfpe-wasm-trap
3 years ago
Sean McBride 7a9b2ce938 feat: linear memory OOB via SIGSEGV handler
3 years ago
Sean McBride 45fcaa9115
Merge pull request #322 from gwsystems/268-wasm-page-size
3 years ago
Sean McBride a0474d34f2 chore: Remove zombie macros
3 years ago
Sean McBride 4cd34aa5aa
Merge pull request #321 from gwsystems/deque-type-fix
3 years ago
Sean McBride 7ce17ffae1 Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into sigfpe-wasm-trap
3 years ago
Sean McBride d1cc5885f7 chore: Update wasm_apps
3 years ago
Sean McBride 4b1aec0788 fix: global_request_scheduler_deque_add type
3 years ago
Sean McBride 37a203c774 fix: unmask SIGFPE handler no preemption
3 years ago
Sean McBride 99b39de791 feat: trap wasm app overflow
3 years ago
Sean McBride 62a8dafa7c feat: sigfpe wasm traps
3 years ago
Sean McBride 44d04f213a
Wasm apps update (#317)
3 years ago
Sean McBride 492f61ae93
Merge pull request #316 from gwsystems/validate-setup
3 years ago
Sean McBride 434baa283f docs: prep to merge
3 years ago
Sean McBride bbe1305bcc chore: Add wasm-ld alternatives
3 years ago
Sean McBride b551973cef chore: Update to clang-11 wasm args
3 years ago
Sean McBride 173a2c579d chore: downlevel to wasi-sdk-12
3 years ago
Sean McBride 3d40b656cb chore: add applications to toplevel all and clean
3 years ago
Sean McBride 6d3c0298e2 chore: fix wasi_sdk version
3 years ago
Sean McBride 5f0988df8c chore: Additional install script changes
3 years ago
Sean McBride f325c36183 docs: Cleanup README instructions
3 years ago
Sean McBride 0fe40da3e5 chore: improve install script
3 years ago
Sean McBride bee3df2801 chore: Update install_deb
3 years ago
Sean McBride 587615c465 chore: Add missing dependencies
3 years ago
Sean McBride 154c7e0627
Merge pull request #315 from gwsystems/no-memsize-perf-log
3 years ago
Sean McBride 908cdefa3b fix: Remove memory size from perf log
3 years ago
Sean McBride f351127dbb
Merge pull request #314 from gwsystems/update-awsm-2
3 years ago
Sean McBride aab2e614b1 chore: Update gitmodules file
3 years ago
Sean McBride bae1fcd53e chore: update awsm
3 years ago
Sean McBride af244fe5a2
Merge pull request #313 from gwsystems/update-awsm
3 years ago
Sean McBride 6776b53276 chore: Update awsm
3 years ago
Sean McBride 5bee5bf6bd
Merge pull request #306 from gwsystems/dynamically-size-global-table
3 years ago
Sean McBride 02187fefc5
Merge pull request #308 from gwsystems/valgrind-nits
3 years ago
Sean McBride 85294ccd96 fix: Correct error handling get_globals_len
3 years ago
Sean McBride 156f5335bb
Merge pull request #307 from gwsystems/remove-fd-logs
3 years ago
Sean McBride cf2d136c81 refactor: stack use mprotect
3 years ago
Sean McBride 15c6606353 refator: replace malloc with calloc
3 years ago
Sean McBride 2be838b11e fix: PAGE_SIZE used before defined
3 years ago
Sean McBride d1009f4987 fix: flipped calloc args
3 years ago
Sean McBride 2c64f7ed41 refactor: Add missing header
3 years ago
Sean McBride bd94d0e645 fix: Check heap allocations
3 years ago
Sean McBride 32469bf1ab fix: state history not flexible array member
3 years ago
Sean McBride 5f5d99952a fix: invalid dereference of array in memset
3 years ago
Sean McBride ba21a7f09c fix: Use default content type if needed
3 years ago
Sean McBride 9cef2280bc refactor: Remove unused value
3 years ago
Sean McBride ece929ebe9 chore: Remove fd logs
3 years ago
Sean McBride 54f36f8471 feat: Dynamically size runtime globals
3 years ago
Sean McBride eb74a306ff
Wasm traps (#301)
3 years ago
Sean McBride a35d749db9
Merge pull request #305 from gwsystems/update-awsm
3 years ago
Sean McBride 866c71f5e2 chore: update awsm
3 years ago
Sean McBride 2e75a3d7f0
Merge pull request #304 from gwsystems/303-missing-abi-symbols
3 years ago
Sean McBride 3fda8b8e3b chore: Remove extraneous comments
3 years ago
Sean McBride a15dffef51 feat: Implement missing float instructions
3 years ago
Sean McBride a257c9e485
Merge pull request #302 from gwsystems/asc
3 years ago
Sean McBride a5c8374b51 test: restore C fib
3 years ago
Sean McBride f10ccd827e chore: Update wasm_apps
3 years ago
Sean McBride 1cb220f348 fix: Correct globals bugs
3 years ago
Sean McBride 20bc6cee86 test: assemblyscript fib
3 years ago
Sean McBride 7cacac64c0
WIP: WASI Support (#267)
3 years ago
Sean McBride 5d19891e63
feat: libsledge pattern for wasmception (#299)
4 years ago
Sean McBride bbaae33ce9
Merge pull request #300 from gwsystems/fix-fib-make
4 years ago
Sean McBride 010f454092 fix: fib test make
4 years ago
Sean McBride 22f33ad568
Merge pull request #298 from gwsystems/test-assets
4 years ago
Sean McBride f89c1d0018 fix: additional rule misspelling
4 years ago
Sean McBride e4e3295111 fix: Correct incorrect build names
4 years ago
Sean McBride feb80243fe build: correct ekf name
4 years ago
Sean McBride f7ecc11a71 test: cleanup tests
4 years ago
Sean McBride f8c5bf6283
Merge pull request #297 from gwsystems/http-improvements
4 years ago
Sean McBride 4ba4cf4969 feat: Add new HTTP codes
4 years ago
Sean McBride 06296d8996
Merge pull request #296 from gwsystems/move-tests
4 years ago
Sean McBride 31226d5bdd refactor: Move tests
4 years ago
Sean McBride 0e7d5286c4
Merge pull request #295 from gwsystems/move-apps
4 years ago
Sean McBride ffc7573ec9 fix: Resolve wasmception build issues
4 years ago
Sean McBride 33d60fd936 chore: Update application path in github yaml
4 years ago
Sean McBride ea728b013b chore: Move apps
4 years ago
Sean McBride 03ed5c8133
Merge pull request #294 from gwsystems/test-mk
4 years ago
Sean McBride 9cc448d3a2 test: Correct make rules
4 years ago
Sean McBride a058d1b2e4 test: Fix application install directory
4 years ago
Sean McBride 3167c99454
Merge pull request #293 from gwsystems/abstract-vec
4 years ago
Sean McBride 3d051a2e53 test: Replace test.sh with test.mk
4 years ago
Sean McBride 65434b15e5 feat: Abstract vec
4 years ago
Sean McBride 24fc351b02
Merge pull request #288 from gwsystems/object-pool
4 years ago
Sean McBride e89696d911 refactor: DRY up pool macro
4 years ago
Sean McBride 9eec575e9e refactor: remove size_t from wasm_stack
4 years ago
Sean McBride d562a9315d refactor: Shift module valildation to JSON parsing
4 years ago
Sean McBride 639fa953b6 docs: Better explain bounds check assertions
4 years ago
Sean McBride 35b83ba090 refactor: Eliminate _new and _delete functions
4 years ago
Sean McBride fdaff6c666 docs: Add more inline docs about buffers
4 years ago
Sean McBride 7d91a9cfc0 refactor: rename self
4 years ago
Sean McBride 7f931c5ebb Merge branch 'master' of github.com:gwsystems/sledge-serverless-framework into object-pool
4 years ago
Sean McBride a044f8ec37 fix: redundant wasm memory wipe
4 years ago
Sean McBride 2a21db9a34 style: remove extra newline
4 years ago
Sean McBride ba05a924d3 refactor: Align on doulbe cache line
4 years ago
Sean McBride 773dbf3f70 refactor: Align memory pools on cache lines
4 years ago
Sean McBride af016f2a40
Merge pull request #287 from gwsystems/spec-alignment-2
4 years ago
Sean McBride b652613ece refactor: Invert pool structure
4 years ago
Sean McBride e1cb478262 fix: Correct sandbox free stack logic
4 years ago
Sean McBride a446ed077a Merge branch 'spec-alignment-2' of github.com:gwsystems/sledge-serverless-framework into object-pool
4 years ago
Sean McBride 452db10284 refactor: wasm_memory_get_string
4 years ago
Sean McBride 57d95388b1 refactor: wasm_table
4 years ago
Sean McBride 3cf4580b5d refactor: wasm_memory
4 years ago
Sean McBride 4b1f9914f7 refactor: flatten http buffers
4 years ago
Sean McBride ae48d1ace6 fix: Spell environment correctly
4 years ago
Sean McBride acff35683a fix: send_reponse err handling
4 years ago
Sean McBride 569fdd39ea refactor: Use INLINE macro throughout compiletime
4 years ago
Sean McBride b3dc7db31c feat: wasm_stack object pool
4 years ago
Sean McBride 2311ec1ccf feat: wasm_memory pool
4 years ago
Sean McBride f51da123e2 fix: Corrected assorted bugs
4 years ago
Sean McBride 332b492761 refactor: mem instructions
4 years ago
Sean McBride 13b123866f refactor: reorder memory_instructions
4 years ago
Sean McBride 22d3890e06 fix: correct error handling wasm_stack
4 years ago
Sean McBride f1e1e852ae build: Makefile cleanup
4 years ago
Sean McBride e888a14e51 refactor: Eliminate sandbox request
4 years ago
Sean McBride 5e9c7d08d9 fix: debug assorting context switch issues
4 years ago
Sean McBride f4ede43b52 feat: WIP restage of memory allocation features
4 years ago
Sean McBride 6b037e3667
Merge pull request #286 from gwsystems/spec-alignment
4 years ago
Sean McBride b841889846
Merge pull request #285 from gwsystems/tests-makefile-cleanup
4 years ago
Sean McBride 5efee76cae refactor: header include nit
4 years ago
Sean McBride 13e8407884 chore: Adjust memory path
4 years ago
Sean McBride ded4717ed8 docs: Create compiletime README
4 years ago
Sean McBride 93a7ed0017 chore: format nit
4 years ago
Sean McBride 3259808b57 Merge branch 'tests-makefile-cleanup' into spec-alignment
4 years ago
Sean McBride 1f25f3dbd1 build: Update test.sh install logic
4 years ago
Sean McBride 01bca00be4 build: Makefile cleanup
4 years ago
Sean McBride 1a34f91cdd refactor: table instructions
4 years ago
Sean McBride bb41caeae0 refactor: Remove zombie table instruction
4 years ago
Sean McBride 30c3d17a2c refactor: Rename memory_instructions
4 years ago
Sean McBride 9bc023bd1b chore: rename instr
4 years ago

@ -1,4 +1,3 @@
---
BasedOnStyle: Mozilla
IndentWidth: 8
Language: Cpp
@ -10,10 +9,10 @@ AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: AllDefinitions
@ -38,7 +37,7 @@ BreakBeforeBinaryOperators: NonAssignment
ColumnLimit: 120
Cpp11BracedListStyle: false
Cpp11BracedListStyle: true
IndentCaseLabels: false
IndentWrappedFunctionNames: false
@ -47,10 +46,9 @@ KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
DerivePointerAlignment: false
PointerAlignment: Right
SortIncludes: false
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true

@ -24,6 +24,6 @@
],
"workspaceMount": "source=${localWorkspaceFolder},target=/sledge,type=bind,consistency=cached",
"workspaceFolder": "/sledge",
"postCreateCommand": "make -C /sledge install && make -B -C /sledge/runtime/tests clean all",
"postCreateCommand": "make -C /sledge install && make -B -C /sledge/applications clean all",
"containerUser": "dev",
}

@ -1,6 +1,12 @@
# top-most EditorConfig file
root = true
[.clang-format]
ignore = true
[*.yaml]
ignore = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf

@ -3,9 +3,9 @@ name: sledge
on: [push, pull_request]
env:
LLVM_VERSION: 8
WASMCEPTION_URL: https://github.com/gwsystems/wasmception/releases/download/v0.2.0/wasmception-linux-x86_64-0.2.0.tar.gz
# WASI_SDK: /opt/wasi-sdk
LLVM_VERSION: 13
WASI_SDK_VERSION: 12
WASI_SDK_PATH: /opt/wasi-sdk
LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
@ -13,19 +13,18 @@ env:
# job control
jobs:
format:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Apt Update
run: sudo apt-get update
- uses: actions/checkout@v2
- name: Install clang-format-11
- name: Install Clang Format
run: |
sudo apt-get remove -y --no-install-recommends clang-format-10 && sudo apt-get install -y --no-install-recommends clang-format-11
- name: Update alternatives
run: |
sudo update-alternatives --remove-all clang-format && sudo update-alternatives --install /usr/bin/clang-format clang-format "/usr/bin/clang-format-11" 100
- name: Clang Format
sudo ./install_llvm.sh $LLVM_VERSION
- name: Run Clang Format
run: ./format.sh -d
test:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Apt Update
run: sudo apt-get update
@ -61,10 +60,12 @@ jobs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- --default-toolchain stable --component rustfmt --target wasm32-wasi -y
echo "/root/.cargo/bin:$PATH" >> $GITHUB_PATH
# - name: Get WASI-SDK
# run: |
# curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb && sudo dpkg -i wasi-sdk_8.0_amd64.deb && rm -f wasi-sdk_8.0_amd64.deb
# echo "ENV WASI_SDK=/opt/wasi-sdk" >> $GITHUB_ENV
- name: Get wasi-sdk
run: |
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-linux.tar.gz
wget $WASI_SDK_URL -O wasi-sdk.tar.gz
mkdir -p $WASI_SDK_PATH
tar xvfz wasi-sdk.tar.gz --strip-components=1 -C $WASI_SDK_PATH
- name: Install Test Script Utilities
run: |
sudo apt-get install -y --no-install-recommends \
@ -72,6 +73,7 @@ jobs:
fonts-cascadia-code \
fonts-roboto \
gnuplot \
httpie \
imagemagick \
netpbm \
pango1.0-tools \
@ -84,97 +86,107 @@ jobs:
~/.cargo/git
./awsm/target
key: ${{ runner.os }}-cargo-${{ hashFiles('./awsm/Cargo.lock') }}
- name: Compile sledge
run: |
make build
make rtinit
mkdir bin
mkdir lib
SYS_PREFIX="$(pwd)" ./install.sh
PATH="$(pwd)/bin:$PATH"
echo "$PATH" >> $GITHUB_PATH
LD_LIBRARY_PATH="$(pwd)/lib:$LD_LIBRARY_PATH"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
make build-validate
- name: Compile aWsm
run: |
make awsm
- name: Compile libsledge
run: |
make libsledge
- name: Compile SLEdge
run: |
make runtime
- name: Install wasm_apps link
run: |
make wasm_apps
# TODO:Cache assets before being copied to ./runtime/bin
- name: Cache gocr
uses: actions/cache@v2
with:
path: ./runtime/bin/gocr_wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/gocr/**', './runtime/compiletime/**') }}
path: ./runtime/bin/gocr.wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./applications/Makefile', './applications/wasm_apps/gocr/**', './libsledge/Makefile' , './libsledge/src/**', './libsledge/include/**') }}
if: success() || failure()
- name: Hyde
run: |
./test.sh ocr_hyde
echo $WASI_SDK_PATH
ls $WASI_SDK_PATH
make -f test.mk gocr__hyde
if: success() || failure()
- name: Upload Hyde Logs on Failure
uses: actions/upload-artifact@v2
if: failure()
with:
name: hyde-logs
path: ./runtime/experiments/applications/ocr/hyde/res/**/
path: ./tests/gocr/hyde/res/**/
- name: Handwriting
run: |
./test.sh ocr_handwriting
make -f test.mk gocr__handwriting
if: success() || failure()
- name: Five by Eight
run: |
./test.sh ocr_fivebyeight
make -f test.mk gocr__fivebyeight
if: success() || failure()
# - name: OCR by Word
# run: |
# ./test.sh ocr_by_word
# make -f test.mk gocr__by_word
# if: success() || failure()
# - name: OCR by Font
# run: |
# ./test.sh ocr_by_font
# make -f test.mk gocr__by_font
# if: success() || failure()
# - name: OCR by DPI
# run: |
# ./test.sh ocr_by_dpi
# make -f test.mk gocr__by_dpi
# if: success() || failure()
# TODO:Cache assets before being copied to ./runtime/bin
- name: Cache EKF
uses: actions/cache@v2
with:
path: ./runtime/bin/ekf_wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./runtime/tests/TinyEKF/**', './runtime/compiletime/**') }}
path: ./runtime/bin/gps_ekf.wasm.so
key: ${{ runner.os }}-gocr2-${{ hashFiles('./applications/Makefile', './applications/wasm_apps/TinyEKF/**', './libsledge/Makefile' , './libsledge/src/**', './libsledge/include/**') }}
if: success() || failure()
- name: EKF one iteration
run: |
./test.sh ekf_one_iteration
make -f test.mk ekf__one_iteration
if: success() || failure()
# - name: EKF by Iteration
# run: |
# ./test.sh ekf_by_iteration
# make -f test.mk ekf__by_iteration
# if: success() || failure()
# TODO:Cache assets before being copied to ./runtime/bin
- name: Image Classification
run: |
./test.sh image_classification
make -f test.mk cifar10__image_classification
if: success() || failure()
# TODO:Cache assets before being copied to ./runtime/bin
- name: Image Resize
run: |
./test.sh image_resize
make -f test.mk sod__image_resize__test
if: success() || failure()
# - name: Image Resize by Resolution
# run: |
# ./test.sh image_resize_by_resolution
# make -f test.mk sod__image_resize__by_resolution
# if: success() || failure()
# - name: License Plate Detection by Plate Count
# run: |
# ./test.sh lpd_by_plate_count
# make -f test.mk sod__lpd_by_plate_count
# if: success() || failure()
# - name: Bimodal
# run: |
# ./test.sh bimodal
# make -f test.mk fibonacci__bimodal
# if: success() || failure()
# - name: Concurrency
# run: |
# ./test.sh concurrency
# make -f test.mk empty__concurrency
# if: success() || failure()
# - name: Payload
# run: |
# ./test.sh payload
# make -f test.mk TODO
# if: success() || failure()
- name: Wasm Trap Divide by Zero
run: |
make -f test.mk trap_divzero
if: success() || failure()
- name: Wasm Trap Stack Overflow
run: |
make -f test.mk stack_overflow
if: success() || failure()

9
.gitignore vendored

@ -52,10 +52,11 @@ dkms.conf
runtime/tags
runtime/bin
runtime/tests/tmp/
runtime/tests/**/*.csv
runtime/tests/**/*.txt
runtime/tests/**/*.xlsx
applications/wasm_apps
applications/tmp/
applications/**/*.csv
applications/**/*.txt
applications/**/*.xlsx
# Swap Files
*.swp

39
.gitmodules vendored

@ -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
}

@ -80,9 +80,7 @@
"sandbox_set_as_runnable.h": "c",
"sandbox_set_as_complete.h": "c",
"deque.h": "c",
"sandbox_request.h": "c",
"sandbox_send_response.h": "c",
"sandbox_setup_arguments.h": "c",
"worker_thread.h": "c",
"sandbox_set_as_error.h": "c",
"likely.h": "c",
@ -91,6 +89,9 @@
"sandbox_set_as_running.h": "c",
"sandbox_summarize_page_allocations.h": "c",
"wasm_types.h": "c",
"wasi_impl.h": "c",
"wasi_backing.h": "c",
"wasi_serdes.h": "c",
"atomic": "c",
"sandbox_set_as_running_kernel.h": "c",
"stdbool.h": "c",
@ -101,7 +102,62 @@
"scheduler.h": "c",
"sandbox_set_as_returned.h": "c",
"software_interrupt_counts.h": "c",
"sandbox_set_as_running_sys.h": "c"
"sandbox_set_as_running_sys.h": "c",
"wasm_module_instance.h": "c",
"wasm_stack.h": "c",
"wasm_table.h": "c",
"wasi_spec.h": "c",
"current_wasm_module_instance.h": "c",
"wasm_memory.h": "c",
"sledge_abi.h": "c",
"vec.h": "c",
"perf_window_t.h": "c",
"module_config.h": "c",
"tenant.h": "c",
"route_config.h": "c",
"http_router.h": "c",
"execution_histogram.h": "c",
"tcp_server.h": "c",
"stdint.h": "c",
"scheduler_options.h": "c",
"route_config_parse.h": "c",
"route.h": "c",
"pool.h": "c",
"local_cleanup_queue.h": "c",
"sandbox_state_transition.h": "c",
"http_session_perf_log.h": "c",
"traffic_control.h": "c",
"memory_resource": "c",
"memory": "c",
"istream": "c",
"ostream": "c",
"sstream": "c",
"streambuf": "c",
"sandbox_perf_log.h": "c",
"global_request_scheduler_deque.h": "c",
"message.h": "c",
"dbf.h": "c",
"dbf_generic.h": "c",
"tenant_functions.h": "c",
"thread": "c",
"limits": "c",
"algorithm": "c",
"stdio.h": "c",
"get_time.h": "c",
"unistd.h": "c",
"wasi.h": "c",
"stat.h": "c",
"functional": "c",
"sandbox_state.h": "c",
"ratio": "c",
"tuple": "c",
"type_traits": "c",
"perf_window.h": "c",
"http_route_total.h": "c",
"sledge_abi_symbols.h": "c",
"mutex": "c",
"lock.h": "c",
"route_latency.h": "c"
},
"files.exclude": {
"**/.git": true,
@ -124,10 +180,12 @@
],
"shellformat.path": "/usr/local/bin/shfmt",
"shellformat.flag": "-ln=bash -i 0 -bn -ci -sr -kp",
"terminal.integrated.shell.linux": "bash",
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[yaml]": {
"editor.formatOnSave": false,
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
@ -153,5 +211,14 @@
"*.o": true,
"*.bc": true,
"*.wasm": true,
}
},
"C_Cpp.formatting": "clangFormat",
"cSpell.words": [
"gregs",
"mctx",
"TKILL",
"WASI"
],
"C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.default.compilerPath": "/usr/bin/clang"
}

@ -15,6 +15,7 @@ RUN apt-get install -y --no-install-recommends \
pkg-config \
gcc \
g++ \
httpie \
clang-8 \
clang-tools-8 \
llvm-8 \
@ -49,4 +50,6 @@ RUN rustup target add wasm32-wasi
RUN cargo install --debug cargo-audit cargo-watch rsign2
ENV PATH=/opt/sledge/bin:$PATH
ENV PATH=/sledge/runtime/bin:$PATH
ENV PATH=/sledge/awsm/target/release:$PATH
ENV LD_LIBRARY_PATH=/sledge/runtime/bin:$LD_LIBRARY_PATH

@ -1,11 +1,14 @@
# using ubuntu 20 docker image
FROM ubuntu:focal
ENV LLVM_VERSION=13
ENV WASI_SDK_VERSION=12
ARG DEBIAN_FRONTEND=noninteractive
ARG HEY_URL=https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64
ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk_8.0_amd64.deb
ARG WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
ARG SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.2.4/shfmt_v3.2.4_linux_amd64
ARG SHELLCHECK_URL=https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz
ARG SHELLCHECK_URL=https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz
# Use bash, not sh
SHELL ["/bin/bash", "-c"]
@ -46,6 +49,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
fonts-cascadia-code \
fonts-roboto \
gnuplot \
httpie \
imagemagick \
jq \
libz3-4 \
@ -73,14 +77,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
wabt
ENV LLVM_VERSION=8
ADD install_llvm.sh /sledge/install_llvm.sh
RUN ./sledge/install_llvm.sh $LLVM_VERSION
# WASI-SDK
# TODO: Refactor to output as an arch-neutral filename
# RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_8.0_amd64.deb && rm -f wasi-sdk_8.0_amd64.deb
# ENV WASI_SDK=/opt/wasi-sdk
RUN curl -sS -L -O $WASI_SDK_URL && dpkg -i wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb && rm -f wasi-sdk_$WASI_SDK_VERSION.0_amd64.deb
ENV WASI_SDK_PATH=/opt/wasi-sdk
# Create non-root user and add to sudoers
ARG USERNAME=dev
@ -99,8 +101,6 @@ USER $USER_UID
RUN sudo chown $USER_GID:$USER_GID /sledge
ADD fix_root.sh /sledge/fix_root.sh
RUN cd sledge && ./fix_root.sh
RUN sudo mkdir /opt/sledge
RUN sudo chown $USER_GID:$USER_GID /opt/sledge
################################
# Final Setup as non-root user #
@ -118,8 +118,6 @@ ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8
# Update PATH and LD_LIBRARY_PATH
ENV PATH=/opt/sledge/bin:$PATH
# TODO: Does the build process for the sample applications actually copy here?
# TODO: Should we create a special SLEDGE_MODULE_PATH that is searched for these modules?
ENV LD_LIBRARY_PATH=/opt/sledge/bin:$LD_LIBRARY_PATH
ENV PATH=/sledge/runtime/bin:$PATH
ENV PATH=/sledge/awsm/target/release:$PATH
ENV LD_LIBRARY_PATH=/sledge/runtime/bin:$LD_LIBRARY_PATH

@ -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

@ -2,14 +2,25 @@
**SLEdge** is a lightweight serverless solution suitable for edge computing. It builds on WebAssembly sandboxing provided by the [aWsm compiler](https://github.com/gwsystems/aWsm).
## Host Dependencies
## Setting up a development environment
- Docker - [Installation Instructions](https://docs.docker.com/install/)
### Native on Debian Host
## Setting up the environment
```sh
git clone https://github.com/gwsystems/sledge-serverless-framework.git
cd sledge-serverless-framework
./install_deb.sh
source ~/.bashrc
make install
make test
```
### Docker
**Note: These steps require Docker. Make sure you've got it installed!**
[Docker Installation Instructions](https://docs.docker.com/install/)
We provide a Docker build environment configured with the dependencies and toolchain needed to build the SLEdge runtime and serverless functions.
To setup this environment, run:
@ -18,7 +29,7 @@ To setup this environment, run:
./devenv.sh setup
```
## Using the Docker container to compile your serverless functions
### Using the Docker container to compile your serverless functions
To enter the docker environment, run:
@ -33,10 +44,10 @@ cd /sledge/runtime
make clean all
```
There are a set of benchmarking applications in the `/sledge/runtime/tests` directory. Run the following to compile all benchmarks runtime tests using the aWsm compiler and then copy all resulting `<application>_wasm.so` files to /sledge/runtime/bin.
There are a set of benchmarking applications in the `/sledge/applications` directory. Run the following to compile all benchmarks runtime tests using the aWsm compiler and then copy all resulting `<application>.wasm.so` files to /sledge/runtime/bin.
```bash
cd /sledge/runtime/tests/
cd /sledge/applications/
make clean all
```
@ -54,59 +65,85 @@ To stop the Docker container:
./devenv.sh stop
```
### Deleting Docker Build Containers
If you are finished working with the SLEdge runtime and wish to remove it, run the following command to delete our Docker build and runtime images.
```bash
./devenv.sh rma
```
And then simply delete this repository.
## Running your first serverless function
An SLEdge serverless function consists of a shared library (\*.so) and a JSON configuration file that determines how the runtime should execute the serverless function. As an example, here is the configuration file for our sample fibonacci function:
```json
{
"name": "fibonacci",
"path": "fibonacci_wasm.so",
"port": 10000,
"expected-execution-us": 600,
"relative-deadline-us": 2000,
"http-req-size": 1024,
"http-resp-size": 1024,
"http-resp-content-type": "text/plain"
}
[
{
"name": "GWU",
"port": 10010,
"routes": [
{
"route": "/fib",
"path": "fibonacci.wasm.so",
"expected-execution-us": 6000,
"relative-deadline-us": 20000,
"http-resp-content-type": "text/plain"
}
]
}
]
```
The `port` and `name` fields are used to determine the path where our serverless function will be served served.
The `port` and `route` fields are used to determine the path where our serverless function will be served served.
In our case, we are running the SLEdge runtime on localhost, so our function is available at `http://localhost:10000/fibonacci`
In our case, we are running the SLEdge runtime on localhost, so our function is available at `localhost:10010/fib`.
Our fibonacci function will parse a single argument from the HTTP POST body that we send. The expected Content-Type is "text/plain" and the buffer is sized to 1024 bytes for both the request and response. This is sufficient for our simple Fibonacci function, but this must be changed and sized for other functions, such as image processing.
Our fibonacci function will parse a single argument from the HTTP POST body that we send. The expected Content-Type is "text/plain".
Now that we understand roughly how the SLEdge runtime interacts with serverless function, let's run Fibonacci!
The fastest way to check it out is just to click on the following URL on your Web browser: [http://localhost:10010/fib?10](http://localhost:10010/fib?10)
From the root project directory of the host environment (not the Docker container!), navigate to the binary directory
```bash
cd runtime/bin/
```
Now run the sledgert binary, passing the JSON file of the serverless function we want to serve. Because serverless functions are loaded by SLEdge as shared libraries, we want to add the `runtime/tests/` directory to LD_LIBRARY_PATH.
Now run the sledgert binary, passing the JSON file of the serverless function we want to serve. Because serverless functions are loaded by SLEdge as shared libraries, we want to add the `applications/` directory to LD_LIBRARY_PATH.
```bash
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/test_fibonacci.json
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../../tests/fibonacci/bimodal/spec.json
```
While you don't see any output to the console, the runtime is running in the foreground.
Let's now invoke our serverless function to compute the 10th fibonacci number. I'll use [HTTPie](https://httpie.org/) to send a POST request with a body containing the parameter I want to pass to my serverless function. Feel free to use cURL or whatever network client you prefer!
Let's now invoke our serverless function to compute the 10th fibonacci number. We'll use `cURL` and [HTTPie](https://httpie.org/) to send a HTTP GET and POST requests with the parameter we want to pass to my serverless function. Feel free to use whatever other network client you prefer!
Open a new terminal session and execute the following
Open a **new** terminal session and execute the following
```bash
echo "10" | http :10000
# HTTP GET method:
http localhost:10010/fib?10
curl localhost:10010/fib?10
# HTTP POST method:
echo "10" | http POST localhost:10010/fib
curl -i -d 10 localhost:10010/fib
```
You should receive the following in response. The serverless function says that the 10th fibonacci number is 55, which seems to be correct!
```bash
HTTP/1.1 200 OK
Content-length: 3
Content-type: text/plain
Server: SLEdge
Connection: close
Content-Type: text/plain
Content-Length: 3
55
```
@ -115,18 +152,10 @@ When done, terminal the SLEdge runtime with `Ctrl+c`
## Running Test Workloads
Various synthetic and real-world tests can be found in `runtime/experiments`. Generally, each experiment can be run be executing the `run.sh` script.
## Removing the SLEdge Runtime
If you are finished working with the SLEdge runtime and wish to remove it, run the following command to delete our Docker build and runtime images.
Various synthetic and real-world tests can be found in `runtime/tests`. Generally, each experiment can be run by Make rules in the top level `test.mk`.
```bash
./devenv.sh rma
```
And then simply delete this repository.
`make -f test.mk all`
## Problems or Feedback?
If you encountered bugs or have feedback, please let us know in our [issue tracker.](https://github.com/phanikishoreg/awsm-Serverless-Framework/issues)
If you encountered bugs or have feedback, please let us know in our [issue tracker.](https://github.com/gwsystems/sledge-serverless-framework/issues)

@ -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,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

@ -136,6 +136,7 @@ envrun() {
echo "Starting ${SYS_DOC_NAME}"
docker run \
--privileged \
--network="host" \
--security-opt seccomp:unconfined \
--name=${SYS_DOC_NAME} \
--detach \

@ -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,5 +1,7 @@
#!/bin/bash
LLVM_VERSION=13
validate() {
utility="clang-format"
utility_version="$("$utility" --version 2> /dev/null)" || {
@ -11,7 +13,7 @@ validate() {
declare -i major=0
declare -i minor=0
declare -i patch=0
declare -i required_major=11
declare -i required_major=$LLVM_VERSION
declare -i required_minor=0
declare -i required_patch=0
@ -43,16 +45,16 @@ help() {
dry_run() {
find runtime \
\( -path "runtime/thirdparty" -o -path "runtime/tests/gocr" -o -path "runtime/tests/TinyEKF" -o -path "runtime/tests/CMSIS_5_NN" -o -path "runtime/tests/sod" -o -path "runtime/tests/**/thirdparty" \) -prune -false -o \
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print \
| xargs clang-format -Werror -n -ferror-limit=0
\( -path "runtime/thirdparty" \) -prune -false -o \
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print0 \
| xargs --null clang-format -Werror -n -ferror-limit=1
}
format() {
find runtime \
\( -path "runtime/thirdparty" -o -path "runtime/tests/gocr" -o -path "runtime/tests/TinyEKF" -o -path "runtime/tests/CMSIS_5_NN" -o -path "runtime/tests/sod" -o -path "runtime/tests/**/thirdparty" \) -prune -false -o \
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print \
| xargs clang-format -i
\( -path "runtime/thirdparty" \) -prune -false -o \
-type f \( -iname \*.h -o -iname \*.c -o -iname \*.s \) -print0 \
| xargs --null clang-format -i
}
case $1 in

@ -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);
}

@ -1,12 +1,9 @@
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <types.h>
#define CHAR_BIT 8
#include "sledge_abi.h"
// TODO: Throughout here we use `assert` for error conditions, which isn't optimal
// Instead we should use `unlikely` branches to a single trapping function (which should optimize better)
// The below functions are for implementing WASM instructions
#define INLINE __attribute__((always_inline))
// ROTL and ROTR helper functions
INLINE uint32_t
@ -57,56 +54,48 @@ rotr_u64(uint64_t n, uint64_t c_u64)
INLINE uint32_t
u32_div(uint32_t a, uint32_t b)
{
assert(b);
return a / b;
}
INLINE uint32_t
u32_rem(uint32_t a, uint32_t b)
{
assert(b);
return a % b;
}
INLINE int32_t
i32_div(int32_t a, int32_t b)
{
assert(b && (a != INT32_MIN || b != -1));
return a / b;
}
INLINE int32_t
i32_rem(int32_t a, int32_t b)
{
assert(b && (a != INT32_MIN || b != -1));
return a % b;
}
INLINE uint64_t
u64_div(uint64_t a, uint64_t b)
{
assert(b);
return a / b;
}
INLINE uint64_t
u64_rem(uint64_t a, uint64_t b)
{
assert(b);
return a % b;
}
INLINE int64_t
i64_div(int64_t a, int64_t b)
{
assert(b && (a != INT64_MIN || b != -1));
return a / b;
}
INLINE int64_t
i64_rem(int64_t a, int64_t b)
{
assert(b && (a != INT64_MIN || b != -1));
return a % b;
}
@ -116,64 +105,71 @@ i64_rem(int64_t a, int64_t b)
uint32_t
u32_trunc_f32(float f)
{
assert(0 <= f && f <= (float)UINT32_MAX);
if (unlikely(f < 0 || f > (float)UINT32_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (uint32_t)f;
}
int32_t
i32_trunc_f32(float f)
{
assert(INT32_MIN <= f && f <= (float)INT32_MAX);
if (unlikely(f < INT32_MIN || f > (float)INT32_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (int32_t)f;
}
uint32_t
u32_trunc_f64(double f)
{
assert(0 <= f && f <= (double)UINT32_MAX);
if (unlikely(f < 0 || f > (double)UINT32_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (uint32_t)f;
}
int32_t
i32_trunc_f64(double f)
{
assert(INT32_MIN <= f && f <= (double)INT32_MAX);
if (unlikely(f < (double)INT32_MIN || f > (double)INT32_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (int32_t)f;
}
uint64_t
u64_trunc_f32(float f)
{
assert(0 <= f && f <= (float)UINT64_MAX);
if (unlikely(f < 0 || f > (float)UINT64_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (uint64_t)f;
}
int64_t
i64_trunc_f32(float f)
{
assert(INT64_MIN <= f && f <= (float)INT64_MAX);
if (unlikely(f < (float)INT64_MIN || f > (float)INT64_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (int64_t)f;
}
uint64_t
u64_trunc_f64(double f)
{
assert(0 <= f && f <= (double)UINT64_MAX);
if (unlikely(f < 0 || f > (float)UINT64_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (uint64_t)f;
}
int64_t
i64_trunc_f64(double f)
{
assert(INT64_MIN <= f && f <= (double)INT64_MAX);
if (unlikely(f < (double)INT64_MIN || f > (double)INT64_MAX))
sledge_abi__wasm_trap_raise(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
return (int64_t)f;
}
// Float => Float truncation functions
INLINE float
f32_trunc_f32(float f)
{
return trunc(f);
return truncf(f);
}
INLINE float
@ -191,7 +187,31 @@ f32_max(float a, float b)
INLINE float
f32_floor(float a)
{
return floor(a);
return floorf(a);
}
INLINE float
f32_ceil(float a)
{
return ceilf(a);
}
INLINE float
f32_copysign(float a, float b)
{
return copysignf(a, b);
}
INLINE float
f32_nearest(float a)
{
return nearbyintf(a);
}
INLINE double
f64_trunc_f64(double f)
{
return trunc(f);
}
INLINE double
@ -211,3 +231,21 @@ f64_floor(double a)
{
return floor(a);
}
INLINE double
f64_ceil(double a)
{
return ceil(a);
}
INLINE double
f64_copysign(double a, double b)
{
return copysign(a, b);
}
INLINE double
f64_nearest(double a)
{
return nearbyint(a);
}

@ -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);
}

@ -17,31 +17,42 @@ CFLAGS+=-D_GNU_SOURCE
CFLAGS+=-O3 -flto
# Debugging Flags
# CFLAGS+=-O0 -g
# CFLAGS+=-O0 -g3
# CFI Sanitizer
# CFLAGS+=-O0 -g -flto -fvisibility=default -fsanitize=cfi
# CFLAGS+=-fvisibility=default -fsanitize=cfi
# Undefined Sanitizer
# CFLAGS+=-O0 -g -fsanitize=undefined,float-divide-by-zero,unsigned-integer-overflow,implicit-conversion,local-bounds
# Undefined Sanitizer - https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
# CFLAGS+=-fsanitize=undefined,float-divide-by-zero,unsigned-integer-overflow,implicit-conversion,local-bounds,nullability
# Clang SafeStack - https://clang.llvm.org/docs/SafeStack.html
# CFLAGS+=-O0 -g -fsanitize=safe-stack
# CFLAGS+=-fsanitize=safe-stack
# Memory Sanitizer - https://clang.llvm.org/docs/MemorySanitizer.html
# CFLAGS+=-O0 -g -fsanitize=memory -fno-omit-frame-pointer
# CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
# Address Sanitizer - https://clang.llvm.org/docs/AddressSanitizer.html
# CFLAGS+=-O0 -g -fsanitize=address -fno-omit-frame-pointer
# Address Sanitizer - "Fast Memory Error Detector" - https://clang.llvm.org/docs/AddressSanitizer.html
# CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
BINARY_NAME=sledgert
# Feature Toggles
CFLAGS += -DEXECUTION_HISTOGRAM
# CFLAGS += -DEXECUTION_REGRESSION
# It is recommended (not mandatory) to enable this flag along with the EXECUTION_HISTOGRAM flag:
# CFLAGS += -DADMISSIONS_CONTROL
# Debugging Flags
# Enables logs of WASI syscalls
# CFLAGS += -DLOG_WASI
# Sandbox writes to stdout and stderr are both written to the client socket
# However, when set, stderr is also written to the host stderr to assist with debugging
# CFLAGS += -DLOG_SANDBOX_STDERR
# Strips out calls to assert() and disables debuglog
# CFLAGS += -DNDEBUG
@ -49,13 +60,14 @@ BINARY_NAME=sledgert
# CFLAGS += -DLOG_TO_FILE
# Various Informational Logs for Debugging
# CFLAGS += -DLOG_EXECUTION_HISTOGRAM
# CFLAGS += -DLOG_ADMISSIONS_CONTROL
# CFLAGS += -DLOG_CONTEXT_SWITCHES
# CFLAGS += -DLOG_HTTP_PARSER
# CFLAGS += -DLOG_LOCK_OVERHEAD
# CFLAGS += -DLOG_MODULE_LOADING
# CFLAGS += -DLOG_TENANT_LOADING
# CFLAGS += -DLOG_PREEMPTION
# CFLAGS += -DLOG_REQUEST_ALLOCATION
# CFLAGS += -DLOG_SANDBOX_ALLOCATION
# CFLAGS += -DLOG_UNSUPPORTED_WASI
# Stores and logs extended signal information for each worker
# CFLAGS += -DLOG_SOFTWARE_INTERRUPT_COUNTS
@ -68,15 +80,26 @@ BINARY_NAME=sledgert
# page is allocated. This helps understand the relationship to memory allocation and execution time.
# CFLAGS += -DLOG_SANDBOX_MEMORY_PROFILE
# This flag dumps totals of incoming requests and outgoing responses, broken out by status code
# family, such as 2XX, 4XX, 5XX. It is useful to debug clients hanging waiting for a response.
# This flag enables runtime-level metrics from procfs
# CFLAGS += -DPROC_STAT_METRICS
# This flag enables HTTP-level counters of incoming requests and outgoing responses, broken out by status code
# family, such as 2XX, 4XX, 5XX.
# To log, run `call http_total_log()` while in GDB
# CFLAGS += -DLOG_TOTAL_REQS_RESPS
# CFLAGS += -DHTTP_TOTAL_COUNTERS
# This flag enables per-route counters of incoming requests and outgoing responses, broken out by status code
# family, such as 2XX, 4XX, 5XX.
# CFLAGS += -DHTTP_ROUTE_TOTAL_COUNTERS
# This flag logs the total number of sandboxes in the various states
# This flag enables per-route latency perf-logs.
# This has a perf impact due to the use of locks.
# This flag has a dependency on the flag HTTP_ROUTE_TOTAL_COUNTERS
# CFLAGS += -DROUTE_LATENCY
# This flag tracks the total number of sandboxes in the various states
# It is useful to debug if sandboxes are "getting caught" in a particular state
# To log, run `call runtime_log_sandbox_states()` while in GDB
# CFLAGS += -DLOG_SANDBOX_COUNT
# CFLAGS += -DSANDBOX_STATE_TOTALS
# This flag enables an per-worker atomic count of sandbox's local runqueue count in thread local storage
# Useful to debug if sandboxes are "getting caught" or "leaking" while in a local runqueue
@ -87,7 +110,6 @@ BINARY_NAME=sledgert
# Sets a flag equal to the processor architecture
CFLAGS += -D${ARCH}
# Preprocessor
# SLEdge serverless functions are *.so shared-libraries. The runtime thus requires the dynamic linker
@ -99,49 +121,50 @@ LDFLAGS += -Wl,--export-dynamic -ldl -lm
# Our third-party dependencies build into a single dist directory to simplify configuration here.
LDFLAGS += -Lthirdparty/dist/lib/
INCLUDES += -Iinclude/ -Ithirdparty/dist/include/
INCLUDES += -Iinclude/ -Ithirdparty/dist/include/ -I../libsledge/include/
# CFILES
CFILES += src/*.c
CFILES += src/arch/${ARCH}/*.c
CFILES += src/libc/*.c
CFILES += src/memory/common.c
CFILES += src/memory/64bit_nix.c
CFILES += thirdparty/dist/lib/http_parser.o
# Configuring Jasmine
JSMNCFLAGS += -DJSMN_STATIC
JSMNCFLAGS += -DJSMN_STRICT
# Force sledgert to rebuild when header files change
# This is a bit fragile, as it does not recurse subdirectories when detecting last changed times
HEADER_DEPS = thirdparty/dist/include/*.h include/*.h include/arch/x86_64/*.h include/arch/aarch64/*.h
.PHONY: all
all: runtime
all: thirdparty runtime
.PHONY: clean
clean: thirdparty.clean runtime.clean
bin/sledgert: ${CFILES}
# sledgert Rules
bin/${BINARY_NAME}: ${HEADER_DEPS} ${CFILES}
@echo "Compiling runtime"
@mkdir -p bin/
${CC} ${INCLUDES} ${CFLAGS} ${LDFLAGS} ${JSMNCFLAGS} -L/usr/lib/ $^ -o bin/sledgert
@${CC} ${INCLUDES} ${CFLAGS} ${LDFLAGS} ${JSMNCFLAGS} -L/usr/lib/ ${CFILES} -o bin/${BINARY_NAME}
.PHONY: runtime
runtime: thirdparty bin/sledgert
runtime: bin/${BINARY_NAME}
.PHONY: runtime.clean
runtime.clean:
@rm -f bin/${BINARY_NAME}
# Thirdparty Dependency Rules
thirdparty/dist/lib/http_parser.o: thirdparty
thirdparty/dist/include/*.h: thirdparty
.PHONY: thirdparty
thirdparty:
@echo "Compiling thirdparty"
@make --no-print-directory -C thirdparty build
.PHONY: clean
clean:
@rm -f core
@echo "Cleaning up runtime"
@rm -f bin/${BINARY_NAME}
.PHONY: distclean
distclean: clean
.PHONY: thirdparty.clean
thirdparty.clean:
@make --no-print-directory -C thirdparty clean
.PHONY: submodules
submodules:
@git submodule update --init --recursive
.PHONY: init
init: submodules clean thirdparty runtime

@ -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 @@
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 @@
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 @@
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,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,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"
}
]

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…
Cancel
Save