Open Bug 1478912 Opened 7 years ago Updated 2 years ago

Can we move rest parameter binding from "positional formals" to "other formals" or dedicated optional range in FunctionScope ?

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

ASSIGNED
Tracking Status
firefox63 --- affected

People

(Reporter: arai, Assigned: arai)

References

Details

User Story

The goal here is to make it possible to construct FunctionScope::Data up to varStart, at the point of reading AssertedParameterScope in BinAST.

the most problematic case is destructuring rest parameter, which doesn't have single binding for rest parameter, but we still need a slot in positional formal parameter which holds nullptr,
such info is not provided in AssertedParameterScope, and I don't think it's reasonable to put those info in BinAST spec.
separated from bug 1475458 If we can move rest parameter binding (including nullptr for destructuring rest) out of "positional formals" range, the range's length is fixed to function.length, and that helps streaming compilation of BinAST.
there are so many places that depends on the current layout (BytecodeEmitter, Scope, Interpreter, JIT, Debugger API), so this would be really complicated change :/
some places want to access rest parameter name, which means we cannot just move it to 'other formals' range. we could add extra range for optional simple rest parameter, which is in local range but still directly accessible
User Story: (updated)
(In reply to Tooru Fujisawa [:arai] from comment #0) > If we can move rest parameter binding (including nullptr for destructuring > rest) out of "positional formals" range, the range's length is fixed to > function.length this wasn't correct for the case there's default parameter.
Summary: Can we move rest parameter binding from "positional formals" to "other formals" in FunctionScope ? → Can we move rest parameter binding from "positional formals" to "other formals" or dedicated optional range in FunctionScope ?
what I'm now thinking is the following: current: > // positional formals - [0, nonPositionalFormalStart) > // other formals - [nonPositionalParamStart, varStart) > // vars - [varStart, length) modified: > // positional formals - [0, restStart) > // rest - [restStart, nonPositionalFormalStart) > // other formals - [nonPositionalParamStart, varStart) > // vars - [varStart, length) the rest range is optional and used only if there's simple rest parameter, which is |function f(...args) {}|, and not used for destructuring rest |function f(...[a, b, c]) {}|. in latter case, those bindings are stored in 'other formals' range, which is same as current behavior. in this way we can construct the FunctionScope::Data up to var range at the point of reading AssertedParameterScope+AssertedPositionalParameterName+AssertedRestParameterName. and also we can get the simple rest parameter binding from the slot when we need it.
(In reply to Tooru Fujisawa [:arai] from comment #1) > there are so many places that depends on the current layout > (BytecodeEmitter, Scope, Interpreter, JIT, Debugger API), > so this would be really complicated change :/ Just curious, what's the JIT dependency exactly? Does that also apply to comment 4?
(In reply to Jan de Mooij [:jandem] from comment #5) > (In reply to Tooru Fujisawa [:arai] from comment #1) > > there are so many places that depends on the current layout > > (BytecodeEmitter, Scope, Interpreter, JIT, Debugger API), > > so this would be really complicated change :/ > > Just curious, what's the JIT dependency exactly? Does that also apply to > comment 4? when we move rest parameter out of positional formals, the following will change (not-complete list, I'm still figuring out the affected area): * JSFunction.nargs_ * JSScript::numArgs() * FunctionScope::numPositionalFormalParameters() * FrameIter::numFormalArgs * ... and there are several places in JIT that touches them, by reading those values (reading them in C++ code or in assembly by offset), iterates over parameters, etc. and now I'm wondering how much change will be required there, and if it's feasible.
User Story: (updated)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.