Bug 661770: Avoid call overhead atomizing from js_AtomizeChars. (r=njn)
authorChris Leary <cdleary@mozilla.com>
Fri, 03 Jun 2011 15:36:07 -0700
changeset 71174 eac7f013bacc500836d67c9ea107f714aac7197b
parent 71173 3ab18e7ea3d57983f4e94486067a7a4a4852183b
child 71175 31a757125589931622adc96a217acc30542b4d8b
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs661770
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 661770: Avoid call overhead atomizing from js_AtomizeChars. (r=njn)
js/src/jsatom.cpp
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -454,19 +454,20 @@ enum OwnCharsBehavior
     TakeCharOwnership
 };
 
 /*
  * Callers passing OwnChars have freshly allocated *pchars and thus this
  * memory can be used as a new JSAtom's buffer without copying. When this flag
  * is set, the contract is that callers will free *pchars iff *pchars == NULL.
  */
+JS_ALWAYS_INLINE
 static JSAtom *
-Atomize(JSContext *cx, const jschar **pchars, size_t length,
-        InternBehavior ib, OwnCharsBehavior ocb = CopyChars)
+AtomizeInline(JSContext *cx, const jschar **pchars, size_t length,
+              InternBehavior ib, OwnCharsBehavior ocb = CopyChars)
 {
     const jschar *chars = *pchars;
 
     if (JSAtom *s = JSAtom::lookupStatic(chars, length))
         return s;
 
     AutoLockAtomsCompartment lock(cx);
 
@@ -507,16 +508,23 @@ Atomize(JSContext *cx, const jschar **pc
     if (!atoms.relookupOrAdd(p, lookup, AtomStateEntry(key, ib))) {
         JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report */
         return NULL;
     }
 
     return key->morphAtomizedStringIntoAtom();
 }
 
+static JSAtom *
+Atomize(JSContext *cx, const jschar **pchars, size_t length,
+        InternBehavior ib, OwnCharsBehavior ocb = CopyChars)
+{
+    return AtomizeInline(cx, pchars, length, ib, ocb);
+}
+
 JSAtom *
 js_AtomizeString(JSContext *cx, JSString *str, InternBehavior ib)
 {
     if (str->isAtom()) {
         JSAtom &atom = str->asAtom();
         /* N.B. static atoms are effectively always interned. */
         if (ib != InternAtom || atom.isStaticAtom())
             return &atom;
@@ -590,17 +598,17 @@ js_Atomize(JSContext *cx, const char *by
 JSAtom *
 js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, InternBehavior ib)
 {
     CHECK_REQUEST(cx);
 
     if (!CheckStringLength(cx, length))
         return NULL;
 
-    return Atomize(cx, &chars, length, ib);
+    return AtomizeInline(cx, &chars, length, ib);
 }
 
 JSAtom *
 js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length)
 {
     if (JSAtom *atom = JSAtom::lookupStatic(chars, length))
         return atom;
     AutoLockAtomsCompartment lock(cx);