Closed Bug 1781242 Opened 3 years ago Closed 3 years ago

Simplify JitContext a bit

Categories

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

task

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: jandem, Assigned: jandem)

Details

Attachments

(10 files, 2 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

JitContext has some complexity, for example multiple contexts can be nested.

Last week I wrote some patches to simplify this to prepare for bug 1774178, but then went with a different approach for that bug. We should still land the JitContext parts though.

A long time ago, JitContext was also used for entering JIT code, but now we only
use it for the compiler backend where we don't need to support nesting.

This requires some minor changes to avoid having multiple active contexts on the
stack, but makes it easier to reason about.

One of the MacroAssembler constructors instantiates a JitContext lazily, but
it's simpler to require the callers to create a JitContext.

Depends on D152762

With this patch we always pass a non-null allocator to the JitContext constructor,
and then never change it. Use references instead of pointers to make this clearer.

This lets us clean up more code: AutoJitContextAlloc can be removed and the
MacroAssembler no longer needs the constructor to optionally instantiate that
class.

Depends on D152763

The MacroAssembler is the main place where we still do TLS lookups for JitContext.
We can avoid that by caching the JitContext in the MacroAssembler.

This works because we now always instantiate the JitContext before we create the assembler.
Exceptions are Wasm compilations where we currently don't need the JitContext, and off-thread
JIT compilations where we can reset the context manually.

Depends on D152766

Attachment #9287073 - Attachment is obsolete: true

This removes some old code to tag debug spew with an ID per assembler, based on a
counter stored in JitContext. Usually there's only one assembler per JitContext and
we were also not using this for Wasm compilations (it always used id 0), so this
patch removes it.

Depends on D152766

Attachment #9287074 - Attachment is obsolete: true

This follows the Wasm code and prepares for (a) removing the second MacroAssembler
constructor and (b) removing the allocator from JitContext.

Depends on D152846

MacroAssembler now has a single constructor, instead of three different ones
before this patch stack.

Depends on D152847

This lets us replace relatively slow TLS lookups with a simple dereference.

This also removes the realm from JitContext. The runtime still has a few uses
in the MIR backend.

Depends on D152849

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/80977afb9edc part 1 - Remove support for nested JitContexts. r=iain https://hg.mozilla.org/integration/autoland/rev/bbf8fe85e541 part 2 - Remove MacroAssembler::jitContext. r=iain https://hg.mozilla.org/integration/autoland/rev/090af82e2597 part 3 - Ensure JitContext always has an allocator. r=iain https://hg.mozilla.org/integration/autoland/rev/8de9467effb2 part 4 - Remove AutoJitContextAlloc.h and some references. r=iain https://hg.mozilla.org/integration/autoland/rev/83749da6cc3c part 5 - Remove arm32/arm64 assembler buffer id. r=iain https://hg.mozilla.org/integration/autoland/rev/175d3849180d part 6 - Always pass TempAllocator to MacroAssembler. r=iain https://hg.mozilla.org/integration/autoland/rev/322cae63ed26 part 7 - Remove Wasm-specific MacroAssembler constructor. r=iain https://hg.mozilla.org/integration/autoland/rev/28f6e56b0ebb part 8 - Remove allocator from JitContext. r=iain https://hg.mozilla.org/integration/autoland/rev/371648da494c part 9 - Store CompileRealm and CompileRuntime in the MacroAssembler. r=iain https://hg.mozilla.org/integration/autoland/rev/b1526450d444 part 10 - Mark JitContext MOZ_RAII, update a comment. r=iain
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: