-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DSL for module semantics #32
Changes from 16 commits
152b2d0
a1c51f9
5380d76
2b82dcc
6b6bd32
835bf0d
7d757da
7aaff60
cecacb5
2a158db
066f8c3
6c7d379
97d3fe6
68c6067
b8681db
9b3e6e3
030a3a8
d967107
8f6c590
0f48772
35be3dd
edda75e
ff216fb
21e0a94
236de04
1560490
e7a5252
6bc75a6
506306e
eb57512
5aeb393
a453c69
88fe94b
42b276f
65e6777
edb1fbf
8bb5fe0
6872abe
616eded
d764e97
5c9aed2
ba5b056
31213dd
474c65f
384016d
fd8ec1f
97e95c3
0e45bef
199efd1
cb45bce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -84,8 +84,8 @@ rule Step_read/call: | |||||||
|
||||||||
rule Step_read/call_indirect-call: | ||||||||
z; (CONST I32 i) (CALL_INDIRECT x ft) ~> (CALL_ADDR a) | ||||||||
-- if $table(z, x)[i] = (REF.FUNC_ADDR a) | ||||||||
-- if $funcinst(z)[a] = m; FUNC ft' t* instr* | ||||||||
-- if $table(z, x).ELEM[i] = (REF.FUNC_ADDR a) | ||||||||
-- if $funcinst(z)[a].CODE = FUNC ft' t* instr* | ||||||||
-- if ft = ft' | ||||||||
|
||||||||
rule Step_read/call_indirect-trap: | ||||||||
|
@@ -94,7 +94,8 @@ rule Step_read/call_indirect-trap: | |||||||
|
||||||||
rule Step_read/call_addr: | ||||||||
z; val^k (CALL_ADDR a) ~> (FRAME_ n `{f} (LABEL_ n `{epsilon} instr*)) | ||||||||
-- if $funcinst(z)[a] = m; FUNC (t_1^k -> t_2^n) t* instr* | ||||||||
-- if $funcinst(z)[a] = {MODULE m, CODE func} | ||||||||
-- if func = FUNC (t_1^k -> t_2^n) t* instr* | ||||||||
-- if f = {LOCAL val^k ($default_(t))*, MODULE m} | ||||||||
|
||||||||
|
||||||||
|
@@ -172,44 +173,47 @@ rule Step_pure/local.tee: | |||||||
|
||||||||
|
||||||||
rule Step_read/global.get: | ||||||||
z; (GLOBAL.GET x) ~> $global(z, x) | ||||||||
z; (GLOBAL.GET x) ~> $global(z, x).VALUE | ||||||||
|
||||||||
rule Step/global.set: | ||||||||
z; val (GLOBAL.SET x) ~> $with_global(z, x, val); epsilon | ||||||||
|
||||||||
|
||||||||
rule Step_read/table.get-trap: | ||||||||
z; (CONST I32 i) (TABLE.GET x) ~> TRAP | ||||||||
-- if i >= |$table(z, x)| | ||||||||
-- if i >= |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step_read/table.get-val: | ||||||||
z; (CONST I32 i) (TABLE.GET x) ~> $table(z,x)[i] | ||||||||
-- if i < |$table(z, x)| | ||||||||
z; (CONST I32 i) (TABLE.GET x) ~> $table(z,x).ELEM[i] | ||||||||
-- if i < |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step/table.set-trap: | ||||||||
z; (CONST I32 i) ref (TABLE.GET x) ~> z; TRAP | ||||||||
-- if i >= |$table(z, x)| | ||||||||
-- if i >= |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step/table.set-val: | ||||||||
z; (CONST I32 i) ref (TABLE.GET x) ~> $with_table(z, x, i, ref); epsilon | ||||||||
-- if i < |$table(z, x)| | ||||||||
-- if i < |$table(z, x).ELEM| | ||||||||
|
||||||||
|
||||||||
rule Step_read/table.size: | ||||||||
z; (TABLE.SIZE x) ~> (CONST I32 n) | ||||||||
-- if |$table(z, x)| = n ;; TODO: inline this | ||||||||
-- if |$table(z, x).ELEM| = n ;; TODO: inline this | ||||||||
|
||||||||
|
||||||||
rule Step/table.grow-succeed: | ||||||||
z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableext(z, x, ref^n); (CONST I32 $(|$table(z, x)|)) | ||||||||
z; ref (CONST I32 n) (TABLE.GROW x) ~> $with_tableinst(z, x, ti'); (CONST I32 $(|$table(z, x).ELEM|)) | ||||||||
-- if $table(z, x) = ti | ||||||||
-- if $grow_table(ti, n, ref) = ti' | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
-- Tabletype_ok: |- ti'.TYPE : OK | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition should probably be moved to $grow_table, such that that becomes a self-contained abstraction. |
||||||||
|
||||||||
rule Step/table.grow-fail: | ||||||||
z; ref (CONST I32 n) (TABLE.GROW x) ~> z; (CONST I32 $(-1)) | ||||||||
|
||||||||
|
||||||||
rule Step_read/table.fill-trap: | ||||||||
z; (CONST I32 i) val (CONST I32 n) (TABLE.FILL x) ~> TRAP | ||||||||
-- if $(i + n) > |$table(z, x)| | ||||||||
-- if $(i + n) > |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step_read/table.fill-zero: | ||||||||
z; (CONST I32 i) val (CONST I32 n) (TABLE.FILL x) ~> epsilon | ||||||||
|
@@ -225,7 +229,7 @@ rule Step_read/table.fill-succ: | |||||||
|
||||||||
rule Step_read/table.copy-trap: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.COPY x y) ~> TRAP | ||||||||
-- if $(i + n) > |$table(z, y)| \/ $(j + n) > |$table(z, x)| | ||||||||
-- if $(i + n) > |$table(z, y).ELEM| \/ $(j + n) > |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step_read/table.copy-zero: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.COPY x y) ~> epsilon | ||||||||
|
@@ -248,7 +252,7 @@ rule Step_read/table.copy-gt: | |||||||
|
||||||||
rule Step_read/table.init-trap: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> TRAP | ||||||||
-- if $(i + n) > |$elem(z, y)| \/ $(j + n) > |$table(z, x)| | ||||||||
-- if $(i + n) > |$elem(z, y).ELEM| \/ $(j + n) > |$table(z, x).ELEM| | ||||||||
|
||||||||
rule Step_read/table.init-zero: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> epsilon | ||||||||
|
@@ -257,7 +261,7 @@ rule Step_read/table.init-zero: | |||||||
|
||||||||
rule Step_read/table.init-succ: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (TABLE.INIT x y) ~> | ||||||||
(CONST I32 j) $elem(z,y)[i] (TABLE.SET x) | ||||||||
(CONST I32 j) $elem(z,y).ELEM[i] (TABLE.SET x) | ||||||||
(CONST I32 $(j+1)) (CONST I32 $(i+1)) (CONST I32 $(n-1)) (TABLE.INIT x y) | ||||||||
-- otherwise | ||||||||
|
||||||||
|
@@ -268,32 +272,32 @@ rule Step/elem.drop: | |||||||
|
||||||||
rule Step_read/load-num-trap: | ||||||||
z; (CONST I32 i) (LOAD nt n_A n_O) ~> TRAP | ||||||||
-- if $(i + n_O + $size(nt)/8 > |$mem(z, 0)|) | ||||||||
-- if $(i + n_O + $size(nt)/8 > |$mem(z, 0).DATA|) | ||||||||
|
||||||||
rule Step_read/load-num-val: | ||||||||
z; (CONST I32 i) (LOAD nt n_A n_O) ~> (CONST nt c) | ||||||||
-- if $bytes_($size(nt), c) = $mem(z, 0)[i + n_O : $size(nt)/8] | ||||||||
-- if $bytes_($size(nt), c) = $mem(z, 0).DATA[i + n_O : $size(nt)/8] | ||||||||
|
||||||||
rule Step_read/load-pack-trap: | ||||||||
z; (CONST I32 i) (LOAD nt (n _ sx) n_A n_O) ~> TRAP | ||||||||
-- if $(i + n_O + n/8 > |$mem(z, 0)|) | ||||||||
-- if $(i + n_O + n/8 > |$mem(z, 0).DATA|) | ||||||||
|
||||||||
rule Step_read/load-pack-val: | ||||||||
z; (CONST I32 i) (LOAD nt (n _ sx) n_A n_O) ~> (CONST nt $ext(n, $size(nt), sx, c)) | ||||||||
-- if $bytes_(n, c) = $mem(z, 0)[i + n_O : n/8] | ||||||||
-- if $bytes_(n, c) = $mem(z, 0).DATA[i + n_O : n/8] | ||||||||
|
||||||||
|
||||||||
rule Step/store-num-trap: | ||||||||
z; (CONST I32 i) (CONST nt c) (STORE nt n_A n_O) ~> z; TRAP | ||||||||
-- if $(i + n_O + $size(nt)/8) > |$mem(z, 0)| | ||||||||
-- if $(i + n_O + $size(nt)/8) > |$mem(z, 0).DATA| | ||||||||
|
||||||||
rule Step/store-num-val: | ||||||||
z; (CONST I32 i) (CONST nt c) (STORE nt n_A n_O) ~> $with_mem(z, 0, $(i + n_O), $($size(nt)/8), b*); epsilon | ||||||||
-- if b* = $bytes_($size(nt), c) | ||||||||
|
||||||||
rule Step/store-pack-trap: | ||||||||
z; (CONST I32 i) (CONST nt c) (STORE nt n n_A n_O) ~> z; TRAP | ||||||||
-- if $(i + n_O + n/8) > |$mem(z, 0)| | ||||||||
-- if $(i + n_O + n/8) > |$mem(z, 0).DATA| | ||||||||
|
||||||||
rule Step/store-pack-val: | ||||||||
z; (CONST I32 i) (CONST nt c) (STORE nt n n_A n_O) ~> $with_mem(z, 0, $(i + n_O), $(n/8), b*); epsilon | ||||||||
|
@@ -302,19 +306,22 @@ rule Step/store-pack-val: | |||||||
|
||||||||
rule Step_read/memory.size: | ||||||||
z; (MEMORY.SIZE) ~> (CONST I32 n) | ||||||||
-- if $(n * 64 * $Ki) = |$mem(z, 0)| | ||||||||
-- if $(n * 64 * $Ki) = |$mem(z, 0).DATA| | ||||||||
|
||||||||
|
||||||||
rule Step/memory.grow-succeed: | ||||||||
z; (CONST I32 n) (MEMORY.GROW) ~> $with_memext(z, 0, 0^(n * 64 * $Ki)); (CONST I32 $(|$mem(z, 0)| / (64 * $Ki))) | ||||||||
z; (CONST I32 n) (MEMORY.GROW) ~> $with_meminst(z, 0, mi'); (CONST I32 $(|$mem(z, 0).DATA| / (64 * $Ki))) | ||||||||
-- if $mem(z, 0) = mi | ||||||||
-- if $grow_memory(mi, n) = mi' | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
-- Memtype_ok: |- mi'.TYPE : OK | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||||||||
|
||||||||
rule Step/memory.grow-fail: | ||||||||
z; (CONST I32 n) (MEMORY.GROW) ~> z; (CONST I32 $(-1)) | ||||||||
|
||||||||
|
||||||||
rule Step_read/memory.fill-trap: | ||||||||
z; (CONST I32 i) val (CONST I32 n) (MEMORY.FILL) ~> TRAP | ||||||||
-- if $(i + n) > |$mem(z, 0)| | ||||||||
-- if $(i + n) > |$mem(z, 0).DATA| | ||||||||
|
||||||||
rule Step_read/memory.fill-zero: | ||||||||
z; (CONST I32 i) val (CONST I32 n) (MEMORY.FILL) ~> epsilon | ||||||||
|
@@ -330,7 +337,7 @@ rule Step_read/memory.fill-succ: | |||||||
|
||||||||
rule Step_read/memory.copy-trap: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.COPY) ~> TRAP | ||||||||
-- if $(i + n) > |$mem(z, 0)| \/ $(j + n) > |$mem(z, 0)| | ||||||||
-- if $(i + n) > |$mem(z, 0).DATA| \/ $(j + n) > |$mem(z, 0).DATA| | ||||||||
|
||||||||
rule Step_read/memory.copy-zero: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.COPY) ~> epsilon | ||||||||
|
@@ -353,7 +360,7 @@ rule Step_read/memory.copy-gt: | |||||||
|
||||||||
rule Step_read/memory.init-trap: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> TRAP | ||||||||
-- if $(i + n) > |$data(z, x)| \/ $(j + n) > |$mem(z, 0)| | ||||||||
-- if $(i + n) > |$data(z, x).DATA| \/ $(j + n) > |$mem(z, 0).DATA| | ||||||||
|
||||||||
rule Step_read/memory.init-zero: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> epsilon | ||||||||
|
@@ -362,7 +369,7 @@ rule Step_read/memory.init-zero: | |||||||
|
||||||||
rule Step_read/memory.init-succ: | ||||||||
z; (CONST I32 j) (CONST I32 i) (CONST I32 n) (MEMORY.INIT x) ~> | ||||||||
(CONST I32 j) (CONST I32 $data(z,x)[i]) (STORE I32 8 0 0) | ||||||||
(CONST I32 j) (CONST I32 $data(z,x).DATA[i]) (STORE I32 8 0 0) | ||||||||
(CONST I32 $(j+1)) (CONST I32 $(i+1)) (CONST I32 $(n-1)) (MEMORY.INIT x) | ||||||||
-- otherwise | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I dropped the option on purpose, since I figured it's simpler to just desugar an empty upper bound into 2^32-1 in the AST.