Bug 487413 - Delete unnecessary fast natives in js shell. r=gal.
authorJason Orendorff <jorendorff@mozilla.com>
Sat, 18 Apr 2009 14:14:39 -0400
changeset 24901 5e44f0ccda9a1b7b67e381183368312a82f45253
parent 24900 145b1c8acb86dd3d18741639851b0634a070de4a
child 24902 9dca035160fc8864ab45a073478e7c1e939b7f65
push id1267
push userrsayre@mozilla.com
push dateSun, 19 Apr 2009 02:47:24 +0000
reviewersgal
bugs487413
milestone1.9.1b4pre
Bug 487413 - Delete unnecessary fast natives in js shell. r=gal.
js/src/js.cpp
--- a/js/src/js.cpp
+++ b/js/src/js.cpp
@@ -946,32 +946,16 @@ ReadLine(JSContext *cx, uintN argc, jsva
         JS_free(cx, buf);
         return JS_FALSE;
     }
 
     *vp = STRING_TO_JSVAL(str);
     return JS_TRUE;
 }
 
-#ifdef JS_TRACER
-static jsval JS_FASTCALL
-Print_tn(JSContext *cx, JSString *str)
-{
-    char *bytes = JS_EncodeString(cx, str);
-    if (!bytes) {
-        cx->builtinStatus |= JSBUILTIN_ERROR;
-        return JSVAL_VOID;
-    }
-    fprintf(gOutFile, "%s\n", bytes);
-    JS_free(cx, bytes);
-    fflush(gOutFile);
-    return JSVAL_VOID;
-}
-#endif
-
 static JSBool
 Print(JSContext *cx, uintN argc, jsval *vp)
 {
     jsval *argv;
     uintN i;
     JSString *str;
     char *bytes;
 
@@ -1039,24 +1023,16 @@ AssertEq(JSContext *cx, uintN argc, jsva
         JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_ASSERT_EQ_FAILED,
                              actual, expected);
         return JS_FALSE;
     }
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
-#ifdef JS_TRACER
-static jsval JS_FASTCALL
-AssertEq_tn(JSContext *cx, jsval v1, jsval v2)
-{
-    return (js_StrictlyEqual(cx, v1, v2)) ? JSVAL_VOID : JSVAL_ERROR_COOKIE;
-}
-#endif
-
 static JSBool
 GC(JSContext *cx, uintN argc, jsval *vp)
 {
     JSRuntime *rt;
     uint32 preBytes;
 
     rt = cx->runtime;
     preBytes = rt->gcBytes;
@@ -2863,35 +2839,34 @@ EvalInContext(JSContext *cx, JSObject *o
 out:
     JS_EndRequest(scx);
     WITH_LOCKED_CONTEXT_LIST(
         JS_DestroyContextNoGC(scx)
     );
     return ok;
 }
 
-static int32 JS_FASTCALL
-ShapeOf_tn(JSObject *obj)
-{
-    if (!obj)
-        return 0;
-    if (!OBJ_IS_NATIVE(obj))
-        return -1;
-    return OBJ_SHAPE(obj);
-}
-
 static JSBool
 ShapeOf(JSContext *cx, uintN argc, jsval *vp)
 {
     jsval v = JS_ARGV(cx, vp)[0];
     if (!JSVAL_IS_OBJECT(v)) {
         JS_ReportError(cx, "shapeOf: object expected");
         return JS_FALSE;
     }
-    return JS_NewNumberValue(cx, ShapeOf_tn(JSVAL_TO_OBJECT(v)), vp);
+    JSObject *obj = JSVAL_TO_OBJECT(v);
+    if (!obj) {
+        *vp = JSVAL_ZERO;
+        return JS_TRUE;
+    }
+    if (!OBJ_IS_NATIVE(obj)) {
+        *vp = INT_TO_JSVAL(-1);
+        return JS_TRUE;
+    }
+    return JS_NewNumberValue(cx, OBJ_SHAPE(obj), vp);
 }
 
 #ifdef JS_THREADSAFE
 
 /*
  * Check that t1 comes strictly before t2. The function correctly deals with
  * PRIntervalTime wrap-around between t2 and t1 assuming that t2 and t1 stays
  * within INT32_MAX from each other. We use MAX_TIMEOUT_INTERVAL to enforce
@@ -3423,20 +3398,16 @@ Elapsed(JSContext *cx, uintN argc, jsval
         if (data)
             d = js_IntervalNow() - data->startTime;
         return JS_NewNumberValue(cx, d, vp);
     }
     JS_ReportError(cx, "Wrong number of arguments");
     return JS_FALSE;
 }
 
-JS_DEFINE_TRCINFO_1(AssertEq, (3, (static, JSVAL_RETRY, AssertEq_tn, CONTEXT, JSVAL, JSVAL, 0, 0)))
-JS_DEFINE_TRCINFO_1(Print, (2, (static, JSVAL_FAIL, Print_tn, CONTEXT, STRING, 0, 0)))
-JS_DEFINE_TRCINFO_1(ShapeOf, (1, (static, INT32, ShapeOf_tn, OBJECT, 0, 0)))
-
 #ifdef XP_UNIX
 
 #include <fcntl.h>
 #include <sys/stat.h>
 
 /*
  * Returns a JS_malloc'd string (that the caller needs to JS_free)
  * containing the directory (non-leaf) part of |from| prepended to |leaf|.
@@ -3557,20 +3528,20 @@ Snarf(JSContext *cx, JSObject *obj, uint
 }
 
 /* We use a mix of JS_FS and JS_FN to test both kinds of natives. */
 static JSFunctionSpec shell_functions[] = {
     JS_FS("version",        Version,        0,0,0),
     JS_FS("options",        Options,        0,0,0),
     JS_FS("load",           Load,           1,0,0),
     JS_FN("readline",       ReadLine,       0,0),
-    JS_TN("print",          Print,          0,0, Print_trcinfo),
+    JS_FN("print",          Print,          0,0),
     JS_FS("help",           Help,           0,0,0),
     JS_FS("quit",           Quit,           0,0,0),
-    JS_TN("assertEq",       AssertEq,       2,0, AssertEq_trcinfo),
+    JS_FN("assertEq",       AssertEq,       2,0),
     JS_FN("gc",             GC,             0,0),
     JS_FN("gcparam",        GCParameter,    2,0),
     JS_FN("countHeap",      CountHeap,      0,0),
 #ifdef JS_GC_ZEAL
     JS_FN("gczeal",         GCZeal,         1,0),
 #endif
     JS_FS("trap",           Trap,           3,0,0),
     JS_FS("untrap",         Untrap,         2,0,0),
@@ -3596,17 +3567,17 @@ static JSFunctionSpec shell_functions[] 
     JS_FS("clear",          Clear,          0,0,0),
     JS_FN("intern",         Intern,         1,0),
     JS_FS("clone",          Clone,          1,0,0),
     JS_FS("seal",           Seal,           1,0,1),
     JS_FN("getpda",         GetPDA,         1,0),
     JS_FN("getslx",         GetSLX,         1,0),
     JS_FN("toint32",        ToInt32,        1,0),
     JS_FS("evalcx",         EvalInContext,  1,0,0),
-    JS_TN("shapeOf",        ShapeOf,        1,0, ShapeOf_trcinfo),
+    JS_FN("shapeOf",        ShapeOf,        1,0),
 #ifdef MOZ_SHARK
     JS_FS("startShark",     js_StartShark,      0,0,0),
     JS_FS("stopShark",      js_StopShark,       0,0,0),
     JS_FS("connectShark",   js_ConnectShark,    0,0,0),
     JS_FS("disconnectShark",js_DisconnectShark, 0,0,0),
 #endif
 #ifdef MOZ_CALLGRIND
     JS_FS("startCallgrind", js_StartCallgrind,  0,0,0),