Bug 238444

Summary: [JSC] Use spoolers in FTL OSR exit thunk
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch mark.lam: review+, ews-feeder: commit-queue-

Yusuke Suzuki
Reported 2022-03-28 04:02:34 PDT
[JSC] Use spoolers in FTL OSR exit thunk
Attachments
Patch (18.22 KB, patch)
2022-03-28 04:12 PDT, Yusuke Suzuki
no flags
Patch (18.88 KB, patch)
2022-03-28 04:15 PDT, Yusuke Suzuki
mark.lam: review+
ews-feeder: commit-queue-
Yusuke Suzuki
Comment 1 2022-03-28 04:12:10 PDT
Yusuke Suzuki
Comment 2 2022-03-28 04:15:57 PDT
Mark Lam
Comment 3 2022-03-28 12:57:14 PDT
Comment on attachment 455899 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455899&action=review Nice. r=me. > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:389 > + if (!undefinedGPR) { Use UNLIKELY? > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:400 > + if (!undefinedGPR) { Use UNLIKELY? > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:503 > + // The FTL compilation didn't preserve this register. This means that it also > + // didn't use the register. So its value at the beginning of OSR exit should be > + // preserved by the thunk. Luckily, we saved all registers into the register > + // scratch buffer, so we can restore them from there. Since this now describe all the registers restorations below (as opposed to a single register as before), we should pluralized references to "register" in this comment. I suggest (with some additional detail for added context): unwindIndex == UINT_MAX indicates that the FTL compilation didn't preserve these registers. This means that it also didn't use them. Their values at the beginning of OSR exit should be the ones to retain. We saved all registers into the register scratch buffer at the beginning of the thunk. So we can restore them from there. > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:521 > + CCallHelpers::CopySpooler spooler(jit, GPRInfo::regT3, CCallHelpers::framePointerRegister, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0, FPRInfo::fpRegT1); nit: I suggest adding ASSERTs above the `jit.move(CCallHelpers::TrustedImmPtr(registerScratch), GPRInfo::regT3);` line above to ASSERT that regT0, refT1, and regT3 are not callee save since these loops include restoration of callee saves. Hence, we can't use callee saves as temps. > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:542 > + // The FTL compilation preserved the register. Its new value is therefore > + // irrelevant, but we can get the value that was preserved by using the unwind > + // data. We've already copied all unwind-able preserved registers into the unwind > + // scratch buffer, so we can get it from there. Again, pluralize. I suggest: The FTL compilation preserved these registers. Their new values are therefore irrelevant, but we can get their values that were preserved by using the unwind data. We've already copied all unwind-able preserved registers into the unwind scratch buffer, so we can get the values to restore from there.
Yusuke Suzuki
Comment 4 2022-03-29 14:06:47 PDT
Comment on attachment 455899 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=455899&action=review Thank you! >> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:389 >> + if (!undefinedGPR) { > > Use UNLIKELY? Nice. Added. >> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:400 >> + if (!undefinedGPR) { > > Use UNLIKELY? Done. >> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:503 >> + // scratch buffer, so we can restore them from there. > > Since this now describe all the registers restorations below (as opposed to a single register as before), we should pluralized references to "register" in this comment. I suggest (with some additional detail for added context): > > unwindIndex == UINT_MAX indicates that the FTL compilation didn't preserve these registers. > This means that it also didn't use them. Their values at the beginning of OSR exit should be > the ones to retain. We saved all registers into the register scratch buffer at the beginning of > the thunk. So we can restore them from there. Sounds good! Changed. >> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:521 >> + CCallHelpers::CopySpooler spooler(jit, GPRInfo::regT3, CCallHelpers::framePointerRegister, GPRInfo::regT0, GPRInfo::regT1, FPRInfo::fpRegT0, FPRInfo::fpRegT1); > > nit: I suggest adding ASSERTs above the `jit.move(CCallHelpers::TrustedImmPtr(registerScratch), GPRInfo::regT3);` line above to ASSERT that regT0, refT1, and regT3 are not callee save since these loops include restoration of callee saves. Hence, we can't use callee saves as temps. Sounds good! >> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:542 >> + // scratch buffer, so we can get it from there. > > Again, pluralize. I suggest: > > The FTL compilation preserved these registers. Their new values are therefore > irrelevant, but we can get their values that were preserved by using the unwind > data. We've already copied all unwind-able preserved registers into the unwind > scratch buffer, so we can get the values to restore from there. Nice, changed.
Yusuke Suzuki
Comment 5 2022-03-29 15:54:22 PDT
Radar WebKit Bug Importer
Comment 6 2022-03-29 15:55:19 PDT
Note You need to log in before you can comment on or make changes to this bug.