Bug 662946 - Remove various headers from INSTALLED_HEADERS that shouldn't be there. r=jimb
authorJeff Walden <jwalden@mit.edu>
Thu, 09 Jun 2011 01:12:21 -0700
changeset 71365 ce077af8195c82557525c5b4aada944f4add9629
parent 71364 8e030595916317d42a7982be2ded49a88f489d0f
child 71366 5da430ecfdd758083ba270676557c8f058becb24
push idunknown
push userunknown
push dateunknown
reviewersjimb
bugs662946
milestone7.0a1
Bug 662946 - Remove various headers from INSTALLED_HEADERS that shouldn't be there. r=jimb
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/base/src/nsFrameMessageManager.cpp
dom/ipc/TabParent.cpp
dom/src/json/nsJSON.cpp
js/jetpack/JetpackChild.cpp
js/src/Makefile.in
js/src/jsarray.cpp
js/src/jsarray.h
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsscopeinlines.h
js/src/jsval.h
js/src/vm/GlobalObject.cpp
storage/src/mozStorageStatementRow.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1590,27 +1590,16 @@ public:
   {
     return WrapNative(cx, scope, native, cache, nsnull, vp, aHolder,
                       aAllowWrapping);
   }
 
   static void StripNullChars(const nsAString& aInStr, nsAString& aOutStr);
 
   /**
-   * Creates a structured clone of the given jsval according to the algorithm
-   * at:
-   *     http://www.whatwg.org/specs/web-apps/current-work/multipage/
-   *                                   urls.html#safe-passing-of-structured-data
-   *
-   * If the function returns a success code then rval is set to point at the
-   * cloned jsval. rval is not set if the function returns a failure code.
-   */
-  static nsresult CreateStructuredClone(JSContext* cx, jsval val, jsval* rval);
-
-  /**
    * Strip all \n, \r and nulls from the given string
    * @param aString the string to remove newlines from [in/out]
    */
   static void RemoveNewlines(nsString &aString);
 
   /**
    * Convert Windows and Mac platform linebreaks to \n.
    * @param aString the string to convert the newlines inside [in/out]
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -37,17 +37,18 @@
  * 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 ***** */
 
 /* A namespace class for static layout utilities. */
 
-#include "jscntxt.h"
+#include "jsapi.h"
+#include "jsdbgapi.h"
 
 #include "nsJSUtils.h"
 #include "nsCOMPtr.h"
 #include "nsAString.h"
 #include "nsPrintfCString.h"
 #include "nsUnicharUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIScriptGlobalObject.h"
@@ -187,21 +188,16 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_
 
 // for ReportToConsole
 #include "nsIStringBundle.h"
 #include "nsIScriptError.h"
 #include "nsIConsoleService.h"
 
 #include "mozAutoDocUpdate.h"
 #include "imgICache.h"
-#include "jsinterp.h"
-#include "jsarray.h"
-#include "jsdate.h"
-#include "jsregexp.h"
-#include "jstypedarray.h"
 #include "xpcprivate.h"
 #include "nsScriptSecurityManager.h"
 #include "nsIChannelPolicy.h"
 #include "nsChannelPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsContentDLF.h"
 #ifdef MOZ_MEDIA
 #include "nsHTMLMediaElement.h"
@@ -5281,405 +5277,16 @@ nsContentUtils::StripNullChars(const nsA
   aInStr.EndReading(end);
   while (start != end) {
     if (*start != '\0')
       aOutStr.Append(*start);
     ++start;
   }
 }
 
-namespace {
-
-const unsigned int kCloneStackFrameStackSize = 20;
-
-class CloneStackFrame
-{
-  friend class CloneStack;
-
-public:
-  // These three jsvals must all stick together as they're treated as a jsval
-  // array!
-  jsval source;
-  jsval clone;
-  jsval temp;
-  js::AutoIdArray ids;
-  jsuint index;
-
-private:
-  // Only let CloneStack access these.
-  CloneStackFrame(JSContext* aCx, jsval aSource, jsval aClone, JSIdArray* aIds)
-  : source(aSource), clone(aClone), temp(JSVAL_NULL), ids(aCx, aIds), index(0),
-    prevFrame(nsnull),  tvrVals(aCx, 3, &source)
-  {
-    MOZ_COUNT_CTOR(CloneStackFrame);
-  }
-
-  ~CloneStackFrame()
-  {
-    MOZ_COUNT_DTOR(CloneStackFrame);
-  }
-
-  CloneStackFrame* prevFrame;
-  js::AutoArrayRooter tvrVals;
-};
-
-class CloneStack
-{
-public:
-  CloneStack(JSContext* cx)
-  : mCx(cx), mLastFrame(nsnull) {
-    mObjectSet.Init();
-  }
-
-  ~CloneStack() {
-    while (!IsEmpty()) {
-      Pop();
-    }
-  }
-
-  PRBool
-  Push(jsval source, jsval clone, JSIdArray* ids) {
-    NS_ASSERTION(!JSVAL_IS_PRIMITIVE(source) && !JSVAL_IS_PRIMITIVE(clone),
-                 "Must be an object!");
-    if (!ids) {
-      return PR_FALSE;
-    }
-
-    CloneStackFrame* newFrame;
-    if (mObjectSet.Count() < kCloneStackFrameStackSize) {
-      // If the object can fit in our stack space then use that.
-      CloneStackFrame* buf = reinterpret_cast<CloneStackFrame*>(mStackFrames);
-      newFrame = new (buf + mObjectSet.Count())
-                     CloneStackFrame(mCx, source, clone, ids);
-    }
-    else {
-      // Use the heap.
-      newFrame = new CloneStackFrame(mCx, source, clone, ids);
-    }
-
-    mObjectSet.PutEntry(JSVAL_TO_OBJECT(source));
-
-    newFrame->prevFrame = mLastFrame;
-    mLastFrame = newFrame;
-
-    return PR_TRUE;
-  }
-
-  CloneStackFrame*
-  Peek() {
-    return mLastFrame;
-  }
-
-  void
-  Pop() {
-    if (IsEmpty()) {
-      NS_ERROR("Empty stack!");
-      return;
-    }
-
-    CloneStackFrame* lastFrame = mLastFrame;
-
-    mObjectSet.RemoveEntry(JSVAL_TO_OBJECT(lastFrame->source));
-    mLastFrame = lastFrame->prevFrame;
-
-    if (mObjectSet.Count() >= kCloneStackFrameStackSize) {
-      // Only delete if this was a heap object.
-      delete lastFrame;
-    }
-    else {
-      // Otherwise just run the destructor.
-      lastFrame->~CloneStackFrame();
-    }
-  }
-
-  PRBool
-  IsEmpty() {
-    NS_ASSERTION((!mLastFrame && !mObjectSet.Count()) ||
-                 (mLastFrame && mObjectSet.Count()),
-                 "Hashset is out of sync!");
-    return mObjectSet.Count() == 0;
-  }
-
-  PRBool
-  Search(JSObject* obj) {
-    return !!mObjectSet.GetEntry(obj);
-  }
-
-private:
-  JSContext* mCx;
-  CloneStackFrame* mLastFrame;
-  nsTHashtable<nsVoidPtrHashKey> mObjectSet;
-
-  // Use a char array instead of CloneStackFrame array to prevent the JSAuto*
-  // helpers from running until we're ready for them.
-  char mStackFrames[kCloneStackFrameStackSize * sizeof(CloneStackFrame)];
-};
-
-struct ReparentObjectData {
-  ReparentObjectData(JSContext* cx, JSObject* obj)
-  : cx(cx), obj(obj), ids(nsnull), index(0) { }
-
-  ~ReparentObjectData() {
-    if (ids) {
-      JS_DestroyIdArray(cx, ids);
-    }
-  }
-
-  JSContext* cx;
-  JSObject* obj;
-  JSIdArray* ids;
-  jsint index;
-};
-
-inline nsresult
-SetPropertyOnValueOrObject(JSContext* cx,
-                           jsval val,
-                           jsval* rval,
-                           JSObject* obj,
-                           jsid id)
-{
-  NS_ASSERTION((rval && !obj) || (!rval && obj), "Can only clone to one dest!");
-  if (rval) {
-    *rval = val;
-    return NS_OK;
-  }
-  if (!JS_DefinePropertyById(cx, obj, id, val, nsnull, nsnull,
-                             JSPROP_ENUMERATE)) {
-    return NS_ERROR_FAILURE;
-  }
-  return NS_OK;
-}
-
-inline JSObject*
-CreateEmptyObjectOrArray(JSContext* cx,
-                         JSObject* obj)
-{
-  if (JS_IsArrayObject(cx, obj)) {
-    jsuint length;
-    if (!JS_GetArrayLength(cx, obj, &length)) {
-      NS_ERROR("Failed to get array length?!");
-      return nsnull;
-    }
-    return JS_NewArrayObject(cx, length, NULL);
-  }
-  return JS_NewObject(cx, NULL, NULL, NULL);
-}
-
-nsresult
-CloneSimpleValues(JSContext* cx,
-                  jsval val,
-                  jsval* rval,
-                  PRBool* wasCloned,
-                  JSObject* robj = nsnull,
-                  jsid rid = INT_TO_JSID(0))
-{
-  *wasCloned = PR_TRUE;
-
-  // No cloning necessary for these non-GC'd jsvals.
-  if (!JSVAL_IS_GCTHING(val) || JSVAL_IS_NULL(val)) {
-    return SetPropertyOnValueOrObject(cx, val, rval, robj, rid);
-  }
-
-  // We'll use immutable strings to prevent copying if we can.
-  if (JSVAL_IS_STRING(val)) {
-    if (!JS_MakeStringImmutable(cx, JSVAL_TO_STRING(val))) {
-      return NS_ERROR_FAILURE;
-    }
-    return SetPropertyOnValueOrObject(cx, val, rval, robj, rid);
-  }
-
-  NS_ASSERTION(!JSVAL_IS_PRIMITIVE(val), "Not an object!");
-  JSObject* obj = JSVAL_TO_OBJECT(val);
-
-  // Dense arrays of primitives can be cloned quickly.
-  JSObject* newArray;
-  if (!js_CloneDensePrimitiveArray(cx, obj, &newArray)) {
-    return NS_ERROR_FAILURE;
-  }
-  if (newArray) {
-    return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newArray), rval, robj,
-                                      rid);
-  }
-
-  // Date objects.
-  if (js_DateIsValid(cx, obj)) {
-    jsdouble msec = js_DateGetMsecSinceEpoch(cx, obj);
-    JSObject* newDate;
-    if (!(msec  && (newDate = js_NewDateObjectMsec(cx, msec)))) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newDate), rval, robj,
-                                      rid);
-  }
-
-  // RegExp objects.
-  if (js_ObjectIsRegExp(obj)) {
-    JSObject* proto;
-    if (!js_GetClassPrototype(cx, JS_GetScopeChain(cx), JSProto_RegExp,
-                              &proto)) {
-      return NS_ERROR_FAILURE;
-    }
-    JSObject* newRegExp = js_CloneRegExpObject(cx, obj, proto);
-    if (!newRegExp) {
-      return NS_ERROR_FAILURE;
-    }
-    return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newRegExp), rval,
-                                      robj, rid);
-  }
-
-  // Typed array objects.
-  if (js_IsTypedArray(obj)) {
-    js::TypedArray* src = js::TypedArray::fromJSObject(obj);
-    JSObject* newTypedArray = js_CreateTypedArrayWithArray(cx, src->type, obj);
-    if (!newTypedArray) {
-      return NS_ERROR_FAILURE;
-    }
-    return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newTypedArray), rval,
-                                      robj, rid);
-  }
-
-  // ArrayBuffer objects.
-  if (js_IsArrayBuffer(obj)) {
-    JSObject* src = js::ArrayBuffer::getArrayBuffer(src);
-    if (!src) {
-      return NS_ERROR_FAILURE;
-    }
-
-    JSObject* newBuffer = js_CreateArrayBuffer(cx, js::ArrayBuffer::getByteLength(src));
-    if (!newBuffer) {
-      return NS_ERROR_FAILURE;
-    }
-    memcpy(js::ArrayBuffer::getDataOffset(newBuffer), js::ArrayBuffer::getDataOffset(src),
-           js::ArrayBuffer::getByteLength(src));
-    return SetPropertyOnValueOrObject(cx, OBJECT_TO_JSVAL(newBuffer), rval,
-                                      robj, rid);
-  }
-
-  // Do we support File?
-  // Do we support Blob?
-  // Do we support FileList?
-
-  // Function objects don't get cloned.
-  if (JS_ObjectIsFunction(cx, obj)) {
-    return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-  }
-
-  // Security wrapped objects are not allowed either.
-  if (obj->isWrapper() && !obj->getClass()->ext.innerObject)
-    return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-
-  // See if this JSObject is backed by some C++ object. If it is then we assume
-  // that it is inappropriate to clone.
-  nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
-  nsContentUtils::XPConnect()->
-    GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wrapper));
-  if (wrapper) {
-    return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-  }
-
-  *wasCloned = PR_FALSE;
-  return NS_OK;
-}
-
-} // anonymous namespace
-
-// static
-nsresult
-nsContentUtils::CreateStructuredClone(JSContext* cx,
-                                      jsval val,
-                                      jsval* rval)
-{
-  JSAutoRequest ar(cx);
-
-  nsCOMPtr<nsIXPConnect> xpconnect(sXPConnect);
-  NS_ENSURE_STATE(xpconnect);
-
-  PRBool wasCloned;
-  nsresult rv = CloneSimpleValues(cx, val, rval, &wasCloned);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  if (wasCloned) {
-    return NS_OK;
-  }
-
-  NS_ASSERTION(JSVAL_IS_OBJECT(val), "Not an object?!");
-  JSObject* obj = CreateEmptyObjectOrArray(cx, JSVAL_TO_OBJECT(val));
-  if (!obj) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  jsval output = OBJECT_TO_JSVAL(obj);
-  js::AutoValueRooter tvr(cx, output);
-
-  CloneStack stack(cx);
-  if (!stack.Push(val, OBJECT_TO_JSVAL(obj),
-                  JS_Enumerate(cx, JSVAL_TO_OBJECT(val)))) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  while (!stack.IsEmpty()) {
-    CloneStackFrame* frame = stack.Peek();
-
-    NS_ASSERTION(!!frame->ids &&
-                 frame->ids.length() >= frame->index &&
-                 !JSVAL_IS_PRIMITIVE(frame->source) &&
-                 !JSVAL_IS_PRIMITIVE(frame->clone),
-                 "Bad frame state!");
-
-    if (frame->index == frame->ids.length()) {
-      // Done cloning this object, pop the frame.
-      stack.Pop();
-      continue;
-    }
-
-    // Get the current id and increment the index.
-    jsid id = frame->ids[frame->index++];
-
-    if (!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(frame->source), id,
-                            &frame->temp)) {
-      return NS_ERROR_FAILURE;
-    }
-
-    if (!JSVAL_IS_PRIMITIVE(frame->temp) &&
-        stack.Search(JSVAL_TO_OBJECT(frame->temp))) {
-      // Spec says to throw this particular exception for cyclical references.
-      return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
-    }
-
-    JSObject* clone = JSVAL_TO_OBJECT(frame->clone);
-
-    PRBool wasCloned;
-    nsresult rv = CloneSimpleValues(cx, frame->temp, nsnull, &wasCloned, clone,
-                                    id);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    if (!wasCloned) {
-      NS_ASSERTION(JSVAL_IS_OBJECT(frame->temp), "Not an object?!");
-      obj = CreateEmptyObjectOrArray(cx, JSVAL_TO_OBJECT(frame->temp));
-      if (!obj ||
-          !stack.Push(frame->temp, OBJECT_TO_JSVAL(obj),
-                      JS_Enumerate(cx, JSVAL_TO_OBJECT(frame->temp)))) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-      // Set the new object as a property of the clone. We'll fill it on the
-      // next iteration.
-      if (!JS_DefinePropertyById(cx, clone, id, OBJECT_TO_JSVAL(obj), nsnull,
-                                 nsnull, JSPROP_ENUMERATE)) {
-        return NS_ERROR_FAILURE;
-      }
-    }
-  }
-
-  *rval = output;
-  return NS_OK;
-}
 struct ClassMatchingInfo {
   nsAttrValue::AtomArray mClasses;
   nsCaseTreatment mCaseTreatment;
 };
 
 static PRBool
 MatchClassNames(nsIContent* aContent, PRInt32 aNamespaceID, nsIAtom* aAtom,
                 void* aData)
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -37,17 +37,16 @@
 
 #include "ContentChild.h"
 #include "ContentParent.h"
 #include "jscntxt.h"
 #include "nsFrameMessageManager.h"
 #include "nsContentUtils.h"
 #include "nsIXPConnect.h"
 #include "jsapi.h"
