Add a builtin for RegExp.test (459766, r=mrbkap).
authorAndreas Gal <gal@mozilla.com>
Mon, 13 Oct 2008 17:39:36 -0700
changeset 20896 3b894cc33338bb920b9225000abd48574043990a
parent 20894 84960b72d2a4d53a9cb65c020f317b8299452ae4
child 20897 4078e3d9318eec25c451f943656a9785ff30d91a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs459766
milestone1.9.1b2pre
Add a builtin for RegExp.test (459766, r=mrbkap).
js/src/jsregexp.cpp
--- a/js/src/jsregexp.cpp
+++ b/js/src/jsregexp.cpp
@@ -46,16 +46,17 @@
 #include <string.h>
 #include <stdarg.h>
 #include "jstypes.h"
 #include "jsarena.h" /* Added by JSIFY */
 #include "jsutil.h" /* Added by JSIFY */
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsatom.h"
+#include "jsbuiltins.h"
 #include "jscntxt.h"
 #include "jsversion.h"
 #include "jsfun.h"
 #include "jsgc.h"
 #include "jsinterp.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsobj.h"
@@ -4268,24 +4269,41 @@ regexp_test(JSContext *cx, uintN argc, j
 {
     if (!regexp_exec_sub(cx, JS_THIS_OBJECT(cx, vp), argc, vp + 2, JS_TRUE, vp))
         return JS_FALSE;
     if (*vp != JSVAL_TRUE)
         *vp = JSVAL_FALSE;
     return JS_TRUE;
 }
 
+#ifdef JS_TRACER
+jsint FASTCALL
+js_Regexp_p_test(JSContext* cx, JSObject* regexp, JSString* str)
+{
+    jsval vp[3] = { JSVAL_NULL, OBJECT_TO_JSVAL(regexp), STRING_TO_JSVAL(str) };
+    if (!regexp_exec_sub(cx, regexp, 1, vp + 2, JS_TRUE, vp))
+        return JSVAL_TO_BOOLEAN(JSVAL_VOID);
+    return *vp == JSVAL_TRUE;
+}
+#endif
+
+JS_DEFINE_CALLINFO_3(BOOL,       Regexp_p_test, CONTEXT, OBJECT, STRING,                     1, 1)
+
+static const JSTraceableNative regexp_test_trcinfo[] = {
+    { regexp_test,           &ci_Regexp_p_test,        "TC", "s",    FAIL_VOID }
+};
+
 static JSFunctionSpec regexp_methods[] = {
 #if JS_HAS_TOSOURCE
     JS_FN(js_toSource_str,  regexp_toString,    0,0),
 #endif
     JS_FN(js_toString_str,  regexp_toString,    0,0),
     JS_FN("compile",        regexp_compile,     2,0),
     JS_FN("exec",           regexp_exec,        1,0),
-    JS_FN("test",           regexp_test,        1,0),
+    JS_TN("test",           regexp_test,        1,0, regexp_test_trcinfo),
     JS_FS_END
 };
 
 static JSBool
 RegExp(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
     if (!(cx->fp->flags & JSFRAME_CONSTRUCTING)) {
         /*