Closed Bug 1307494 Opened 7 years ago Closed 3 years ago

Improve type information for default parameters

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jandem, Unassigned)

References

(Blocks 2 open bugs)

Details

(Keywords: perf)

See bug 1306450. The following pattern is quite common:

  if (x === undefined)
      x = 0;

ES6 default arguments use similar bytecode:

  function f(x = 0) {}

IonBuilder has code to optimize TypeSets when using these comparisons, but it doesn't handle this case. After the if-statement, we should be able to remove |undefined| from x's TypeSet, with some analysis.
Keywords: perf
Blocks: es6perf
Summary: Improve type information for optional arguments → Improve type information for default parameters
Assignee: nobody → evilpies
Assignee: evilpies → nobody
Is this still a problem? I think I get the correct information for this trivial example.

> function f(x) {
>    if (x === undefined)
>        x = 0;
>    return x;
> }
>
> function g(x = 0) {
>    return x;
> }
>
> f()
> g()
This example is probably too trivial. We want good type information even when the call to f or g is not inlined and the method is called with no parameter, undefined and some number like 0.

So even when type of x is undefined or a number the type inside the body (or after the if) is still a number.

We don't have TypeSets anymore.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.