-#include "jsarray.h"
 #include "jsinterp.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsScriptLoader.h"
 #include "nsIJSContextStack.h"
 #include "nsIXULRuntime.h"
 #include "nsIScriptError.h"
 #include "nsIConsoleService.h"
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -54,17 +54,16 @@
 #include "nsIDOMWindow.h"
 #include "nsIIdentityInfo.h"
 #include "nsPIDOMWindow.h"
 #include "TabChild.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsFrameLoader.h"
 #include "nsNetUtil.h"
-#include "jsarray.h"
 #include "nsContentUtils.h"
 #include "nsContentPermissionHelper.h"
 #include "nsIDOMNSHTMLFrameElement.h"
 #include "nsIDialogCreator.h"
 #include "nsThreadUtils.h"
 #include "nsSerializationHelper.h"
 #include "nsIPromptFactory.h"
 #include "nsIContent.h"
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -34,24 +34,17 @@
  * 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 ***** */
 
 #include "jsapi.h"
-#include "jsdtoa.h"
-#include "jsprvtd.h"
-#include "jsbool.h"
-#include "jsarena.h"
-#include "jscntxt.h"
-#include "jsinterp.h"
-#include "jsiter.h"
-#include "jstypes.h"
+#include "jsdbgapi.h"
 #include "nsIServiceManager.h"
 #include "nsJSON.h"
 #include "nsIXPConnect.h"
 #include "nsIXPCScriptable.h"
 #include "nsStreamUtils.h"
 #include "nsIInputStream.h"
 #include "nsStringStream.h"
 #include "nsICharsetConverterManager.h"
