Bug 733260 followup: use uint32_t for array and string lengths, r=luke
authorDavid Mandelin <dmandelin@mozilla.com>
Tue, 06 Mar 2012 15:52:55 -0800
changeset 91297 5ca23d2045b649c845e1015dfddd3559f00cf8a0
parent 91296 4091b2b24293f47d1d6e3774dcd75b6673f7e77b
child 91298 878c5c8b8b2116c4c9b0026b307787b647a57ada
push id783
push userlsblakk@mozilla.com
push dateTue, 24 Apr 2012 17:33:42 +0000
treeherdermozilla-beta@11faed19f136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs733260
milestone13.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 733260 followup: use uint32_t for array and string lengths, r=luke
content/base/src/nsWebSocket.cpp
content/canvas/src/CanvasUtils.cpp
content/canvas/src/CanvasUtils.h
dom/indexedDB/AsyncConnectionHelper.cpp
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBIndex.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/indexedDB/Key.cpp
dom/sms/src/SmsFilter.cpp
dom/sms/src/SmsManager.cpp
js/src/ctypes/CTypes.cpp
js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
js/src/jsapi-tests/testNewObject.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsarray.cpp
js/src/jsarray.h
js/src/jsatom.cpp
js/src/jsfriendapi.h
js/src/jsfun.cpp
js/src/jsgc.cpp
js/src/jsinterp.cpp
js/src/jsinterpinlines.h
js/src/jsobj.cpp
js/src/json.cpp
js/src/jsopcode.cpp
js/src/jsproxy.cpp
js/src/jsscope.cpp
js/src/jsstr.cpp
js/src/jstypedarray.cpp
js/src/jstypedarray.h
js/src/jsxml.cpp
js/src/methodjit/MonoIC.cpp
js/src/methodjit/StubCalls.cpp
js/src/shell/jsheaptools.cpp
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/src/XPCVariant.cpp
js/xpconnect/src/dombindings.cpp
startupcache/test/TestStartupCache.cpp
toolkit/components/places/History.cpp
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -597,17 +597,17 @@ nsWebSocket::Initialize(nsISupports* aOw
   nsTArray<nsString> protocolArray;
 
   if (aArgc == 2) {
     JSObject *jsobj;
 
     if (JSVAL_IS_OBJECT(aArgv[1]) &&
         (jsobj = JSVAL_TO_OBJECT(aArgv[1])) &&
         JS_IsArrayObject(aContext, jsobj)) {
-      unsigned len;
+      uint32_t len;
       JS_GetArrayLength(aContext, jsobj, &len);
       
       for (PRUint32 index = 0; index < len; ++index) {
         jsval value;
 
         if (!JS_GetElement(aContext, jsobj, index, &value))
           return NS_ERROR_DOM_SYNTAX_ERR;
 
--- a/content/canvas/src/CanvasUtils.cpp
+++ b/content/canvas/src/CanvasUtils.cpp
@@ -117,17 +117,17 @@ CoerceDouble(jsval v, double* d)
 }
 
 template<size_t N>
 static bool
 JSValToMatrixElts(JSContext* cx, const jsval& val,
                   double* (&elts)[N], nsresult* rv)
 {
     JSObject* obj;
-    unsigned length;
+    uint32_t length;
 
     if (JSVAL_IS_PRIMITIVE(val) ||
         !(obj = JSVAL_TO_OBJECT(val)) ||
         !JS_GetArrayLength(cx, obj, &length) ||
         N != length) {
         // Not an array-like thing or wrong size
         *rv = NS_ERROR_INVALID_ARG;
         return false;
--- a/content/canvas/src/CanvasUtils.h
+++ b/content/canvas/src/CanvasUtils.h
@@ -141,21 +141,21 @@ DashArrayToJSVal(FallibleTArray<T>& dash
 
 template<typename T>
 nsresult
 JSValToDashArray(JSContext* cx, const jsval& patternArray,
                  FallibleTArray<T>& dashes)
 {
     // The cap is pretty arbitrary.  16k should be enough for
     // anybody...
-    static const unsigned MAX_NUM_DASHES = 1 << 14;
+    static const uint32_t MAX_NUM_DASHES = 1 << 14;
 
     if (!JSVAL_IS_PRIMITIVE(patternArray)) {
         JSObject* obj = JSVAL_TO_OBJECT(patternArray);
-        unsigned length;
+        uint32_t length;
         if (!JS_GetArrayLength(cx, obj, &length)) {
             // Not an array-like thing
             return NS_ERROR_INVALID_ARG;
         } else if (length > MAX_NUM_DASHES) {
             // Too many dashes in the pattern
             return NS_ERROR_ILLEGAL_VALUE;
         }
 
--- a/dom/indexedDB/AsyncConnectionHelper.cpp
+++ b/dom/indexedDB/AsyncConnectionHelper.cpp
@@ -85,17 +85,17 @@ ConvertCloneReadInfosToArrayInternal(
 {
   JSObject* array = JS_NewArrayObject(aCx, 0, nsnull);
   if (!array) {
     NS_WARNING("Failed to make array!");
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   if (!aReadInfos.IsEmpty()) {
-    if (!JS_SetArrayLength(aCx, array, unsigned(aReadInfos.Length()))) {
+    if (!JS_SetArrayLength(aCx, array, uint32_t(aReadInfos.Length()))) {
       NS_WARNING("Failed to set array length!");
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     for (uint32_t index = 0, count = aReadInfos.Length(); index < count;
          index++) {
       StructuredCloneReadInfo& readInfo = aReadInfos[index];
 
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -405,28 +405,28 @@ IDBDatabase::CreateObjectStore(const nsA
     // Get keyPath
     jsval val = params.keyPath;
     if (!JSVAL_IS_VOID(val) && !JSVAL_IS_NULL(val)) {
       if (!JSVAL_IS_PRIMITIVE(val) &&
           JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(val))) {
     
         JSObject* obj = JSVAL_TO_OBJECT(val);
     
-        unsigned length;
+        uint32_t length;
         if (!JS_GetArrayLength(aCx, obj, &length)) {
           return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
         }
     
         if (!length) {
           return NS_ERROR_DOM_SYNTAX_ERR;
         }
     
         keyPathArray.SetCapacity(length);
     
-        for (unsigned index = 0; index < length; index++) {
+        for (uint32_t index = 0; index < length; index++) {
           jsval val;
           JSString* jsstr;
           nsDependentJSString str;
           if (!JS_GetElement(aCx, obj, index, &val) ||
               !(jsstr = JS_ValueToString(aCx, val)) ||
               !str.init(aCx, jsstr)) {
             return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
           }
@@ -561,28 +561,28 @@ IDBDatabase::Transaction(const jsval& aS
   nsresult rv;
   nsTArray<nsString> storesToOpen;
 
   if (!JSVAL_IS_PRIMITIVE(aStoreNames)) {
     JSObject* obj = JSVAL_TO_OBJECT(aStoreNames);
 
     // See if this is a JS array.
     if (JS_IsArrayObject(aCx, obj)) {
-      unsigned length;
+      uint32_t length;
       if (!JS_GetArrayLength(aCx, obj, &length)) {
         return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
       }
 
       if (!length) {
         return NS_ERROR_DOM_INVALID_ACCESS_ERR;
       }
 
       storesToOpen.SetCapacity(length);
 
-      for (unsigned index = 0; index < length; index++) {
+      for (uint32_t index = 0; index < length; index++) {
         jsval val;
         JSString* jsstr;
         nsDependentJSString str;
         if (!JS_GetElement(aCx, obj, index, &val) ||
             !(jsstr = JS_ValueToString(aCx, val)) ||
             !str.init(aCx, jsstr)) {
           return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
         }
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -899,17 +899,17 @@ GetAllKeysHelper::GetSuccessResult(JSCon
 
   JSObject* array = JS_NewArrayObject(aCx, 0, NULL);
   if (!array) {
     NS_WARNING("Failed to make array!");
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   if (!keys.IsEmpty()) {
-    if (!JS_SetArrayLength(aCx, array, unsigned(keys.Length()))) {
+    if (!JS_SetArrayLength(aCx, array, uint32_t(keys.Length()))) {
       NS_WARNING("Failed to set array length!");
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     for (uint32 index = 0, count = keys.Length(); index < count; index++) {
       const Key& key = keys[index];
       NS_ASSERTION(!key.IsUnset(), "Bad key!");
 
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -613,22 +613,22 @@ IDBObjectStore::AppendIndexUpdateInfo(PR
 
   jsval key;
   rv = GetJSValFromKeyPath(aCx, aVal, aKeyPath, key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aMultiEntry && !JSVAL_IS_PRIMITIVE(key) &&
       JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(key))) {
     JSObject* array = JSVAL_TO_OBJECT(key);
-    unsigned arrayLength;
+    uint32_t arrayLength;
     if (!JS_GetArrayLength(aCx, array, &arrayLength)) {
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
-    for (unsigned arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
+    for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
       jsval arrayItem;
       if (!JS_GetElement(aCx, array, arrayIndex, &arrayItem)) {
         return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
       }
 
       Key value;
       if (NS_FAILED(value.SetFromJSVal(aCx, arrayItem)) ||
           value.IsUnset()) {
@@ -1695,28 +1695,28 @@ IDBObjectStore::CreateIndex(const nsAStr
   nsTArray<nsString> keyPathArray;
 
   // See if this is a JS array.
   if (!JSVAL_IS_PRIMITIVE(aKeyPath) &&
       JS_IsArrayObject(aCx, JSVAL_TO_OBJECT(aKeyPath))) {
 
     JSObject* obj = JSVAL_TO_OBJECT(aKeyPath);
 
-    unsigned length;
+    uint32_t length;
     if (!JS_GetArrayLength(aCx, obj, &length)) {
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
     if (!length) {
       return NS_ERROR_DOM_SYNTAX_ERR;
     }
 
     keyPathArray.SetCapacity(length);
 
-    for (unsigned index = 0; index < length; index++) {
+    for (uint32_t index = 0; index < length; index++) {
       jsval val;
       JSString* jsstr;
       nsDependentJSString str;
       if (!JS_GetElement(aCx, obj, index, &val) ||
           !(jsstr = JS_ValueToString(aCx, val)) ||
           !str.init(aCx, jsstr)) {
         return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
       }
--- a/dom/indexedDB/Key.cpp
+++ b/dom/indexedDB/Key.cpp
@@ -165,22 +165,22 @@ Key::EncodeJSVal(JSContext* aCx, const j
       if (aTypeOffset == eMaxType * MaxArrayCollapse) {
         mBuffer.Append(aTypeOffset);
         aTypeOffset = 0;
       }
       NS_ASSERTION((aTypeOffset % eMaxType) == 0 &&
                    aTypeOffset < (eMaxType * MaxArrayCollapse),
                    "Wrong typeoffset");
 
-      unsigned length;
+      uint32_t length;
       if (!JS_GetArrayLength(aCx, obj, &length)) {
         return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
       }
 
-      for (unsigned index = 0; index < length; index++) {
+      for (uint32_t index = 0; index < length; index++) {
         jsval val;
         if (!JS_GetElement(aCx, obj, index, &val)) {
           return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
         }
 
         nsresult rv = EncodeJSVal(aCx, val, aTypeOffset);
         NS_ENSURE_SUCCESS(rv, rv);
 
@@ -215,17 +215,17 @@ Key::DecodeJSVal(const unsigned char*& a
 
     aTypeOffset += eMaxType;
 
     if (aTypeOffset == eMaxType * MaxArrayCollapse) {
       ++aPos;
       aTypeOffset = 0;
     }
 
-    unsigned index = 0;
+    uint32_t index = 0;
     while (aPos < aEnd && *aPos - aTypeOffset != eTerminator) {
       jsval val;
       nsresult rv = DecodeJSVal(aPos, aEnd, aCx, aTypeOffset, &val);
       NS_ENSURE_SUCCESS(rv, rv);
 
       aTypeOffset = 0;
 
       if (!JS_SetElement(aCx, array, index++, &val)) {
--- a/dom/sms/src/SmsFilter.cpp
+++ b/dom/sms/src/SmsFilter.cpp
@@ -185,22 +185,22 @@ SmsFilter::SetNumbers(JSContext* aCx, co
     return NS_ERROR_INVALID_ARG;
   }
 
   JSObject& obj = aNumbers.toObject();
   if (!JS_IsArrayObject(aCx, &obj)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  unsigned size;
+  uint32_t size;
   JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, &obj, &size));
 
   nsTArray<nsString> numbers;
 
-  for (unsigned i=0; i<size; ++i) {
+  for (uint32_t i=0; i<size; ++i) {
     jsval jsNumber;
     if (!JS_GetElement(aCx, &obj, i, &jsNumber)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     if (!jsNumber.isString()) {
       return NS_ERROR_INVALID_ARG;
     }
--- a/dom/sms/src/SmsManager.cpp
+++ b/dom/sms/src/SmsManager.cpp
@@ -194,22 +194,22 @@ SmsManager::Send(const jsval& aNumber, c
 
   if (aNumber.isString()) {
     return Send(cx, global, aNumber.toString(), aMessage, aReturn);
   }
 
   // Must be an array then.
   JSObject& numbers = aNumber.toObject();
 
-  unsigned size;
+  uint32_t size;
   JS_ALWAYS_TRUE(JS_GetArrayLength(cx, &numbers, &size));
 
   jsval* requests = new jsval[size];
 
-  for (unsigned i=0; i<size; ++i) {
+  for (uint32_t i=0; i<size; ++i) {
     jsval number;
     if (!JS_GetElement(cx, &numbers, i, &number)) {
       return NS_ERROR_INVALID_ARG;
     }
 
     nsresult rv = Send(cx, global, number.toString(), aMessage, &requests[i]);
     NS_ENSURE_SUCCESS(rv, rv);
   }
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -1950,33 +1950,33 @@ ImplicitConvert(JSContext* cx,
       default:
         return TypeError(cx, "array", val);
       }
 
     } else if (!JSVAL_IS_PRIMITIVE(val) &&
                JS_IsArrayObject(cx, JSVAL_TO_OBJECT(val))) {
       // Convert each element of the array by calling ImplicitConvert.
       JSObject* sourceArray = JSVAL_TO_OBJECT(val);
-      unsigned sourceLength;
+      uint32_t sourceLength;
       if (!JS_GetArrayLength(cx, sourceArray, &sourceLength) ||
           targetLength != size_t(sourceLength)) {
         JS_ReportError(cx, "ArrayType length does not match source array length");
         return false;
       }
 
       // Convert into an intermediate, in case of failure.
       size_t elementSize = CType::GetSize(baseType);
       size_t arraySize = elementSize * targetLength;
       AutoPtr<char>::Array intermediate(cx->array_new<char>(arraySize));
       if (!intermediate) {
         JS_ReportAllocationOverflow(cx);
         return false;
       }
 
-      for (unsigned i = 0; i < sourceLength; ++i) {
+      for (uint32_t i = 0; i < sourceLength; ++i) {
         js::AutoValueRooter item(cx);
         if (!JS_GetElement(cx, sourceArray, i, item.jsval_addr()))
           return false;
 
         char* data = intermediate.get() + elementSize * i;
         if (!ImplicitConvert(cx, item.jsval_value(), baseType, data, false, NULL))
           return false;
       }
@@ -4107,17 +4107,17 @@ StructType::Create(JSContext* cx, unsign
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
   return JS_TRUE;
 }
 
 JSBool
 StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj)
 {
-  unsigned len;
+  uint32_t len;
   ASSERT_OK(JS_GetArrayLength(cx, fieldsObj, &len));
 
   // Get the common prototype for CData objects of this type from
   // ctypes.CType.prototype.
   JSObject* dataProto = CType::GetProtoFromType(typeObj, SLOT_STRUCTDATAPROTO);
 
   // Set up the 'prototype' and 'prototype.constructor' properties.
   // The prototype will reflect the struct fields as properties on CData objects
@@ -4145,17 +4145,17 @@ StructType::DefineInternal(JSContext* cx
     fieldRootsArray.begin());
 
   // Process the field types.
   size_t structSize, structAlign;
   if (len != 0) {
     structSize = 0;
     structAlign = 0;
 
-    for (unsigned i = 0; i < len; ++i) {
+    for (uint32_t i = 0; i < len; ++i) {
       js::AutoValueRooter item(cx);
       if (!JS_GetElement(cx, fieldsObj, i, item.jsval_addr()))
         return JS_FALSE;
 
       JSObject* fieldType = NULL;
       JSFlatString* name = ExtractStructField(cx, item.jsval_value(), &fieldType);
       if (!name)
         return JS_FALSE;
@@ -4920,29 +4920,29 @@ FunctionType::Create(JSContext* cx, unsi
     // Prepare an array of jsvals for the arguments.
     if (JSVAL_IS_PRIMITIVE(argv[2]) ||
         !JS_IsArrayObject(cx, JSVAL_TO_OBJECT(argv[2]))) {
       JS_ReportError(cx, "third argument must be an array");
       return JS_FALSE;
     }
 
     arrayObj = JSVAL_TO_OBJECT(argv[2]);
-    unsigned len;
+    uint32_t len;
     ASSERT_OK(JS_GetArrayLength(cx, arrayObj, &len));
 
     if (!argTypes.appendN(JSVAL_VOID, len)) {
       JS_ReportOutOfMemory(cx);
       return JS_FALSE;
     }
   }
 
   // Pull out the argument types from the array, if any.
   JS_ASSERT(!argTypes.length() || arrayObj);
   js::AutoArrayRooter items(cx, argTypes.length(), argTypes.begin());
-  for (unsigned i = 0; i < argTypes.length(); ++i) {
+  for (uint32_t i = 0; i < argTypes.length(); ++i) {
     if (!JS_GetElement(cx, arrayObj, i, &argTypes[i]))
       return JS_FALSE;
   }
 
   JSObject* result = CreateInternal(cx, argv[0], argv[1],
       argTypes.begin(), argTypes.length());
   if (!result)
     return JS_FALSE;
--- a/js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
+++ b/js/src/jsapi-tests/testIsAboutToBeFinalized.cpp
@@ -122,15 +122,15 @@ cls_testIsAboutToBeFinalized_bug528645::
      * Overwrite the registers and stack with new GC things to avoid false
      * positives with the finalization test.
      */
     EVAL("[]", root.addr());
 
     array = JSVAL_TO_OBJECT(root.value());
     JS_ASSERT(JS_IsArrayObject(cx, array));
 
-    unsigned tmp;
+    uint32_t tmp;
     CHECK(JS_GetArrayLength(cx, array, &tmp));
     CHECK(ok);
 
     return true;
 }
 
--- a/js/src/jsapi-tests/testNewObject.cpp
+++ b/js/src/jsapi-tests/testNewObject.cpp
@@ -50,17 +50,17 @@ BEGIN_TEST(testNewObject_1)
     EVAL("Array", &v);
     JSObject *Array = JSVAL_TO_OBJECT(v);
 
     // With no arguments.
     JSObject *obj = JS_New(cx, Array, 0, NULL);
     CHECK(obj);
     jsvalRoot rt(cx, OBJECT_TO_JSVAL(obj));
     CHECK(JS_IsArrayObject(cx, obj));
-    unsigned len;
+    uint32_t len;
     CHECK(JS_GetArrayLength(cx, obj, &len));
     CHECK_EQUAL(len, 0);
 
     // With one argument.
     argv[0] = INT_TO_JSVAL(4);
     obj = JS_New(cx, Array, 1, argv);
     CHECK(obj);
     rt = OBJECT_TO_JSVAL(obj);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4404,38 +4404,38 @@ JS_SetReservedSlot(JSObject *obj, uint32
 
 JS_PUBLIC_API(JSObject *)
 JS_NewArrayObject(JSContext *cx, int length, jsval *vector)
 {
     JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
     
-    assertSameCompartment(cx, JSValueArray(vector, vector ? (unsigned)length : 0));
-    return NewDenseCopiedArray(cx, (unsigned)length, vector);
+    assertSameCompartment(cx, JSValueArray(vector, vector ? (uint32_t)length : 0));
+    return NewDenseCopiedArray(cx, (uint32_t)length, vector);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_IsArrayObject(JSContext *cx, JSObject *obj)
 {
     assertSameCompartment(cx, obj);
     return ObjectClassIs(*obj, ESClass_Array, cx);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_GetArrayLength(JSContext *cx, JSObject *obj, unsigned *lengthp)
+JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp)
 {
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj);
     return js_GetLengthProperty(cx, obj, lengthp);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_SetArrayLength(JSContext *cx, JSObject *obj, unsigned length)
+JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length)
 {
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj);
     return js_SetLengthProperty(cx, obj, length);
 }
 
 JS_PUBLIC_API(JSBool)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1891,18 +1891,18 @@ JSID_TO_INT(jsid id)
  * js_CheckForStringIndex is still valid.
  */
 #define JSID_INT_MIN  (-(1 << 30))
 #define JSID_INT_MAX  ((1 << 30) - 1)
 
 static JS_ALWAYS_INLINE JSBool
 INT_FITS_IN_JSID(int32_t i)
 {
-    return ((unsigned)(i) - (unsigned)JSID_INT_MIN <=
-            (unsigned)(JSID_INT_MAX - JSID_INT_MIN));
+    return ((uint32_t)(i) - (uint32_t)JSID_INT_MIN <=
+            (uint32_t)(JSID_INT_MAX - JSID_INT_MIN));
 }
 
 static JS_ALWAYS_INLINE jsid
 INT_TO_JSID(int32_t i)
 {
     jsid id;
     JS_ASSERT(INT_FITS_IN_JSID(i));
     JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT);
@@ -3981,20 +3981,20 @@ JS_DeleteUCProperty2(JSContext *cx, JSOb
 
 extern JS_PUBLIC_API(JSObject *)
 JS_NewArrayObject(JSContext *cx, int length, jsval *vector);
 
 extern JS_PUBLIC_API(JSBool)
 JS_IsArrayObject(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
-JS_GetArrayLength(JSContext *cx, JSObject *obj, unsigned *lengthp);
+JS_GetArrayLength(JSContext *cx, JSObject *obj, uint32_t *lengthp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_SetArrayLength(JSContext *cx, JSObject *obj, unsigned length);
+JS_SetArrayLength(JSContext *cx, JSObject *obj, uint32_t length);
 
 extern JS_PUBLIC_API(JSBool)
 JS_DefineElement(JSContext *cx, JSObject *obj, uint32_t index, jsval value,
                  JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
 
 extern JS_PUBLIC_API(JSBool)
 JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32_t index, JSBool *foundp);
 
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -143,17 +143,17 @@
 #include "vm/Stack-inl.h"
 
 using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
 JSBool
-js_GetLengthProperty(JSContext *cx, JSObject *obj, unsigned *lengthp)
+js_GetLengthProperty(JSContext *cx, JSObject *obj, uint32_t *lengthp)
 {
     if (obj->isArray()) {
         *lengthp = obj->getArrayLength();
         return true;
     }
 
     if (obj->isArguments()) {
         ArgumentsObject &argsobj = obj->asArguments();
@@ -163,17 +163,17 @@ js_GetLengthProperty(JSContext *cx, JSOb
         }
     }
 
     AutoValueRooter tvr(cx);
     if (!obj->getProperty(cx, cx->runtime->atomState.lengthAtom, tvr.addr()))
         return false;
 
     if (tvr.value().isInt32()) {
-        *lengthp = unsigned(tvr.value().toInt32()); /* unsigned cast does ToUint32_t */
+        *lengthp = uint32_t(tvr.value().toInt32()); /* uint32_t cast does ToUint32_t */
         return true;
     }
 
     
     return ToUint32(cx, tvr.value(), (uint32_t *)lengthp);
 }
 
 namespace js {
@@ -193,17 +193,17 @@ namespace js {
  * In our implementation, it would be sufficient to check for JSVAL_IS_INT(id)
  * except that by using signed 31-bit integers we miss the top half of the
  * valid range. This function checks the string representation itself; note
  * that calling a standard conversion routine might allow strings such as
  * "08" or "4.0" as array indices, which they are not.
  *
  */
 JS_FRIEND_API(bool)
-StringIsArrayIndex(JSLinearString *str, unsigned *indexp)
+StringIsArrayIndex(JSLinearString *str, uint32_t *indexp)
 {
     const jschar *s = str->chars();
     uint32_t length = str->length();
     const jschar *end = s + length;
 
     if (length == 0 || length > (sizeof("4294967294") - 1) || !JS7_ISDEC(*s))
         return false;
 
@@ -232,17 +232,17 @@ StringIsArrayIndex(JSLinearString *str, 
     }
 
     return false;
 }
 
 }
 
 static JSBool
-BigIndexToId(JSContext *cx, JSObject *obj, unsigned index, JSBool createAtom,
+BigIndexToId(JSContext *cx, JSObject *obj, uint32_t index, JSBool createAtom,
              jsid *idp)
 {
     
     JS_ASSERT(index > JSID_INT_MAX);
 
     jschar buf[10];
     jschar *start = ArrayEnd(buf);
     do {
@@ -314,18 +314,18 @@ static bool
 IndexToId(JSContext* cx, JSObject* obj, double index, JSBool* hole, jsid* idp,
           JSBool createAtom = JS_FALSE)
 {
     if (index <= JSID_INT_MAX) {
         *idp = INT_TO_JSID(int(index));
         return JS_TRUE;
     }
 
-    if (index <= unsigned(-1)) {
-        if (!BigIndexToId(cx, obj, unsigned(index), createAtom, idp))
+    if (index <= uint32_t(-1)) {
+        if (!BigIndexToId(cx, obj, uint32_t(index), createAtom, idp))
             return JS_FALSE;
         if (hole && JSID_IS_VOID(*idp))
             *hole = JS_TRUE;
         return JS_TRUE;
     }
 
     return ReallyBigIndexToId(cx, index, idp);
 }
@@ -433,17 +433,17 @@ GetElementsSlow(JSContext *cx, JSObject 
         if (!aobj->getElement(cx, i, &vp[i]))
             return false;
     }
 
     return true;
 }
 
 bool
-GetElements(JSContext *cx, JSObject *aobj, unsigned length, Value *vp)
+GetElements(JSContext *cx, JSObject *aobj, uint32_t length, Value *vp)
 {
     if (aobj->isDenseArray() && length <= aobj->getDenseArrayInitializedLength() &&
         !js_PrototypeHasIndexedProperties(cx, aobj)) {
         /* The prototype does not have indexed properties so hole = undefined */
         const Value *srcbeg = aobj->getDenseArrayElements();
         const Value *srcend = srcbeg + length;
         const Value *src = srcbeg;
         for (Value *dst = vp; src < srcend; ++dst, ++src)
@@ -471,19 +471,19 @@ static JSBool
 SetArrayElement(JSContext *cx, JSObject *obj, double index, const Value &v)
 {
     JS_ASSERT(index >= 0);
 
     if (obj->isDenseArray()) {
         /* Predicted/prefetched code should favor the remains-dense case. */
         JSObject::EnsureDenseResult result = JSObject::ED_SPARSE;
         do {
-            if (index > unsigned(-1))
+            if (index > uint32_t(-1))
                 break;
-            unsigned idx = unsigned(index);
+            uint32_t idx = uint32_t(index);
             result = obj->ensureDenseArrayElements(cx, idx, 1);
             if (result != JSObject::ED_OK)
                 break;
             if (idx >= obj->getArrayLength())
                 obj->setDenseArrayLength(idx + 1);
             obj->setDenseArrayElementWithType(cx, idx, v);
             return true;
         } while (false);
@@ -625,18 +625,18 @@ array_length_setter(JSContext *cx, JSObj
 
     if (obj->isDenseArray()) {
         /*
          * Don't reallocate if we're not actually shrinking our slots. If we do
          * shrink slots here, shrink the initialized length too.  This permits us
          * us to disregard length when reading from arrays as long we are within
          * the initialized capacity.
          */
-        unsigned oldcap = obj->getDenseArrayCapacity();
-        unsigned oldinit = obj->getDenseArrayInitializedLength();
+        uint32_t oldcap = obj->getDenseArrayCapacity();
+        uint32_t oldinit = obj->getDenseArrayInitializedLength();
         if (oldinit > newlen)
             obj->setDenseArrayInitializedLength(newlen);
         if (oldcap > newlen)
             obj->shrinkElements(cx, newlen);
     } else if (oldlen - newlen < (1 << 24)) {
         do {
             --oldlen;
             if (!JS_CHECK_OPERATION_LIMIT(cx)) {
@@ -656,23 +656,23 @@ array_length_setter(JSContext *cx, JSObj
          * oldlen, we iterate through all properties and remove those that
          * correspond to indexes in the half-open range [newlen, oldlen).  See
          * bug 322135.
          */
         JSObject *iter = JS_NewPropertyIterator(cx, obj);
         if (!iter)
             return false;
 
-        unsigned gap = oldlen - newlen;
+        uint32_t gap = oldlen - newlen;
         for (;;) {
             if (!JS_CHECK_OPERATION_LIMIT(cx) || !JS_NextProperty(cx, iter, &id))
                 return false;
             if (JSID_IS_VOID(id))
                 break;
-            unsigned index;
+            uint32_t index;
             Value junk;
             if (js_IdIsIndex(id, &index) && index - newlen < gap &&
                 !obj->deleteElement(cx, index, &junk, false)) {
                 return false;
             }
         }
     }
 
@@ -859,17 +859,17 @@ array_getGeneric(JSContext *cx, JSObject
         return array_getElement(cx, obj, receiver, index, vp);
 
     return array_getProperty(cx, obj, receiver, atom->asPropertyName(), vp);
 }
 
 static JSBool
 slowarray_addProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
 {
-    unsigned index, length;
+    uint32_t index, length;
 
     if (!js_IdIsIndex(id, &index))
         return JS_TRUE;
     length = obj->getArrayLength();
     if (index >= length)
         obj->setArrayLength(cx, index + 1);
     return JS_TRUE;
 }
@@ -1484,21 +1484,21 @@ array_toSource(JSContext *cx, unsigned a
         if (!sb.append("[]"))
             return false;
         goto make_string;
     }
 
     if (!sb.append('['))
         return false;
 
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return false;
 
-    for (unsigned index = 0; index < length; index++) {
+    for (uint32_t index = 0; index < length; index++) {
         JSBool hole;
         Value elt;
         if (!JS_CHECK_OPERATION_LIMIT(cx) ||
             !GetElement(cx, obj, index, &hole, &elt)) {
             return false;
         }
 
         /* Get element's character string. */
@@ -1604,17 +1604,17 @@ array_toString_sub(JSContext *cx, JSObje
     if (!detector.init())
         return false;
 
     if (detector.foundCycle()) {
         args.rval().setString(cx->runtime->atomState.emptyAtom);
         return true;
     }
 
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return false;
 
     StringBuffer sb(cx);
 
     if (!locale && !seplen && obj->isDenseArray() && !js_PrototypeHasIndexedProperties(cx, obj)) {
         const Value *start = obj->getDenseArrayElements();
         const Value *end = start + obj->getDenseArrayInitializedLength();
@@ -1645,17 +1645,17 @@ array_toString_sub(JSContext *cx, JSObje
             if (!GetElement(cx, obj, i, &hole, &v))
                 return false;
             if (!hole && !v.isNullOrUndefined()) {
                 if (!ValueToStringBuffer(cx, v, sb))
                     return false;
             }
         }
     } else {
-        for (unsigned index = 0; index < length; index++) {
+        for (uint32_t index = 0; index < length; index++) {
             if (!JS_CHECK_OPERATION_LIMIT(cx))
                 return false;
 
             JSBool hole;
             Value elt;
             if (!GetElement(cx, obj, index, &hole, &elt))
                 return false;
 
@@ -1789,17 +1789,17 @@ InitArrayElements(JSContext *cx, JSObjec
 
         JSObject::EnsureDenseResult result = obj->ensureDenseArrayElements(cx, start, count);
         if (result != JSObject::ED_OK) {
             if (result == JSObject::ED_FAILED)
                 return false;
             JS_ASSERT(result == JSObject::ED_SPARSE);
             break;
         }
-        unsigned newlen = start + count;
+        uint32_t newlen = start + count;
         if (newlen > obj->getArrayLength())
             obj->setDenseArrayLength(newlen);
 
         JS_ASSERT(count < UINT32_MAX / sizeof(Value));
         obj->copyDenseArrayElements(start, vector, count);
         JS_ASSERT_IF(count != 0, !obj->getDenseArrayElement(newlen - 1).isMagic(JS_ARRAY_HOLE));
         return true;
     } while (false);
@@ -1832,17 +1832,17 @@ InitArrayElements(JSContext *cx, JSObjec
         idval.getDoubleRef() += 1;
     } while (vector != end);
 
     return true;
 }
 
 #if 0
 static JSBool
-InitArrayObject(JSContext *cx, JSObject *obj, unsigned length, const Value *vector)
+InitArrayObject(JSContext *cx, JSObject *obj, uint32_t length, const Value *vector)
 {
     JS_ASSERT(obj->isArray());
 
     JS_ASSERT(obj->isDenseArray());
     obj->setArrayLength(cx, length);
     if (!vector || !length)
         return true;
 
@@ -1851,17 +1851,17 @@ InitArrayObject(JSContext *cx, JSObject 
 
     /* Avoid ensureDenseArrayElements to skip sparse array checks there. */
     if (!obj->ensureElements(cx, length))
         return false;
 
     obj->setDenseArrayInitializedLength(length);
 
     bool hole = false;
-    for (unsigned i = 0; i < length; i++) {
+    for (uint32_t i = 0; i < length; i++) {
         obj->setDenseArrayElement(i, vector[i]);
         hole |= vector[i].isMagic(JS_ARRAY_HOLE);
     }
     if (hole)
         obj->markDenseArrayNotPacked(cx);
 
     return true;
 }
@@ -1894,17 +1894,17 @@ array_join(JSContext *cx, unsigned argc,
 static JSBool
 array_reverse(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return false;
 
-    unsigned len;
+    uint32_t len;
     if (!js_GetLengthProperty(cx, obj, &len))
         return false;
 
     do {
         if (!obj->isDenseArray())
             break;
         if (js_PrototypeHasIndexedProperties(cx, obj))
             break;
@@ -1956,17 +1956,17 @@ array_reverse(JSContext *cx, unsigned ar
          * array has trailing holes (and thus the original array began with
          * holes).
          */
         args.rval().setObject(*obj);
         return true;
     } while (false);
 
     Value lowval, hival;
-    for (unsigned i = 0, half = len / 2; i < half; i++) {
+    for (uint32_t i = 0, half = len / 2; i < half; i++) {
         JSBool hole, hole2;
         if (!JS_CHECK_OPERATION_LIMIT(cx) ||
             !GetElement(cx, obj, i, &hole, &lowval) ||
             !GetElement(cx, obj, len - i - 1, &hole2, &hival) ||
             !SetOrDeleteArrayElement(cx, obj, len - i - 1, hole, lowval) ||
             !SetOrDeleteArrayElement(cx, obj, i, hole2, hival)) {
             return false;
         }
@@ -2198,17 +2198,17 @@ js::array_sort(JSContext *cx, unsigned a
     } else {
         fval.setNull();
     }
 
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return false;
 
-    unsigned len;
+    uint32_t len;
     if (!js_GetLengthProperty(cx, obj, &len))
         return false;
     if (len == 0) {
         args.rval().setObject(*obj);
         return true;
     }
 
     /*
@@ -2245,17 +2245,17 @@ js::array_sort(JSContext *cx, unsigned a
          * value undefined and that is always greater than any other property.
          * Thus to sort holes and undefs we simply count them, sort the rest
          * of elements, append undefs after them and then make holes after
          * undefs.
          */
         undefs = 0;
         bool allStrings = true;
         bool allInts = true;
-        for (unsigned i = 0; i < len; i++) {
+        for (uint32_t i = 0; i < len; i++) {
             if (!JS_CHECK_OPERATION_LIMIT(cx))
                 return false;
 
             /* Clear vec[newlen] before including it in the rooted set. */
             JSBool hole;
             Value v;
             if (!GetElement(cx, obj, i, &hole, &v))
                 return false;
@@ -2336,17 +2336,17 @@ js::array_sort(JSContext *cx, unsigned a
         } else {
             InvokeArgsGuard args;
             if (!MergeSort(vec.begin(), n, vec.begin() + n,
                            SortComparatorFunction(cx, fval, args))) {
                 return false;
             }
         }
 
-        if (!InitArrayElements(cx, obj, 0, unsigned(n), result, DontUpdateTypes))
+        if (!InitArrayElements(cx, obj, 0, uint32_t(n), result, DontUpdateTypes))
             return false;
     }
 
     /* Set undefs that sorted after the rest of elements. */
     while (undefs != 0) {
         --undefs;
         if (!JS_CHECK_OPERATION_LIMIT(cx) || !SetArrayElement(cx, obj, n++, UndefinedValue()))
             return false;
@@ -2362,17 +2362,17 @@ js::array_sort(JSContext *cx, unsigned a
 }
 
 /*
  * Perl-inspired push, pop, shift, unshift, and splice methods.
  */
 static bool
 array_push_slowly(JSContext *cx, JSObject *obj, CallArgs &args)
 {
-    unsigned length;
+    uint32_t length;
 
     if (!js_GetLengthProperty(cx, obj, &length))
         return false;
     if (!InitArrayElements(cx, obj, length, args.length(), args.array(), UpdateTypes))
         return false;
 
     /* Per ECMA-262, return the new array length. */
     double newlength = length + double(args.length());
@@ -2446,17 +2446,17 @@ js::array_push(JSContext *cx, unsigned a
         return array_push_slowly(cx, obj, args);
 
     return array_push1_dense(cx, obj, args);
 }
 
 static JSBool
 array_pop_slowly(JSContext *cx, JSObject* obj, CallArgs &args)
 {
-    unsigned index;
+    uint32_t index;
     if (!js_GetLengthProperty(cx, obj, &index))
         return false;
 
     if (index == 0) {
         args.rval().setUndefined();
         return js_SetLengthProperty(cx, obj, index);
     }
 
@@ -2472,17 +2472,17 @@ array_pop_slowly(JSContext *cx, JSObject
 
     args.rval() = elt;
     return js_SetLengthProperty(cx, obj, index);
 }
 
 static JSBool
 array_pop_dense(JSContext *cx, JSObject* obj, CallArgs &args)
 {
-    unsigned index = obj->getArrayLength();
+    uint32_t index = obj->getArrayLength();
     if (index == 0) {
         args.rval().setUndefined();
         return JS_TRUE;
     }
 
     index--;
 
     JSBool hole;
@@ -2533,17 +2533,17 @@ mjit::stubs::ArrayShift(VMFrame &f)
 JSBool
 js::array_shift(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return JS_FALSE;
 
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return JS_FALSE;
 
     if (length == 0) {
         args.rval().setUndefined();
     } else {
         length--;
 
@@ -2562,17 +2562,17 @@ js::array_shift(JSContext *cx, unsigned 
         }
 
         JSBool hole;
         if (!GetElement(cx, obj, 0u, &hole, &args.rval()))
             return JS_FALSE;
 
         /* Slide down the array above the first element. */
         AutoValueRooter tvr(cx);
-        for (unsigned i = 0; i < length; i++) {
+        for (uint32_t i = 0; i < length; i++) {
             if (!JS_CHECK_OPERATION_LIMIT(cx) ||
                 !GetElement(cx, obj, i + 1, &hole, tvr.addr()) ||
                 !SetOrDeleteArrayElement(cx, obj, i, hole, tvr.value())) {
                 return JS_FALSE;
             }
         }
 
         /* Delete the only or last element when it exists. */
@@ -2585,17 +2585,17 @@ js::array_shift(JSContext *cx, unsigned 
 static JSBool
 array_unshift(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return false;
 
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return JS_FALSE;
 
     double newlen = length;
     if (args.length() > 0) {
         /* Slide up the array to make room for all args at the bottom. */
         if (length > 0) {
             bool optimized = false;
@@ -2931,21 +2931,21 @@ js::array_concat(JSContext *cx, unsigned
     Value *p = JS_ARGV(cx, vp) - 1;
 
     /* Create a new Array object and root it using *vp. */
     JSObject *aobj = ToObject(cx, &vp[1]);
     if (!aobj)
         return false;
 
     JSObject *nobj;
-    unsigned length;
+    uint32_t length;
     if (aobj->isDenseArray()) {
         length = aobj->getArrayLength();
         const Value *vector = aobj->getDenseArrayElements();
-        unsigned initlen = aobj->getDenseArrayInitializedLength();
+        uint32_t initlen = aobj->getDenseArrayInitializedLength();
         nobj = NewDenseCopiedArray(cx, initlen, vector);
         if (!nobj)
             return JS_FALSE;
         TryReuseArrayType(aobj, nobj);
         nobj->setArrayLength(cx, length);
         vp->setObject(*nobj);
         if (argc == 0)
             return JS_TRUE;
@@ -2962,17 +2962,17 @@ js::array_concat(JSContext *cx, unsigned
     /* Loop over [0, argc] to concat args into nobj, expanding all Arrays. */
     for (unsigned i = 0; i <= argc; i++) {
         if (!JS_CHECK_OPERATION_LIMIT(cx))
             return false;
         const Value &v = p[i];
         if (v.isObject()) {
             JSObject &obj = v.toObject();
             if (ObjectClassIs(obj, ESClass_Array, cx)) {
-                unsigned alength;
+                uint32_t alength;
                 if (!js_GetLengthProperty(cx, &obj, &alength))
                     return false;
                 for (uint32_t slot = 0; slot < alength; slot++) {
                     JSBool hole;
                     Value tmp;
                     if (!JS_CHECK_OPERATION_LIMIT(cx) || !GetElement(cx, &obj, slot, &hole, &tmp))
                         return false;
 
@@ -2995,17 +2995,17 @@ js::array_concat(JSContext *cx, unsigned
 
     return js_SetLengthProperty(cx, nobj, length);
 }
 
 static JSBool
 array_slice(JSContext *cx, unsigned argc, Value *vp)
 {
     JSObject *nobj;
-    unsigned length, begin, end, slot;
+    uint32_t length, begin, end, slot;
     JSBool hole;
 
     CallArgs args = CallArgsFromVp(argc, vp);
 
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return false;
 
@@ -3020,29 +3020,29 @@ array_slice(JSContext *cx, unsigned argc
             return false;
         if (d < 0) {
             d += length;
             if (d < 0)
                 d = 0;
         } else if (d > length) {
             d = length;
         }
-        begin = (unsigned)d;
+        begin = (uint32_t)d;
 
         if (args.hasDefined(1)) {
             if (!ToInteger(cx, args[1], &d))
                 return false;
             if (d < 0) {
                 d += length;
                 if (d < 0)
                     d = 0;
             } else if (d > length) {
                 d = length;
             }
-            end = (unsigned)d;
+            end = (uint32_t)d;
         }
     }
 
     if (begin > end)
         begin = end;
 
     if (obj->isDenseArray() && end <= obj->getDenseArrayInitializedLength() &&
         !js_PrototypeHasIndexedProperties(cx, obj)) {
@@ -3076,17 +3076,17 @@ array_slice(JSContext *cx, unsigned argc
 enum IndexOfKind {
     IndexOf,
     LastIndexOf
 };
 
 static JSBool
 array_indexOfHelper(JSContext *cx, IndexOfKind mode, CallArgs &args)
 {
-    unsigned length, i, stop;
+    uint32_t length, i, stop;
     Value tosearch;
     int direction;
     JSBool hole;
 
     JSObject *obj = ToObject(cx, &args.thisv());
     if (!obj)
         return false;
     if (!js_GetLengthProperty(cx, obj, &length))
@@ -3105,39 +3105,39 @@ array_indexOfHelper(JSContext *cx, Index
             return false;
         if (start < 0) {
             start += length;
             if (start < 0) {
                 if (mode == LastIndexOf)
                     goto not_found;
                 i = 0;
             } else {
-                i = (unsigned)start;
+                i = (uint32_t)start;
             }
         } else if (start >= length) {
             if (mode == IndexOf)
                 goto not_found;
             i = length - 1;
         } else {
-            i = (unsigned)start;
+            i = (uint32_t)start;
         }
     }
 
     if (mode == LastIndexOf) {
         stop = 0;
         direction = -1;
     } else {
         stop = length - 1;
         direction = 1;
     }
 
     for (;;) {
         Value elt;
         if (!JS_CHECK_OPERATION_LIMIT(cx) ||
-            !GetElement(cx, obj, (unsigned)i, &hole, &elt)) {
+            !GetElement(cx, obj, (uint32_t)i, &hole, &elt)) {
             return JS_FALSE;
         }
         if (!hole) {
             bool equal;
             if (!StrictlyEqual(cx, elt, tosearch, &equal))
                 return false;
             if (equal) {
                 args.rval().setNumber(i);
@@ -3731,17 +3731,17 @@ js_InitArrayClass(JSContext *cx, JSObjec
 }
 
 /*
  * Array allocation functions.
  */
 namespace js {
 
 static inline bool
-EnsureNewArrayElements(JSContext *cx, JSObject *obj, unsigned length)
+EnsureNewArrayElements(JSContext *cx, JSObject *obj, uint32_t length)
 {
     /*
      * If ensureElements creates dynamically allocated slots, then having
      * fixedSlots is a waste.
      */
     DebugOnly<uint32_t> cap = obj->getDenseArrayCapacity();
 
     if (!obj->ensureElements(cx, length))
--- a/js/src/jsarray.h
+++ b/js/src/jsarray.h
@@ -52,23 +52,23 @@
 const unsigned MIN_SPARSE_INDEX = 256;
 
 namespace js {
 /* 2^32-2, inclusive */
 const uint32_t MAX_ARRAY_INDEX = 4294967294u;
 }
 
 inline JSBool
-js_IdIsIndex(jsid id, unsigned *indexp)
+js_IdIsIndex(jsid id, uint32_t *indexp)
 {
     if (JSID_IS_INT(id)) {
         int32_t i = JSID_TO_INT(id);
         if (i < 0)
             return JS_FALSE;
-        *indexp = (unsigned)i;
+        *indexp = (uint32_t)i;
         return JS_TRUE;
     }
 
     if (JS_UNLIKELY(!JSID_IS_STRING(id)))
         return JS_FALSE;
 
     return js::StringIsArrayIndex(JSID_TO_ATOM(id), indexp);
 }
@@ -132,17 +132,17 @@ NewDenseCopiedArray(JSContext *cx, uint3
 
 /* Create a sparse array. */
 extern JSObject *
 NewSlowEmptyArray(JSContext *cx);
 
 } /* namespace js */
 
 extern JSBool
-js_GetLengthProperty(JSContext *cx, JSObject *obj, unsigned *lengthp);
+js_GetLengthProperty(JSContext *cx, JSObject *obj, uint32_t *lengthp);
 
 extern JSBool
 js_SetLengthProperty(JSContext *cx, JSObject *obj, double length);
 
 namespace js {
 
 extern JSBool
 array_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *value,
@@ -153,17 +153,17 @@ array_deleteElement(JSContext *cx, JSObj
 
 /*
  * Copy 'length' elements from aobj to vp.
  *
  * This function assumes 'length' is effectively the result of calling
  * js_GetLengthProperty on aobj.
  */
 extern bool
-GetElements(JSContext *cx, JSObject *aobj, unsigned length, js::Value *vp);
+GetElements(JSContext *cx, JSObject *aobj, uint32_t length, js::Value *vp);
 
 /* Natives exposed for optimization by the interpreter and JITs. */
 
 extern JSBool
 array_sort(JSContext *cx, unsigned argc, js::Value *vp);
 
 extern JSBool
 array_push(JSContext *cx, unsigned argc, js::Value *vp);
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -707,19 +707,19 @@ js_CheckForStringIndex(jsid id)
 
     size_t n = atom->length() - negative;
     if (n > sizeof(JSBOXEDWORD_INT_MAX_STRING) - 1)
         return id;
 
     const jschar *cp = s;
     const jschar *end = s + n;
 
-    unsigned index = JS7_UNDEC(*cp++);
-    unsigned oldIndex = 0;
-    unsigned c = 0;
+    uint32_t index = JS7_UNDEC(*cp++);
+    uint32_t oldIndex = 0;
+    uint32_t c = 0;
 
     if (index != 0) {
         while (JS7_ISDEC(*cp)) {
             oldIndex = index;
             c = JS7_UNDEC(*cp);
             index = 10 * index + c;
             cp++;
         }
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -508,17 +508,17 @@ CastAsJSStrictPropertyOp(JSObject *objec
 {
     return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object);
 }
 
 JS_FRIEND_API(bool)
 GetPropertyNames(JSContext *cx, JSObject *obj, unsigned flags, js::AutoIdVector *props);
 
 JS_FRIEND_API(bool)
-StringIsArrayIndex(JSLinearString *str, unsigned *indexp);
+StringIsArrayIndex(JSLinearString *str, uint32_t *indexp);
 
 JS_FRIEND_API(void)
 SetPreserveWrapperCallback(JSRuntime *rt, PreserveWrapperCallback callback);
 
 JS_FRIEND_API(bool)
 IsObjectInContextCompartment(const JSObject *obj, const JSContext *cx);
 
 /*
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1291,17 +1291,17 @@ js_fun_apply(JSContext *cx, unsigned arg
         return false;
     }
 
     /*
      * Steps 4-5 (note erratum removing steps originally numbered 5 and 7 in
      * original version of ES5).
      */
     JSObject *aobj = &vp[3].toObject();
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, aobj, &length))
         return false;
 
     /* Step 6. */
     if (length > StackSpace::ARGS_LENGTH_MAX) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_TOO_MANY_FUN_APPLY_ARGS);
         return false;
     }
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -719,17 +719,17 @@ Chunk::removeFromAvailableList()
 }
 
 /*
  * Search for and return the next decommitted Arena. Our goal is to keep
  * lastDecommittedArenaOffset "close" to a free arena. We do this by setting
  * it to the most recently freed arena when we free, and forcing it to
  * the last alloc + 1 when we allocate.
  */
-unsigned
+uint32_t
 Chunk::findDecommittedArenaOffset()
 {
     /* Note: lastFreeArenaOffset can be past the end of the list. */
     for (unsigned i = info.lastDecommittedArenaOffset; i < ArenasPerChunk; i++)
         if (decommittedArenas.get(i))
             return i;
     for (unsigned i = 0; i < info.lastDecommittedArenaOffset; i++)
         if (decommittedArenas.get(i))
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -2900,17 +2900,17 @@ BEGIN_CASE(JSOP_TABLESWITCH)
     }
 
     pc2 += JUMP_OFFSET_LEN;
     int32_t low = GET_JUMP_OFFSET(pc2);
     pc2 += JUMP_OFFSET_LEN;
     int32_t high = GET_JUMP_OFFSET(pc2);
 
     i -= low;
-    if ((unsigned)i < (unsigned)(high - low + 1)) {
+    if ((uint32_t)i < (uint32_t)(high - low + 1)) {
         pc2 += JUMP_OFFSET_LEN + JUMP_OFFSET_LEN * i;
         int32_t off = (int32_t) GET_JUMP_OFFSET(pc2);
         if (off)
             len = off;
     }
 }
 END_VARLEN_CASE
 }
@@ -3552,19 +3552,19 @@ BEGIN_CASE(JSOP_INITELEM)
     /*
      * If rref is a hole, do not call JSObject::defineProperty. In this case,
      * obj must be an array, so if the current op is the last element
      * initialiser, set the array length to one greater than id.
      */
     if (rref.isMagic(JS_ARRAY_HOLE)) {
         JS_ASSERT(obj->isArray());
         JS_ASSERT(JSID_IS_INT(id));
-        JS_ASSERT(unsigned(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
+        JS_ASSERT(uint32_t(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
         if (JSOp(regs.pc[JSOP_INITELEM_LENGTH]) == JSOP_ENDINIT &&
-            !js_SetLengthProperty(cx, obj, (unsigned) (JSID_TO_INT(id) + 1))) {
+            !js_SetLengthProperty(cx, obj, (uint32_t) (JSID_TO_INT(id) + 1))) {
             goto error;
         }
     } else {
         if (!obj->defineGeneric(cx, id, rref, NULL, NULL, JSPROP_ENUMERATE))
             goto error;
     }
     regs.sp -= 2;
 }
--- a/js/src/jsinterpinlines.h
+++ b/js/src/jsinterpinlines.h
@@ -227,17 +227,17 @@ GetPropertyOperation(JSContext *cx, jsby
         }
         if (lval.isMagic(JS_LAZY_ARGUMENTS)) {
             *vp = Int32Value(cx->fp()->numActualArgs());
             return true;
         }
         if (lval.isObject()) {
             JSObject *obj = &lval.toObject();
             if (obj->isArray()) {
-                unsigned length = obj->getArrayLength();
+                uint32_t length = obj->getArrayLength();
                 *vp = NumberValue(length);
                 return true;
             }
 
             if (obj->isArguments()) {
                 ArgumentsObject *argsobj = &obj->asArguments();
                 if (!argsobj->hasOverriddenLength()) {
                     uint32_t length = argsobj->initialLength();
@@ -799,23 +799,23 @@ GetElementOperation(JSContext *cx, const
 
 static JS_ALWAYS_INLINE bool
 SetObjectElementOperation(JSContext *cx, JSObject *obj, jsid id, const Value &value, bool strict)
 {
     types::TypeScript::MonitorAssign(cx, obj, id);
 
     do {
         if (obj->isDenseArray() && JSID_IS_INT(id)) {
-            unsigned length = obj->getDenseArrayInitializedLength();
+            uint32_t length = obj->getDenseArrayInitializedLength();
             int32_t i = JSID_TO_INT(id);
-            if ((unsigned)i < length) {
+            if ((uint32_t)i < length) {
                 if (obj->getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE)) {
                     if (js_PrototypeHasIndexedProperties(cx, obj))
                         break;
-                    if ((unsigned)i >= obj->getArrayLength())
+                    if ((uint32_t)i >= obj->getArrayLength())
                         obj->setArrayLength(cx, i + 1);
                 }
                 obj->setDenseArrayElementWithType(cx, i, value);
                 return true;
             } else {
                 JSScript *script;
                 jsbytecode *pc;
                 types::TypeScript::GetPcScript(cx, &script, &pc);
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -2189,17 +2189,17 @@ DefinePropertyOnArray(JSContext *cx, JSO
      * the descriptor describes a traditional array property (enumerable,
      * configurable, writable, numeric index or length without altering its
      * attributes).  Such definitions are probably unlikely, so we don't bother
      * for now.
      */
     if (obj->isDenseArray() && !obj->makeDenseArraySlow(cx))
         return JS_FALSE;
 
-    unsigned oldLen = obj->getArrayLength();
+    uint32_t oldLen = obj->getArrayLength();
 
     if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
         /*
          * Our optimization of storage of the length property of arrays makes
          * it very difficult to properly implement defining the property.  For
          * now simply throw an exception (NB: not merely Reject) on any attempt
          * to define the "length" property, rather than attempting to implement
          * some difficult-for-authors-to-grasp subset of that functionality.
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -495,17 +495,17 @@ JA(JSContext *cx, JSObject *obj, Stringi
     CycleDetector detect(scx, obj);
     if (!detect.init(cx))
         return JS_FALSE;
 
     if (!scx->sb.append('['))
         return JS_FALSE;
 
     /* Step 6. */
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return JS_FALSE;
 
     /* Steps 7-10. */
     if (length != 0) {
         /* Steps 4, 10b(i). */
         if (!WriteIndent(cx, scx, scx->depth))
             return JS_FALSE;
@@ -644,27 +644,27 @@ js_Stringify(JSContext *cx, Value *vp, J
              *            or "Number" then let item be ToString(v).
              *      6. If item is not undefined and item is not currently an
              *         element of PropertyList then,
              *         a. Append item to the end of PropertyList.
              *      7. Let i be i + 1.
              */
 
             /* Step 4b(ii). */
-            unsigned len;
+            uint32_t len;
             JS_ALWAYS_TRUE(js_GetLengthProperty(cx, replacer, &len));
             if (replacer->isDenseArray())
                 len = JS_MIN(len, replacer->getDenseArrayCapacity());
 
             HashSet<jsid> idSet(cx);
             if (!idSet.init(len))
                 return false;
 
             /* Step 4b(iii). */
-            unsigned i = 0;
+            uint32_t i = 0;
 
             /* Step 4b(iv). */
             for (; i < len; i++) {
                 /* Step 4b(iv)(2). */
                 Value v;
                 if (!replacer->getElement(cx, i, &v))
                     return false;
 
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -1820,30 +1820,30 @@ GetLocal(SprintStack *ss, int i)
         JS_ASSERT(pc < (ss->printer->script->code + ss->printer->script->length));
 
         if (JSOP_ENTERBLOCK == (JSOp)*pc) {
             JSObject *obj = script->getObject(GET_UINT32_INDEX(pc));
 
             if (obj->isBlock()) {
                 uint32_t depth = obj->asBlock().stackDepth();
                 uint32_t count = obj->asBlock().slotCount();
-                if (unsigned(i - depth) < unsigned(count))
+                if (uint32_t(i - depth) < uint32_t(count))
                     return GetLocalInSlot(ss, i, int(i - depth), obj);
             }
         }
     }
 
     // Iterate over all objects.
     for (jsatomid j = 0, n = script->objects()->length; j != n; j++) {
         JSObject *obj = script->getObject(j);
 
         if (obj->isBlock()) {
             uint32_t depth = obj->asBlock().stackDepth();
             uint32_t count = obj->asBlock().slotCount();
-            if (unsigned(i - depth) < unsigned(count))
+            if (uint32_t(i - depth) < uint32_t(count))
                 return GetLocalInSlot(ss, i, int(i - depth), obj);
         }
     }
 
     return GetStr(ss, i);
 }
 
 #undef LOCAL_ASSERT
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -489,21 +489,21 @@ static bool
 ArrayToIdVector(JSContext *cx, const Value &array, AutoIdVector &props)
 {
     JS_ASSERT(props.length() == 0);
 
     if (array.isPrimitive())
         return true;
 
     JSObject *obj = &array.toObject();
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, obj, &length))
         return false;
 
-    for (unsigned n = 0; n < length; ++n) {
+    for (uint32_t n = 0; n < length; ++n) {
         if (!JS_CHECK_OPERATION_LIMIT(cx))
             return false;
         Value v;
         if (!obj->getElement(cx, n, &v))
             return false;
         jsid id;
         if (!ValueToId(cx, v, &id))
             return false;
--- a/js/src/jsscope.cpp
+++ b/js/src/jsscope.cpp
@@ -639,17 +639,17 @@ JSObject::addPropertyInternal(JSContext 
 
     JS_ASSERT(!!table == !!spp);
 
     /* Find or create a property tree node labeled by our arguments. */
     Shape *shape;
     {
         shape = self->lastProperty();
 
-        unsigned index;
+        uint32_t index;
         bool indexed = js_IdIsIndex(id, &index);
         UnownedBaseShape *nbase;
         if (shape->base()->matchesGetterSetter(getter, setter) && !indexed) {
             nbase = shape->base()->unowned();
         } else {
             StackBaseShape base(shape->base());
             base.updateGetterSetter(attrs, getter, setter);
             if (indexed)
@@ -753,17 +753,17 @@ JSObject::putProperty(JSContext *cx, jsi
      */
     bool hadSlot = shape->hasSlot();
     uint32_t oldSlot = shape->maybeSlot();
     if (!(attrs & JSPROP_SHARED) && slot == SHAPE_INVALID_SLOT && hadSlot)
         slot = oldSlot;
 
     RootedVar<UnownedBaseShape*> nbase(cx);
     {
-        unsigned index;
+        uint32_t index;
         bool indexed = js_IdIsIndex(id, &index);
         StackBaseShape base(self->lastProperty()->base());
         base.updateGetterSetter(attrs, getter, setter);
         if (indexed)
             base.flags |= BaseShape::INDEXED;
         nbase = BaseShape::getUnowned(cx, base);
         if (!nbase)
             return NULL;
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -872,77 +872,77 @@ out_of_range:
 }
 
 /*
  * Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen.
  * The patlen argument must be positive and no greater than sBMHPatLenMax.
  *
  * Return the index of pat in text, or -1 if not found.
  */
-static const unsigned sBMHCharSetSize = 256; /* ISO-Latin-1 */
-static const unsigned sBMHPatLenMax   = 255; /* skip table element is uint8_t */
+static const uint32_t sBMHCharSetSize = 256; /* ISO-Latin-1 */
+static const uint32_t sBMHPatLenMax   = 255; /* skip table element is uint8_t */
 static const int      sBMHBadPattern  = -2;  /* return value if pat is not ISO-Latin-1 */
 
 int
-js_BoyerMooreHorspool(const jschar *text, unsigned textlen,
-                      const jschar *pat, unsigned patlen)
+js_BoyerMooreHorspool(const jschar *text, uint32_t textlen,
+                      const jschar *pat, uint32_t patlen)
 {
     uint8_t skip[sBMHCharSetSize];
 
     JS_ASSERT(0 < patlen && patlen <= sBMHPatLenMax);
-    for (unsigned i = 0; i < sBMHCharSetSize; i++)
+    for (uint32_t i = 0; i < sBMHCharSetSize; i++)
         skip[i] = (uint8_t)patlen;
-    unsigned m = patlen - 1;
-    for (unsigned i = 0; i < m; i++) {
+    uint32_t m = patlen - 1;
+    for (uint32_t i = 0; i < m; i++) {
         jschar c = pat[i];
         if (c >= sBMHCharSetSize)
             return sBMHBadPattern;
         skip[c] = (uint8_t)(m - i);
     }
     jschar c;
-    for (unsigned k = m;
+    for (uint32_t k = m;
          k < textlen;
          k += ((c = text[k]) >= sBMHCharSetSize) ? patlen : skip[c]) {
-        for (unsigned i = k, j = m; ; i--, j--) {
+        for (uint32_t i = k, j = m; ; i--, j--) {
             if (text[i] != pat[j])
                 break;
             if (j == 0)
                 return static_cast<int>(i);  /* safe: max string size */
         }
     }
     return -1;
 }
 
 struct MemCmp {
-    typedef unsigned Extent;
-    static JS_ALWAYS_INLINE Extent computeExtent(const jschar *, unsigned patlen) {
+    typedef uint32_t Extent;
+    static JS_ALWAYS_INLINE Extent computeExtent(const jschar *, uint32_t patlen) {
         return (patlen - 1) * sizeof(jschar);
     }
     static JS_ALWAYS_INLINE bool match(const jschar *p, const jschar *t, Extent extent) {
         return memcmp(p, t, extent) == 0;
     }
 };
 
 struct ManualCmp {
     typedef const jschar *Extent;
-    static JS_ALWAYS_INLINE Extent computeExtent(const jschar *pat, unsigned patlen) {
+    static JS_ALWAYS_INLINE Extent computeExtent(const jschar *pat, uint32_t patlen) {
         return pat + patlen;
     }
     static JS_ALWAYS_INLINE bool match(const jschar *p, const jschar *t, Extent extent) {
         for (; p != extent; ++p, ++t) {
             if (*p != *t)
                 return false;
         }
         return true;
     }
 };
 
 template <class InnerMatch>
 static int
-UnrolledMatch(const jschar *text, unsigned textlen, const jschar *pat, unsigned patlen)
+UnrolledMatch(const jschar *text, uint32_t textlen, const jschar *pat, uint32_t patlen)
 {
     JS_ASSERT(patlen > 0 && textlen > 0);
     const jschar *textend = text + textlen - (patlen - 1);
     const jschar p0 = *pat;
     const jschar *const patNext = pat + 1;
     const typename InnerMatch::Extent extent = InnerMatch::computeExtent(pat, patlen);
     uint8_t fixup;
 
@@ -977,18 +977,18 @@ UnrolledMatch(const jschar *text, unsign
             }
           failed_match:;
         } while (--fixup > 0);
     }
     return -1;
 }
 
 static JS_ALWAYS_INLINE int
-StringMatch(const jschar *text, unsigned textlen,
-            const jschar *pat, unsigned patlen)
+StringMatch(const jschar *text, uint32_t textlen,
+            const jschar *pat, uint32_t patlen)
 {
     if (patlen == 0)
         return 0;
     if (textlen < patlen)
         return -1;
 
 #if defined(__i386__) || defined(_M_IX86) || defined(__i386)
     /*
@@ -1041,17 +1041,17 @@ StringMatch(const jschar *text, unsigned
 static const size_t sRopeMatchThresholdRatioLog2 = 5;
 
 /*
  * RopeMatch takes the text to search, the patern to search for in the text.
  * RopeMatch returns false on OOM and otherwise returns the match index through
  * the 'match' outparam (-1 for not found).
  */
 static bool
-RopeMatch(JSContext *cx, JSString *textstr, const jschar *pat, unsigned patlen, int *match)
+RopeMatch(JSContext *cx, JSString *textstr, const jschar *pat, uint32_t patlen, int *match)
 {
     JS_ASSERT(textstr->isRope());
 
     if (patlen == 0) {
         *match = 0;
         return true;
     }
     if (textstr->length() < patlen) {
@@ -1152,31 +1152,31 @@ str_indexOf(JSContext *cx, unsigned argc
     JSString *str = ThisToStringForStringProto(cx, args);
     if (!str)
         return false;
 
     JSLinearString *patstr = ArgToRootedString(cx, args, 0);
     if (!patstr)
         return false;
 
-    unsigned textlen = str->length();
+    uint32_t textlen = str->length();
     const jschar *text = str->getChars(cx);
     if (!text)
         return false;
 
-    unsigned patlen = patstr->length();
+    uint32_t patlen = patstr->length();
     const jschar *pat = patstr->chars();
 
-    unsigned start;
+    uint32_t start;
     if (args.length() > 1) {
         if (args[1].isInt32()) {
             int i = args[1].toInt32();
             if (i <= 0) {
                 start = 0;
-            } else if (unsigned(i) > textlen) {
+            } else if (uint32_t(i) > textlen) {
                 start = textlen;
                 textlen = 0;
             } else {
                 start = i;
                 text += start;
                 textlen -= start;
             }
         } else {
@@ -3952,17 +3952,17 @@ Decode(JSContext *cx, JSString *str, con
     for (size_t k = 0; k < length; k++) {
         jschar c = chars[k];
         if (c == '%') {
             size_t start = k;
             if ((k + 2) >= length)
                 goto report_bad_uri;
             if (!JS7_ISHEX(chars[k+1]) || !JS7_ISHEX(chars[k+2]))
                 goto report_bad_uri;
-            unsigned B = JS7_UNHEX(chars[k+1]) * 16 + JS7_UNHEX(chars[k+2]);
+            uint32_t B = JS7_UNHEX(chars[k+1]) * 16 + JS7_UNHEX(chars[k+2]);
             k += 2;
             if (!(B & 0x80)) {
                 c = (jschar)B;
             } else {
                 int n = 1;
                 while (B & (0x80 >> n))
                     n++;
                 if (n == 1 || n > 4)
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -76,32 +76,32 @@ using namespace js::types;
 /*
  * Allocate array buffers with the maximum number of fixed slots marked as
  * reserved, so that the fixed slots may be used for the buffer's contents.
  * The last fixed slot is kept for the object's private data.
  */
 static const uint8_t ARRAYBUFFER_RESERVED_SLOTS = JSObject::MAX_FIXED_SLOTS - 1;
 
 static bool
-ValueIsLength(JSContext *cx, const Value &v, unsigned *len)
+ValueIsLength(JSContext *cx, const Value &v, uint32_t *len)
 {
     if (v.isInt32()) {
         int32_t i = v.toInt32();
         if (i < 0)
             return false;
         *len = i;
         return true;
     }
 
     if (v.isDouble()) {
         double d = v.toDouble();
         if (JSDOUBLE_IS_NaN(d))
             return false;
 
-        unsigned length = unsigned(d);
+        uint32_t length = uint32_t(d);
         if (d != double(length))
             return false;
 
         *len = length;
         return true;
     }
 
     return false;
@@ -725,19 +725,19 @@ JSObject *
 TypedArray::getTypedArray(JSObject *obj)
 {
     while (!js_IsTypedArray(obj))
         obj = obj->getProto();
     return obj;
 }
 
 inline bool
-TypedArray::isArrayIndex(JSContext *cx, JSObject *obj, jsid id, unsigned *ip)
+TypedArray::isArrayIndex(JSContext *cx, JSObject *obj, jsid id, uint32_t *ip)
 {
-    unsigned index;
+    uint32_t index;
     if (js_IdIsIndex(id, &index) && index < getLength(obj)) {
         if (ip)
             *ip = index;
         return true;
     }
 
     return false;
 }
@@ -1259,17 +1259,17 @@ class TypedArrayTemplate
         JSObject *tarray = getTypedArray(obj);
         JS_ASSERT(tarray);
 
         if (JSID_IS_ATOM(id, cx->runtime->atomState.lengthAtom)) {
             vp->setNumber(getLength(tarray));
             return true;
         }
 
-        unsigned index;
+        uint32_t index;
         // We can't just chain to js_SetPropertyHelper, because we're not a normal object.
         if (!isArrayIndex(cx, tarray, id, &index)) {
             // Silent ignore is better than an exception here, because
             // at some point we may want to support other properties on
             // these objects.  This is especially true when these arrays
             // are used to implement HTML Canvas 2D's PixelArray objects,
             // which used to be plain old arrays.
             vp->setUndefined();
@@ -1504,17 +1504,17 @@ class TypedArrayTemplate
     }
 
     static JSObject *
     create(JSContext *cx, unsigned argc, Value *argv)
     {
         /* N.B. there may not be an argv[-2]/argv[-1]. */
 
         /* () or (number) */
-        unsigned len = 0;
+        uint32_t len = 0;
         if (argc == 0 || ValueIsLength(cx, argv[0], &len)) {
             JSObject *bufobj = createBufferWithSizeAndCount(cx, len);
             if (!bufobj)
                 return NULL;
 
             return createTypedArray(cx, bufobj, 0, len);
         }
 
@@ -1658,17 +1658,17 @@ class TypedArrayTemplate
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                      JSMSG_TYPED_ARRAY_BAD_ARGS);
                 return false;
             }
 
             if (!copyFromTypedArray(cx, obj, src, offset))
                 return false;
         } else {
-            unsigned len;
+            uint32_t len;
             if (!js_GetLengthProperty(cx, arg0, &len))
                 return false;
 
             // avoid overflow; we know that offset <= length
             if (len > getLength(tarray) - offset) {
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                      JSMSG_TYPED_ARRAY_BAD_ARGS);
                 return false;
@@ -1729,17 +1729,17 @@ class TypedArrayTemplate
 
             return createTypedArray(cx, other, boffset, len);
         }
 
         /*
          * Otherwise create a new typed array and copy len properties from the
          * object.
          */
-        unsigned len;
+        uint32_t len;
         if (!js_GetLengthProperty(cx, other, &len))
             return NULL;
 
         JSObject *bufobj = createBufferWithSizeAndCount(cx, len);
         if (!bufobj)
             return NULL;
 
         JSObject *obj = createTypedArray(cx, bufobj, 0, len);
@@ -1819,17 +1819,17 @@ class TypedArrayTemplate
 
         return ArrayTypeIsFloatingPoint()
                ? NativeType(js_NaN)
                : NativeType(int32_t(0));
     }
 
     static bool
     copyFromArray(JSContext *cx, JSObject *thisTypedArrayObj,
-             JSObject *ar, unsigned len, unsigned offset = 0)
+             JSObject *ar, uint32_t len, uint32_t offset = 0)
     {
         thisTypedArrayObj = getTypedArray(thisTypedArrayObj);
         JS_ASSERT(thisTypedArrayObj);
 
         JS_ASSERT(offset <= getLength(thisTypedArrayObj));
         JS_ASSERT(len <= getLength(thisTypedArrayObj) - offset);
         NativeType *dest = static_cast<NativeType*>(getDataOffset(thisTypedArrayObj)) + offset;
 
@@ -1853,17 +1853,17 @@ class TypedArrayTemplate
                 *dest++ = nativeFromValue(cx, v);
             }
         }
 
         return true;
     }
 
     static bool
-    copyFromTypedArray(JSContext *cx, JSObject *thisTypedArrayObj, JSObject *tarray, unsigned offset)
+    copyFromTypedArray(JSContext *cx, JSObject *thisTypedArrayObj, JSObject *tarray, uint32_t offset)
     {
         thisTypedArrayObj = getTypedArray(thisTypedArrayObj);
         JS_ASSERT(thisTypedArrayObj);
 
         JS_ASSERT(offset <= getLength(thisTypedArrayObj));
         JS_ASSERT(getLength(tarray) <= getLength(thisTypedArrayObj) - offset);
         if (getBuffer(tarray) == getBuffer(thisTypedArrayObj))
             return copyFromWithOverlap(cx, thisTypedArrayObj, tarray, offset);
@@ -1930,17 +1930,17 @@ class TypedArrayTemplate
             JS_NOT_REACHED("copyFrom with a TypedArray of unknown type");
             break;
         }
 
         return true;
     }
 
     static bool
-    copyFromWithOverlap(JSContext *cx, JSObject *self, JSObject *tarray, unsigned offset)
+    copyFromWithOverlap(JSContext *cx, JSObject *self, JSObject *tarray, uint32_t offset)
     {
         JS_ASSERT(offset <= getLength(self));
 
         NativeType *dest = static_cast<NativeType*>(getDataOffset(self)) + offset;
 
         if (getType(tarray) == getType(self)) {
             memmove(dest, getDataOffset(tarray), getByteLength(tarray));
             return true;
@@ -2527,23 +2527,23 @@ JS_FRIEND_API(JSBool)
 js_IsTypedArray(JSObject *obj)
 {
     JS_ASSERT(obj);
     Class *clasp = obj->getClass();
     return IsFastTypedArrayClass(clasp);
 }
 
 JS_FRIEND_API(JSObject *)
-js_CreateArrayBuffer(JSContext *cx, unsigned nbytes)
+js_CreateArrayBuffer(JSContext *cx, uint32_t nbytes)
 {
     return ArrayBuffer::create(cx, nbytes);
 }
 
 JS_FRIEND_API(JSObject *)
-JS_NewArrayBuffer(JSContext *cx, unsigned nbytes)
+JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes)
 {
     return js_CreateArrayBuffer(cx, nbytes);
 }
 
 static inline JSObject *
 TypedArrayConstruct(JSContext *cx, int atype, unsigned argc, Value *argv)
 {
     switch (atype) {
@@ -2576,17 +2576,17 @@ TypedArrayConstruct(JSContext *cx, int a
 
       default:
         JS_NOT_REACHED("shouldn't have gotten here");
         return NULL;
     }
 }
 
 JS_FRIEND_API(JSObject *)
-js_CreateTypedArray(JSContext *cx, int atype, unsigned nelements)
+js_CreateTypedArray(JSContext *cx, int atype, uint32_t nelements)
 {
     JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
 
     Value nelems = Int32Value(nelements);
     return TypedArrayConstruct(cx, atype, 1, &nelems);
 }
 
 JS_FRIEND_API(JSObject *)
--- a/js/src/jstypedarray.h
+++ b/js/src/jstypedarray.h
@@ -247,17 +247,17 @@ struct JS_FRIEND_API(TypedArray) {
     static uint32_t getByteOffset(JSObject *obj);
     static uint32_t getByteLength(JSObject *obj);
     static uint32_t getType(JSObject *obj);
     static JSObject * getBuffer(JSObject *obj);
     static void * getDataOffset(JSObject *obj);
 
   public:
     static bool
-    isArrayIndex(JSContext *cx, JSObject *obj, jsid id, unsigned *ip = NULL);
+    isArrayIndex(JSContext *cx, JSObject *obj, jsid id, uint32_t *ip = NULL);
 
     static inline uint32_t slotWidth(int atype) {
         switch (atype) {
           case js::TypedArray::TYPE_INT8:
           case js::TypedArray::TYPE_UINT8:
           case js::TypedArray::TYPE_UINT8_CLAMPED:
             return 1;
           case js::TypedArray::TYPE_INT16:
@@ -330,17 +330,17 @@ js_CreateTypedArrayWithBuffer(JSContext 
 
 extern int32_t JS_FASTCALL
 js_TypedArray_uint8_clamp_double(const double x);
 
 JS_FRIEND_API(JSBool)
 JS_IsArrayBufferObject(JSObject *obj);
 
 JS_FRIEND_API(JSObject *)
-JS_NewArrayBuffer(JSContext *cx, unsigned nbytes);
+JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes);
 
 JS_FRIEND_API(uint32_t)
 JS_GetArrayBufferByteLength(JSObject *obj);
 
 JS_FRIEND_API(uint8_t *)
 JS_GetArrayBufferData(JSObject *obj);
 
 JS_FRIEND_API(uint32_t)
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -4660,25 +4660,25 @@ HasFunctionProperty(JSContext *cx, JSObj
                 return false;
         }
     }
     *found = (prop != NULL);
     return true;
 }
 
 static bool
-IdValIsIndex(JSContext *cx, jsval id, unsigned *indexp, bool *isIndex)
+IdValIsIndex(JSContext *cx, jsval id, uint32_t *indexp, bool *isIndex)
 {
     if (JSVAL_IS_INT(id)) {
         int32_t i = JSVAL_TO_INT(id);
         if (i < 0) {
             *isIndex = false;
             return true;
         }
-        *indexp = (unsigned)i;
+        *indexp = (uint32_t)i;
         *isIndex = true;
         return true;
     }
 
     if (!JSVAL_IS_STRING(id)) {
         *isIndex = false;
         return true;
     }
@@ -6193,17 +6193,17 @@ xml_name(JSContext *cx, unsigned argc, j
     *vp = OBJECT_TO_JSVAL(xml->name);
     return JS_TRUE;
 }
 
 static JSBool
 xml_namespace(JSContext *cx, unsigned argc, jsval *vp)
 {
     JSLinearString *prefix, *nsprefix;
-    unsigned i, length;
+    uint32_t i, length;
     JSObject *ns;
 
     NON_LIST_XML_METHOD_PROLOG;
     if (argc == 0 && !JSXML_HAS_NAME(xml)) {
         *vp = JSVAL_NULL;
         return true;
     }
 
--- a/js/src/methodjit/MonoIC.cpp
+++ b/js/src/methodjit/MonoIC.cpp
@@ -1138,17 +1138,17 @@ ic::SplatApplyArgs(VMFrame &f)
     /* Step 3. */
     if (!vp[3].isObject()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_APPLY_ARGS, js_apply_str);
         THROWV(false);
     }
 
     /* Steps 4-5. */
     JSObject *aobj = &vp[3].toObject();
-    unsigned length;
+    uint32_t length;
     if (!js_GetLengthProperty(cx, aobj, &length))
         THROWV(false);
 
     /* Step 6. */
     if (length > StackSpace::ARGS_LENGTH_MAX) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                              JSMSG_TOO_MANY_FUN_APPLY_ARGS);
         THROWV(false);
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -229,23 +229,23 @@ stubs::SetElem(VMFrame &f)
 
     if (!FetchElementId(f.cx, obj, idval, id, &regs.sp[-2]))
         THROW();
 
     TypeScript::MonitorAssign(cx, obj, id);
 
     do {
         if (obj->isDenseArray() && JSID_IS_INT(id)) {
-            unsigned length = obj->getDenseArrayInitializedLength();
+            uint32_t length = obj->getDenseArrayInitializedLength();
             int32_t i = JSID_TO_INT(id);
-            if ((unsigned)i < length) {
+            if ((uint32_t)i < length) {
                 if (obj->getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE)) {
                     if (js_PrototypeHasIndexedProperties(cx, obj))
                         break;
-                    if ((unsigned)i >= obj->getArrayLength())
+                    if ((uint32_t)i >= obj->getArrayLength())
                         obj->setArrayLength(cx, i + 1);
                 }
                 obj->setDenseArrayElementWithType(cx, i, rval);
                 goto end_setelem;
             } else {
                 if (f.script()->hasAnalysis())
                     f.script()->analysis()->getCode(f.pc()).arrayWriteHole = true;
             }
@@ -1029,18 +1029,18 @@ stubs::InitElem(VMFrame &f, uint32_t las
     /*
      * If rref is a hole, do not call JSObject::defineProperty. In this case,
      * obj must be an array, so if the current op is the last element
      * initialiser, set the array length to one greater than id.
      */
     if (rref.isMagic(JS_ARRAY_HOLE)) {
         JS_ASSERT(obj->isArray());
         JS_ASSERT(JSID_IS_INT(id));
-        JS_ASSERT(unsigned(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
-        if (last && !js_SetLengthProperty(cx, obj, (unsigned) (JSID_TO_INT(id) + 1)))
+        JS_ASSERT(uint32_t(JSID_TO_INT(id)) < StackSpace::ARGS_LENGTH_MAX);
+        if (last && !js_SetLengthProperty(cx, obj, (uint32_t) (JSID_TO_INT(id) + 1)))
             THROW();
     } else {
         if (!obj->defineGeneric(cx, id, rref, NULL, NULL, JSPROP_ENUMERATE))
             THROW();
     }
 }
 
 void JS_FASTCALL
@@ -1579,17 +1579,17 @@ stubs::TableSwitch(VMFrame &f, jsbytecod
 
     {
         int32_t low = GET_JUMP_OFFSET(pc);
         pc += JUMP_OFFSET_LEN;
         int32_t high = GET_JUMP_OFFSET(pc);
         pc += JUMP_OFFSET_LEN;
 
         tableIdx -= low;
-        if ((unsigned) tableIdx < (unsigned)(high - low + 1)) {
+        if ((uint32_t) tableIdx < (uint32_t)(high - low + 1)) {
             pc += JUMP_OFFSET_LEN * tableIdx;
             if (uint32_t candidateOffset = GET_JUMP_OFFSET(pc))
                 jumpOffset = candidateOffset;
         }
     }
 
 finally:
     /* Provide the native address. */
--- a/js/src/shell/jsheaptools.cpp
+++ b/js/src/shell/jsheaptools.cpp
@@ -527,17 +527,17 @@ ReferenceFinder::addReferrer(jsval refer
     }
 
     /* The property's value had better be an array. */
     JS_ASSERT(JSVAL_IS_OBJECT(v) && !JSVAL_IS_NULL(v));
     JSObject *array = JSVAL_TO_OBJECT(v);
     JS_ASSERT(JS_IsArrayObject(context, array));
 
     /* Append our referrer to this array. */
-    unsigned length;
+    uint32_t length;
     return JS_GetArrayLength(context, array, &length) &&
            JS_SetElement(context, array, length, &referrer);
 }
 
 JSObject *
 ReferenceFinder::findReferences(JSObject *target)
 {
     result = JS_NewObject(context, NULL, NULL, NULL);
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -1209,27 +1209,27 @@ mozJSComponentLoader::ImportInto(const n
             !(symbolsObj = JSVAL_TO_OBJECT(symbols)) ||
             !JS_IsArrayObject(mContext, symbolsObj)) {
             return ReportOnCaller(cxhelper, ERROR_NOT_AN_ARRAY,
                                   PromiseFlatCString(aLocation).get());
         }
 
         // Iterate over symbols array, installing symbols on targetObj:
 
-        unsigned symbolCount = 0;
+        uint32_t symbolCount = 0;
         if (!JS_GetArrayLength(mContext, symbolsObj, &symbolCount)) {
             return ReportOnCaller(cxhelper, ERROR_GETTING_ARRAY_LENGTH,
                                   PromiseFlatCString(aLocation).get());
         }
 
 #ifdef DEBUG
         nsCAutoString logBuffer;
 #endif
 
-        for (unsigned i = 0; i < symbolCount; ++i) {
+        for (uint32_t i = 0; i < symbolCount; ++i) {
             jsval val;
             jsid symbolId;
 
             if (!JS_GetElement(mContext, symbolsObj, i, &val) ||
                 !JSVAL_IS_STRING(val) ||
                 !JS_ValueToId(mContext, val, &symbolId)) {
                 return ReportOnCaller(cxhelper, ERROR_ARRAY_ELEMENT,
                                       PromiseFlatCString(aLocation).get(), i);
--- a/js/xpconnect/src/XPCVariant.cpp
+++ b/js/xpconnect/src/XPCVariant.cpp
@@ -185,17 +185,17 @@ private:
         tErr          // No valid state or type has this value.
     };
 
     // Table has tUnk as a state (column) but not as a type (row).
     static const Type StateTable[tTypeCount][tTypeCount-1];
 
 public:
     static JSBool GetTypeForArray(XPCCallContext& ccx, JSObject* array,
-                                  unsigned length,
+                                  uint32_t length,
                                   nsXPTType* resultType, nsID* resultID);
 };
 
 
 // Current state is the column down the side.
 // Current type is the row along the top.
 // New state is in the box at the intersection.
 
@@ -210,17 +210,17 @@ XPCArrayHomogenizer::StateTable[tTypeCou
 /* tID   */{tID  ,tVar ,tVar ,tVar ,tVar ,tID  ,tVar ,tVar  },
 /* tArr  */{tErr ,tErr ,tErr ,tErr ,tErr ,tErr ,tErr ,tErr  },
 /* tISup */{tISup,tVar ,tVar ,tVar ,tVar ,tVar ,tVar ,tISup },
 /* tUnk  */{tNull,tInt ,tDbl ,tBool,tStr ,tID  ,tVar ,tISup }};
 
 // static
 JSBool
 XPCArrayHomogenizer::GetTypeForArray(XPCCallContext& ccx, JSObject* array,
-                                     unsigned length,
+                                     uint32_t length,
                                      nsXPTType* resultType, nsID* resultID)
 {
     Type state = tUnk;
     Type type;
 
     for (uint32_t i = 0; i < length; i++) {
         jsval val;
         if (!JS_GetElement(ccx, array, i, &val))
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -602,17 +602,17 @@ GetArrayIndexFromId(JSContext *cx, jsid 
     if (NS_LIKELY(id == s_length_id))
         return -1;
     if (NS_LIKELY(JSID_IS_ATOM(id))) {
         JSAtom *atom = JSID_TO_ATOM(id);
         jschar s = *js::GetAtomChars(atom);
         if (NS_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z'))
             return -1;
 
-        unsigned i;
+        uint32_t i;
         JSLinearString *str = js::AtomToLinearString(JSID_TO_ATOM(id));
         return js::StringIsArrayIndex(str, &i) ? i : -1;
     }
     return IdToInt32(cx, id);
 }
 
 static void
 FillPropertyDescriptor(JSPropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly)
--- a/startupcache/test/TestStartupCache.cpp
+++ b/startupcache/test/TestStartupCache.cpp
@@ -354,27 +354,27 @@ GetHistogramCounts(const char *testmsg, 
                       snapshot_fn, 0, NULL, ss.addr())
           && JS_GetProperty(cx, JSVAL_TO_OBJECT(ss.value()),
                             "counts", counts));
 }
 
 nsresult
 CompareCountArrays(JSContext *cx, JSObject *before, JSObject *after)
 {
-  unsigned before_size, after_size;
+  uint32_t before_size, after_size;
   if (!(JS_GetArrayLength(cx, before, &before_size)
         && JS_GetArrayLength(cx, after, &after_size))) {
     return NS_ERROR_UNEXPECTED;
   }
 
   if (before_size != after_size) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  for (unsigned i = 0; i < before_size; ++i) {
+  for (uint32_t i = 0; i < before_size; ++i) {
     jsval before_num, after_num;
 
     if (!(JS_GetElement(cx, before, i, &before_num)
           && JS_GetElement(cx, after, i, &after_num))) {
       return NS_ERROR_UNEXPECTED;
     }
 
     JSBool same = JS_TRUE;
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -313,17 +313,17 @@ GetIntFromJSObject(JSContext* aCtx,
  * @param aIndex
  *        The index to get the object from.
  * @param _object
  *        The JSObject pointer on success.
  */
 nsresult
 GetJSObjectFromArray(JSContext* aCtx,
                      JSObject* aArray,
-                     unsigned aIndex,
+                     uint32_t aIndex,
                      JSObject** _rooter)
 {
   NS_PRECONDITION(JS_IsArrayObject(aCtx, aArray),
                   "Must provide an object that is an array!");
 
   jsval value;
   JSBool rc = JS_GetElement(aCtx, aArray, aIndex, &value);
   NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
@@ -2099,17 +2099,17 @@ History::AddDownload(nsIURI* aSource, ns
 NS_IMETHODIMP
 History::UpdatePlaces(const jsval& aPlaceInfos,
                       mozIVisitInfoCallback* aCallback,
                       JSContext* aCtx)
 {
   NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_UNEXPECTED);
   NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aPlaceInfos), NS_ERROR_INVALID_ARG);
 
-  unsigned infosLength = 1;
+  uint32_t infosLength = 1;
   JSObject* infos;
   if (JS_IsArrayObject(aCtx, JSVAL_TO_OBJECT(aPlaceInfos))) {
     infos = JSVAL_TO_OBJECT(aPlaceInfos);
     (void)JS_GetArrayLength(aCtx, infos, &infosLength);
     NS_ENSURE_ARG(infosLength > 0);
   }
   else {
     // Build a temporary array to store this one item so the code below can
@@ -2117,17 +2117,17 @@ History::UpdatePlaces(const jsval& aPlac
     infos = JS_NewArrayObject(aCtx, 0, NULL);
     NS_ENSURE_TRUE(infos, NS_ERROR_OUT_OF_MEMORY);
 
     JSBool rc = JS_DefineElement(aCtx, infos, 0, aPlaceInfos, NULL, NULL, 0);
     NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
   }
 
   nsTArray<VisitData> visitData;
-  for (unsigned i = 0; i < infosLength; i++) {
+  for (uint32_t i = 0; i < infosLength; i++) {
     JSObject* info;
     nsresult rv = GetJSObjectFromArray(aCtx, infos, i, &info);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> uri = GetURIFromJSObject(aCtx, info, "uri");
     nsCString guid;
     {
       nsString fatGUID;
@@ -2163,25 +2163,25 @@ History::UpdatePlaces(const jsval& aPlac
       NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
       if (!JSVAL_IS_PRIMITIVE(visitsVal)) {
         visits = JSVAL_TO_OBJECT(visitsVal);
         NS_ENSURE_ARG(JS_IsArrayObject(aCtx, visits));
       }
     }
     NS_ENSURE_ARG(visits);
 
-    unsigned visitsLength = 0;
+    uint32_t visitsLength = 0;
     if (visits) {
       (void)JS_GetArrayLength(aCtx, visits, &visitsLength);
     }
     NS_ENSURE_ARG(visitsLength > 0);
 
     // Check each visit, and build our array of VisitData objects.
     visitData.SetCapacity(visitData.Length() + visitsLength);
-    for (unsigned j = 0; j < visitsLength; j++) {
+    for (uint32_t j = 0; j < visitsLength; j++) {
       JSObject* visit;
       rv = GetJSObjectFromArray(aCtx, visits, j, &visit);
       NS_ENSURE_SUCCESS(rv, rv);
 
       VisitData& data = *visitData.AppendElement(VisitData(uri));
       data.title = title;
       data.guid = guid;