Drop cx argument from JS_GetClass(cx, obj)

RESOLVED FIXED in mozilla13

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Igor Bukanov, Assigned: Igor Bukanov)

Tracking

({dev-doc-complete})

unspecified
mozilla13
dev-doc-complete
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
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.

Comment 1

6 years ago
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.
(Assignee)

Comment 2

6 years ago
Created attachment 594306 [details] [diff] [review]
v1

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)

Updated

6 years ago
Attachment #594306 - Flags: review?(luke) → review+
(Assignee)

Comment 3

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/948fe2e7f1d5
https://hg.mozilla.org/mozilla-central/rev/948fe2e7f1d5
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
(Assignee)

Comment 5

6 years ago
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.
Keywords: dev-doc-needed
(Assignee)

Comment 6

6 years ago
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.
Keywords: dev-doc-needed → dev-doc-complete
OS: Linux → All
Hardware: x86_64 → All
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.