Skip to content

Commit e2e6243

Browse files
authored
Remove some unnecessary use of EMSCRIPTEN_KEEPALIVE. NFC (#20604)
1 parent 641b0b1 commit e2e6243

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

emcc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,8 @@ def setup_pthreads(target):
17671767
'_pthread_self',
17681768
'checkMailbox',
17691769
]
1770+
if settings.EMBIND:
1771+
worker_imports.append('__embind_initialize_bindings')
17701772
settings.EXPORTED_FUNCTIONS += worker_imports
17711773
building.user_requested_exports.update(worker_imports)
17721774

@@ -2497,6 +2499,9 @@ def phase_linker_setup(options, state, newargs):
24972499
# overrides that.
24982500
default_setting('ABORTING_MALLOC', 0)
24992501

2502+
if '-lembind' in [x for _, x in state.link_flags]:
2503+
settings.EMBIND = 1
2504+
25002505
if settings.PTHREADS:
25012506
setup_pthreads(target)
25022507
settings.JS_LIBRARIES.append((0, 'library_pthread.js'))
@@ -2615,9 +2620,6 @@ def check_memory_setting(setting):
26152620
if not settings.DECLARE_ASM_MODULE_EXPORTS or '-lexports.js' in [x for _, x in state.link_flags]:
26162621
settings.MINIFY_WASM_EXPORT_NAMES = 0
26172622

2618-
if '-lembind' in [x for _, x in state.link_flags]:
2619-
settings.EMBIND = 1
2620-
26212623
# Enable minification of wasm imports and exports when appropriate, if we
26222624
# are emitting an optimized JS+wasm combo (then the JS knows how to load the minified names).
26232625
# Things that process the JS after this operation would be done must disable this.

src/library_pthread.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ var LibraryPThread = {
12431243
#endif // MAIN_MODULE
12441244

12451245
$checkMailbox__deps: ['$callUserCallback',
1246+
'_emscripten_check_mailbox',
12461247
'_emscripten_thread_mailbox_await'],
12471248
$checkMailbox: () => {
12481249
// Only check the mailbox if we have a live pthread runtime. We implement

system/lib/embind/bind.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ using namespace emscripten;
2020
using namespace internal;
2121

2222
extern "C" {
23-
const char* EMSCRIPTEN_KEEPALIVE __getTypeName(const std::type_info* ti) {
23+
24+
const char* __getTypeName(const std::type_info* ti) {
2425
if (has_unbound_type_names) {
2526
#ifdef USE_CXA_DEMANGLE
2627
int stat;
@@ -51,7 +52,7 @@ const char* EMSCRIPTEN_KEEPALIVE __getTypeName(const std::type_info* ti) {
5152

5253
static InitFunc* init_funcs = nullptr;
5354

54-
EMSCRIPTEN_KEEPALIVE void _embind_initialize_bindings() {
55+
void _embind_initialize_bindings() {
5556
for (auto* f = init_funcs; f; f = f->next) {
5657
f->init_func();
5758
}

system/lib/gl/webgl1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_get_current_context(void) {
7373
return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)pthread_getspecific(currentActiveWebGLContext);
7474
}
7575

76-
EMSCRIPTEN_RESULT EMSCRIPTEN_KEEPALIVE emscripten_webgl_commit_frame(void) {
76+
EMSCRIPTEN_RESULT emscripten_webgl_commit_frame(void) {
7777
GL_FUNCTION_TRACE(__func__);
7878
if (pthread_getspecific(currentThreadOwnsItsWebGLContext))
7979
return emscripten_webgl_do_commit_frame();

system/lib/pthread/thread_mailbox.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ void _emscripten_thread_mailbox_init(pthread_t thread) {
7171
}
7272

7373
// Exported for use in worker.js, but otherwise an internal function.
74-
EMSCRIPTEN_KEEPALIVE
7574
void _emscripten_check_mailbox() {
7675
// Before we attempt to execute a request from another thread make sure we
7776
// are in sync with all the loaded code.

test/code_size/embind_val_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"a.html.gz": 431,
44
"a.js": 7498,
55
"a.js.gz": 3142,
6-
"a.wasm": 9669,
7-
"a.wasm.gz": 4962,
8-
"total": 17840,
9-
"total_gz": 8535
6+
"a.wasm": 9628,
7+
"a.wasm.gz": 4938,
8+
"total": 17799,
9+
"total_gz": 8511
1010
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14110
1+
14052

0 commit comments

Comments
 (0)