--- a/js/jetpack/JetpackChild.cpp
+++ b/js/jetpack/JetpackChild.cpp
@@ -39,18 +39,16 @@
 #include "jscntxt.h"
 #include "nsXULAppAPI.h"
 #include "nsNativeCharsetUtils.h"
 
 #include "mozilla/jetpack/JetpackChild.h"
 #include "mozilla/jetpack/Handle.h"
 #include "mozilla/IntentionalCrash.h"
 
-#include "jsarray.h"
-
 #include <stdio.h>
 
 namespace mozilla {
 namespace jetpack {
 
 JetpackChild::JetpackChild()
 {
 }
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -191,87 +191,73 @@ CPPSRCS		= \
 # browser builds.  Don't add new files here unless you know what you're
 # doing!
 INSTALLED_HEADERS = \
 		js-config.h \
 		jsautocfg.h \
 		$(CURDIR)/jsautokw.h \
 		js.msg \
 		jsalloc.h \
-		jsanalyze.h \
 		jsapi.h \
-		jsarray.h \
 		jsarena.h \
 		jsatom.h \
 		jsbit.h \
 		jsbool.h \
 		jsclist.h \
 		jsclone.h \
 		jscntxt.h \
 		jscompat.h \
 		jsdate.h \
 		jsdbgapi.h \
 		jsdhash.h \
-		jsdtoa.h \
 		jsemit.h \
 		jsfun.h \
 		jsfriendapi.h \
 		jsgc.h \
-		jsgcmark.h \
 		jscell.h \
 		jsgcchunk.h \
 		jsgcstats.h \
 		jscompartment.h \
 		jshash.h \
 		jsinterp.h \
 		jsinttypes.h \
 		jsiter.h \
 		jslock.h \
 		jslong.h \
-		jsmath.h \
 		jsobj.h \
-		jsobjinlines.h \
 		json.h \
-		jsonparser.h \
 		jsopcode.tbl \
 		jsopcode.h \
-		jsopcodeinlines.h \
 		jsotypes.h \
 		jsparse.h \
 		jsproxy.h \
 		jsprf.h \
 		jsprobes.h \
 		jspropertycache.h \
-		jspropertycacheinlines.h \
 		jspropertytree.h \
 		jsproto.tbl \
 		jsprvtd.h \
 		jspubtd.h \
 		jsreflect.h \
-		jsregexp.h \
 		jsscan.h \
 		jsscope.h \
 		jsscript.h \
-		jsscriptinlines.h \
 		jsstaticcheck.h \
 		jsstdint.h \
 		jsstr.h \
 		jstracer.h \
-		jshotloop.h \
 		jstypedarray.h \
 		jstypes.h \
 		jsutil.h \
 		jsvector.h \
 		jstl.h \
 		jshashtable.h \
 		jsversion.h \
-		jsweakmap.h \
 		jswrapper.h \
 		jsxdrapi.h \
-		jsxml.h \
 		jsval.h \
 		jsvalue.h \
 		prmjtime.h \
 		$(NULL)
 
 ###############################################
 # BEGIN include sources for the vm subdirectory
 #
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -3199,78 +3199,8 @@ js_ArrayInfo(JSContext *cx, uintN argc, 
         fputs(")\n", stderr);
         cx->free_(bytes);
     }
 
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return true;
 }
 #endif
-
-JS_FRIEND_API(JSBool)
-js_IsDensePrimitiveArray(JSObject *obj)
-{
-    if (!obj || !obj->isDenseArray())
-        return JS_FALSE;
-
-    jsuint capacity = obj->getDenseArrayCapacity();
-    for (jsuint i = 0; i < capacity; i++) {
-        if (obj->getDenseArrayElement(i).isObject())
-            return JS_FALSE;
-    }
-
-    return JS_TRUE;
-}
-
-JS_FRIEND_API(JSBool)
-js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone)
-{
-    JS_ASSERT(obj);
-    if (!obj->isDenseArray()) {
-        /*
-         * This wasn't a dense array. Return JS_TRUE but a NULL clone to signal
-         * that no exception was encountered.
-         */
-        *clone = NULL;
-        return JS_TRUE;
-    }
-
-    jsuint length = obj->getArrayLength();
-
-    /*
-     * Must use the minimum of original array's length and capacity, to handle
-     * |a = [1,2,3]; a.length = 10000| "dense" cases efficiently. In the normal
-     * case where length is <= capacity, the clone and original array will have
-     * the same capacity.
-     */
-    jsuint jsvalCount = JS_MIN(obj->getDenseArrayCapacity(), length);
-
-    AutoValueVector vector(cx);
-    if (!vector.reserve(jsvalCount))
-        return JS_FALSE;
-
-    for (jsuint i = 0; i < jsvalCount; i++) {
-        const Value &val = obj->getDenseArrayElement(i);
-
-        if (val.isString()) {
-            // Strings must be made immutable before being copied to a clone.
-            if (!val.toString()->ensureFixed(cx))
-                return JS_FALSE;
-        } else if (val.isObject()) {
-            /*
-             * This wasn't an array of primitives. Return JS_TRUE but a null
-             * clone to signal that no exception was encountered.
-             */
-            *clone = NULL;
-            return JS_TRUE;
-        }
-
-        vector.infallibleAppend(val);
-    }
-
-    *clone = NewDenseCopiedArray(cx, jsvalCount, vector.begin());
-    if (!*clone)
-        return JS_FALSE;
-
-    /* The length will be set to the JS_MIN, above, but length might be larger. */
-    (*clone)->setArrayLength(length);
-    return JS_TRUE;
-}
--- a/js/src/jsarray.h
+++ b/js/src/jsarray.h
@@ -266,32 +266,12 @@ js_PrototypeHasIndexedProperties(JSConte
 JSBool
 js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id,
                              js::Value *vp);
 
 /* Array constructor native. Exposed only so the JIT can know its address. */
 JSBool
 js_Array(JSContext *cx, uintN argc, js::Value *vp);
 
-/*
- * Makes a fast clone of a dense array as long as the array only contains
- * primitive values.
- *
- * If the return value is JS_FALSE then clone will not be set.
- *
- * If the return value is JS_TRUE then clone will either be set to the address
- * of a new JSObject or to NULL if the array was not dense or contained values
- * that were not primitives.
- */
-JS_FRIEND_API(JSBool)
-js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone);
-
-/*
- * Returns JS_TRUE if the given object is a dense array that contains only
- * primitive values.
- */
-JS_FRIEND_API(JSBool)
-js_IsDensePrimitiveArray(JSObject *obj);
-
 extern JSBool JS_FASTCALL
 js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i);
 
 #endif /* jsarray_h___ */
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -57,16 +57,17 @@
 #include "jsarena.h"
 #include "jsutil.h"
 #include "jsclist.h"
 #include "jsprf.h"
 #include "jsatom.h"
 #include "jscntxt.h"
 #include "jsversion.h"
 #include "jsdbgapi.h"
+#include "jsdtoa.h"
 #include "jsexn.h"
 #include "jsfun.h"
 #include "jsgc.h"
 #include "jsgcmark.h"
 #include "jsiter.h"
 #include "jslock.h"
 #include "jsmath.h"
 #include "jsnativestack.h"
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -46,29 +46,26 @@
 #include <string.h>
 
 #include "jsprvtd.h"
 #include "jsarena.h"
 #include "jsclist.h"
 #include "jslong.h"
 #include "jsatom.h"
 #include "jsdhash.h"
-#include "jsdtoa.h"
 #include "jsfun.h"
 #include "jsgc.h"
 #include "jsgcchunk.h"
 #include "jshashtable.h"
 #include "jsinterp.h"
-#include "jsmath.h"
 #include "jsobj.h"
 #include "jspropertycache.h"
 #include "jspropertytree.h"
 #include "jsstaticcheck.h"
 #include "jsutil.h"
-#include "jsarray.h"
 #include "jsvector.h"
 #include "prmjtime.h"
 
 #include "vm/Stack.h"
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4100) /* Silence unreferenced formal parameter warnings */
@@ -83,16 +80,20 @@ class Assembler;
 class CodeAlloc;
 class Fragment;
 template<typename K> struct DefaultHash;
 template<typename K, typename V, typename H> class HashMap;
 template<typename T> class Seq;
 
 }  /* namespace nanojit */
 
+JS_BEGIN_EXTERN_C
+struct DtoaState;
+JS_END_EXTERN_C
+
 namespace js {
 
 /* Tracer constants. */
 static const size_t MONITOR_N_GLOBAL_STATES = 4;
 static const size_t FRAGMENT_TABLE_SIZE = 512;
 static const size_t MAX_GLOBAL_SLOTS = 4096;
 static const size_t GLOBAL_SLOTS_BUFFER_SIZE = MAX_GLOBAL_SLOTS + 1;
 
@@ -204,17 +205,17 @@ struct ThreadData {
      * The GSN cache is per thread since even multi-cx-per-thread embeddings
      * do not interleave js_GetSrcNote calls.
      */
     GSNCache            gsnCache;
 
     /* Property cache for faster call/get/set invocation. */
     PropertyCache       propertyCache;
 
-    /* State used by dtoa.c. */
+    /* State used by jsdtoa.cpp. */
     DtoaState           *dtoaState;
 
     /* Base address of the native stack for the current thread. */
     jsuword             *nativeStackBase;
 
     /* List of currently pending operations on proxies. */
     PendingProxyOperation *pendingProxyOperation;
 
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -38,16 +38,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "jscntxt.h"
 #include "jscompartment.h"
 #include "jsgc.h"
 #include "jsgcmark.h"
 #include "jsiter.h"
+#include "jsmath.h"
 #include "jsproxy.h"
 #include "jsscope.h"
 #include "jstracer.h"
 #include "jswrapper.h"
 #include "assembler/wtf/Platform.h"
 #include "yarr/BumpPointerAllocator.h"
 #include "methodjit/MethodJIT.h"
 #include "methodjit/PolyIC.h"
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -37,22 +37,20 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef jscompartment_h___
 #define jscompartment_h___
 
 #include "jscntxt.h"
 #include "jsgc.h"
-#include "jsmath.h"
 #include "jsobj.h"
 #include "jsfun.h"
 #include "jsgcstats.h"
 #include "jsclist.h"
-#include "jsxml.h"
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4251) /* Silence warning about JS_FRIEND_API and data members. */
 #endif
 
 namespace JSC { class ExecutableAllocator; }
 namespace WTF { class BumpPointerAllocator; }
@@ -342,16 +340,18 @@ class NativeIterCache {
         return data[getIndex(key)];
     }
 
     void set(uint32 key, JSObject *iterobj) {
         data[getIndex(key)] = iterobj;
     }
 };
 
+class MathCache;
+
 /*
  * A single-entry cache for some base-10 double-to-string conversions. This
  * helps date-format-xparb.js.  It also avoids skewing the results for
  * v8-splay.js when measured by the SunSpider harness, where the splay tree
  * initialization (which includes many repeated double-to-string conversions)
  * is erroneously included in the measurement; see bug 562553.
  */
 class DtoaCache {
--- a/js/src/jsscopeinlines.h
+++ b/js/src/jsscopeinlines.h
@@ -36,16 +36,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef jsscopeinlines_h___
 #define jsscopeinlines_h___
 
 #include <new>
+#include "jsarray.h"
 #include "jsbool.h"
 #include "jscntxt.h"
 #include "jsdbgapi.h"
 #include "jsfun.h"
 #include "jsobj.h"
 #include "jsscope.h"
 #include "jsgc.h"
 
--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -457,21 +457,16 @@ JSVAL_TO_BOOLEAN_IMPL(jsval_layout l)
 {
     return l.s.payload.boo;
 }
 
 static JS_ALWAYS_INLINE jsval_layout
 BOOLEAN_TO_JSVAL_IMPL(JSBool b)
 {
     jsval_layout l;
-
-    /*
-     * Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
-     * instance).
-     */
     JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
     l.s.tag = JSVAL_TAG_BOOLEAN;
     l.s.payload.boo = b;
     return l;
 }
 
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_MAGIC_IMPL(jsval_layout l)
@@ -655,21 +650,16 @@ JSVAL_TO_BOOLEAN_IMPL(jsval_layout l)
 {
     return (JSBool)l.asBits;
 }
 
 static JS_ALWAYS_INLINE jsval_layout
 BOOLEAN_TO_JSVAL_IMPL(JSBool b)
 {
     jsval_layout l;
-
-    /*
-     * Happens if XPConnect hands out an illegal value (constructed from C++ through a PRBool, for
-     * instance).
-     */
     JS_ASSERT(b == JS_TRUE || b == JS_FALSE);
     l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN;
     return l;
 }
 
 static JS_ALWAYS_INLINE JSBool
 JSVAL_IS_MAGIC_IMPL(jsval_layout l)
 {
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -37,16 +37,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "GlobalObject.h"
 
 #include "jscntxt.h"
 #include "jsexn.h"
+#include "jsmath.h"
 #include "json.h"
 
 #include "jsobjinlines.h"
 #include "jsregexpinlines.h"
 
 using namespace js;
 
 JSObject *
--- a/storage/src/mozStorageStatementRow.cpp
+++ b/storage/src/mozStorageStatementRow.cpp
@@ -40,17 +40,16 @@
 
 #include "nsMemory.h"
 #include "nsString.h"
 
 #include "mozStorageStatementRow.h"
 #include "mozStorageStatement.h"
 
 #include "jsapi.h"
-#include "jsdate.h"
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// StatementRow
 
 StatementRow::StatementRow(Statement *aStatement)