Bug 812537 - Move GetDenseArrayShape to jsarray. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 17 Nov 2012 11:54:21 +0100
changeset 113618 d5f69614e2250b6b85c2a608eb028dcf32ce37bd
parent 113601 b401cbf179c1e360866180befa76fbb2fe28ea2b
child 113619 98c27827e0d9132e4151ef97d37bf62dd99694f7
push id23880
push userryanvm@gmail.com
push dateSun, 18 Nov 2012 13:36:46 +0000
treeherdermozilla-central@174440fca7da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs812537
milestone19.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 812537 - Move GetDenseArrayShape to jsarray. r=bhackett
js/src/ion/IonCaches.cpp
js/src/jsarray.cpp
js/src/jsarray.h
js/src/methodjit/FastOps.cpp
--- a/js/src/ion/IonCaches.cpp
+++ b/js/src/ion/IonCaches.cpp
@@ -1439,39 +1439,28 @@ IonCacheGetElement::attachGetProp(JSCont
     PatchJump(rejoinJump, rejoinLabel());
     PatchJump(exitJump, cacheLabel());
     updateLastJump(exitJump);
 
     IonSpew(IonSpew_InlineCaches, "Generated GETELEM property stub at %p", code->raw());
     return true;
 }
 
-// Get the common shape used by all dense arrays with a prototype at globalObj.
-static inline Shape *
-GetDenseArrayShape(JSContext *cx, JSObject *globalObj)
-{
-    JSObject *proto = globalObj->global().getOrCreateArrayPrototype(cx);
-    if (!proto)
-        return NULL;
-
-    return EmptyShape::getInitialShape(cx, &ArrayClass, proto,
-                                       proto->getParent(), gc::FINALIZE_OBJECT0);
-}
-
 bool
 IonCacheGetElement::attachDenseArray(JSContext *cx, IonScript *ion, JSObject *obj, const Value &idval)
 {
     JS_ASSERT(obj->isDenseArray());
     JS_ASSERT(idval.isInt32());
 
     Label failures;
     MacroAssembler masm;
 
     // Guard object is a dense array.
-    RootedShape shape(cx, GetDenseArrayShape(cx, &script->global()));
+    RootedObject globalObj(cx, &script->global());
+    RootedShape shape(cx, GetDenseArrayShape(cx, globalObj));
     if (!shape)
         return false;
     masm.branchTestObjShape(Assembler::NotEqual, object(), shape, &failures);
 
     // Ensure the index is an int32 value.
     ValueOperand val = index().reg().valueReg();
     masm.branchTestInt32(Assembler::NotEqual, val, &failures);
 
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -201,16 +201,29 @@ StringIsArrayIndex(JSLinearString *str, 
         JS_ASSERT(index <= MAX_ARRAY_INDEX);
         *indexp = index;
         return true;
     }
 
     return false;
 }
 
+Shape *
+GetDenseArrayShape(JSContext *cx, HandleObject globalObj)
+{
+    JS_ASSERT(globalObj);
+
+    JSObject *proto = globalObj->global().getOrCreateArrayPrototype(cx);
+    if (!proto)
+        return NULL;
+
+    return EmptyShape::getInitialShape(cx, &ArrayClass, proto, proto->getParent(),
+                                       gc::FINALIZE_OBJECT0);
+}
+
 }
 
 bool
 JSObject::willBeSparseDenseArray(unsigned requiredCapacity, unsigned newElementsHint)
 {
     JS_ASSERT(isDenseArray());
     JS_ASSERT(requiredCapacity > MIN_SPARSE_INDEX);
 
--- a/js/src/jsarray.h
+++ b/js/src/jsarray.h
@@ -70,16 +70,20 @@ NewDenseCopiedArray(JSContext *cx, uint3
 /* Create a dense array from the given array values, which must be rooted */
 extern JSObject *
 NewDenseCopiedArray(JSContext *cx, uint32_t length, const Value *values, RawObject proto = NULL);
 
 /* Create a sparse array. */
 extern JSObject *
 NewSlowEmptyArray(JSContext *cx);
 
+/* Get the common shape used by all dense arrays with a prototype at globalObj. */
+extern Shape *
+GetDenseArrayShape(JSContext *cx, HandleObject globalObj);
+
 extern JSBool
 GetLengthProperty(JSContext *cx, HandleObject obj, uint32_t *lengthp);
 
 extern JSBool
 SetLengthProperty(JSContext *cx, HandleObject obj, double length);
 
 extern JSBool
 array_defineElement(JSContext *cx, HandleObject obj, uint32_t index, HandleValue value,
--- a/js/src/methodjit/FastOps.cpp
+++ b/js/src/methodjit/FastOps.cpp
@@ -1372,30 +1372,16 @@ mjit::Compiler::tryConvertInteger(FrameE
     masm.branchConvertDoubleToInt32(fpreg, reg, isDouble, Registers::FPConversionTemp);
     Jump j = masm.jump();
     isDouble.linkTo(masm.label(), &masm);
     stubcc.linkExit(masm.jump(), uses);
     j.linkTo(masm.label(), &masm);
     frame.learnType(fe, JSVAL_TYPE_INT32, reg);
 }
 
-/* Get the common shape used by all dense arrays with a prototype at globalObj. */
-static inline Shape *
-GetDenseArrayShape(JSContext *cx, JSObject *globalObj)
-{
-    JS_ASSERT(globalObj);
-
-    JSObject *proto = globalObj->global().getOrCreateArrayPrototype(cx);
-    if (!proto)
-        return NULL;
-
-    return EmptyShape::getInitialShape(cx, &ArrayClass, proto,
-                                       proto->getParent(), gc::FINALIZE_OBJECT0);
-}
-
 bool
 mjit::Compiler::jsop_setelem(bool popGuaranteed)
 {
     FrameEntry *obj = frame.peek(-3);
     FrameEntry *id = frame.peek(-2);
     FrameEntry *value = frame.peek(-1);
 
     if (!IsCacheableSetElem(obj, id, value) || monitored(PC)) {