Closed Bug 606271 Opened 14 years ago Closed 14 years ago

Provide an API to notify when JIT pages are allocated/deallocated

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: ted, Assigned: dmandelin)

References

Details

We'd like to include info about JIT code pages in our minidumps. If we had an API such that the JIT would notify the caller when JIT pages are allocated and deallocated, that would probably be sufficient for our needs. Something like: typedef bool(*JITNotify_callback)(uintptr_t address, size_t size, bool allocated); JS_JITPageNotify(JSRuntime runtime, JITNotify_callback callback); Then when a page was allocated, JS would call: callback(page_address, page_size, true); and when it was deallocated: callback(page_address, page_size, false);
Seems fairly easy. A few questions: - What kind of info about JIT code pages are you going to put in minidumps. - How will minidump users access it? - How can it be used to diagnose/understand crashes? - Does this help with the getting jitcode into the dumps issue, or is it separate? Also, if this is going to really help us fix crashes, it should probably block betaN or final.
(In reply to comment #1) > Seems fairly easy. A few questions: > > - What kind of info about JIT code pages are you going to put in minidumps. My plan is to simply use the API I implemented in bug 603592 to insert them as "modules" in the minidump. > - How will minidump users access it? They would show up if you listed the modules, I'm not sure that it'd be terribly useful for humans. > - How can it be used to diagnose/understand crashes? Currently when encountering a JIT frame on the stack, the stack walker resorts to scanning the stack, looking for a plausible return address. bug 604725 proposes a set of things we could implement to give the stack walker info on how to accurately find the caller of a JIT frame. One of the prerequisites is that we know that the PC is in a JIT frame. > - Does this help with the getting jitcode into the dumps issue, or is it > separate? This is a separate issue, see bug 601312 for example. > Also, if this is going to really help us fix crashes, it should probably block > betaN or final. In bug 601312 I doubled the number of words that the stack walker would scan on the stack, so that may be enough to allow it to find the caller frame in most cases, in which case this may not need to block. I do think long-term this would be a better solution.
Assignee: general → dmandelin
OK, I want to do this. Question: Do you want to get notified for the code memory allocations, or the actual chunks of generated code? We allocate code memory in 16K/64K chunks. Not all of that chunk is necessarily used for code, but it can't be used for anything else. So if the IP is in that region, it pretty much has to be a JIT frame, unless it jumped off into space. On the other hand, by calling you back for the chunks of code we actually generate, you would get more precise info, at the cost of more notifications. There might be a perf cost to doing it that way, as ICs can do lots of small allocations. It seems like the allocations are probably better, but I want to check.
The former, since all we need to know is whether we're in a JIT frame. While thinking about this, though, I had another thought. If you reliably have a frame pointer in JIT-generated code, why not just use the usual framepointer (%ebp, %rbp), since Breakpad already knows how to walk the stack using that method?
(In reply to comment #4) > The former, since all we need to know is whether we're in a JIT frame. > > While thinking about this, though, I had another thought. If you reliably have > a frame pointer in JIT-generated code, why not just use the usual framepointer > (%ebp, %rbp), since Breakpad already knows how to walk the stack using that > method? Yes, we set up ebp/rbp in the standard way when activating jit code. See JaegerTrampoline in MethodJIT.cpp. Does this mean you don't actually need this API?
I think not. The Breakpad x86-64 stackwalker doesn't currently know to use rbp, since that's not the ABI default, but it would be trivial to teach it. Let's just do that instead.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.