diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-07-24 23:57:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 23:57:04 -0700 |
commit | 443c0069df34bac9640ed75e396c8b76d3870ae0 (patch) | |
tree | 95869cd8599bf83689b7329a5ecc180622091a17 /src/js | |
parent | 7bf827d38eb710069662b99eed6ba9ece20775c1 (diff) | |
download | binaryen-443c0069df34bac9640ed75e396c8b76d3870ae0.tar.gz binaryen-443c0069df34bac9640ed75e396c8b76d3870ae0.tar.bz2 binaryen-443c0069df34bac9640ed75e396c8b76d3870ae0.zip |
More push/pop support (#2260)
This adds
- `push`/`pop` support for other types: v128 and exnref
- `push`/`pop` support for binaryen.js
Because binaryen.js follows Binaryen's AST structure, without `pop` in
binaryen.js, EH instructions cannot be represented in binaryen.js.
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/binaryen.js-post.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 5b24f3a8f..e08d3cf4d 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -78,6 +78,8 @@ Module['MemoryInitId'] = Module['_BinaryenMemoryInitId'](); Module['DataDropId'] = Module['_BinaryenDataDropId'](); Module['MemoryCopyId'] = Module['_BinaryenMemoryCopyId'](); Module['MemoryFillId'] = Module['_BinaryenMemoryFillId'](); +Module['PushId'] = Module['_BinaryenPushId'](); +Module['PopId'] = Module['_BinaryenPopId'](); // External kinds Module['ExternalFunction'] = Module['_BinaryenExternalFunction'](); @@ -761,6 +763,9 @@ function wrapModule(module, self) { 'wait': function(ptr, expected, timeout) { return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i32']); }, + 'pop': function() { + return Module['_BinaryenPop'](module, Module['i32']); + } }; self['i64'] = { @@ -1062,6 +1067,9 @@ function wrapModule(module, self) { 'wait': function(ptr, expected, timeout) { return Module['_BinaryenAtomicWait'](module, ptr, expected, timeout, Module['i64']); }, + 'pop': function() { + return Module['_BinaryenPop'](module, Module['i64']); + } }; self['f32'] = { @@ -1167,6 +1175,9 @@ function wrapModule(module, self) { 'ge': function(left, right) { return Module['_BinaryenBinary'](module, Module['GeFloat32'], left, right); }, + 'pop': function() { + return Module['_BinaryenPop'](module, Module['f32']); + } }; self['f64'] = { @@ -1272,6 +1283,9 @@ function wrapModule(module, self) { 'ge': function(left, right) { return Module['_BinaryenBinary'](module, Module['GeFloat64'], left, right); }, + 'pop': function() { + return Module['_BinaryenPop'](module, Module['f64']); + } }; self['v128'] = { @@ -1302,6 +1316,9 @@ function wrapModule(module, self) { }, 'bitselect': function(left, right, cond) { return Module['_BinaryenSIMDBitselect'](module, left, right, cond); + }, + 'pop': function() { + return Module['_BinaryenPop'](module, Module['v128']); } }; @@ -1724,6 +1741,12 @@ function wrapModule(module, self) { }, }; + self['exnref'] = { + 'pop': function() { + return Module['_BinaryenPop'](module, Module['exnref']); + } + }; + self['select'] = function(condition, ifTrue, ifFalse) { return Module['_BinaryenSelect'](module, condition, ifTrue, ifFalse); }; @@ -1748,6 +1771,9 @@ function wrapModule(module, self) { self['notify'] = function(ptr, notifyCount) { return Module['_BinaryenAtomicNotify'](module, ptr, notifyCount); }; + self['push'] = function(value) { + return Module['_BinaryenPush'](module, value); + }; // 'Module' operations self['addFunctionType'] = function(name, result, paramTypes) { @@ -2225,6 +2251,7 @@ Module['getExpressionInfo'] = function(expr) { }; case Module['NopId']: case Module['UnreachableId']: + case Module['PopId']: return { 'id': id, 'type': type @@ -2349,6 +2376,11 @@ Module['getExpressionInfo'] = function(expr) { 'value': Module['_BinaryenMemoryFillGetValue'](expr), 'size': Module['_BinaryenMemoryFillGetSize'](expr) }; + case Module['PushId']: + return { + 'id': id, + 'value': Module['_BinaryenPushGetValue'](expr) + }; default: throw Error('unexpected id: ' + id); |