Closed Bug 1571008 Opened 4 months ago Closed 3 months ago

Code to select the GC thing alloc kind is confusing

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

When allocating objects we want to use a background alloc kind if possible. We use a pattern like:

  MOZ_ASSERT(gc::IsObjectAllocKind(allocKind));
  if (CanBeFinalizedInBackground(allocKind, group->clasp())) {
    allocKind = GetBackgroundAllocKind(allocKind);
  }

Here CanBeFinalizedInBackground() will return true if allocKind is not a background alloc kind. This is confusing as you might expect it be the other way around. (GetBackgroundAllocKind() will return the background alloc kind corresponding to a foreground alloc kind).

Really there are two concepts here: the kind of GC thing and whether it is background finalized. For objects, both foreground and background finalization are possible but for other GC things there is only one possibility (depending on the thing).

I'm not sure how to fix this entirely but we could start by giving these functions better names or otherwise refactoring this pattern.

This renames a couple of functions to hopefully make their intent clearer add adds comments and assertions.

Assignee: nobody → jcoppeard
Priority: -- → P3
Attachment #9089122 - Attachment description: Bug 1571008 - Make background alloc kind selection less confusing r?sfink → Bug 1571008 - Make background alloc kind selection less confusing r=jandem
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/62533f3df2b6
Make background alloc kind selection less confusing r=jandem
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.