Closed Bug 1335571 Opened 7 years ago Closed 7 years ago

Use template craziness to allow covering more cases with compartment asserts

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: sfink, Assigned: sfink)

Details

Attachments

(1 file)

If we extend the compartment asserts a little more, we can handle things like a properties vector, which is of type MutableHandle<IdVector> aka MutableHandle<GCVector<jsid>>.
The template is a little wonky, since I should probably also be testing whether operator++ exists, but I figure handling begin() and end() is enough of a signal that you intend to support C++ style iteration. Checking whether begin() and end() return the same type is kind of irrelevant; the point is really that they exist.
Attachment #8832251 - Flags: review?(jwalden+bmo)
Comment on attachment 8832251 [details] [diff] [review]
Use template craziness to allow covering more cases with compartment asserts

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

What you "should" use is concepts, but...well...not quite yet.  :-\  Can't wait til a proposal's far enough along that we can start adding macro-ized concepts usage, then for at least one compiler to support it so you can use that one compiler to get that substantial benefit.

::: js/src/jscntxtinlines.h
@@ +108,5 @@
> +        mozilla::IsSame<
> +            decltype(((Container*)nullptr)->begin()),
> +            decltype(((Container*)nullptr)->end())
> +        >::value,
> +        void

void is the default, so you can omit the extra parameter.

@@ +110,5 @@
> +            decltype(((Container*)nullptr)->end())
> +        >::value,
> +        void
> +    >::Type
> +    check(Container& container) {

I think you can make |Container| const.
Attachment #8832251 - Flags: review?(jwalden+bmo) → review+
Pushed by sfink@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ad428bc273fe
Use template craziness to allow covering more cases with compartment asserts, r=Waldo
https://hg.mozilla.org/mozilla-central/rev/ad428bc273fe
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: