Remove addProperty JSClass hook
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: jandem, Assigned: jandem)
References
Details
The only addProperty class hooks left in the code base (ignoring tests) are:
array_addProperty(this could be inlined)- Some XPConnect hooks for wrapped natives that throw to prevent adding additional properties:
XPC_WN_CannotModifyPropertyStubXPC_WN_MaybeResolvingPropertyStubXPC_WN_OnlyIWrite_AddPropertyStubXPC_WN_OnlyIWrite_Proto_AddPropertyStub
We should check what (2) needs exactly because it would be nice if we could remove this.
| Assignee | ||
Comment 1•1 year ago
|
||
(In reply to Jan de Mooij [:jandem] from comment #0)
- Some XPConnect hooks for wrapped natives that throw to prevent adding additional properties:
XPC_WN_CannotModifyPropertyStubXPC_WN_MaybeResolvingPropertyStubXPC_WN_OnlyIWrite_AddPropertyStubXPC_WN_OnlyIWrite_Proto_AddPropertyStub
When we removed the similar setProperty hooks in bug 1390159, bz and mrbkap thought that was fine because we have these addProperty hooks...
The most complicated case is when the class also has a resolve hook and we allow adding properties while resolving but not in other cases (XPC_SCRIPTABLE_ALLOW_PROP_MODS_DURING_RESOLVE). This applies to nsXPCComponents_Utils, nsXPCComponents_Interfaces, AsyncStatementJSHelper, and some others.
If that's the behavior we need to preserve then maybe (some of) these objects would be proxies nowadays but that's a larger change.
One option would be replacing the addProperty hook with a JSClass flag that means "throw when adding a new property (outside resolve hooks)" but that still requires special behavior for these objects.
Another option is to call JS_PreventExtensions on these objects. That resolves lazy properties eagerly so might affect memory usage and/or performance.
Updated•1 year ago
|
Description
•