Skip to content

JIT: a throw under rc, none and own links without TypeScriptRuntime.dll - #418

Merged
ASDAlexander77 merged 1 commit into
mainfrom
jit-throw-type-info
Sep 30, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
jit-throw-type-info

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Under the JIT, any program with a throw failed to run under -mm=rc, none and own unless --shared-libs=TypeScriptRuntime.dll was passed:

JIT session error: Symbols not found: [ ??_7type_info@@6B@ ]
tslang: error: JIT invocation failed, error: Failed to materialize symbols: ...

This is the rc JIT type_info gap noted in #417. It isn't specific to any comparisons: every throw hits it.

Cause

  • Every type descriptor a throw emits points at type_info's vtable, ??_7type_info@@6B@.
  • tslang.exe links the CRT statically, so no DLL in the process exports that vtable.
  • TypeScriptRuntime.dll re-exports its own copy (mlir_init.cpp). A JIT run loads that DLL by itself only under gc.

Fix

jit.cpp binds ??_7type_info@@6B@ itself, next to __CxxFrameHandler3 and _CxxThrowException. It uses tslang.exe's own vtable, read from typeid(int), which is the same static CRT as the exception personality. Under gc this definition now shadows the DLL's copy.

Tests

test-runner always passes --shared-libs=TypeScriptRuntime.dll, which is why the suite never saw this.

The new test-jit-throw-without-runtime (jit-throw-without-runtime.cmake, Windows only) runs 00jit_throw_without_runtime.ts under the JIT with no --shared-libs, under rc, none and own. The program throws and catches a number, a string and a class instance. Before the change it fails in all three models.

Results

Release ctest 3312/3312
00any_equality_undefined.ts (#417), JIT with the default lib and no --shared-libs, gc and rc runs

🤖 Generated with Claude Code

@ASDAlexander77
ASDAlexander77 merged commit fd3d56e into main Sep 30, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the jit-throw-type-info branch September 30, 2026 18:38
ASDAlexander77 added a commit that referenced this pull request Sep 30, 2026
#419's split of the async runtime applies to the static library on Linux
as well, and before it the failure was the same there: checked in WSL at
#418, the scheduler's object (AsyncRuntime.cpp.o) referenced
GC_allow_register_threads, GC_register_my_thread, GC_unregister_my_thread
and GC_get_stack_base, and 00async_await.ts built with `tslang --emit=exe`
under rc, none and own failed to link ("undefined reference to
`GC_register_my_thread'"). At main only AsyncGCThreads.cpp.o references
them, and all four models link and run at -O0 and -O3.

The test was registered for Windows only; async-without-collector.cmake
passes as is on Linux, so the guard goes. Its comments name both
platforms' messages and linkers.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant