dart2js: useless argument / parameter on generative constructor bodies with initializing formals #17868
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
dart2js-optimization
type-enhancement
A request for a change that isn't a bug
web-dart2js
This probably won't make a huge difference, but it is an example of where we can remove unused parameters without much analysis. I think there are 20-30 useless expressions that can be eliminated in swarm.
An initializing formal is not a parameter of a generative constructor body.
-------- example
class A {
var a,b,c,d;
A(this.a, b, c, d) : b = b {
// There are only three parameters: b, c, d. 'a' resolves to this.a
if (false) throw 123; // inhibit inlining
this.c = c;
a++;b++;c++;
this.d = [a, b, c, d];
}
toString() => 'A($a, $b, $c, $d)';
}
make() => new A(10, 20, 30, 40);
main() {
print((make)());
}
-------- output
A(11, 20, 30, [11, 21, 31, 40])
-------- generated code
make: [function() {
var t1 = new E.A(10, 20, null, null);
t1.A$4(10, 20, 30, 40);
return t1;
}, "call$0", "make$closure", 0, 0, 0],
main: ...,
A: {
...,
A$4: function(a, b, c, d) {
var t1;
this.c = c;
t1 = this.a + 1;
this.a = t1;
this.d = [t1, b + 1, c + 1, d];
}
}
Notice that A$4 has a useless 'a' parameter, and the call is passed a useless argument.
The text was updated successfully, but these errors were encountered: