Closed Bug 1148214 Opened 10 years ago Closed 10 years ago

Encapsulate AllocKind range checks in a few functions

Categories

(Core :: JavaScript: GC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: ehoogeveen, Assigned: ehoogeveen)

References

Details

Attachments

(1 file, 1 obsolete file)

With all the range-based for loops in place we barely use specific AllocKinds directly anymore except to set a variable or pass into a function. The notable exceptions to this are the various assertions and other range checks we have scattered around to ensure that we're not holding on to some invalid AllocKind.
I went with IsValidAllocKind() for the common check of |< AllocKind::LIMIT|, and IsAllocKind() for the less common |<= AllocKind::LIMIT|. AllocKind::LIMIT is obviously a 'valid' AllocKind in some sense, but where we allow it at all, we use it to mean 'not allocated' or 'not initialized'. I put IsValidAllocKind() higher up in Heap.h so people will hopefully see it first and consider which variant they want. As for the implementation, I chose to go with >= and <= everywhere for consistency, and added back the |>= AllocKind::FIRST| and |>= AllocKind::OBJECT0| parts. Now that the underlying type of AllocKind is |int| again, it makes sense to check for negative values.
Attachment #8584185 - Flags: review?(terrence)
This only depends on bug 1146662 in that it touches the same code, and has to land after that bug. I did change the assertions in SomeAllocKinds() a bit - checking |first| to make sure it isn't negative, and removing the |first <= limit| check since MakeEnumeratedRange already has an assertion for that.
Depends on: 1146662
Comment on attachment 8584185 [details] [diff] [review] Replace manual AllocKind range checks with a few centralized functions. Review of attachment 8584185 [details] [diff] [review]: ----------------------------------------------------------------- Very nice!
Attachment #8584185 - Flags: review?(terrence) → review+
Keywords: checkin-needed
Carrying forward r=terrence. The mass SM restyle meant this needed some rebasing.
Attachment #8584185 - Attachment is obsolete: true
Attachment #8585047 - Flags: review+
Attachment #8585047 - Attachment is obsolete: true
Comment on attachment 8584185 [details] [diff] [review] Replace manual AllocKind range checks with a few centralized functions. The SM restyle got backed out.
Attachment #8584185 - Attachment is obsolete: false
Thanks for landing the right one for me, Ryan!
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: