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

RESOLVED FIXED in mozilla1.9beta4

Status

()

Core
JavaScript Engine
RESOLVED FIXED
10 years ago
10 years ago

People

(Reporter: dbaron, Assigned: dbaron)

Tracking

Trunk
mozilla1.9beta4
Points:
---
Bug Flags:
in-testsuite -
in-litmus -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

10 years ago
Created attachment 303766 [details] [diff] [review]
patch

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 1

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

Comment 2

10 years ago
Created attachment 303768 [details] [diff] [review]
patch

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)
(Assignee)

Comment 3

10 years ago
Checked in to trunk, 2008-02-18 22:19 -0800.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9beta4

Updated

10 years ago
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.