Closed
Bug 866432
Opened 12 years ago
Closed 12 years ago
Remove AutoValueRooter and replace it with RootedValue
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: sfink, Assigned: sfink)
Details
Attachments
(2 files)
14.26 KB,
patch
|
terrence
:
review+
sfink
:
checkin+
|
Details | Diff | Splinter Review |
12.30 KB,
patch
|
smaug
:
review+
sfink
:
checkin+
|
Details | Diff | Splinter Review |
AutoValueRooter is dangerous in a moving GC world. A Value protected by an autoValueRooter could still end up on the stack and not get updated. Also, all uses of AutoValueRooter can trivially be replaced with RootedValue right now.
Assignee | ||
Comment 1•12 years ago
|
||
Attachment #742729 -
Flags: review?(terrence)
Assignee | ||
Comment 2•12 years ago
|
||
Basic rooting guide is at https://developer.mozilla.org/en-US/docs/SpiderMonkey/GC_Rooting_Guide
More detailed documentation is in the source, see http://mxr.mozilla.org/mozilla-central/source/js/public/RootingAPI.h
Attachment #742730 -
Flags: review?(benjamin)
Updated•12 years ago
|
Attachment #742730 -
Flags: review?(benjamin) → review?(bugs)
Comment 3•12 years ago
|
||
Comment on attachment 742730 [details] [diff] [review]
Replace AutoValueRooter with JS::Rooted<JS::Value> in gecko
You're using both RootedValue and Rooted<Value>. We really must get rid of one of
those, or at least not expose them both in public JS APIs.
Please use Rooted<Value>
Attachment #742730 -
Flags: review?(bugs) → review+
Comment 4•12 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #3)
> Comment on attachment 742730 [details] [diff] [review]
> Replace AutoValueRooter with JS::Rooted<JS::Value> in gecko
>
> You're using both RootedValue and Rooted<Value>. We really must get rid of
> one of
> those, or at least not expose them both in public JS APIs.
> Please use Rooted<Value>
I agree, I think we should be able to remove RootedValue and the other typedefs from js:: with a bit of work.
Comment 5•12 years ago
|
||
Comment on attachment 742729 [details] [diff] [review]
Remove AutoValueRooter and replace it with RootedValue
Review of attachment 742729 [details] [diff] [review]:
-----------------------------------------------------------------
This is full of win!
::: js/src/ctypes/CTypes.cpp
@@ +4649,4 @@
> return NULL;
>
> + if (propVal.isPrimitive() ||
> + !CType::IsCType(JSVAL_TO_OBJECT(propVal))) {
While you are here, propVal.toObjectOrNull().
@@ +4656,5 @@
>
> // Undefined size or zero size struct members are illegal.
> // (Zero-size arrays are legal as struct members in C++, but libffi will
> // choke on a zero-size struct, so we disallow them.)
> + *typeObj = JSVAL_TO_OBJECT(propVal);
While you are here, propVal.toObjectOrNull().
::: js/src/jsapi.h
@@ -111,5 @@
> */
> ptrdiff_t tag_;
>
> enum {
> - JSVAL = -1, /* js::AutoValueRooter */
\o/
@@ -117,5 @@
> PARSER = -3, /* js::frontend::Parser */
> SHAPEVECTOR = -4, /* js::AutoShapeVector */
> IDARRAY = -6, /* js::AutoIdArray */
> DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */
> - OBJECT = -8, /* js::AutoObjectRooter */
\o/ \o/
::: js/xpconnect/src/XPCConvert.cpp
@@ +1135,5 @@
> }
>
> /********************************/
>
> class AutoExceptionRestorer
We should probably mark this as a stack class.
Attachment #742729 -
Flags: review?(terrence) → review+
Assignee | ||
Comment 6•12 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #3)
> Comment on attachment 742730 [details] [diff] [review]
> Replace AutoValueRooter with JS::Rooted<JS::Value> in gecko
>
> You're using both RootedValue and Rooted<Value>. We really must get rid of
> one of
> those, or at least not expose them both in public JS APIs.
> Please use Rooted<Value>
Argh! I can't believe I did that. You are right, of course.
Assignee | ||
Comment 7•12 years ago
|
||
(In reply to Terrence Cole [:terrence] from comment #5)
> @@ -117,5 @@
> > PARSER = -3, /* js::frontend::Parser */
> > SHAPEVECTOR = -4, /* js::AutoShapeVector */
> > IDARRAY = -6, /* js::AutoIdArray */
> > DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */
> > - OBJECT = -8, /* js::AutoObjectRooter */
>
> \o/ \o/
Sadly, this was just a patch splitting screwup. I have a separate set of patches that I'm working on for this.
Assignee | ||
Updated•12 years ago
|
Attachment #742729 -
Flags: checkin+
Assignee | ||
Updated•12 years ago
|
Attachment #742730 -
Flags: checkin+
Assignee | ||
Comment 8•12 years ago
|
||
Assignee | ||
Comment 9•12 years ago
|
||
Comment 10•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/9fd825f383a6
https://hg.mozilla.org/mozilla-central/rev/354d7c54a270
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Comment 11•12 years ago
|
||
(In reply to Terrence Cole [:terrence] from comment #5)
> Comment on attachment 742729 [details] [diff] [review]
> Remove AutoValueRooter and replace it with RootedValue
>
> Review of attachment 742729 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> This is full of win!
>
> ::: js/src/ctypes/CTypes.cpp
> @@ +4649,4 @@
> > return NULL;
> >
> > + if (propVal.isPrimitive() ||
> > + !CType::IsCType(JSVAL_TO_OBJECT(propVal))) {
>
> While you are here, propVal.toObjectOrNull().
>
> @@ +4656,5 @@
> >
> > // Undefined size or zero size struct members are illegal.
> > // (Zero-size arrays are legal as struct members in C++, but libffi will
> > // choke on a zero-size struct, so we disallow them.)
> > + *typeObj = JSVAL_TO_OBJECT(propVal);
>
> While you are here, propVal.toObjectOrNull().
Why toObjectOrNull()? It can't be null.
You need to log in
before you can comment on or make changes to this bug.
Description
•