Closed Bug 1360248 Opened 9 years ago Closed 9 years ago

Baldr: kill WasmActivation::entrySP_

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: luke, Assigned: luke)

References

Details

Attachments

(4 files, 1 obsolete file)

This is one of the oldest asm.js cheats; instead we can use the existing stack unwinding to return to the entry stub's epilogue which is a first step to what we'll need to do for EH anyway.
Attached patch rm-entry-sp (obsolete) — Splinter Review
Attachment #8862975 - Flags: review?(bbouvier)
Oops, hit Enter before comment. I meant to say: mostly pretty easy; the only challenge is that each entry stub needs to pop a different amount of stack b/c the stack holds stack arguments. The easiest thing I found was to have the throw stub return to the entry stub (using the return address it pushed when calling the real function). The only trick is to know whether to propagate success or failure which the patch does using the fp register.
Actually, lemme split this up a bit so it's easier to see entry stub changes. This patch is pure code motion.
Attachment #8862975 - Attachment is obsolete: true
Attachment #8862975 - Flags: review?(bbouvier)
Attachment #8862991 - Flags: review?(bbouvier)
Attached patch rm-entry-spSplinter Review
And here's the remaining patch.
Attachment #8863000 - Flags: review?(bbouvier)
Unrelated cleanup patch to change type of 'fp' from void* to wasm::Frame* in frame iterators.
Attachment #8863012 - Flags: review?(bbouvier)
Attachment #8863031 - Flags: review?(bbouvier)
Comment on attachment 8862991 [details] [diff] [review] hoist-arg-return-code Review of attachment 8862991 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for splitting it up!
Attachment #8862991 - Flags: review?(bbouvier) → review+
Comment on attachment 8863000 [details] [diff] [review] rm-entry-sp Review of attachment 8863000 [details] [diff] [review]: ----------------------------------------------------------------- Nice and easy, thank you! ::: js/src/jit-test/tests/wasm/profiling.js @@ +191,5 @@ > (func $foo (unreachable)) > (func (export "") (call $foo)) > )`, > WebAssembly.RuntimeError, > +["", ">", "1,>", "0,1,>", "interstitial,0,1,>", "trap handling,0,1,>", "", ">", ""]); Just to confirm my understanding: - the first-to-final entry `>` is because we're getting back in the entry stub; - the second-to-final entry `` accounts for time spent in the throw stub; Is that right? ::: js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp @@ +1551,5 @@ > +void > +MacroAssembler::PopStackPtr() > +{ > + loadPtr(Address(StackPointer, stackAdjust), StackPointer); > + adjustFrame(-stackAdjust); I think stackAdjust isn't defined here? ::: js/src/wasm/WasmFrameIterator.h @@ +34,5 @@ > class Code; > class CodeRange; > class DebugFrame; > class DebugState; > +class Frame; We don't need this declaration here, do we? ::: js/src/wasm/WasmStubs.cpp @@ +339,5 @@ > > // Recover the 'argv' pointer which was saved before aligning the stack. > masm.Pop(argv); > > + // Store the return value in argv[0] uber-nit: dot at the end of sentence. @@ +350,5 @@ > + Label success, join; > + masm.branchTestPtr(Assembler::Zero, FramePointer, FramePointer, &success); > +#ifdef DEBUG > + Label ok; > + masm.branchPtr(Assembler::Equal, FramePointer, Imm32(FailFP), &ok); Just to assess my understanding, the FailFP magic value trick won't interfere with the profiling frame iterator because it doesn't use the FP register for starting unwinding, but does use the exitFP for that purpose, correct?
Attachment #8863000 - Flags: review?(bbouvier) → review+
Comment on attachment 8863012 [details] [diff] [review] simplify-frame-iter Review of attachment 8863012 [details] [diff] [review]: ----------------------------------------------------------------- Seems this is a subset of the next patch, so will cancel review on that one.
Attachment #8863012 - Flags: review?(bbouvier)
Comment on attachment 8863031 [details] [diff] [review] simplify-frame-iter Review of attachment 8863031 [details] [diff] [review]: ----------------------------------------------------------------- Yay to more typing.
Attachment #8863031 - Flags: review?(bbouvier) → review+
(In reply to Benjamin Bouvier [:bbouvier] from comment #8) > > +["", ">", "1,>", "0,1,>", "interstitial,0,1,>", "trap handling,0,1,>", "", ">", ""]); > > Just to confirm my understanding: > - the first-to-final entry `>` is because we're getting back in the entry > stub; > - the second-to-final entry `` accounts for time spent in the throw stub; > Is that right? Exactly > > + masm.branchPtr(Assembler::Equal, FramePointer, Imm32(FailFP), &ok); > > Just to assess my understanding, the FailFP magic value trick won't > interfere with the profiling frame iterator because it doesn't use the FP > register for starting unwinding, but does use the exitFP for that purpose, > correct? Right, as explained in the comment in the ProfilingFrameIterator ctor, when exitFP is set, it takes precedence. Moreover, even w/o this special case, pc is Throw and Entry stubs both of which immediately mark the iterator as done().
Pushed by lwagner@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/502f442198b6 Baldr: factor out argument/return ABI code (r=bbouvier) https://hg.mozilla.org/integration/mozilla-inbound/rev/5b0d8eb9dc56 Baldr: remove WasmActivation::exitSP_, using unwinding instead (r=bbouvier) https://hg.mozilla.org/integration/mozilla-inbound/rev/20f376c71c88 Baldr: use wasm::Frame* type for fp instead of void* (r=bbouvier)
D'oh, that's what I get for blindly applying a windows-only change without recompiling on windows. The second failure was because the AutoNoteSingleThreadedRegion bug 1360263 added was narrower in scope than the one I the local patch I try server'd and then deleted when bug 1360263 landed. Updated patch broadens the scope again.
Flags: needinfo?(luke)
Pushed by lwagner@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/0284ba593ded Baldr: factor out argument/return ABI code (r=bbouvier) https://hg.mozilla.org/integration/mozilla-inbound/rev/f13207882d12 Baldr: remove WasmActivation::exitSP_, using unwinding instead (r=bbouvier) https://hg.mozilla.org/integration/mozilla-inbound/rev/44f970fca9ed Baldr: use wasm::Frame* type for fp instead of void* (r=bbouvier)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: