Bug 49725 - Add DWARF table generation support for JITted code
Summary: Add DWARF table generation support for JITted code
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P3 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 49720
  Show dependency treegraph
 
Reported: 2010-11-18 04:21 PST by Kent Hansen
Modified: 2011-04-12 22:03 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Hansen 2010-11-18 04:21:25 PST
This is needed in order for libgcc to be able to unwind the stack if a C++ exception is thrown from native code called from JITted code.
See https://bugs.webkit.org/show_bug.cgi?id=49720 for testcase (Qt-specific).
Comment 1 Kent Hansen 2010-11-22 02:05:11 PST
This might not be a problem with the JITed code itself, but rather with mixing C and C++ and exceptions.

JITed code is not invoked directly, but through the ctiTrampoline() function, which has C linkage. So what we have is:
C++ --> C --> C++ & throw.
In a small test application, without JIT or anything, I'm not able to catch such an exception.

From http://yosefk.com/c++fqa/mixing.html#fqa-32.6: "I've just tried this with the GNU C and C++ compilers. When a C++ function calls a C function which calls a C++ function which throws an exception, you can't even catch it at the first C++ function, not to mention disposing the resources allocated by the C function."

From http://developers.sun.com/solaris/articles/mixing.html#except: "What happens if you call a C++ function from a C function, and the C++ function throws an exception? The C++ standard is somewhat vague about whether you can expect exceptions to behave properly, and on some systems you have to take special precautions. Generally, you must consult the user manuals to determine whether the code will work properly."

Supposedly it does work on MSVC without having to do anything special.
I'm not sure how to solve it for gcc. Could a frame description entry be dynamically registered with libgcc to establish unwinding rules for ctiTrampoline? Is this really worth the effort?

FWIW, relevant section of the DWARF spec is 6.4 "Call Frame Information": http://dwarfstd.org/Dwarf3Std.php

libgcc does provide a function to dynamically register a frame description entry, __register_frame(). (This is what LLVM uses to make exception handling work with JITed code.)