Closed Bug 461549 Opened 16 years ago Closed 16 years ago

Traceable print and shapeOf functions for js shell

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch v1 (obsolete) — Splinter Review
I found them useful for debugging bug 456384 (v8-richards); YMMV.
Attachment #344652 - Flags: review?(mrbkap)
Comment on attachment 344652 [details] [diff] [review]
v1

>diff --git a/js/src/js.cpp b/js/src/js.cpp
>+static jsval
>+Print_tn(JSContext *cx, JSString *str)

This needs to be FASTCALL, right?

>+static JSBool
>+ShapeOf(JSContext *cx, uintN argc, jsval *vp)
>+{
...
>+    JSBool ok = JS_NewNumberValue(cx, ShapeOf_tn(JSVAL_TO_OBJECT(v)), &v);
>+    if (ok)
>+        JS_SET_RVAL(cx, vp, v);
>     return ok;

If we wanted to assume that we knew what's going on here (which we do), then this could just be:

  return JS_NewNumberValue(cx, ShapeOf_tn(JSVAL_TO_OBJECT(f)), vp);

but that's your call. Holding off on stamping because of the FASTCALL thing.
Attached patch v2Splinter Review
OK, I'll take that.  We're already breaking abstractions here, might as well be thorough.

$ interdiff shapeOf-v1.patch shapeOf-v2.patch 
diff -u b/js/src/js.cpp b/js/src/js.cpp
--- b/js/src/js.cpp
+++ b/js/src/js.cpp
@@ -760,7 +760,7 @@
     return JS_TRUE;
 }
 
-static jsval
+static jsval JS_FASTCALL
 Print_tn(JSContext *cx, JSString *str)
 {
     char *bytes = JS_EncodeString(cx, str);
@@ -2570,10 +2570,7 @@
         JS_ReportError(cx, "shapeOf: object expected");
         return JS_FALSE;
     }
-    JSBool ok = JS_NewNumberValue(cx, ShapeOf_tn(JSVAL_TO_OBJECT(v)), &v);
-    if (ok)
-        JS_SET_RVAL(cx, vp, v);
-    return ok;
+    return JS_NewNumberValue(cx, ShapeOf_tn(JSVAL_TO_OBJECT(v)), vp);
 }
 
 #ifdef JS_THREADSAFE
Assignee: general → jorendorff
Attachment #344652 - Attachment is obsolete: true
Attachment #344666 - Flags: review?(mrbkap)
Attachment #344652 - Flags: review?(mrbkap)
Attachment #344666 - Flags: review?(mrbkap) → review+
Please use "fflush(gOutFile);" in Print_tn to be consistent with Print.  See bug 423042.
http://hg.mozilla.org/tracemonkey/rev/70955fd0d1ee

I added a call to fflush - sorry I missed that.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Flags: in-testsuite-
Flags: in-litmus-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: