Closed Bug 1745665 Opened 3 years ago Closed 2 years ago

Remove AutoSuppressNurseryCellAlloc

Categories

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

task

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: arai, Assigned: tcampbell)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [sp3])

Attachments

(5 files)

bug 1745662 is going to remove the last non-test consumer of AutoSuppressNurseryCellAlloc,
and the last test consumer of AutoSuppressNurseryCellAlloc has the following comment:

https://searchfox.org/mozilla-central/rev/aaa1799be461b768bef81a337ac6969a1eae969e/js/src/vm/StringType.cpp#1989-1994

  // Now create forcibly-tenured versions of each of these string types. Note
  // that this is best-effort; if nursery strings are disabled, or we GC
  // midway through here, then we may end up with fewer nursery strings than
  // desired. Also, some types of strings are not nursery-allocatable, so
  // this will always produce some number of redundant strings.
  gc::AutoSuppressNurseryCellAlloc suppress(cx);

So, if this isn't something guaranteed, we'd better removing it.

There are some comments that mentions off-thread allocation, that no longer happens,
and that's related to AutoSuppressNurseryCellAlloc.

https://searchfox.org/mozilla-central/rev/93c6fe08a4ef08d4146a30c2c9494bf0f3bb42e0/js/src/gc/Allocator.cpp#211

template <AllowGC allowGC /* = CanGC */>
JSString* js::AllocateStringImpl(JSContext* cx, AllocKind kind, size_t size,
                                 InitialHeap heap) {
...
  // Off-thread alloc cannot trigger GC or make runtime assertions.
  if (cx->isNurseryAllocSuppressed()) {

https://searchfox.org/mozilla-central/rev/93c6fe08a4ef08d4146a30c2c9494bf0f3bb42e0/js/src/gc/Allocator.cpp#289

template <AllowGC allowGC /* = CanGC */>
JS::BigInt* js::AllocateBigInt(JSContext* cx, InitialHeap heap) {
...
  // Off-thread alloc cannot trigger GC or make runtime assertions.
  if (cx->isNurseryAllocSuppressed()) {

https://searchfox.org/mozilla-central/rev/93c6fe08a4ef08d4146a30c2c9494bf0f3bb42e0/js/src/vm/StringType-inl.h#284

template <js::AllowGC allowGC, typename CharT>
MOZ_ALWAYS_INLINE JSLinearString* JSLinearString::new_(
    JSContext* cx, js::UniquePtr<CharT[], JS::FreePolicy> chars, size_t length,
    js::gc::InitialHeap heap) {
...
  if (!str->isTenured()) {
...
  } else {
    // This can happen off the main thread for the atoms zone.

the last one might be unrelated to AutoSuppressNurseryCellAlloc, but still looks removable.

or, at least we could make it debug-only, so that the non-debug build doesn't have the branch

Component: JavaScript Engine → JavaScript: GC

Depends on D133618

Blocks: 1803803

I was looking to fix this as well. Based on comments, it sounds like sfink doesn't need for the StructuredClone case.

I am able to refactor FillWithRepresentatives to simply pass gc::InitialHeap to have the same effect as existing code.

Assignee: arai.unmht → tcampbell

Use the gc::InitialHeap parameters for string allocation functions instead to
guide strings as nursery vs tenured. The AutoSuppressNurseryCellAlloc mechanism
adds complexity to the GC that should probably be removed.

There shouldn't be any GC allocations any more. This looks like an minor
oversight that snuck in during a rebase.

Depends on D164299

Add an internal API to be able to specify the gc::InitialHeap instead.

Depends on D164300

This lets us remove some code from the various object and string allocation
paths.

Depends on D164301

Pushed by tcampbell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2f2a278c67a6 Avoid AutoSuppressNurseryCellAlloc in JSString::fillWithRepresentatives. r=sfink https://hg.mozilla.org/integration/autoland/rev/8baadad13803 Avoid AutoSuppressNurseryCellAlloc in off-thread delazification. r=nbp https://hg.mozilla.org/integration/autoland/rev/fa48ad694a00 Avoid AutoSuppressNurseryCellAlloc in testGCHeapBarriers. r=sfink https://hg.mozilla.org/integration/autoland/rev/099904436a20 Remove unused AutoSuppressNurseryCellAlloc. r=sfink
Whiteboard: [sp3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: