Closed Bug 1643586 Opened 5 years ago Closed 3 years ago

Remove AutoSetHelperThreadContext from GCParallelTask

Categories

(Core :: JavaScript: GC, task, P3)

task

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: jandem, Assigned: jonco)

References

Details

Attachments

(6 files)

Longer-term we'd like to get rid of helper thread JSContexts. The two cases where we still rely on them are GCParallelTask and ParseTask. The ParseTask use will be easier to address after Stencil. For GCParallelTask maybe we could add a GCThreadContext TLS class that stores the thread-specific bits we care about and then remove AutoSetHelperThreadContext.

I suspect this would be a nice refactoring because it will make it explicit what state is used by off-thread tasks. For example, poking at this a bit, I noticed helper threads currently use AutoDisableProxyCheck but the JSContext flag we set there is only checked on the main thread so this could stay on JSContext/JSRuntime.

This sounds good to me.

Assignee: nobody → jcoppeard

The plan is to move the parts of JSContext that are used by helper threads into JSFreeOp, which already functions as a kind of GC context.

This replaces such uses with an RAII class where necessary.

This uses the context's default free op for background sweeping so there is now
only one free op per thread. This makes all free ops 'default' ones so this
flag is removed. All free ops now have a runtime so maybeOnHelperThread() is
also removed.

Depends on D140188

JSFreeOp is defined in gc/FreeOp.h so moves its method implementations under gc/ as well.

Depends on D140189

This is only used in one place and it's simpler to check the tracer kind there.

Depends on D140190

This patch moves the debug-only GC state from JSContext to JSFreeOp. Support
functions for this move to FreeOp.h and most RAII classes move to GCInternals.h.

The default free op member is removed from JSContext. A free op for the main
thread is added to GCRuntime, and the helper thread system creates a vector of
free ops that can be used by tasks. GCParallelTask takes one of these and sets
it in TLS when running a task.

Use of JSContext by GC helper threads is replaced by JSFreeOp.

Depends on D140192

Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a022c7b2bf0c Part 1: Remove use of scoped JSFreeOps to poison freed JIT code r=jandem https://hg.mozilla.org/integration/autoland/rev/f40e41f905a4 Part 2: Use one JSFreeOp per thread r=jandem https://hg.mozilla.org/integration/autoland/rev/619f2aabe4d5 Part 3: Move JSFreeOp code under js/src/gc r=jandem https://hg.mozilla.org/integration/autoland/rev/b29a261a06ec Part 4: Remove flag for disabling compartment checks from JSContext r=jandem https://hg.mozilla.org/integration/autoland/rev/054a08d13999 Part 5: Replace heap state checks that rely on there being a JSContext for the thread r=jandem https://hg.mozilla.org/integration/autoland/rev/2fa53cd9ac4e Part 6: Stop using JSContext for GC helper thread tasks r=jandem
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3c2076b122e0 Part 1: Remove use of scoped JSFreeOps to poison freed JIT code r=jandem https://hg.mozilla.org/integration/autoland/rev/a6b5cbbdd54b Part 2: Use one JSFreeOp per thread r=jandem https://hg.mozilla.org/integration/autoland/rev/8611c3ef5a77 Part 3: Move JSFreeOp code under js/src/gc r=jandem https://hg.mozilla.org/integration/autoland/rev/f78d139e1d0e Part 4: Remove flag for disabling compartment checks from JSContext r=jandem https://hg.mozilla.org/integration/autoland/rev/410d1b57bb09 Part 5: Replace heap state checks that rely on there being a JSContext for the thread r=jandem https://hg.mozilla.org/integration/autoland/rev/28829816a629 Part 6: Stop using JSContext for GC helper thread tasks r=jandem
Blocks: 1757956
Regressions: 1759107
Regressions: 1758768
No longer regressions: 1758768
Flags: needinfo?(jcoppeard)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: