[dart2js] Initialize all primitive constants in field allocators.

Change-Id: I6e1c3618758b1a569ee6d5d6c21520571d3234fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244361
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Mayank Patke 2022-05-11 23:37:44 +00:00 committed by Commit Bot
parent 143c6df41b
commit 4ea2b74256
4 changed files with 17 additions and 16 deletions

View file

@ -371,10 +371,7 @@ class JFieldAnalysis {
assert(value != null);
if (!memberUsage.hasWrite && canBeElided(kField)) {
isEffectivelyConstant = true;
} else if (value is NullConstantValue ||
value is IntConstantValue ||
value is BoolConstantValue ||
value is StringConstantValue ||
} else if (value is PrimitiveConstantValue ||
value is LateSentinelConstantValue) {
// TODO(johnniwinther,sra): Support non-primitive constants in
// allocators when it does cause allocators to deoptimized

View file

@ -1,2 +1 @@
spec=pkg/compiler/test/field_analysis/jfield_analysis_test.dart
prod=pkg/compiler/test/field_analysis/jfield_analysis_test.dart

View file

@ -166,7 +166,10 @@ class Class1 {
/*member: Class1.field7b:constant=StringConstant("foo")*/
var field7b = 'foo';
/*member: Class1.field8a:initial=DoubleConstant(0.5)*/
/*member: Class1.field8a:
allocator,
initial=DoubleConstant(0.5)
*/
var field8a = 0.5;
/*member: Class1.field8b:constant=DoubleConstant(0.5)*/
@ -178,10 +181,10 @@ class Class1 {
/*member: Class1.field9b:constant=ListConstant([])*/
var field9b = const [];
/*spec.member: Class1.field9c:initial=ListConstant(<int*>[IntConstant(0), IntConstant(1)])*/
/*member: Class1.field9c:initial=ListConstant(<int*>[IntConstant(0), IntConstant(1)])*/
var field9c = const [0, 1];
/*spec.member: Class1.field9d:constant=ListConstant(<int*>[IntConstant(0), IntConstant(1), IntConstant(2)])*/
/*member: Class1.field9d:constant=ListConstant(<int*>[IntConstant(0), IntConstant(1), IntConstant(2)])*/
var field9d = const [0, 1, 2];
/*member: Class1.field10a:initial=MapConstant({})*/
@ -190,10 +193,10 @@ class Class1 {
/*member: Class1.field10b:constant=MapConstant({})*/
var field10b = const {};
/*spec.member: Class1.field10c:initial=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3)})*/
/*member: Class1.field10c:initial=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3)})*/
var field10c = const {0: 1, 2: 3};
/*spec.member: Class1.field10d:constant=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3), IntConstant(4): IntConstant(5)})*/
/*member: Class1.field10d:constant=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3), IntConstant(4): IntConstant(5)})*/
var field10d = const {0: 1, 2: 3, 4: 5};
/*member: Class1.field11a:initial=ConstructedConstant(Symbol(_name=StringConstant("foo")))*/
@ -258,7 +261,10 @@ class Class2 {
/*member: Class2.field7b:constant=StringConstant("foo")*/
var field7b;
/*member: Class2.field8a:initial=DoubleConstant(0.5)*/
/*member: Class2.field8a:
allocator,
initial=DoubleConstant(0.5)
*/
var field8a;
/*member: Class2.field8b:constant=DoubleConstant(0.5)*/
@ -270,10 +276,10 @@ class Class2 {
/*member: Class2.field9b:constant=ListConstant([])*/
var field9b;
/*spec.member: Class2.field9c:initial=ListConstant(<int*>[IntConstant(0), IntConstant(1)])*/
/*member: Class2.field9c:initial=ListConstant(<int*>[IntConstant(0), IntConstant(1)])*/
var field9c;
/*spec.member: Class2.field9d:constant=ListConstant(<int*>[IntConstant(0), IntConstant(1), IntConstant(2)])*/
/*member: Class2.field9d:constant=ListConstant(<int*>[IntConstant(0), IntConstant(1), IntConstant(2)])*/
var field9d;
/*member: Class2.field10a:initial=MapConstant({})*/
@ -282,10 +288,10 @@ class Class2 {
/*member: Class2.field10b:constant=MapConstant({})*/
var field10b;
/*spec.member: Class2.field10c:initial=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3)})*/
/*member: Class2.field10c:initial=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3)})*/
var field10c;
/*spec.member: Class2.field10d:constant=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3), IntConstant(4): IntConstant(5)})*/
/*member: Class2.field10d:constant=MapConstant(<int*, int*>{IntConstant(0): IntConstant(1), IntConstant(2): IntConstant(3), IntConstant(4): IntConstant(5)})*/
var field10d;
/*member: Class2.field11a:initial=ConstructedConstant(Symbol(_name=StringConstant("foo")))*/

View file

@ -1,2 +1 @@
spec=pkg/compiler/test/field_analysis/kfield_analysis_test.dart
prod=pkg/compiler/test/field_analysis/kfield_analysis_test.dart