Last active
July 30, 2019 17:31
-
-
Save kripken/7345b98074c31b80ed81cdc4f42500d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(module | |
(type $FUNCSIG$vi (func (param i32))) | |
(type $FUNCSIG$v (func)) | |
(import "spectest" "print" (func $print (param i32))) | |
(memory $0 1 1) | |
(global $sleeping (mut i32) (i32.const 0)) | |
(global $__asyncify_state (mut i32) (i32.const 0)) | |
(global $__asyncify_data (mut i32) (i32.const 0)) | |
(export "asyncify_start_unwind" (func $asyncify_start_unwind)) | |
(export "asyncify_stop_unwind" (func $asyncify_stop_unwind)) | |
(export "asyncify_start_rewind" (func $asyncify_start_rewind)) | |
(export "asyncify_stop_rewind" (func $asyncify_stop_rewind)) | |
(start $runtime) | |
(func $main (; 1 ;) (type $FUNCSIG$v) | |
(local $0 i32) | |
(local.set $0 | |
(block $__asyncify_unwind (result i32) | |
(if | |
(select | |
(block (result i32) | |
(if | |
(i32.eq | |
(global.get $__asyncify_state) | |
(i32.const 2) | |
) | |
(block | |
(i32.store | |
(global.get $__asyncify_data) | |
(i32.add | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.const -4) | |
) | |
) | |
(local.set $0 | |
(i32.load | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
) | |
) | |
) | |
) | |
(i32.eqz | |
(local.get $0) | |
) | |
) | |
(i32.const 1) | |
(global.get $__asyncify_state) | |
) | |
(block | |
(call $print | |
(i32.const 1) | |
) | |
(drop | |
(br_if $__asyncify_unwind | |
(i32.const 0) | |
(i32.eq | |
(global.get $__asyncify_state) | |
(i32.const 1) | |
) | |
) | |
) | |
) | |
) | |
(if | |
(select | |
(i32.eq | |
(local.get $0) | |
(i32.const 1) | |
) | |
(i32.const 1) | |
(global.get $__asyncify_state) | |
) | |
(block | |
(call $sleep) | |
(drop | |
(br_if $__asyncify_unwind | |
(i32.const 1) | |
(i32.eq | |
(global.get $__asyncify_state) | |
(i32.const 1) | |
) | |
) | |
) | |
) | |
) | |
(if | |
(select | |
(i32.eq | |
(local.get $0) | |
(i32.const 2) | |
) | |
(i32.const 1) | |
(global.get $__asyncify_state) | |
) | |
(block | |
(call $print | |
(i32.const 3) | |
) | |
(drop | |
(br_if $__asyncify_unwind | |
(i32.const 2) | |
(i32.eq | |
(global.get $__asyncify_state) | |
(i32.const 1) | |
) | |
) | |
) | |
) | |
) | |
(return) | |
) | |
) | |
(i32.store | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(local.get $0) | |
) | |
(i32.store | |
(global.get $__asyncify_data) | |
(i32.add | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.const 4) | |
) | |
) | |
) | |
(func $sleep (; 2 ;) (type $FUNCSIG$v) | |
(if | |
(global.get $sleeping) | |
(block | |
(call $asyncify_stop_rewind) | |
(global.set $sleeping | |
(i32.const 0) | |
) | |
) | |
(block | |
(global.set $sleeping | |
(i32.const 1) | |
) | |
(i32.store | |
(i32.const 16) | |
(i32.const 24) | |
) | |
(i32.store | |
(i32.const 20) | |
(i32.const 1024) | |
) | |
(call $asyncify_start_unwind | |
(i32.const 16) | |
) | |
) | |
) | |
) | |
(func $runtime (; 3 ;) (type $FUNCSIG$v) | |
(call $main) | |
(call $asyncify_stop_unwind) | |
(call $print | |
(i32.const 2) | |
) | |
(call $asyncify_start_rewind | |
(i32.const 16) | |
) | |
(call $main) | |
) | |
(func $asyncify_start_unwind (; 4 ;) (param $0 i32) | |
(global.set $__asyncify_state | |
(i32.const 1) | |
) | |
(global.set $__asyncify_data | |
(local.get $0) | |
) | |
(if | |
(i32.gt_u | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.load offset=4 | |
(global.get $__asyncify_data) | |
) | |
) | |
(unreachable) | |
) | |
) | |
(func $asyncify_stop_unwind (; 5 ;) | |
(global.set $__asyncify_state | |
(i32.const 0) | |
) | |
(if | |
(i32.gt_u | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.load offset=4 | |
(global.get $__asyncify_data) | |
) | |
) | |
(unreachable) | |
) | |
) | |
(func $asyncify_start_rewind (; 6 ;) (param $0 i32) | |
(global.set $__asyncify_state | |
(i32.const 2) | |
) | |
(global.set $__asyncify_data | |
(local.get $0) | |
) | |
(if | |
(i32.gt_u | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.load offset=4 | |
(global.get $__asyncify_data) | |
) | |
) | |
(unreachable) | |
) | |
) | |
(func $asyncify_stop_rewind (; 7 ;) | |
(global.set $__asyncify_state | |
(i32.const 0) | |
) | |
(if | |
(i32.gt_u | |
(i32.load | |
(global.get $__asyncify_data) | |
) | |
(i32.load offset=4 | |
(global.get $__asyncify_data) | |
) | |
) | |
(unreachable) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment