Closed Bug 884410 Opened 12 years ago Closed 11 years ago

GC: Handlify the JSAPI

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: terrence, Assigned: evilpies)

References

Details

(Whiteboard: [js:t])

Attachments

(10 files)

I've been doing these piecemeal while building other things and will be attaching pieces as I create them. So far they have been trivial. Anyone that wants to pitch in and handlify a few functions would be more than welcome.
Attachment #764240 - Flags: review?(jcoppeard)
Attachment #764242 - Flags: review?(jcoppeard)
Attachment #764243 - Flags: review?(jcoppeard)
The browser does not use this and I don't think we want to expose such functionality anyway, even in the friend api.
Attachment #764246 - Flags: superreview?(luke)
Attachment #764246 - Flags: review?(jwalden+bmo)
Comment on attachment 764240 [details] [diff] [review] TransplantObject*; v0 Review of attachment 764240 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/base/nsGlobalWindow.cpp @@ +2395,5 @@ > } else { > JS::Rooted<JSObject*> global(cx, > xpc_UnmarkGrayObject(newInnerWindow->mJSObject)); > + JS::Rooted<JSObject*> outerObject(cx, > + NewOuterWindowProxy(cx, global, thisChrome)); You'll want a dom peer as usual ::: js/src/jsapi.h @@ +2012,4 @@ > > extern JS_FRIEND_API(JSObject *) > js_TransplantObjectWithWrapper(JSContext *cx, > + JS::HandleObject origobj, I thought we just decided over in bug 884371 that we'd use JS::Handle<JSObject*> in jsapi.h?
Comment on attachment 764242 [details] [diff] [review] ResolveStandardClass; v0 Review of attachment 764242 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/xbl/src/nsXBLDocumentInfo.cpp @@ +162,5 @@ > NS_RELEASE(nativeThis); > } > > static JSBool > +nsXBLDocGlobalObject_resolve(JSContext *cx, JS::HandleObject obj, JS::HandleId id) Conflicts with bug 884371, and doesn't seem necessary?
(In reply to :Ms2ger from comment #5) > ::: content/xbl/src/nsXBLDocumentInfo.cpp > > static JSBool > > +nsXBLDocGlobalObject_resolve(JSContext *cx, JS::HandleObject obj, JS::HandleId id) > > Conflicts with bug 884371, and doesn't seem necessary? That bug seemed to only be about MutableHandleValue. Besides, they will be trivial to merge and I'd rather over-fix than miss some. (In reply to :Ms2ger from comment #4) > ::: dom/base/nsGlobalWindow.cpp > @@ +2395,5 @@ > > } else { > > JS::Rooted<JSObject*> global(cx, > > xpc_UnmarkGrayObject(newInnerWindow->mJSObject)); > > + JS::Rooted<JSObject*> outerObject(cx, > > + NewOuterWindowProxy(cx, global, thisChrome)); > > You'll want a dom peer as usual For something this trivial? > ::: js/src/jsapi.h > @@ +2012,4 @@ > > > > extern JS_FRIEND_API(JSObject *) > > js_TransplantObjectWithWrapper(JSContext *cx, > > + JS::HandleObject origobj, > > I thought we just decided over in bug 884371 that we'd use > JS::Handle<JSObject*> in jsapi.h? Well, JSAPI is technically in JS. There is a fair argument to be made that the API should look how we expect users of the API to look, but we haven't really had that discussion yet.
Attachment #764246 - Flags: superreview?(luke) → superreview+
Comment on attachment 764246 [details] [diff] [review] REMOVAL EnumerateResolvedStandardClasses; v0 Review of attachment 764246 [details] [diff] [review]: ----------------------------------------------------------------- \o/
Attachment #764246 - Flags: review?(jwalden+bmo) → review+
Attachment #764240 - Flags: review?(jcoppeard) → review+
Attachment #764242 - Flags: review?(jcoppeard) → review+
Comment on attachment 764243 [details] [diff] [review] EnumerateStandardClasses; v0 Review of attachment 764243 [details] [diff] [review]: ----------------------------------------------------------------- All looks good. We should decide on a style for jsapi.h though.
Attachment #764243 - Flags: review?(jcoppeard) → review+
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Not sure if this needs addional reviewers.
Attachment #765256 - Flags: review?(terrence)
This is going to see quite some more activity
Status: REOPENED → NEW
Whiteboard: [leave open][js:t]
All our rooting work really shows.
Attachment #765299 - Flags: review?(terrence)
Comment on attachment 765256 [details] [diff] [review] JS_GetPrototype v0 Review of attachment 765256 [details] [diff] [review]: ----------------------------------------------------------------- \o/ Thanks! r=me ::: js/src/jsapi.cpp @@ +3329,5 @@ > return obj->getPrivate(); > } > > JS_PUBLIC_API(JSBool) > +JS_GetPrototype(JSContext *cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JSObject*> protop) As below. ::: js/src/jsapi.h @@ +3099,5 @@ > JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, > jsval *argv); > > extern JS_PUBLIC_API(JSBool) > +JS_GetPrototype(JSContext *cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JSObject*> protop); Lets stick with the typedefs for now. I'm not sure how this is going to shake out eventually, but lets at least remain consistent until we get a clear concensus.
Attachment #765256 - Flags: review?(terrence) → review+
Comment on attachment 765299 [details] [diff] [review] JS_SetPrototype v0 Review of attachment 765299 [details] [diff] [review]: ----------------------------------------------------------------- r=me ::: js/src/jsapi.h @@ +3102,5 @@ > extern JS_PUBLIC_API(JSBool) > JS_GetPrototype(JSContext *cx, JS::Handle<JSObject*> obj, JS::MutableHandle<JSObject*> protop); > > extern JS_PUBLIC_API(JSBool) > +JS_SetPrototype(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<JSObject*> proto); As per the prior patch, lets stick with typedefs for now.
Attachment #765299 - Flags: review?(terrence) → review+
Oh damn, I forgot about these patches.
It seems we're going with external style in jsapi.h, so ignore my review comments.
Blocks: 795030
No longer blocks: 773686
Removes JS_ValueToECMAInt32 and replaces it by ToInt32, which already used handles. I had a patch for the uint32 version, but I screwed something up and can't find the changes anymore.
Attachment #788955 - Flags: review?(terrence)
Comment on attachment 788955 [details] [diff] [review] Remove JS_ValueToECMAInt32 Review of attachment 788955 [details] [diff] [review]: ----------------------------------------------------------------- The handlification changes look fine to me. I do, however, vaguely recall there being some extensive discussion about the naming of the method you are removing: a difference between machine int32 and JS's "Int32" that we wanted to distinguis in the API. Please ask around (guessing Waldo, but I don't remember exactly) or make a search to ensure that this renaming is actually okay.
Attachment #788955 - Flags: review?(terrence)
This function was just a wrapper around the ToInt32. ToInt32 also appears in the ES spec. If we still expose some non spec-conform version we should give that one an ugly name.
Comment on attachment 788955 [details] [diff] [review] Remove JS_ValueToECMAInt32 Review of attachment 788955 [details] [diff] [review]: ----------------------------------------------------------------- There used to be JS_ValueToInt32 and JS_ValueToECMAInt32 both. The former did weird clamping stuff, I don't remember. The latter implemented, exactly, the spec's ToInt32 method. Since JS::ToInt32 does exactly the spec's method, this looks fine on all those points. I'm fairly sure that's the distinction being mooted in comment 21.
Comment on attachment 788955 [details] [diff] [review] Remove JS_ValueToECMAInt32 Review of attachment 788955 [details] [diff] [review]: ----------------------------------------------------------------- Excellent! In that case, r=me.
Attachment #788955 - Flags: review+
Not try test yet, but compiles. Test some of the dumpHeap functionality.
Attachment #804206 - Flags: review?(terrence)
Comment on attachment 804206 [details] [diff] [review] Remove JS_ValueToECMAUint32 Review of attachment 804206 [details] [diff] [review]: ----------------------------------------------------------------- In future, please try to split stuff like this up to make reviewing less context-switchy. It is a righteous cleanup, however, so I won't complain too much. :-) r=me, but I would like Andrew to take a look at the DumpHeap changes too: he is DumpHeap's owner after all. ::: ipc/testshell/XPCShellEnvironment.cpp @@ +327,3 @@ > if (!fileName) { > dumpFile = stdout; > } else { ditto ::: js/src/shell/js.cpp @@ +2205,5 @@ > + startThing.isUndefined() ? nullptr : startThing.toGCThing(), > + startThing.isUndefined() ? JSTRACE_OBJECT : startThing.get().gcKind(), > + thingToFind.isUndefined() ? nullptr : thingToFind.toGCThing(), > + maxDepth, > + thingToIgnore.isUndefined() ? nullptr : thingToIgnore.toGCThing()); Has the shell finally gotten the right C++0x flags to compile everywhere with nullptr? I thought there were still some platforms that require an include to get the shim? ::: js/xpconnect/shell/xpcshell.cpp @@ +534,1 @@ > } else { FILE *dumpFile = stdout; if (fileName) { dumpFile = fopen(...); .... }
Attachment #804206 - Flags: review?(terrence)
Attachment #804206 - Flags: review?(continuation)
Attachment #804206 - Flags: review+
I can get to it in a day or two, or Bill can probably take a look.
I would suggest deleting these two implementations of DumpHeap. Would that be okay with you, Andrew?
Oh, that's DumpHeap, not DumpHeapComplete, I don't know much about that. I think the idea is that you can use it from the gdb and get somewhat useful results from it. But yeah, I don't know if anybody uses it from xpcshell or the shell like that, so it is probably okay to get rid of.
Attachment #804206 - Flags: review?(continuation)
Attachment #804206 - Flags: feedback+
Attached patch JS_WrapObjectSplinter Review
Attachment #816704 - Flags: review?(terrence)
Comment on attachment 816704 [details] [diff] [review] JS_WrapObject Review of attachment 816704 [details] [diff] [review]: ----------------------------------------------------------------- Awesomesauce, deep fried and dipped in more awesomesauce. r=me
Attachment #816704 - Flags: review?(terrence) → review+
Just for the record, this landed with an incorrect bug number (8844195). https://hg.mozilla.org/mozilla-central/rev/5126b48adf91
How in gods name did I end up with that number? :( Sorry for that.
Not try approved, but I just think this okay.
Attachment #817851 - Flags: review?(terrence)
Comment on attachment 817851 [details] [diff] [review] Remove JS_ValueToNumber Review of attachment 817851 [details] [diff] [review]: ----------------------------------------------------------------- Looks good to me with one dev-doc-needed. I'd definitely try-server this before landing though. ::: js/src/jsapi.h @@ -1041,5 @@ > extern JS_PUBLIC_API(JSString *) > JS_ValueToSource(JSContext *cx, jsval v); > > -extern JS_PUBLIC_API(bool) > -JS_ValueToNumber(JSContext *cx, jsval v, double *dp); It looks like JS::ToNumber isn't documented in MDN. Could you add that (maybe just copy the JS_ValueToNumber article), deprecate JS_ValueToNumber and link it to JS::ToNumber.
Attachment #817851 - Flags: review?(terrence) → review+
Flags: in-testsuite-
Blocks: 773686
Keywords: dev-doc-needed
Okay let's close this one.
Status: NEW → RESOLVED
Closed: 12 years ago11 years ago
Resolution: --- → FIXED
Whiteboard: [leave open][js:t] → [js:t]
Assignee: general → evilpies
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: