Skip to content

library_async.js cleanup #11867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2020
Merged

Conversation

Akaricchi
Copy link
Contributor

@Akaricchi Akaricchi commented Aug 11, 2020

Follow up to #11868

  • Fix subtle regression in emscripten_scan_registers introduced by Add new Fibers context-switching API #9859
  • Replace some hardcoded offsets with C_STRUCT references
  • Remove stub functions for the old fastcomp-only coroutines API

@sbc100
Copy link
Collaborator

sbc100 commented Aug 11, 2020

Great!

Would you mind splitting the fastcomp deletion into its own PR and referencing #11860?

@Akaricchi
Copy link
Contributor Author

Okay, I'll leave this PR for the minor cleanups and create a new one with fastcomp removal in a few minutes.

@@ -20,228 +20,6 @@ mergeInto(LibraryManager.library, {
},

#if ASYNCIFY
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also just move this into an assert at the top of the file, and always conditionally include this in src/modules.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we do about the stub functions then?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't see those. I guess we still need it then.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. can't we just remove those and let them turn into linker errors?

Copy link
Contributor Author

@Akaricchi Akaricchi Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it looks like src/modules.js already does this, actually: https://github.com/emscripten-core/emscripten/blob/master/src/modules.js#L136

I guess this means the stub functions are dead code then? Or are they still needed in case someone does -lasync.js or -s AUTO_JS_LIBRARIES without -s ASYNCIFY? A link-time error might be better in the -lasync.js case, and library_async.js could just be excluded from AUTO_JS_LIBRARIES... But I'm not sure if that might break anything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AUTO_JS_LIBRARIES is on by default, and only normally disabled as part of -s STRICT, so those stubs are still normally available to non ASYNCIFY users... but I'm not sure they should be. Such users should probably just get link error if they reference those functions. Although I could be missing some reason why a non-ASYNCIFY need those symbols to exist at link time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented stub removal in a separate commit for now 269a6e9, let's see if any tests fail. The only potential reason I see for keeping those symbols around is that maybe some user code happens to reference them in a dead code path that emscripten can't eliminate for some reason? But I really don't know. Maybe @kripken has something to say about this one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah If we do that it can be followup for sure. Lets land this change as a small cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I actually made the commit on this branch, but I guess I can split it off too if you want.

@Akaricchi
Copy link
Contributor Author

I have split off fastcomp removal into #11868, but for now also based this PR on top of it for simplicity, so it still includes the fastcomp diff. I'll rebase onto master when #11868 is merged.

* Fix subtle regression in emscripten_scan_registers introduced by emscripten-core#9859
* Replace some hardcoded offsets with C_STRUCT references
* Remove spurious parameters from stub functions
@@ -8,6 +8,10 @@
// Async support via ASYNCIFY
//

if (!ASYNCIFY) {
throw "To link with the async library you must use -s ASYNCIFY";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do:

assert(ASYNCIFY, "To link with the async library you must use -s ASYNCIFY");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually isn't it:

#if !ASYNCIFY
assert(false, "To link with the async library you must use -s ASYNCIFY");
#endif 

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if tests pass we can land this as is.

@Akaricchi
Copy link
Contributor Author

The thing we haven't considered is code that uses emscripten_has_asyncify() to conditionally execute Asyncify functions. SDL2 is one such case, which is why the test failed. So I guess the stubs are here to stay for now. I think stubs for completely removed functionality (like old coroutines) can be safely removed, though.

@sbc100 sbc100 merged commit de71520 into emscripten-core:master Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants