kenz-gelsoft / gecko-dev

Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org. How to contribute: https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/setup/index.html
Other
16 stars 2 forks source link

Enable JS JIT #56

Open kenz-gelsoft opened 1 month ago

kenz-gelsoft commented 1 month ago

I disabled JIT for WasmSignalHandler build error in https://github.com/kenz-gelsoft/Inari/issues/24

It seems to need CPU register handling. I don't know we can access register in normal (non-debugger) process but it may help me what I explored when tried to port LLDB:

https://github.com/kenz-gelsoft/llvm-project/compare/5a97e917640529d10821993413e0722244068ad4...110ec133bb6f96f8db34e4af0b2d1f26d1f59efd

kenz-gelsoft commented 1 month ago

non windows platform it looks like this

https://searchfox.org/mozilla-esr128/source/js/src/wasm/WasmSignalHandlers.cpp#82

https://stackoverflow.com/questions/12349169/where-is-uc-mcontext-definition#12349831

kenz-gelsoft commented 1 month ago
struct Thread : TeamThreadIteratorEntry<thread_id>, KernelReferenceable {
// snip
    ucontext_t*     user_signal_context;    // only accessed by this thread
kenz-gelsoft commented 1 month ago
 * The sigaction() function allows finer grained control of the signal
 * handling. It also allows an opportunity, via the 'sigaction' struct, to
 * enable additional data to be passed to the handler. For example:
 *    void
 *    my_signal_handler(int sig, char* userData, vregs* regs)
 *    {
 *    . . .
 *    }
 *
 *    struct sigaction sa;
 *    char data_buffer[32];
 *
 *    sa.sa_handler = (__sighandler_t)my_signal_handler;
 *    sigemptyset(&sa.sa_mask);
 *    sa.sa_userdata = userData;
 *
 *    // install the handler
 *    sigaction(SIGINT, &sa, NULL);
 *
 * The two additional arguments available to the signal handler are extensions
 * to the Posix standard. This feature was introduced by the BeOS and retained
 * by Haiku. However, to remain compatible with Posix and ANSI C, the type
 * of the sa_handler field is defined as '__sighandler_t'. This requires the
 * handler to be cast when assigned to the sa_handler field, as in the example
 * above.
 *
 * The 3 arguments that Haiku provides to signal handlers are as follows:
 * 1) The first argument is the (usual) signal number.
 *
 * 2) The second argument is whatever value is put in the sa_userdata field
 *    of the sigaction struct.
 *
 * 3) The third argument is a pointer to a vregs struct (defined below).
 *    The vregs struct contains the contents of the volatile registers at
 *    the time the signal was delivered to your thread. You can change the
 *    fields of the structure. After your signal handler completes, the OS uses
 *    this struct to reload the registers for your thread (privileged registers
 *    are not loaded of course). The vregs struct is of course terribly machine
 *    dependent.
 *    Note that in BeOS the vregs argument was passed by value, not by pointer.
 *    While Haiku retains binary compability with code compiled for BeOS, code
 *    built under Haiku must use the pointer argument.
 */

/*
 * the vregs struct:
 *
 * signal handlers get this as the last argument
 */
typedef struct vregs vregs;
    /* BeOS extension */

/* include architecture specific definitions */
#include __HAIKU_ARCH_HEADER(signal.h)

typedef struct vregs mcontext_t;

typedef struct __ucontext_t {
    struct __ucontext_t*    uc_link;
    sigset_t                uc_sigmask;
    stack_t                 uc_stack;
    mcontext_t              uc_mcontext;
} ucontext_t;
kenz-gelsoft commented 1 month ago
#ifdef __x86_64__

struct vregs {
    unsigned long       rax;
    unsigned long       rbx;
    unsigned long       rcx;
    unsigned long       rdx;
    unsigned long       rdi;
    unsigned long       rsi;
    unsigned long       rbp;
    unsigned long       r8;
    unsigned long       r9;
    unsigned long       r10;
    unsigned long       r11;
    unsigned long       r12;
    unsigned long       r13;
    unsigned long       r14;
    unsigned long       r15;

    unsigned long       rsp;
    unsigned long       rip;
    unsigned long       rflags;

    struct savefpu      fpu;
};

#endif
kenz-gelsoft commented 1 month ago

It doesn't finish compiling if jit enabled. pending...(at least now)

kenz-gelsoft commented 3 weeks ago

It finished building on retry. But it crashed immediately after launching the browser. I will investigate.