summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-07-15 14:50:04 -0700
committerGitHub <noreply@github.com>2019-07-15 14:50:04 -0700
commit774fdbb2f691e367113169d2641810402b8806ad (patch)
tree4847e46b5bb54b3a798817e4d5506c3ce0b60dd4 /test/unit
parentcdab4ef130626958790cb2601209f14d192fa10a (diff)
downloadbinaryen-774fdbb2f691e367113169d2641810402b8806ad.tar.gz
binaryen-774fdbb2f691e367113169d2641810402b8806ad.tar.bz2
binaryen-774fdbb2f691e367113169d2641810402b8806ad.zip
Bysyncify => Asyncify (#2226)
After some discussion this seems like a less confusing name: what the pass does is "asyncify" code, after all. The one downside is the name overlaps with the old emscripten "Asyncify" utility, which we'll need to clarify in the docs there. This keeps the old --bysyncify flag around for now, which is helpful for avoiding temporary breakage on CI as we move the emscripten side as well.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/input/asyncify-coroutine.wast (renamed from test/unit/input/bysyncify-coroutine.wast)0
-rw-r--r--test/unit/input/asyncify-pure.txt (renamed from test/unit/input/bysyncify-pure.txt)0
-rw-r--r--test/unit/input/asyncify-pure.wast (renamed from test/unit/input/bysyncify-pure.wast)16
-rw-r--r--test/unit/input/asyncify-sleep.wast (renamed from test/unit/input/bysyncify-sleep.wast)0
-rw-r--r--test/unit/input/asyncify-stackOverflow.wast (renamed from test/unit/input/bysyncify-stackOverflow.wast)0
-rw-r--r--test/unit/input/asyncify.js (renamed from test/unit/input/bysyncify.js)24
-rw-r--r--test/unit/test_asyncify.py29
-rw-r--r--test/unit/test_bysyncify.py29
8 files changed, 49 insertions, 49 deletions
diff --git a/test/unit/input/bysyncify-coroutine.wast b/test/unit/input/asyncify-coroutine.wast
index ace97c6e6..ace97c6e6 100644
--- a/test/unit/input/bysyncify-coroutine.wast
+++ b/test/unit/input/asyncify-coroutine.wast
diff --git a/test/unit/input/bysyncify-pure.txt b/test/unit/input/asyncify-pure.txt
index 1f85db1f1..1f85db1f1 100644
--- a/test/unit/input/bysyncify-pure.txt
+++ b/test/unit/input/asyncify-pure.txt
diff --git a/test/unit/input/bysyncify-pure.wast b/test/unit/input/asyncify-pure.wast
index b79bfe2b0..27c9da111 100644
--- a/test/unit/input/bysyncify-pure.wast
+++ b/test/unit/input/asyncify-pure.wast
@@ -1,10 +1,10 @@
(module
(memory 1 1)
(import "spectest" "print" (func $print (param i32)))
- (import "bysyncify" "start_unwind" (func $bysyncify_start_unwind (param i32)))
- (import "bysyncify" "stop_unwind" (func $bysyncify_stop_unwind))
- (import "bysyncify" "start_rewind" (func $bysyncify_start_rewind (param i32)))
- (import "bysyncify" "stop_rewind" (func $bysyncify_stop_rewind))
+ (import "asyncify" "start_unwind" (func $asyncify_start_unwind (param i32)))
+ (import "asyncify" "stop_unwind" (func $asyncify_stop_unwind))
+ (import "asyncify" "start_rewind" (func $asyncify_start_rewind (param i32)))
+ (import "asyncify" "stop_rewind" (func $asyncify_stop_rewind))
(global $sleeping (mut i32) (i32.const 0))
(start $runtime)
(func $main
@@ -28,11 +28,11 @@
(global.set $sleeping (i32.const 1))
(i32.store (i32.const 16) (i32.const 24))
(i32.store (i32.const 20) (i32.const 1024))
- (call $bysyncify_start_unwind (i32.const 16))
+ (call $asyncify_start_unwind (i32.const 16))
)
(block
(call $print (i32.const 3000))
- (call $bysyncify_stop_rewind)
+ (call $asyncify_stop_rewind)
(global.set $sleeping (i32.const 0))
)
)
@@ -46,11 +46,11 @@
;; call main the first time, let the stack unwind
(call $main)
(call $print (i32.const 200))
- (call $bysyncify_stop_unwind)
+ (call $asyncify_stop_unwind)
(call $print (i32.const 300))
;; ...can do some async stuff around here...
;; set the rewind in motion
- (call $bysyncify_start_rewind (i32.const 16))
+ (call $asyncify_start_rewind (i32.const 16))
(call $print (i32.const 400))
(call $main)
(call $print (i32.const 500))
diff --git a/test/unit/input/bysyncify-sleep.wast b/test/unit/input/asyncify-sleep.wast
index 91fb5a327..91fb5a327 100644
--- a/test/unit/input/bysyncify-sleep.wast
+++ b/test/unit/input/asyncify-sleep.wast
diff --git a/test/unit/input/bysyncify-stackOverflow.wast b/test/unit/input/asyncify-stackOverflow.wast
index a36a06b40..a36a06b40 100644
--- a/test/unit/input/bysyncify-stackOverflow.wast
+++ b/test/unit/input/asyncify-stackOverflow.wast
diff --git a/test/unit/input/bysyncify.js b/test/unit/input/asyncify.js
index be6d32903..0dcd87302 100644
--- a/test/unit/input/bysyncify.js
+++ b/test/unit/input/asyncify.js
@@ -35,11 +35,11 @@ function sleepTests() {
view[DATA_ADDR >> 2] = DATA_ADDR + 8;
// The end of the stack will not be reached here anyhow.
view[DATA_ADDR + 4 >> 2] = 1024;
- exports.bysyncify_start_unwind(DATA_ADDR);
+ exports.asyncify_start_unwind(DATA_ADDR);
} else {
// We are called as part of a resume/rewind. Stop sleeping.
console.log('resume...');
- exports.bysyncify_stop_rewind();
+ exports.asyncify_stop_rewind();
// The stack should have been all used up, and so returned to the original state.
assert(view[DATA_ADDR >> 2] == DATA_ADDR + 8);
assert(view[DATA_ADDR + 4 >> 2] == 1024);
@@ -77,19 +77,19 @@ function sleepTests() {
if (expectedSleeps > 0) {
assert(!result, 'results during sleep are meaningless, just 0');
- exports.bysyncify_stop_unwind();
+ exports.asyncify_stop_unwind();
for (var i = 0; i < expectedSleeps - 1; i++) {
console.log('rewind, run until the next sleep');
- exports.bysyncify_start_rewind(DATA_ADDR);
+ exports.asyncify_start_rewind(DATA_ADDR);
result = exports[name](); // no need for params on later times
assert(!result, 'results during sleep are meaningless, just 0');
logMemory();
- exports.bysyncify_stop_unwind();
+ exports.asyncify_stop_unwind();
}
console.log('rewind and run til the end.');
- exports.bysyncify_start_rewind(DATA_ADDR);
+ exports.asyncify_start_rewind(DATA_ADDR);
result = exports[name]();
}
@@ -175,19 +175,19 @@ function coroutineTests() {
// Initialize the data.
view[dataStart >> 2] = dataStart + 8;
view[dataStart + 4 >> 2] = dataEnd;
- exports.bysyncify_start_unwind(dataStart);
+ exports.asyncify_start_unwind(dataStart);
// (With C etc. coroutines we would also have
// a C stack to pause and resume here.)
};
this.stopUnwind = function() {
- exports.bysyncify_stop_unwind();
+ exports.asyncify_stop_unwind();
};
this.startRewind = function() {
- exports.bysyncify_start_rewind(dataStart);
+ exports.asyncify_start_rewind(dataStart);
exports[name]();
};
this.stopRewind = function() {
- exports.bysyncify_stop_rewind();
+ exports.asyncify_stop_rewind();
};
}
@@ -267,7 +267,7 @@ function stackOverflowAssertTests() {
env: {
sleep: function() {
console.log('sleep...');
- exports.bysyncify_start_unwind(DATA_ADDR);
+ exports.asyncify_start_unwind(DATA_ADDR);
view[DATA_ADDR >> 2] = DATA_ADDR + 8;
// The end of the stack will be reached as the stack is tiny.
view[DATA_ADDR + 4 >> 2] = view[DATA_ADDR >> 2] + 1;
@@ -282,7 +282,7 @@ function stackOverflowAssertTests() {
// All API calls should now fail, since we wrote past the end of the
// stack
var fails = 0;
- ['bysyncify_stop_unwind', 'bysyncify_start_rewind', 'bysyncify_stop_rewind', 'bysyncify_start_unwind'].forEach(function(name) {
+ ['asyncify_stop_unwind', 'asyncify_start_rewind', 'asyncify_stop_rewind', 'asyncify_start_unwind'].forEach(function(name) {
try {
exports[name](DATA_ADDR);
console.log('no fail on', name);
diff --git a/test/unit/test_asyncify.py b/test/unit/test_asyncify.py
new file mode 100644
index 000000000..479d24cab
--- /dev/null
+++ b/test/unit/test_asyncify.py
@@ -0,0 +1,29 @@
+import os
+
+from scripts.test.shared import WASM_OPT, WASM_DIS, WASM_SHELL, NODEJS, run_process
+from utils import BinaryenTestCase
+
+
+class AsyncifyTest(BinaryenTestCase):
+ def test_asyncify_js(self):
+ def test(args):
+ print(args)
+ run_process(WASM_OPT + args + [self.input_path('asyncify-sleep.wast'), '--asyncify', '-o', 'a.wasm'])
+ run_process(WASM_OPT + args + [self.input_path('asyncify-coroutine.wast'), '--asyncify', '-o', 'b.wasm'])
+ run_process(WASM_OPT + args + [self.input_path('asyncify-stackOverflow.wast'), '--asyncify', '-o', 'c.wasm'])
+ print(' file size: %d' % os.path.getsize('a.wasm'))
+ run_process([NODEJS, self.input_path('asyncify.js')])
+
+ test(['-g'])
+ test([])
+ test(['-O1'])
+ test(['--optimize-level=1'])
+ test(['-O3'])
+ test(['-Os', '-g'])
+
+ def test_asyncify_pure_wasm(self):
+ run_process(WASM_OPT + [self.input_path('asyncify-pure.wast'), '--asyncify', '-o', 'a.wasm'])
+ run_process(WASM_DIS + ['a.wasm', '-o', 'a.wast'])
+ output = run_process(WASM_SHELL + ['a.wast'], capture_output=True).stdout
+ with open(self.input_path('asyncify-pure.txt')) as f:
+ self.assertEqual(f.read(), output)
diff --git a/test/unit/test_bysyncify.py b/test/unit/test_bysyncify.py
deleted file mode 100644
index 407f3f7f9..000000000
--- a/test/unit/test_bysyncify.py
+++ /dev/null
@@ -1,29 +0,0 @@
-import os
-
-from scripts.test.shared import WASM_OPT, WASM_DIS, WASM_SHELL, NODEJS, run_process
-from utils import BinaryenTestCase
-
-
-class BysyncifyTest(BinaryenTestCase):
- def test_bysyncify_js(self):
- def test(args):
- print(args)
- run_process(WASM_OPT + args + [self.input_path('bysyncify-sleep.wast'), '--bysyncify', '-o', 'a.wasm'])
- run_process(WASM_OPT + args + [self.input_path('bysyncify-coroutine.wast'), '--bysyncify', '-o', 'b.wasm'])
- run_process(WASM_OPT + args + [self.input_path('bysyncify-stackOverflow.wast'), '--bysyncify', '-o', 'c.wasm'])
- print(' file size: %d' % os.path.getsize('a.wasm'))
- run_process([NODEJS, self.input_path('bysyncify.js')])
-
- test(['-g'])
- test([])
- test(['-O1'])
- test(['--optimize-level=1'])
- test(['-O3'])
- test(['-Os', '-g'])
-
- def test_bysyncify_pure_wasm(self):
- run_process(WASM_OPT + [self.input_path('bysyncify-pure.wast'), '--bysyncify', '-o', 'a.wasm'])
- run_process(WASM_DIS + ['a.wasm', '-o', 'a.wast'])
- output = run_process(WASM_SHELL + ['a.wast'], capture_output=True).stdout
- with open(self.input_path('bysyncify-pure.txt')) as f:
- self.assertEqual(f.read(), output)