mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #2142 - Change InitPropertyOperation to accept a PropertyName directy and use DefineDataProperty
Based-on: m-c 1413907, 1547129
This commit is contained in:
parent
6f56a494e6
commit
627d0da7dc
4 changed files with 11 additions and 12 deletions
|
|
@ -4584,7 +4584,7 @@ DoSetPropFallback(JSContext* cx, BaselineFrame* frame, ICSetProp_Fallback* stub_
|
||||||
op == JSOP_INITLOCKEDPROP ||
|
op == JSOP_INITLOCKEDPROP ||
|
||||||
op == JSOP_INITHIDDENPROP)
|
op == JSOP_INITHIDDENPROP)
|
||||||
{
|
{
|
||||||
if (!InitPropertyOperation(cx, op, obj, id, rhs))
|
if (!InitPropertyOperation(cx, op, obj, name, rhs))
|
||||||
return false;
|
return false;
|
||||||
} else if (op == JSOP_SETNAME ||
|
} else if (op == JSOP_SETNAME ||
|
||||||
op == JSOP_STRICTSETNAME ||
|
op == JSOP_STRICTSETNAME ||
|
||||||
|
|
|
||||||
|
|
@ -232,8 +232,7 @@ bool
|
||||||
InitProp(JSContext* cx, HandleObject obj, HandlePropertyName name, HandleValue value,
|
InitProp(JSContext* cx, HandleObject obj, HandlePropertyName name, HandleValue value,
|
||||||
jsbytecode* pc)
|
jsbytecode* pc)
|
||||||
{
|
{
|
||||||
RootedId id(cx, NameToId(name));
|
return InitPropertyOperation(cx, JSOp(*pc), obj, name, value);
|
||||||
return InitPropertyOperation(cx, JSOp(*pc), obj, id, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool Equal>
|
template<bool Equal>
|
||||||
|
|
|
||||||
|
|
@ -340,12 +340,15 @@ InitGlobalLexicalOperation(JSContext* cx, LexicalEnvironmentObject* lexicalEnvAr
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
InitPropertyOperation(JSContext* cx, JSOp op, HandleObject obj, HandleId id, HandleValue rhs)
|
InitPropertyOperation(JSContext* cx, JSOp op, HandleObject obj, HandlePropertyName name, HandleValue rhs)
|
||||||
{
|
{
|
||||||
if (obj->is<PlainObject>() || obj->is<JSFunction>()) {
|
RootedId id(cx, NameToId(name));
|
||||||
|
|
||||||
|
// {Goanna} DefineProperty works on almost any JSObject, but there's no good way to check what works
|
||||||
|
// So instead, check what we don't handle explicitly.
|
||||||
|
if (!obj->is<UnboxedPlainObject>()) {
|
||||||
unsigned propAttrs = GetInitDataPropAttrs(op);
|
unsigned propAttrs = GetInitDataPropAttrs(op);
|
||||||
return NativeDefineProperty(cx, obj.as<NativeObject>(), id, rhs, nullptr, nullptr,
|
return DefineProperty(cx, obj, id, rhs, nullptr, nullptr, propAttrs);
|
||||||
propAttrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(obj->as<UnboxedPlainObject>().layout().lookup(id));
|
MOZ_ASSERT(obj->as<UnboxedPlainObject>().layout().lookup(id));
|
||||||
|
|
|
||||||
|
|
@ -3744,12 +3744,9 @@ CASE(JSOP_INITHIDDENPROP)
|
||||||
/* Load the object being initialized into lval/obj. */
|
/* Load the object being initialized into lval/obj. */
|
||||||
ReservedRooted<JSObject*> obj(&rootObject0, ®S.sp[-2].toObject());
|
ReservedRooted<JSObject*> obj(&rootObject0, ®S.sp[-2].toObject());
|
||||||
|
|
||||||
PropertyName* name = script->getName(REGS.pc);
|
ReservedRooted<PropertyName*> name(&rootName0, script->getName(REGS.pc));
|
||||||
|
|
||||||
RootedId& id = rootId0;
|
if (!InitPropertyOperation(cx, JSOp(*REGS.pc), obj, name, rval))
|
||||||
id = NameToId(name);
|
|
||||||
|
|
||||||
if (!InitPropertyOperation(cx, JSOp(*REGS.pc), obj, id, rval))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
REGS.sp--;
|
REGS.sp--;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue