tc39 / proposal-explicit-resource-management

ECMAScript Explicit Resource Management
https://arai-a.github.io/ecma262-compare/?pr=3000
BSD 3-Clause "New" or "Revised" License
725 stars 29 forks source link

`NewFunctionEnvironment` AO missing call to `NewDisposeCapability()` #170

Closed rbuckton closed 3 months ago

rbuckton commented 1 year ago

In FunctionDefinitionInstantiation in non-strict mode we set the LexicalEnvironment of a function to a NewDeclarativeEnvironment() which correctly initializes [[DisposeCapability]] to a NewDisposeCapability(). However, in strict mode we reuse the LexicalEnvironment which happens to be a Function Environment Record that was created by NewFunctionEnvironment(), which does not correctly set its [[DisposeCapability]] slot.

We either need to unconditionally set [[DisposeCapability]] in NewFunctionEnvironment(), or conditionally set it in FunctionDefinitionInstantiation() when we opt to reuse the LexicalEnvironment. I feel the first option is probably cleaner, though.

rbuckton commented 1 year ago

We may also need to do the same in NewModuleEnvironment().

rbuckton commented 1 year ago

We may also need to do the same in NewModuleEnvironment().

It seems like this is necessary, per a reference implementation I am working on for engine262 as well as work in progress for test262 tests.

rbuckton commented 1 year ago

We also seem to be missing a call to the DisposeResources() AO in a Source Text Module Record's ExecuteModule, which is necessary to properly dispose resources at the top level of a Module.

rbuckton commented 1 year ago

We may also need to do the same in NewModuleEnvironment().

It seems like this is necessary, per a reference implementation I am working on for engine262 as well as work in progress for test262 tests.

Filed as #173

rbuckton commented 1 year ago

We also seem to be missing a call to the DisposeResources() AO in a Source Text Module Record's ExecuteModule, which is necessary to properly dispose resources at the top level of a Module.

Filed as #174