Closed Bug 417972 Opened 13 years ago Closed 13 years ago

JS_PrintTraceThingInfo prints first slot as private when !(clasp->flags & JSCLASS_HAS_PRIVATE)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9beta4

People

(Reporter: dbaron, Assigned: dbaron)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
I got a bit confused in bug 417949 comment 8 because JS_PrintTraceThingInfo prints something as though it's the object's private even when JSCLASS_HAS_PRIVATE is not set.  In that case, what's there is just the first slot.

This patch makes it print "<no private>" instead.
Attachment #303766 - Flags: review?(igor)
Comment on attachment 303766 [details] [diff] [review]
patch

>In JS_PrintTraceThingInfo, only print the contents of JSSLOT_PRIVATE if it represents the class's private rather than the first slot.
>
>diff --git a/js/src/jsapi.c b/js/src/jsapi.c
>--- a/js/src/jsapi.c
>+++ b/js/src/jsapi.c
>@@ -2006,12 +2006,17 @@ JS_PrintTraceThingInfo(char *buf, size_t
>           case JSTRACE_OBJECT:
>           {
>             JSObject  *obj = (JSObject *)thing;
>-            jsval     privateValue = STOBJ_GET_SLOT(obj, JSSLOT_PRIVATE);
>-            void      *privateThing = JSVAL_IS_VOID(privateValue)
>-                                      ? NULL
>-                                      : JSVAL_TO_PRIVATE(privateValue);
>-
>-            JS_snprintf(buf, bufsize, "%p", privateThing);
>+            JSClass *clasp = STOBJ_GET_CLASS(obj);
>+            if (clasp->flags & JSCLASS_HAS_PRIVATE) {
>+              jsval     privateValue = STOBJ_GET_SLOT(obj, JSSLOT_PRIVATE);

Nit: the indent level in SpiderMonkey is 4. It is 2 only after a case or label. r+ with that fixed.
Attached patch patchSplinter Review
er, right, thanks.  That's what I get for being in the middle of a case statement.
Attachment #303766 - Attachment is obsolete: true
Attachment #303768 - Flags: review+
Attachment #303766 - Flags: review?(igor)
Checked in to trunk, 2008-02-18 22:19 -0800.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9beta4
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.