This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lucet-wasi-sdk: wasi sdk 12 no longer supports `--no-threads` * dockerfile: use wasi-sdk 12 * ci: use wasi-sdk 12 * lucet-runtime: fix tests for wasi-sdk-12 by rewriting use_allocator.c in wat use_allocator.c was a fixture used for tests that manipulated the size of linear memory. written in C, it depended heavily on the implemention of wasi-libc's allocator, which changed from sdk-11 to sdk-12. Rather than try to depend on the new (still fragile) behavior these tests were rewritten in pure wat, with a much simpler allocator behavior that just expands the linear memory. The tests were modified to observe this new behavior.
- Loading branch information
Pat Hickey
committed
Dec 4, 2020
1 parent
a893069
commit 8fa8a4a
Showing
8 changed files
with
126 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
lucet-runtime/lucet-runtime-tests/guests/entrypoint/use_allocator.c
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
lucet-runtime/lucet-runtime-tests/guests/entrypoint/use_allocator.wat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(module | ||
(memory 1) | ||
;; Expand the wasm heap and initialize it to a value. | ||
;; sets out-pointer to -1 if heap expansion fails. | ||
;; Parameters are: | ||
;; 0. initialization value (byte) | ||
;; 1. size (in wasm pages) | ||
;; 2. out-pointer to store start address of expanded heap | ||
;; Locals are: | ||
;; 3. expanded heap start page | ||
(func $expand_and_memset (export "expand_and_memset") (param i32 i32 i32) | ||
(local i32) | ||
(local.set 3 (memory.grow (local.get 1))) | ||
(if (i32.eq (local.get 3) (i32.const -1)) | ||
(then (i32.store (local.get 2) (i32.const -1))) | ||
(else | ||
(i32.store (local.get 2) (i32.mul (local.get 3) (i32.const 65536))) | ||
(call $memset (i32.load (local.get 2)) (local.get 0) (i32.mul (local.get 1) (i32.const 65536))) | ||
) | ||
) | ||
) | ||
|
||
|
||
;; memset | ||
;; parameters are | ||
;; 0. pointer to start of region | ||
;; 1. constant value (byte) | ||
;; 2. size of region, in bytes | ||
;; locals are | ||
;; 3. current pointer | ||
(func $memset (export "memset") (param i32 i32 i32) | ||
(local i32) | ||
(local.set 3 (local.get 0)) | ||
(loop | ||
(i32.store8 (local.get 3) (local.get 1)) | ||
(local.set 3 (i32.add (local.get 3) (i32.const 1))) | ||
(br_if 0 (i32.lt_u (local.get 3) (i32.add (local.get 0) (local.get 2)))) | ||
) | ||
) | ||
|
||
;; increment_ptr | ||
;; increment the byte at the pointer | ||
;; parameters are | ||
;; 0. pointer to byte | ||
(func $increment_ptr (export "increment_ptr") (param i32) | ||
(i32.store8 (local.get 0) | ||
(i32.add (i32.const 1) (i32.load (local.get 0)))) | ||
) | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.