The default bug view has changed. See this FAQ.

GC: ensure there are no implicit post barriers in a Vector

RESOLVED FIXED in mozilla14

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: terrence, Assigned: terrence)

Tracking

Trunk
mozilla14
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
Created attachment 613773 [details] [diff] [review]
v0

If we store an implicitly post barriered type in a vector, we will fall over when the vector relocates our storage.  This patch simply asserts that we do not have any.  We still compile with this and grepping for "Vector<Heap" did not turn up any results, so I think we are in the clear with these.  This assertion will ensure that we stay in the clear going forward.
Attachment #613773 - Flags: review?(luke)

Comment 1

5 years ago
Comment on attachment 613773 [details] [diff] [review]
v0

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

::: js/public/Vector.h
@@ +284,5 @@
>      Vector &operator=(const Vector &) MOZ_DELETE;
>  
> +    void checkStaticInvarients() {
> +        JS_STATIC_ASSERT(!tl::IsPostBarrieredType<T>::result);
> +    }

I usually make these things 'static'

@@ +534,5 @@
>  #ifdef DEBUG
>    , mReserved(0), entered(false)
>  #endif
> +{
> +    checkStaticInvarients();

I don't think you need to call it to get the static checks.
Attachment #613773 - Flags: review?(luke) → review+
(Assignee)

Comment 2

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/a43eb4a2d2fd

With review comments _not_ applied, as per our IRC conversation.
Assignee: general → terrence
Status: NEW → ASSIGNED
(Assignee)

Comment 3

5 years ago
And backed out in:

https://hg.mozilla.org/integration/mozilla-inbound/rev/4e05bd6470c8

Old and busted gcc says: "error: default template arguments may not be used in function templates".
Actually gcc's right about that.  You have to have a pointless <> when calling a templatized function where all the template arguments are defaulted, in C++98.  (C++11 allows you to omit the <> when calling a function using entirely default template arguments.)  Clang should be warning/erroring on the same thing, not sure why it wouldn't be here.

Oh, and it's "invariants", not "invarients".
Er, wait, that first paragraph of comment 4 is not actually correct, or at least I'm not sure it is as regards the situation here -- ignore it.
(Assignee)

Comment 6

5 years ago
Created attachment 614230 [details] [diff] [review]
v1: Carrying review forward, since Luke gave me the working solution. :-)

Using tl::StaticAssert works much better, and is cleaner to boot.
Attachment #613773 - Attachment is obsolete: true
Attachment #614230 - Flags: review+
(Assignee)

Comment 7

5 years ago
https://tbpl.mozilla.org/?tree=Mozilla-Inbound&rev=380e6f8bd681
https://hg.mozilla.org/mozilla-central/rev/380e6f8bd681
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla14
You need to log in before you can comment on or make changes to this bug.