Open Bug 1973249 Opened 2 days ago Updated 16 hours ago

Remove addProperty JSClass hook

Categories

(Core :: JavaScript Engine, task)

task

Tracking

()

ASSIGNED

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

The only addProperty class hooks left in the code base (ignoring tests) are:

  1. array_addProperty (this could be inlined)
  2. Some XPConnect hooks for wrapped natives that throw to prevent adding additional properties:
    • XPC_WN_CannotModifyPropertyStub
    • XPC_WN_MaybeResolvingPropertyStub
    • XPC_WN_OnlyIWrite_AddPropertyStub
    • XPC_WN_OnlyIWrite_Proto_AddPropertyStub

We should check what (2) needs exactly because it would be nice if we could remove this.

(In reply to Jan de Mooij [:jandem] from comment #0)

  1. Some XPConnect hooks for wrapped natives that throw to prevent adding additional properties:
    • XPC_WN_CannotModifyPropertyStub
    • XPC_WN_MaybeResolvingPropertyStub
    • XPC_WN_OnlyIWrite_AddPropertyStub
    • XPC_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.

You need to log in before you can comment on or make changes to this bug.