Factor jsscopeinlines.h out, clean up #include order (524267, r=gal/jorendorff).
authorBrendan Eich <brendan@mozilla.org>
Mon, 26 Oct 2009 13:39:39 -0700
changeset 34349 d0602cc15d62b8231afc5144116028b2496652ba
parent 34348 bdfb51f0f9ef48eee7aed5bd30a9b1e946a67c13
child 34350 8de5fbb7e1b4ce1a032dd9184090716bd0e0c82e
push idunknown
push userunknown
push dateunknown
reviewersgal, jorendorff
bugs524267
milestone1.9.3a1pre
Factor jsscopeinlines.h out, clean up #include order (524267, r=gal/jorendorff).
js/src/jsapi.cpp
js/src/jsatominlines.h
js/src/jsbuiltins.cpp
js/src/jsinterp.cpp
js/src/jsobj.cpp
js/src/jsscope.cpp
js/src/jsscope.h
js/src/jsscopeinlines.h
js/src/jsstrinlines.h
js/src/jstracer.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -81,26 +81,27 @@
 #include "jsstr.h"
 #include "jstask.h"
 #include "jstracer.h"
 #include "jsdbgapi.h"
 #include "prmjtime.h"
 #include "jsstaticcheck.h"
 #include "jsvector.h"
 
+#include "jsatominlines.h"
+#include "jsscopeinlines.h"
+
 #if JS_HAS_FILE_OBJECT
 #include "jsfile.h"
 #endif
 
 #if JS_HAS_XML_SUPPORT
 #include "jsxml.h"
 #endif
 
-#include "jsatominlines.h"
-
 #ifdef HAVE_VA_LIST_AS_ARRAY
 #define JS_ADDRESSOF_VA_LIST(ap) ((va_list *)(ap))
 #else
 #define JS_ADDRESSOF_VA_LIST(ap) (&(ap))
 #endif
 
 #if defined(JS_THREADSAFE)
 #define CHECK_REQUEST(cx)                                                   \
--- a/js/src/jsatominlines.h
+++ b/js/src/jsatominlines.h
@@ -32,18 +32,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef jsatom_inlines_h___
-#define jsatom_inlines_h___
+#ifndef jsatominlines_h___
+#define jsatominlines_h___
 
 #include "jsatom.h"
 #include "jsnum.h"
 
 /*
  * Convert v to an atomized string and wrap it as an id.
  */
 inline JSBool
@@ -87,9 +87,9 @@ js_Int32ToId(JSContext* cx, int32 index,
         return JS_TRUE;
     }
     JSString* str = js_NumberToString(cx, index);
     if (!str)
         return JS_FALSE;
     return js_ValueToStringId(cx, STRING_TO_JSVAL(str), id);
 }
 
-#endif /* jsatom_inlines_h___ */
+#endif /* jsatominlines_h___ */
--- a/js/src/jsbuiltins.cpp
+++ b/js/src/jsbuiltins.cpp
@@ -56,16 +56,17 @@
 #include "jsdate.h"
 #include "jsscope.h"
 #include "jsstr.h"
 #include "jsbuiltins.h"
 #include "jstracer.h"
 #include "jsvector.h"
 
 #include "jsatominlines.h"
+#include "jsscopeinlines.h"
 
 using namespace avmplus;
 using namespace nanojit;
 
 extern jsdouble js_NaN;
 
 JS_FRIEND_API(void)
 js_SetTraceableNativeFailed(JSContext *cx)
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -68,29 +68,30 @@
 #include "jsscan.h"
 #include "jsscope.h"
 #include "jsscript.h"
 #include "jsstr.h"
 #include "jsstaticcheck.h"
 #include "jstracer.h"
 #include "jslibmath.h"
 #include "jsvector.h"
+
+#include "jsatominlines.h"
+#include "jsscopeinlines.h"
+#include "jsscriptinlines.h"
 #include "jsstrinlines.h"
 
 #ifdef INCLUDE_MOZILLA_DTRACE
 #include "jsdtracef.h"
 #endif
 
 #if JS_HAS_XML_SUPPORT
 #include "jsxml.h"
 #endif
 
-#include "jsatominlines.h"
-#include "jsscriptinlines.h"
-
 #include "jsautooplen.h"
 
 /* jsinvoke_cpp___ indicates inclusion from jsinvoke.cpp. */
 #if !JS_LONE_INTERPRET ^ defined jsinvoke_cpp___
 
 JS_REQUIRES_STACK JSPropCacheEntry *
 js_FillPropertyCache(JSContext *cx, JSObject *obj,
                      uintN scopeIndex, uintN protoIndex, JSObject *pobj,
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -66,23 +66,25 @@
 #include "jsinterp.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsobj.h"
 #include "jsopcode.h"
 #include "jsparse.h"
 #include "jsscope.h"
 #include "jsscript.h"
-#include "jsscriptinlines.h"
 #include "jsstaticcheck.h"
 #include "jsstdint.h"
 #include "jsstr.h"
 #include "jstracer.h"
 #include "jsdbgapi.h"
 
+#include "jsscopeinlines.h"
+#include "jsscriptinlines.h"
+
 #if JS_HAS_GENERATORS
 #include "jsiter.h"
 #endif
 
 #if JS_HAS_XML_SUPPORT
 #include "jsxml.h"
 #endif
 
--- a/js/src/jsscope.cpp
+++ b/js/src/jsscope.cpp
@@ -56,16 +56,18 @@
 #include "jscntxt.h"
 #include "jsdbgapi.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsscope.h"
 #include "jsstr.h"
 #include "jstracer.h"
 
+#include "jsscopeinlines.h"
+
 uint32
 js_GenerateShape(JSContext *cx, bool gcLocked)
 {
     JSRuntime *rt;
     uint32 shape;
 
     rt = cx->runtime;
     shape = JS_ATOMIC_INCREMENT(&rt->shapeGen);
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -40,17 +40,16 @@
 
 #ifndef jsscope_h___
 #define jsscope_h___
 /*
  * JS symbol tables.
  */
 #include "jstypes.h"
 #include "jslock.h"
-#include "jsfun.h"
 #include "jsobj.h"
 #include "jsprvtd.h"
 #include "jspubtd.h"
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4800)
 #endif
@@ -286,27 +285,27 @@ struct JSScope : public JSObjectMap
     void clear(JSContext *cx);
 
     void extend(JSContext *cx, JSScopeProperty *sprop);
 
     /*
      * Read barrier to clone a joined function object stored as a method.
      * Defined inline further below.
      */
-    inline bool methodReadBarrier(JSContext *cx, JSScopeProperty *sprop, jsval *vp);
+    bool methodReadBarrier(JSContext *cx, JSScopeProperty *sprop, jsval *vp);
 
     /*
      * Write barrier to check for a method value change. Defined inline below
      * after methodReadBarrier. Two flavors to handle JSOP_*GVAR, which deals
      * in slots not sprops, while not deoptimizing to map slot to sprop unless
      * flags show this is necessary. The methodShapeChange overload (directly
      * below) parallels this.
      */
-    inline bool methodWriteBarrier(JSContext *cx, JSScopeProperty *sprop, jsval v);
-    inline bool methodWriteBarrier(JSContext *cx, uint32 slot, jsval v);
+    bool methodWriteBarrier(JSContext *cx, JSScopeProperty *sprop, jsval v);
+    bool methodWriteBarrier(JSContext *cx, uint32 slot, jsval v);
 
     void trace(JSTracer *trc);
 
     void brandingShapeChange(JSContext *cx, uint32 slot, jsval v);
     void deletingShapeChange(JSContext *cx, JSScopeProperty *sprop);
     bool methodShapeChange(JSContext *cx, JSScopeProperty *sprop, jsval toval);
     bool methodShapeChange(JSContext *cx, uint32 slot, jsval toval);
     void protoShapeChange(JSContext *cx);
@@ -646,129 +645,16 @@ JSScope::drop(JSContext *cx, JSObject *o
         destroy(cx, this);
         return false;
     }
     if (object == obj)
         object = NULL;
     return true;
 }
 
-inline void
-JSScope::extend(JSContext *cx, JSScopeProperty *sprop)
-{
-    js_LeaveTraceIfGlobalObject(cx, object);
-    shape = (!lastProp || shape == lastProp->shape)
-            ? sprop->shape
-            : js_GenerateShape(cx, false);
-    ++entryCount;
-    lastProp = sprop;
-
-    jsuint index;
-    if (js_IdIsIndex(sprop->id, &index))
-        setIndexedProperties();
-
-    if (sprop->isMethod())
-        setMethodBarrier();
-}
-
-/*
- * Property read barrier for deferred cloning of compiler-created function
- * objects optimized as typically non-escaping, ad-hoc methods in obj.
- */
-inline bool
-JSScope::methodReadBarrier(JSContext *cx, JSScopeProperty *sprop, jsval *vp)
-{
-    JS_ASSERT(hasMethodBarrier());
-    JS_ASSERT(has(sprop));
-    JS_ASSERT(sprop->isMethod());
-    JS_ASSERT(sprop->methodValue() == *vp);
-    JS_ASSERT(object->getClass() == &js_ObjectClass);
-
-    JSObject *funobj = JSVAL_TO_OBJECT(*vp);
-    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
-    JS_ASSERT(FUN_OBJECT(fun) == funobj && FUN_NULL_CLOSURE(fun));
-
-    funobj = js_CloneFunctionObject(cx, fun, OBJ_GET_PARENT(cx, funobj));
-    if (!funobj)
-        return false;
-    *vp = OBJECT_TO_JSVAL(funobj);
-    return js_SetPropertyHelper(cx, object, sprop->id, 0, vp);
-}
-
-inline bool
-JSScope::methodWriteBarrier(JSContext *cx, JSScopeProperty *sprop, jsval v)
-{
-    if (branded()) {
-        jsval prev = LOCKED_OBJ_GET_SLOT(object, sprop->slot);
-
-        if (prev != v && VALUE_IS_FUNCTION(cx, prev))
-            return methodShapeChange(cx, sprop, v);
-    }
-    return true;
-}
-
-inline bool
-JSScope::methodWriteBarrier(JSContext *cx, uint32 slot, jsval v)
-{
-    if (branded()) {
-        jsval prev = LOCKED_OBJ_GET_SLOT(object, slot);
-
-        if (prev != v && VALUE_IS_FUNCTION(cx, prev))
-            return methodShapeChange(cx, slot, v);
-    }
-    return true;
-}
-
-inline void
-JSScope::trace(JSTracer *trc)
-{
-    JSContext *cx = trc->context;
-    JSScopeProperty *sprop = lastProp;
-    uint8 regenFlag = cx->runtime->gcRegenShapesScopeFlag;
-    if (IS_GC_MARKING_TRACER(trc) && cx->runtime->gcRegenShapes && hasRegenFlag(regenFlag)) {
-        /*
-         * Either this scope has its own shape, which must be regenerated, or
-         * it must have the same shape as lastProp.
-         */
-        uint32 newShape;
-
-        if (sprop) {
-            if (!(sprop->flags & SPROP_FLAG_SHAPE_REGEN)) {
-                sprop->shape = js_RegenerateShapeForGC(cx);
-                sprop->flags |= SPROP_FLAG_SHAPE_REGEN;
-            }
-            newShape = sprop->shape;
-        }
-        if (!sprop || hasOwnShape()) {
-            newShape = js_RegenerateShapeForGC(cx);
-            JS_ASSERT_IF(sprop, newShape != sprop->shape);
-        }
-        shape = newShape;
-        flags ^= JSScope::SHAPE_REGEN;
-
-        /* Also regenerate the shapes of empty scopes, in case they are not shared. */
-        for (JSScope *empty = emptyScope;
-             empty && empty->hasRegenFlag(regenFlag);
-             empty = empty->emptyScope) {
-            empty->shape = js_RegenerateShapeForGC(cx);
-            empty->flags ^= JSScope::SHAPE_REGEN;
-        }
-    }
-    if (sprop) {
-        JS_ASSERT(has(sprop));
-
-        /* Trace scope's property tree ancestor line. */
-        do {
-            if (hadMiddleDelete() && !has(sprop))
-                continue;
-            sprop->trace(trc);
-        } while ((sprop = sprop->parent) != NULL);
-    }
-}
-
 inline bool
 JSScopeProperty::get(JSContext* cx, JSObject* obj, JSObject *pobj, jsval* vp)
 {
     JS_ASSERT(!SPROP_HAS_STUB_GETTER(this));
     JS_ASSERT(!JSVAL_IS_NULL(this->id));
 
     if (attrs & JSPROP_GETTER) {
         JS_ASSERT(!isMethod());
new file mode 100644
--- /dev/null
+++ b/js/src/jsscopeinlines.h
@@ -0,0 +1,161 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef jsscopeinlines_h___
+#define jsscopeinlines_h___
+
+#include "jscntxt.h"
+#include "jsfun.h"
+#include "jsobj.h"
+#include "jsscope.h"
+
+inline void
+JSScope::extend(JSContext *cx, JSScopeProperty *sprop)
+{
+    js_LeaveTraceIfGlobalObject(cx, object);
+    shape = (!lastProp || shape == lastProp->shape)
+            ? sprop->shape
+            : js_GenerateShape(cx, false);
+    ++entryCount;
+    lastProp = sprop;
+
+    jsuint index;
+    if (js_IdIsIndex(sprop->id, &index))
+        setIndexedProperties();
+
+    if (sprop->isMethod())
+        setMethodBarrier();
+}
+
+/*
+ * Property read barrier for deferred cloning of compiler-created function
+ * objects optimized as typically non-escaping, ad-hoc methods in obj.
+ */
+inline bool
+JSScope::methodReadBarrier(JSContext *cx, JSScopeProperty *sprop, jsval *vp)
+{
+    JS_ASSERT(hasMethodBarrier());
+    JS_ASSERT(has(sprop));
+    JS_ASSERT(sprop->isMethod());
+    JS_ASSERT(sprop->methodValue() == *vp);
+    JS_ASSERT(object->getClass() == &js_ObjectClass);
+
+    JSObject *funobj = JSVAL_TO_OBJECT(*vp);
+    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
+    JS_ASSERT(FUN_OBJECT(fun) == funobj && FUN_NULL_CLOSURE(fun));
+
+    funobj = js_CloneFunctionObject(cx, fun, OBJ_GET_PARENT(cx, funobj));
+    if (!funobj)
+        return false;
+    *vp = OBJECT_TO_JSVAL(funobj);
+    return js_SetPropertyHelper(cx, object, sprop->id, 0, vp);
+}
+
+inline bool
+JSScope::methodWriteBarrier(JSContext *cx, JSScopeProperty *sprop, jsval v)
+{
+    if (branded()) {
+        jsval prev = LOCKED_OBJ_GET_SLOT(object, sprop->slot);
+
+        if (prev != v && VALUE_IS_FUNCTION(cx, prev))
+            return methodShapeChange(cx, sprop, v);
+    }
+    return true;
+}
+
+inline bool
+JSScope::methodWriteBarrier(JSContext *cx, uint32 slot, jsval v)
+{
+    if (branded()) {
+        jsval prev = LOCKED_OBJ_GET_SLOT(object, slot);
+
+        if (prev != v && VALUE_IS_FUNCTION(cx, prev))
+            return methodShapeChange(cx, slot, v);
+    }
+    return true;
+}
+
+inline void
+JSScope::trace(JSTracer *trc)
+{
+    JSContext *cx = trc->context;
+    JSScopeProperty *sprop = lastProp;
+    uint8 regenFlag = cx->runtime->gcRegenShapesScopeFlag;
+    if (IS_GC_MARKING_TRACER(trc) && cx->runtime->gcRegenShapes && hasRegenFlag(regenFlag)) {
+        /*
+         * Either this scope has its own shape, which must be regenerated, or
+         * it must have the same shape as lastProp.
+         */
+        uint32 newShape;
+
+        if (sprop) {
+            if (!(sprop->flags & SPROP_FLAG_SHAPE_REGEN)) {
+                sprop->shape = js_RegenerateShapeForGC(cx);
+                sprop->flags |= SPROP_FLAG_SHAPE_REGEN;
+            }
+            newShape = sprop->shape;
+        }
+        if (!sprop || hasOwnShape()) {
+            newShape = js_RegenerateShapeForGC(cx);
+            JS_ASSERT_IF(sprop, newShape != sprop->shape);
+        }
+        shape = newShape;
+        flags ^= JSScope::SHAPE_REGEN;
+
+        /* Also regenerate the shapes of empty scopes, in case they are not shared. */
+        for (JSScope *empty = emptyScope;
+             empty && empty->hasRegenFlag(regenFlag);
+             empty = empty->emptyScope) {
+            empty->shape = js_RegenerateShapeForGC(cx);
+            empty->flags ^= JSScope::SHAPE_REGEN;
+        }
+    }
+    if (sprop) {
+        JS_ASSERT(has(sprop));
+
+        /* Trace scope's property tree ancestor line. */
+        do {
+            if (hadMiddleDelete() && !has(sprop))
+                continue;
+            sprop->trace(trc);
+        } while ((sprop = sprop->parent) != NULL);
+    }
+}
+
+#endif /* jsscopeinlines_h___ */
--- a/js/src/jsstrinlines.h
+++ b/js/src/jsstrinlines.h
@@ -32,18 +32,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef jsstr_inlines_h___
-#define jsstr_inlines_h___
+#ifndef jsstrinlines_h___
+#define jsstrinlines_h___
 
 #include "jsstr.h"
 
 inline JSString *
 JSString::unitString(jschar c)
 {
     JS_ASSERT(c < UNIT_STRING_LIMIT);
     return &unitStringTable[c];
@@ -67,9 +67,9 @@ JSString::intString(jsint i)
     JS_ASSERT(u < INT_STRING_LIMIT);
     if (u < 10) {
         /* To avoid two ATOMIZED JSString copies of 0-9. */
         return &JSString::unitStringTable['0' + u];
     }
     return &JSString::intStringTable[u];
 }
 
-#endif /* jsstr_inlines_h___ */
+#endif /* jsstrinlines_h___ */
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -72,16 +72,17 @@
 #include "jsregexp.h"
 #include "jsscope.h"
 #include "jsscript.h"
 #include "jsstaticcheck.h"
 #include "jstracer.h"
 #include "jsxml.h"
 
 #include "jsatominlines.h"
+#include "jsscopeinlines.h"
 #include "jsscriptinlines.h"
 
 #include "jsautooplen.h"        // generated headers last
 #include "imacros.c.out"
 
 using namespace nanojit;
 
 #if JS_HAS_XML_SUPPORT