Change information
Commit message:
[turbolev] Clone KNA before emitting CallKnowJSFunction node
... since emitting the CallKnowJSFunction node will clear the unstable
maps from the KNA.
This is especially useful for constructors: the construct stub is
inlined eagerly during graph building, but the constructor itself can
be inlined non-greedily later, but if it has multiple derived classes,
its stores will be megamorphic, and it will thus require the KNA to
make them simple stores rather than calls to the megamorphic store IC.
For instance:
class B {
constructor() {
this.a0 = 42;
this.a1 = 42;
this.a2 = 42;
this.a3 = 42;
this.a4 = 42;
this.a5 = 42;
}
}
class D1 extends B {}
class D2 extends B {}
class D3 extends B {}
class D4 extends B {}
class D5 extends B {}
%PrepareFunctionForOptimization(B);
new B();
new D1();
new D2();
new D3();
new D4();
new D5();
function foo() {
return new B();
}
%PrepareFunctionForOptimization(foo);
print(foo());
%OptimizeFunctionOnNextCall(foo);
print(foo());
Prior to this CL, `foo` would end up calling the megamorphic store IC,
while after this CL, it simply does a few raw stores.
This CL improves FLightPlanner AverageScore with --turbolev-future
by 26%.
Bug: 431933185
Change-Id: I8a8fb8aabad8b9549a9441bf53b44f12fe4e445b
Cr-Commit-Position: refs/heads/main@{#102248}
Files:
- M src/maglev/maglev-graph-builder.cc
Change size: S
Delta: 1 file changed, 8 insertions(+), 2 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Victor Gomes