Closed Bug 723517 Opened 8 years ago Closed 8 years ago
Drop cx argument from JS
_Get Class(cx, obj)
Currently we declare JS_GetClass in jsapi.cpp as: #ifdef JS_THREADSAFE extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSContext *cx, JSObject *obj); #define JS_GET_CLASS(cx,obj) JS_GetClass(cx, obj) #else extern JS_PUBLIC_API(JSClass *) JS_GetClass(JSObject *obj); #define JS_GET_CLASS(cx,obj) JS_GetClass(obj) #endif The reason for the cx argument under is JS_THREADSAFE is that when JS_THREADSAFE were introduced to the JS engine, JSObject did not have fixed slots. So the class pointer were stored in the dynamic slots. However, with thread-shared objects, the slot array could have been reallocated when accessing the object. So it was necessary to synchronize the access to the slot array using the request machinery and the cx argument allowed for that. I suppose the cx argument should have been removed from JS_GetClass right after introduction of fat objects, but is better late then never.
Agreed. We have also stopped enforcing strict source compatibility (as long as there is an obvious transition path), so I'd be in favor of removing the JS_GET_CLASS macro altogether.
The patch drops the cx parameter from JS_GetClass and removes JS_GET_CLASS macro. Besides mechanical renaming JS_GET_CLASS into JS_GetClass the patch also propagated removal of the cx argument from the JS_GetClass callers when JS_GET_CLASS was the sole reason to pass the cx.
Attachment #594306 - Flags: review?(luke)
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
We need to update the documentation that JS_GET_CLASS(JSContext *cx, JSObject *obj) was removed and the code should call JS_GetClass(JSObject *obj) instead.
By mistake I landed the patch for the bug 724310 with the commit message that refers to this bug.
I split JS_GET_CLASS docs into that and one for the method, and I updated both to the current trunk state, also updating links to them to use JS_GetClass. https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_GET_CLASS https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_GetClass The JSAPI reference overview now marks the macro as obsolete, and it links to both the macro and the method for completeness and backwards-usability. Also, the 1.8.8 release notes mention that JS_GetClass's signature changed and that JS_GET_CLASS was removed.
Summary: Drop cx argumrent from JS_GetClass(cx, obj) → Drop cx argument from JS_GetClass(cx, obj)
You need to log in before you can comment on or make changes to this bug.