Bug 607242 - TM: inline js_Array_dense_setelem_hole. r=gal.

This commit is contained in:
Nicholas Nethercote 2010-11-03 20:48:51 -07:00
parent c3f05e2197
commit c8ae37081d
5 changed files with 22 additions and 27 deletions

View File

@ -813,24 +813,6 @@ js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj)
return JS_FALSE; return JS_FALSE;
} }
#ifdef JS_TRACER
JSBool FASTCALL
js_Array_dense_setelem_hole(JSContext* cx, JSObject* obj, jsint i)
{
if (js_PrototypeHasIndexedProperties(cx, obj))
return false;
jsuint u = jsuint(i);
if (u >= obj->getArrayLength())
obj->setArrayLength(u + 1);
return true;
}
/* storeAccSet == ACCSET_OBJ_PRIVATE: because it can set 'length'. */
JS_DEFINE_CALLINFO_3(extern, BOOL, js_Array_dense_setelem_hole, CONTEXT, OBJECT, INT32,
0, tjit::ACCSET_OBJ_PRIVATE)
#endif
static JSBool static JSBool
array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value, array_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *value,
PropertyOp getter, PropertyOp setter, uintN attrs) PropertyOp getter, PropertyOp setter, uintN attrs)

View File

@ -575,7 +575,6 @@ js_dmod(jsdouble a, jsdouble b);
#endif /* !JS_TRACER */ #endif /* !JS_TRACER */
/* Defined in jsarray.cpp. */ /* Defined in jsarray.cpp. */
JS_DECLARE_CALLINFO(js_Array_dense_setelem_hole)
JS_DECLARE_CALLINFO(js_NewEmptyArray) JS_DECLARE_CALLINFO(js_NewEmptyArray)
JS_DECLARE_CALLINFO(js_NewPreallocatedArray) JS_DECLARE_CALLINFO(js_NewPreallocatedArray)
JS_DECLARE_CALLINFO(js_InitializerArray) JS_DECLARE_CALLINFO(js_InitializerArray)

View File

@ -12798,12 +12798,15 @@ TraceRecorder::setElem(int lval_spindex, int idx_spindex, int v_spindex)
#endif #endif
w.nameImmui(JSVAL_TAG_MAGIC)); w.nameImmui(JSVAL_TAG_MAGIC));
w.pauseAddingCSEValues(); w.pauseAddingCSEValues();
if (MaybeBranch mbr = w.jf(isHole_ins)) { if (MaybeBranch mbr1 = w.jf(isHole_ins)) {
LIns* args[] = { idx_ins, obj_ins, cx_ins }; CHECK_STATUS_A(guardPrototypeHasNoIndexedProperties(obj, obj_ins, mismatchExit));
LIns* res_ins = w.name(w.call(&js_Array_dense_setelem_hole_ci, args), LIns* length_ins = w.lduiObjPrivate(obj_ins);
"hasNoIndexedProperties"); if (MaybeBranch mbr2 = w.jt(w.ltui(idx_ins, length_ins))) {
guard(false, w.eqi0(res_ins), mismatchExit); LIns* newLength_ins = w.name(w.addiN(idx_ins, 1), "newLength");
w.label(mbr); w.stuiObjPrivate(obj_ins, newLength_ins);
w.label(mbr2);
}
w.label(mbr1);
} }
w.resumeAddingCSEValues(); w.resumeAddingCSEValues();

View File

@ -403,8 +403,9 @@ void ValidateWriter::checkAccSet(LOpcode op, LIns *base, int32_t disp, AccSet ac
case ACCSET_OBJ_PRIVATE: case ACCSET_OBJ_PRIVATE:
// base = <JSObject> // base = <JSObject>
// ins = ldp.objprivate base[offsetof(JSObject, privateData)] // ins = {ld,st}p.objprivate base[offsetof(JSObject, privateData)]
ok = (op == LIR_ldi || op == LIR_ldp) && ok = (op == LIR_ldi || op == LIR_ldp ||
op == LIR_sti || op == LIR_stp) &&
disp == offsetof(JSObject, privateData) && disp == offsetof(JSObject, privateData) &&
couldBeObjectOrString(base); couldBeObjectOrString(base);
break; break;

View File

@ -490,6 +490,12 @@ class Writer
"private_uint32"); "private_uint32");
} }
nj::LIns *stuiObjPrivate(nj::LIns *obj, nj::LIns *value) const {
return name(lir->insStore(nj::LIR_sti, value, obj, offsetof(JSObject, privateData),
ACCSET_OBJ_PRIVATE),
"private_uint32");
}
nj::LIns *ldiDenseArrayCapacity(nj::LIns *array) const { nj::LIns *ldiDenseArrayCapacity(nj::LIns *array) const {
return name(lir->insLoad(nj::LIR_ldi, array, offsetof(JSObject, capacity), return name(lir->insLoad(nj::LIR_ldi, array, offsetof(JSObject, capacity),
ACCSET_OBJ_CAPACITY), ACCSET_OBJ_CAPACITY),
@ -938,6 +944,10 @@ class Writer
return lir->ins2(nj::LIR_addi, x, y); return lir->ins2(nj::LIR_addi, x, y);
} }
nj::LIns *addiN(nj::LIns *x, int32 imm) const {
return lir->ins2ImmI(nj::LIR_addi, x, imm);
}
nj::LIns *subi(nj::LIns *x, nj::LIns *y) const { nj::LIns *subi(nj::LIns *x, nj::LIns *y) const {
return lir->ins2(nj::LIR_subi, x, y); return lir->ins2(nj::LIR_subi, x, y);
} }