Skip to content

Commit

Permalink
Only apply Asyncify to functions that really need it
Browse files Browse the repository at this point in the history
This creates asyncify.txt from emterpretify.txt, with functions
in the different format needed by ASYNCIFY_ONLY. It leads to a
bunch of these warnings, because some functions get inlined:
warning: Asyncify onlylist contained a non-matching pattern:
That is okay and apparently unavoidable. The important thing is
that no such warnings occur when the final link is done using -O0.

ASYNCIFY_ADVISE has shown that a lot more would be processed by
Asyncify without this. The performance penalty isn't too bad, and
is much better than the Emterpreter. Maybe more extensive use of
Asyncify could make more things work, but taking advantage of that
would require code changes.
  • Loading branch information
dreamlayers committed Dec 6, 2022
1 parent af3aef2 commit 1896ca0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ else
# It is only required when using emterpreter.
dosbox_LDFLAGS+=--memory-init-file 0
if ASYNCIFY
dosbox_LDFLAGS+=-s ASYNCIFY=1 -s FETCH=1
dosbox_LDFLAGS+=-s ASYNCIFY=1 -s FETCH=1 -s [email protected]
EXTRA_dosbox_DEPENDENCIES=asyncify.txt
endif
endif
if WEBASSEMBLY
Expand Down
48 changes: 48 additions & 0 deletions src/asyncify.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[
"main",
"SHELL_Init()",
"DOS_ReadFile(unsigned short, unsigned char*, unsigned short*, bool)",
"DOSBOX_RunMachine()",
"CALLBACK_RunRealInt(unsigned char)",
"CALLBACK_RunRealFar(unsigned short, unsigned short)",
"CALLBACK_Idle()",
"Normal_Loop()",
"DOS_21Handler()",
"PROGRAMS_Handler()",
"device_CON::Read(unsigned char*, unsigned short*)",
"device_CON::device_CON()",
"DOS_Device::Read(unsigned char*, unsigned short*)",
"MEM::Run()",
"INTRO::Run()",
"BOOT::Run()",
"Config::StartUp()",
"Config::Init()",
"Section::ExecuteInit(bool)",
"GUI_StartUp(Section*)",
"DOS_Shell::InputCommand(char*)",
"DOS_Shell::Run()",
"DOS_Shell::Execute(char*, char*)",
"DOS_Shell::DoCommand(char*)",
"DOS_Shell::ParseLine(char*)",
"DOS_Shell::CMD_HELP(char*)",
"DOS_Shell::CMD_PAUSE(char*)",
"DOS_Shell::CMD_CHOICE(char*)",
"DOS_Shell::CMD_DIR(char*)",
"DOS_Shell::CMD_TIME(char*)",
"DOS_Shell::CMD_CLS(char*)",
"DOS_Shell::CMD_DATE(char*)",
"DOS_Shell::CMD_COPY(char*)",
"Reboot_Handler()",
"DOS_LoadKeyboardLayout(char const*, int, char const*)",
"DOS_KeyboardLayout_Init(Section*)",
"DOS_SwitchKeyboardLayout(char const*, int&)",
"keyboard_layout::read_codepage_file(char const*, int)",
"keyboard_layout::switch_keyboard_layout(char const*, keyboard_layout*&, int&)",
"DOS_KeyboardLayout::DOS_KeyboardLayout(Section*)",
"KEYB::Run()",
"PIC_RunQueue()",
"MAPPER_RunEvent(unsigned int)",
"MAPPER_RunInternal()",
"Pause_Loop()",
"WGET::Run()"
]
9 changes: 9 additions & 0 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,15 @@ int main(int argc, char* argv[]) {
LOG_MSG("---");

/* Init SDL */
#if SDL_VERSION_ATLEAST(2,0,0) && defined(EM_ASYNCIFY)
/* SDL calling emscripten_sleep() would be unnecessary, and would also
* require many more functions to be processed via asyncify.
* This was added in SDL 2.0.14, so it can cause compile errors with old
* SDL. Compile errors are better than SDL calling emscripten_sleep()
* and causing mysterious exceptions.
*/
SDL_SetHint(SDL_HINT_EMSCRIPTEN_ASYNCIFY, "0");
#endif
#if SDL_VERSION_ATLEAST(1, 2, 14)
/* Or debian/ubuntu with older libsdl version as they have done this themselves, but then differently.
* with this variable they will work correctly. I've only tested the 1.2.14 behaviour against the windows version
Expand Down

0 comments on commit 1896ca0

Please sign in to comment.