Closed Bug 808181 Opened 12 years ago Closed 12 years ago

GC: don't allow implicit conversion of Return<T> to T

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19

People

(Reporter: terrence, Assigned: terrence)

References

Details

Attachments

(1 file)

Attached patch v0Splinter Review
Jason thought of a brilliant way for us to get type safety for Return<T> without having to re-root in NoGC scopes: make the getter take an unused ref to the AutoAssertNoGC guard.  Between this and the SafeBool idiom that Jeff showed me this week, Return<T> should be much safer and easier to use, to the point where I don't think we need Unrooted<T> anymore.

The attached patch implements this and fixes the ~60 places /that the compiler found/ that needed to be updated.
Attachment #677880 - Flags: review?(jorendorff)
Comment on attachment 677880 [details] [diff] [review]
v0

Review of attachment 677880 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/gc/Root.h
@@ +490,5 @@
> +     * This is the SafeBool idiom for allowing use of Return<T> as a boolean
> +     * without allowing implicit conversions to any arbitrary integer.
> +     */
> +    operator ConvertibleToBool() const {
> +      return ptr_ ? 1 : NULL;

Might as well do ? 1 : 0;
Comment on attachment 677880 [details] [diff] [review]
v0

Review of attachment 677880 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good.
Attachment #677880 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/mozilla-central/rev/4cee05d5b1ce
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: