Bug 790108 part 1 - Use HandleObject, MutableHandleValue for pop/shift/push stubs. r=dvander

This commit is contained in:
Jan de Mooij 2012-09-14 13:44:15 +02:00
parent 9df88444bc
commit 076607a353
3 changed files with 23 additions and 19 deletions

View File

@ -2401,7 +2401,7 @@ CodeGenerator::emitArrayPopShift(LInstruction *lir, const MArrayPopShift *mir, R
Register elementsTemp, Register lengthTemp, TypedOrValueRegister out)
{
OutOfLineCode *ool;
typedef bool (*pf)(JSContext *, JSObject *, Value *);
typedef bool (*pf)(JSContext *, HandleObject, MutableHandleValue);
if (mir->mode() == MArrayPopShift::Pop) {
static const VMFunction Info = FunctionInfo<pf>(ion::ArrayPopDense);
@ -2498,7 +2498,7 @@ bool
CodeGenerator::emitArrayPush(LInstruction *lir, const MArrayPush *mir, Register obj,
ConstantOrRegister value, Register elementsTemp, Register length)
{
typedef bool (*pf)(JSContext *, JSObject *, HandleValue, uint32_t *);
typedef bool (*pf)(JSContext *, HandleObject, HandleValue, uint32_t *);
static const VMFunction Info = FunctionInfo<pf>(ion::ArrayPushDense);
OutOfLineCode *ool = oolCallVM(Info, lir, (ArgList(), obj, value), StoreRegisterTo(length));
if (!ool)

View File

@ -276,28 +276,30 @@ NewInitObject(JSContext *cx, HandleObject templateObject)
}
bool
ArrayPopDense(JSContext *cx, JSObject *obj, Value *rval)
ArrayPopDense(JSContext *cx, HandleObject obj, MutableHandleValue rval)
{
AutoDetectInvalidation adi(cx, rval);
JS_ASSERT(obj->isDenseArray());
Value argv[3] = { UndefinedValue(), ObjectValue(*obj) };
AutoDetectInvalidation adi(cx, rval.address());
Value argv[] = { UndefinedValue(), ObjectValue(*obj) };
if (!js::array_pop(cx, 0, argv))
return false;
// If the result is |undefined|, the array was probably empty and we
// have to monitor the return value.
*rval = argv[0];
if (rval->isUndefined())
types::TypeScript::Monitor(cx, *rval);
rval.set(argv[0]);
if (rval.isUndefined())
types::TypeScript::Monitor(cx, rval);
return true;
}
bool
ArrayPushDense(JSContext *cx, JSObject *obj, HandleValue v, uint32_t *length)
ArrayPushDense(JSContext *cx, HandleObject obj, HandleValue v, uint32_t *length)
{
JS_ASSERT(obj->isDenseArray());
Value argv[3] = { UndefinedValue(), ObjectValue(*obj), v };
Value argv[] = { UndefinedValue(), ObjectValue(*obj), v };
if (!js::array_push(cx, 1, argv))
return false;
@ -306,19 +308,21 @@ ArrayPushDense(JSContext *cx, JSObject *obj, HandleValue v, uint32_t *length)
}
bool
ArrayShiftDense(JSContext *cx, JSObject *obj, Value *rval)
ArrayShiftDense(JSContext *cx, HandleObject obj, MutableHandleValue rval)
{
AutoDetectInvalidation adi(cx, rval);
JS_ASSERT(obj->isDenseArray());
Value argv[3] = { UndefinedValue(), ObjectValue(*obj) };
AutoDetectInvalidation adi(cx, rval.address());
Value argv[] = { UndefinedValue(), ObjectValue(*obj) };
if (!js::array_shift(cx, 0, argv))
return false;
// If the result is |undefined|, the array was probably empty and we
// have to monitor the return value.
*rval = argv[0];
if (rval->isUndefined())
types::TypeScript::Monitor(cx, *rval);
rval.set(argv[0]);
if (rval.isUndefined())
types::TypeScript::Monitor(cx, rval);
return true;
}

View File

@ -426,9 +426,9 @@ bool IteratorMore(JSContext *cx, HandleObject obj, JSBool *res);
JSObject *NewInitArray(JSContext *cx, uint32_t count, types::TypeObject *type);
JSObject *NewInitObject(JSContext *cx, HandleObject templateObject);
bool ArrayPopDense(JSContext *cx, JSObject *obj, Value *rval);
bool ArrayPushDense(JSContext *cx, JSObject *obj, HandleValue v, uint32_t *length);
bool ArrayShiftDense(JSContext *cx, JSObject *obj, Value *rval);
bool ArrayPopDense(JSContext *cx, HandleObject obj, MutableHandleValue rval);
bool ArrayPushDense(JSContext *cx, HandleObject obj, HandleValue v, uint32_t *length);
bool ArrayShiftDense(JSContext *cx, HandleObject obj, MutableHandleValue rval);
bool SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValue value,
bool strict, bool isSetName);