Created
April 27, 2022 14:34
-
-
Save kripken/0b4e39a9f2943887ff122df5557c252c 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
#include "a.h" | |
void a() { | |
data = 42; | |
} |
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
extern int data; | |
void a(); |
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
#include <stdio.h> | |
#include "a.h" | |
int data = 0; | |
struct B { | |
B() { | |
printf("B(), data=%d\n", data); | |
} | |
~B() { | |
printf("~B(), data=%d\n", data); | |
} | |
}; | |
int main() { | |
B b; | |
a(); | |
} |
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
;; | |
;; relevant output from running | |
;; | |
;; ./emcc a.cpp b.cpp -O1 --profiling -fwasm-exceptions -s ENVIRONMENT=shell | |
;; | |
(func $a\28\29 | |
(i32.store offset=1680 | |
(i32.const 0) | |
(i32.const 42) | |
) | |
) | |
(func $__original_main (result i32) | |
(local $0 i32) | |
(global.set $__stack_pointer | |
(local.tee $0 | |
(i32.sub | |
(global.get $__stack_pointer) | |
(i32.const 48) | |
) | |
) | |
) | |
(i32.store offset=32 | |
(local.get $0) | |
(i32.load offset=1680 | |
(i32.const 0) | |
) | |
) | |
(drop | |
(call $iprintf | |
(i32.const 1042) | |
(i32.add | |
(local.get $0) | |
(i32.const 32) | |
) | |
) | |
) | |
(try $label$3 ;; unnecessary try-catch | |
(do | |
(call $a\28\29) | |
) | |
(catch_all | |
(global.set $__stack_pointer | |
(local.get $0) | |
) | |
(i32.store offset=16 | |
(local.get $0) | |
(i32.load offset=1680 | |
(i32.const 0) | |
) | |
) | |
(drop | |
(call $iprintf | |
(i32.const 1041) | |
(i32.add | |
(local.get $0) | |
(i32.const 16) | |
) | |
) | |
) | |
(rethrow $label$3) | |
) | |
) | |
(i32.store | |
(local.get $0) | |
(i32.load offset=1680 | |
(i32.const 0) | |
) | |
) | |
(drop | |
(call $iprintf | |
(i32.const 1041) | |
(local.get $0) | |
) | |
) | |
(global.set $__stack_pointer | |
(i32.add | |
(local.get $0) | |
(i32.const 48) | |
) | |
) | |
(i32.const 0) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment