Bug 639420 - Speed up the scanner ten ways, part 7. r=brendan.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 16 Mar 2011 15:18:12 -0700
changeset 64310 04463409002b0a9209e8a3e5ba830a063e368130
parent 64309 e5e7641a838ea9c2aa0cdf7396f62cd5758413ab
child 64311 3d399dda0723c0f1fa8add8617cd33509db4ec1f
push idunknown
push userunknown
push dateunknown
reviewersbrendan
bugs639420
milestone2.0b13pre
Bug 639420 - Speed up the scanner ten ways, part 7. r=brendan.
js/src/jsstr.cpp
js/src/jsstr.h
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -5657,16 +5657,65 @@ const bool js_alnum[] = {
 /*  7 */ true, true, true, true, true, true, true, true, true, true,
 /*  8 */ true, true, true, true, true, true, true, true, true, true,
 /*  9 */ true, ____, ____, ____, ____, true, ____, true, true, true,
 /* 10 */ true, true, true, true, true, true, true, true, true, true,
 /* 11 */ true, true, true, true, true, true, true, true, true, true,
 /* 12 */ true, true, true, ____, ____, ____, ____, ____
 };
 
+/*
+ * Identifier start chars:
+ * -      36:    $
+ * -  65..90: A..Z
+ * -      95:    _
+ * - 97..122: a..z
+ */
+const bool js_isidstart[] = {
+/*       0     1     2     3     4     5     6     7     8     9  */
+/*  0 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  1 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  2 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  3 */ ____, ____, ____, ____, ____, ____, true, ____, ____, ____,
+/*  4 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  5 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  6 */ ____, ____, ____, ____, ____, true, true, true, true, true, 
+/*  7 */ true, true, true, true, true, true, true, true, true, true, 
+/*  8 */ true, true, true, true, true, true, true, true, true, true, 
+/*  9 */ true, ____, ____, ____, ____, true, ____, true, true, true, 
+/* 10 */ true, true, true, true, true, true, true, true, true, true, 
+/* 11 */ true, true, true, true, true, true, true, true, true, true, 
+/* 12 */ true, true, true, ____, ____, ____, ____, ____
+};
+
+/*
+ * Identifier chars:
+ * -      36:    $
+ * -  48..57: 0..9
+ * -  65..90: A..Z
+ * -      95:    _
+ * - 97..122: a..z
+ */
+const bool js_isident[] = {
+/*       0     1     2     3     4     5     6     7     8     9  */
+/*  0 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  1 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  2 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
+/*  3 */ ____, ____, ____, ____, ____, ____, true, ____, ____, ____,
+/*  4 */ ____, ____, ____, ____, ____, ____, ____, ____, true, true, 
+/*  5 */ true, true, true, true, true, true, true, true, ____, ____,
+/*  6 */ ____, ____, ____, ____, ____, true, true, true, true, true, 
+/*  7 */ true, true, true, true, true, true, true, true, true, true, 
+/*  8 */ true, true, true, true, true, true, true, true, true, true, 
+/*  9 */ true, ____, ____, ____, ____, true, ____, true, true, true, 
+/* 10 */ true, true, true, true, true, true, true, true, true, true, 
+/* 11 */ true, true, true, true, true, true, true, true, true, true, 
+/* 12 */ true, true, true, ____, ____, ____, ____, ____
+};
+
 /* Whitespace chars: '\t', '\n', '\v', '\f', '\r', ' '. */
 const bool js_isspace[] = {
 /*       0     1     2     3     4     5     6     7     8     9  */
 /*  0 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, true,
 /*  1 */ true, true, true, true, ____, ____, ____, ____, ____, ____,
 /*  2 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
 /*  3 */ ____, ____, true, ____, ____, ____, ____, ____, ____, ____,
 /*  4 */ ____, ____, ____, ____, ____, ____, ____, ____, ____, ____,
--- a/js/src/jsstr.h
+++ b/js/src/jsstr.h
@@ -711,18 +711,34 @@ extern const bool js_alnum[];
 /*
  * This macro performs testing for the regular expression word class \w, which
  * is defined by ECMA-262 15.10.2.6 to be [0-9A-Z_a-z].  If we want a
  * Unicode-friendlier definition of "word", we should rename this macro to
  * something regexp-y.
  */
 #define JS_ISWORD(c)    ((c) < 128 && js_alnum[(c)])
 
-#define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$')
-#define JS_ISIDENT(c)   (JS_ISIDPART(c) || (c) == '_' || (c) == '$')
+extern const bool js_isidstart[];
+extern const bool js_isident[];
+
+static inline bool
+JS_ISIDSTART(int c)
+{
+    unsigned w = c;
+
+    return (w < 128) ? js_isidstart[w] : JS_ISLETTER(c);
+}
+
+static inline bool
+JS_ISIDENT(int c)
+{
+    unsigned w = c;
+
+    return (w < 128) ? js_isident[w] : JS_ISIDPART(c);
+}
 
 #define JS_ISXMLSPACE(c)        ((c) == ' ' || (c) == '\t' || (c) == '\r' ||  \
                                  (c) == '\n')
 #define JS_ISXMLNSSTART(c)      ((JS_CCODE(c) & 0x00000100) || (c) == '_')
 #define JS_ISXMLNS(c)           ((JS_CCODE(c) & 0x00000080) || (c) == '.' ||  \
                                  (c) == '-' || (c) == '_')
 #define JS_ISXMLNAMESTART(c)    (JS_ISXMLNSSTART(c) || (c) == ':')
 #define JS_ISXMLNAME(c)         (JS_ISXMLNS(c) || (c) == ':')