Open Bug 1913924 Opened 1 year ago Updated 15 days ago

Experiment with removing VMFunction wrappers

Categories

(Core :: JavaScript Engine: JIT, task, P3)

task

Tracking

()

ASSIGNED
Size Estimate S

People

(Reporter: jandem, Assigned: nbp)

References

(Blocks 4 open bugs)

Details

(Whiteboard: [js-perf-next][sp3])

Last week Ted and I came up with some ideas for 'inlining' VMFunction wrappers by emitting the equivalent code directly at the call site.

The main benefit of this is faster JIT => C++ calls by reducing the number of memory loads/stores for the arguments. It would also avoid some frame pointer overhead. Especially for Baseline Interpreter/IC code that's shared, we don't gain much by calling out to separate trampoline code.

The first step here is to identify some hot VM functions and then prototype calling these functions directly and measure how this affects performance and code size.

Blocks: sm-opt-jits
Severity: -- → N/A
Priority: -- → P3

We do a lot of VM calls. Even if this is a relatively small performance win per-call, it seems quite plausible that it's a meaningful improvement overall.

js-perf-next: Evaluate the performance/code-size implications of doing this by hand for a few hot functions, then implement it if the numbers look good.

Whiteboard: [js-perf-next]
Whiteboard: [js-perf-next] → [js-perf-next][sp3]
See Also: → 1935626
Blocks: sm-perf-next
Assignee: jdemooij → nobody
Status: ASSIGNED → NEW
Size Estimate: --- → S
Assignee: nobody → nicolas.b.pierron
Status: NEW → ASSIGNED
Blocks: 1892374

Nicolas: What's your update here?

Flags: needinfo?(nicolas.b.pierron)

(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #2)

Nicolas: What's your update here?

Still on my list, I just have been pulled away by some crazyness is better left untold for everybody's sanity.

So far the approach I planned so far was to:

  • Add arguments to a new callVM functions, similar to oolCallVM.
  • Add a new callVM functions which merges the implementation of the original callVM with the implementation of the VM wrapper.
  • Check performance and remove VM wrapper if beneficial.
Flags: needinfo?(nicolas.b.pierron)

One additional step that might be worthwhile would be to pick a single hot VM call (there are lists Jan produced of the hottest VM calls in JS3/SP3 in bug 1935626), rewrite it completely by hand for a single platform (using base masm), and then profile ro measure how much improvement we would expect. It's a little bit of extra work up front, but it might save some time if it turns out this isn't a big overhead after all.

Depends on how quickly you think you can write a VM call by hand, I guess.

I just realized that this also lets us use setupAlignedABICall from Ion code instead of the current setupUnalignedABICall from the VM wrapper.

When we converted all callWithABIs in Ion to setupAlignedABICall it was a measurable speedup (bug 1763592).

(In reply to Jan de Mooij [:jandem] from comment #5)

I just realized that this also lets us use setupAlignedABICall from Ion code instead of the current setupUnalignedABICall from the VM wrapper.

I experimented with this a bit, but we would have to fix the following first:

  • The tail-call register handling, which offsets the framePushed accounting to avoid assertions when pulling the return address out of the stack.
  • The offset at which IC are called. At the moment IC are entered with no strict stack depth alignment.

(In reply to Nicolas B. Pierron [:nbp] from comment #6)

I experimented with this a bit, but we would have to fix the following first:

  • The tail-call register handling, which offsets the framePushed accounting to avoid assertions when pulling the return address out of the stack.
  • The offset at which IC are called. At the moment IC are entered with no strict stack depth alignment.

These issues don't affect calls coming from Ion's CodeGenerator where we always have a known stack alignment, right? I was suggesting using setupAlignedABICall only for that case, not for VM calls from Baseline or IC code.

Nicolas: What's the current state of this? If someone else was to look at this, what would you share?

Flags: needinfo?(nicolas.b.pierron)

(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #8)

Nicolas: What's the current state of this? If someone else was to look at this, what would you share?

I am tiding up the patches and fixing other platform issues.

Flags: needinfo?(nicolas.b.pierron)
You need to log in before you can comment on or make changes to this bug.