Bug 841499 - Allow calling SetObjectElementOperation with explicit script and pc arguments. r=jimb

This commit is contained in:
Kannan Vijayan 2013-02-14 18:27:49 -05:00
parent 62314e2b86
commit 1a214bd9e8
3 changed files with 30 additions and 7 deletions

View File

@ -3581,6 +3581,18 @@ js::SetObjectElement(JSContext *cx, HandleObject obj, HandleValue index, HandleV
return SetObjectElementOperation(cx, obj, id, value, strict);
}
bool
js::SetObjectElement(JSContext *cx, HandleObject obj, HandleValue index, HandleValue value,
JSBool strict, HandleScript script, jsbytecode *pc)
{
JS_ASSERT(pc);
RootedId id(cx);
RootedValue indexval(cx, index);
if (!FetchElementId(cx, obj, indexval, &id, &indexval))
return false;
return SetObjectElementOperation(cx, obj, id, value, strict, script, pc);
}
bool
js::AddValues(JSContext *cx, HandleScript script, jsbytecode *pc,
MutableHandleValue lhs, MutableHandleValue rhs,

View File

@ -368,6 +368,9 @@ CallElement(JSContext *cx, MutableHandleValue lref, HandleValue rref, MutableHan
bool
SetObjectElement(JSContext *cx, HandleObject obj, HandleValue index, HandleValue value,
JSBool strict);
bool
SetObjectElement(JSContext *cx, HandleObject obj, HandleValue index, HandleValue value,
JSBool strict, HandleScript script, jsbytecode *pc);
bool
AddValues(JSContext *cx, HandleScript script, jsbytecode *pc,

View File

@ -892,20 +892,28 @@ GetElementOperation(JSContext *cx, JSOp op, MutableHandleValue lref, HandleValue
}
static JS_ALWAYS_INLINE bool
SetObjectElementOperation(JSContext *cx, Handle<JSObject*> obj, HandleId id, const Value &value, bool strict)
SetObjectElementOperation(JSContext *cx, Handle<JSObject*> obj, HandleId id, const Value &value,
bool strict, RawScript maybeScript = NULL, jsbytecode *pc = NULL)
{
RootedScript script(cx, maybeScript);
types::TypeScript::MonitorAssign(cx, obj, id);
if (obj->isArray() && JSID_IS_INT(id)) {
uint32_t length = obj->getDenseInitializedLength();
int32_t i = JSID_TO_INT(id);
if ((uint32_t)i >= length && !cx->fp()->beginsIonActivation()) {
JSScript *script = NULL;
jsbytecode *pc;
types::TypeScript::GetPcScript(cx, &script, &pc);
if ((uint32_t)i >= length) {
// In an Ion activation, GetPcScript won't work. For non-baseline activations,
// that's ok, because optimized ion doesn't generate analysis info. However,
// baseline must generate this information, so it passes the script and pc in
// as arguments.
if (script || !cx->fp()->beginsIonActivation()) {
JS_ASSERT(!!script == !!pc);
if (!script)
types::TypeScript::GetPcScript(cx, script.address(), &pc);
if (script->hasAnalysis())
script->analysis()->getCode(pc).arrayWriteHole = true;
if (script->hasAnalysis())
script->analysis()->getCode(pc).arrayWriteHole = true;
}
}
}