diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-12-30 17:55:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 17:55:20 -0800 |
commit | bcc76146fed433cbc8ba01a9f568d979c145110b (patch) | |
tree | ab70ad24afc257b73513c3e62f3aab9938d05944 /src/passes/InstrumentLocals.cpp | |
parent | a30f1df5696ccb3490e2eaa3a9ed5e7e487c7b0e (diff) | |
download | binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.gz binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.bz2 binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.zip |
Add support for reference types proposal (#2451)
This adds support for the reference type proposal. This includes support
for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`)
and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and
new typed `select`. This also adds subtype relationship support between
reference types.
This does not include table instructions yet. This also does not include
wasm2js support.
Fixes #2444 and fixes #2447.
Diffstat (limited to 'src/passes/InstrumentLocals.cpp')
-rw-r--r-- | src/passes/InstrumentLocals.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index 407903219..ae35ec2d1 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -56,14 +56,18 @@ Name get_i32("get_i32"); Name get_i64("get_i64"); Name get_f32("get_f32"); Name get_f64("get_f64"); +Name get_funcref("get_funcref"); Name get_anyref("get_anyref"); +Name get_nullref("get_nullref"); Name get_exnref("get_exnref"); Name set_i32("set_i32"); Name set_i64("set_i64"); Name set_f32("set_f32"); Name set_f64("set_f64"); +Name set_funcref("set_funcref"); Name set_anyref("set_anyref"); +Name set_nullref("set_nullref"); Name set_exnref("set_exnref"); struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { @@ -84,9 +88,15 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { break; case v128: assert(false && "v128 not implemented yet"); + case funcref: + import = get_funcref; + break; case anyref: import = get_anyref; break; + case nullref: + import = get_nullref; + break; case exnref: import = get_exnref; break; @@ -126,9 +136,15 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { break; case v128: assert(false && "v128 not implemented yet"); + case funcref: + import = set_funcref; + break; case anyref: import = set_anyref; break; + case nullref: + import = set_nullref; + break; case exnref: import = set_exnref; break; @@ -156,10 +172,26 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { addImport(curr, set_f64, {Type::i32, Type::i32, Type::f64}, Type::f64); if (curr->features.hasReferenceTypes()) { + addImport(curr, + get_funcref, + {Type::i32, Type::i32, Type::funcref}, + Type::funcref); + addImport(curr, + set_funcref, + {Type::i32, Type::i32, Type::funcref}, + Type::funcref); addImport( curr, get_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref); addImport( curr, set_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref); + addImport(curr, + get_nullref, + {Type::i32, Type::i32, Type::nullref}, + Type::nullref); + addImport(curr, + set_nullref, + {Type::i32, Type::i32, Type::nullref}, + Type::nullref); } if (curr->features.hasExceptionHandling()) { addImport( |