mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 09:19:28 +00:00
Bug 725532 - Refactor DefVarOrConstOperation() to be Ion-compatible. r=Waldo
This commit is contained in:
parent
728968c78d
commit
b5d961f3e3
@ -3070,7 +3070,18 @@ BEGIN_CASE(JSOP_DEFCONST)
|
||||
BEGIN_CASE(JSOP_DEFVAR)
|
||||
{
|
||||
PropertyName *dn = atoms[GET_INDEX(regs.pc)]->asPropertyName();
|
||||
if (!DefVarOrConstOperation(cx, op, dn, regs.fp()))
|
||||
|
||||
/* ES5 10.5 step 8 (with subsequent errata). */
|
||||
uintN attrs = JSPROP_ENUMERATE;
|
||||
if (!regs.fp()->isEvalFrame())
|
||||
attrs |= JSPROP_PERMANENT;
|
||||
if (op == JSOP_DEFCONST)
|
||||
attrs |= JSPROP_READONLY;
|
||||
|
||||
/* Step 8b. */
|
||||
JSObject &obj = regs.fp()->varObj();
|
||||
|
||||
if (!DefVarOrConstOperation(cx, obj, dn, attrs))
|
||||
goto error;
|
||||
}
|
||||
END_CASE(JSOP_DEFVAR)
|
||||
|
@ -439,27 +439,19 @@ NameOperation(JSContext *cx, jsbytecode *pc, Value *vp)
|
||||
}
|
||||
|
||||
inline bool
|
||||
DefVarOrConstOperation(JSContext *cx, JSOp op, PropertyName *dn, StackFrame *fp)
|
||||
DefVarOrConstOperation(JSContext *cx, JSObject &varobj, PropertyName *dn, uintN attrs)
|
||||
{
|
||||
/* ES5 10.5 step 8 (with subsequent errata). */
|
||||
uintN attrs = JSPROP_ENUMERATE;
|
||||
if (!fp->isEvalFrame())
|
||||
attrs |= JSPROP_PERMANENT;
|
||||
if (op == JSOP_DEFCONST)
|
||||
attrs |= JSPROP_READONLY;
|
||||
|
||||
/* Step 8b. */
|
||||
JSObject &obj = fp->varObj();
|
||||
JS_ASSERT(!obj.getOps()->defineProperty);
|
||||
JS_ASSERT(varobj.isVarObj());
|
||||
JS_ASSERT(!varobj.getOps()->defineProperty);
|
||||
|
||||
JSProperty *prop;
|
||||
JSObject *obj2;
|
||||
if (!obj.lookupProperty(cx, dn, &obj2, &prop))
|
||||
if (!varobj.lookupProperty(cx, dn, &obj2, &prop))
|
||||
return false;
|
||||
|
||||
/* Steps 8c, 8d. */
|
||||
if (!prop || (obj2 != &obj && obj.isGlobal())) {
|
||||
if (!DefineNativeProperty(cx, &obj, dn, UndefinedValue(),
|
||||
if (!prop || (obj2 != &varobj && varobj.isGlobal())) {
|
||||
if (!DefineNativeProperty(cx, &varobj, dn, UndefinedValue(),
|
||||
JS_PropertyStub, JS_StrictPropertyStub, attrs, 0, 0))
|
||||
{
|
||||
return false;
|
||||
@ -470,7 +462,7 @@ DefVarOrConstOperation(JSContext *cx, JSOp op, PropertyName *dn, StackFrame *fp)
|
||||
* see a redeclaration that's |const|, we consider it a conflict.
|
||||
*/
|
||||
uintN oldAttrs;
|
||||
if (!obj.getPropertyAttributes(cx, dn, &oldAttrs))
|
||||
if (!varobj.getPropertyAttributes(cx, dn, &oldAttrs))
|
||||
return false;
|
||||
if (attrs & JSPROP_READONLY) {
|
||||
JSAutoByteString bytes;
|
||||
|
@ -1665,7 +1665,15 @@ stubs::DelElem(VMFrame &f)
|
||||
void JS_FASTCALL
|
||||
stubs::DefVarOrConst(VMFrame &f, PropertyName *dn)
|
||||
{
|
||||
if (!DefVarOrConstOperation(f.cx, JSOp(*f.regs.pc), dn, f.fp()))
|
||||
uintN attrs = JSPROP_ENUMERATE;
|
||||
if (!f.fp()->isEvalFrame())
|
||||
attrs |= JSPROP_PERMANENT;
|
||||
if (JSOp(*f.regs.pc) == JSOP_DEFCONST)
|
||||
attrs |= JSPROP_READONLY;
|
||||
|
||||
JSObject &obj = f.fp()->varObj();
|
||||
|
||||
if (!DefVarOrConstOperation(f.cx, obj, dn, attrs))
|
||||
THROW();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user