[dart2js] Reformat pkg/compiler.

Change-Id: I9e379d1f0673b589139a2389c6d3602c36995cd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413720
Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Mayank Patke
2025-03-07 04:20:04 -08:00
committed by Commit Queue
parent 0539814037
commit f00dbb5856
12 changed files with 76 additions and 107 deletions
@@ -95,10 +95,8 @@ class TypeGraphInferrer implements TypesInferrer {
}
bool throwsAlways =
// Always throws if the return type was inferred to be non-null empty.
abstractValueDomain
.isEmpty(returnType)
.isDefinitelyTrue;
// Always throws if the return type was inferred to be non-null empty.
abstractValueDomain.isEmpty(returnType).isDefinitelyTrue;
bool isCalledOnce = typeInformation.isCalledExactlyOnce;
@@ -46,18 +46,15 @@ class PositionSourceInformation extends SourceInformation {
.readIndexedOrNullNoCache<SourceLocation>(
() => SourceLocation.readFromDataSource(source),
);
List<FrameContext>? inliningContext = source
.readIndexedOrNullNoCache<List<FrameContext>>(
() =>
// FrameContext must be cached since PositionSourceInformation.==
// requires identity comparison on the objects in inliningContext.
source
.readList(
() => source.readIndexed(
() => FrameContext.readFromDataSource(source),
),
),
);
List<FrameContext>?
inliningContext = source.readIndexedOrNullNoCache<List<FrameContext>>(
() =>
// FrameContext must be cached since PositionSourceInformation.==
// requires identity comparison on the objects in inliningContext.
source.readList(
() => source.readIndexed(() => FrameContext.readFromDataSource(source)),
),
);
source.end(tag);
return PositionSourceInformation(
startPosition,
+4 -4
View File
@@ -248,10 +248,10 @@ bool _isWebLibrary(Uri importUri) =>
importUri.path == 'web_gl' ||
importUri.path == 'web_sql' ||
importUri.path == 'html_common') ||
// Mock web library path for testing.
importUri
.path
.contains('native_null_assertions/web_library_interfaces.dart');
// Mock web library path for testing.
importUri.path.contains(
'native_null_assertions/web_library_interfaces.dart',
);
bool nodeIsInWebLibrary(ir.TreeNode? node) {
if (node == null) return false;
@@ -143,10 +143,9 @@ class Collector {
// Compute needed classes.
Set<ClassEntity> instantiatedClasses =
// TODO(johnniwinther): This should be accessed from a codegen closed
// world.
_codegenWorld
.directlyInstantiatedClasses
// TODO(johnniwinther): This should be accessed from a codegen closed
// world.
_codegenWorld.directlyInstantiatedClasses
.where(computeClassFilter(backendTypeHelpers))
.toSet();
@@ -101,8 +101,7 @@ class JsToFrontendMap {
return {
for (final member in set.map(toBackendMember))
// Members that are not live don't have a corresponding backend member.
if (member != null)
member,
if (member != null) member,
};
}
@@ -110,8 +109,7 @@ class JsToFrontendMap {
return {
for (final member in set.map(toBackendMember))
// Members that are not live don't have a corresponding backend member.
if (member != null)
member as FieldEntity,
if (member != null) member as FieldEntity,
};
}
@@ -119,8 +117,7 @@ class JsToFrontendMap {
return {
for (final member in set.map(toBackendMember))
// Members that are not live don't have a corresponding backend member.
if (member != null)
member as FunctionEntity,
if (member != null) member as FunctionEntity,
};
}
+15 -15
View File
@@ -556,21 +556,21 @@ class JClosedWorld implements World {
) {
return selector.name == Identifiers.call &&
(receiver == null ||
// This is logically equivalent to the former implementation using
// `abstractValueDomain.contains` (which wrapped `containsMask`).
// The switch to `abstractValueDomain.containsType` is because
// `contains` was generally unsound but happened to work correctly
// here. See https://dart-review.googlesource.com/c/sdk/+/130565
// for further discussion.
//
// This checks if the receiver mask contains the entire type cone
// originating from [_functionLub] and may therefore be unsound if
// the receiver mask contains only part of the type cone. (Is this
// possible?)
//
// TODO(fishythefish): Use `isDisjoint` or equivalent instead of
// `containsType` once we can ensure it's fast enough.
abstractValueDomain
// This is logically equivalent to the former implementation using
// `abstractValueDomain.contains` (which wrapped `containsMask`).
// The switch to `abstractValueDomain.containsType` is because
// `contains` was generally unsound but happened to work correctly
// here. See https://dart-review.googlesource.com/c/sdk/+/130565
// for further discussion.
//
// This checks if the receiver mask contains the entire type cone
// originating from [_functionLub] and may therefore be unsound if
// the receiver mask contains only part of the type cone. (Is this
// possible?)
//
// TODO(fishythefish): Use `isDisjoint` or equivalent instead of
// `containsType` once we can ensure it's fast enough.
abstractValueDomain
.containsType(receiver, _functionLub)
.isPotentiallyTrue);
}
@@ -241,12 +241,9 @@ class IndexAssignSpecializer extends InvokeDynamicSpecializer {
}
// TODO(johnniwinther): Merge this and the following if statement.
if (index.isInteger(abstractValueDomain).isPotentiallyFalse &&
// TODO(johnniwinther): Support annotations on the possible targets
// and used their parameter check policy here.
closedWorld
.annotationsData
.getParameterCheckPolicy(null)
.isEmitted) {
// TODO(johnniwinther): Support annotations on the possible targets
// and used their parameter check policy here.
closedWorld.annotationsData.getParameterCheckPolicy(null).isEmitted) {
// We want the right checked mode error.
return null;
}
@@ -371,12 +368,9 @@ class IndexSpecializer extends InvokeDynamicSpecializer {
}
HInstruction index = instruction.inputs.last;
if (index.isInteger(abstractValueDomain).isPotentiallyFalse &&
// TODO(johnniwinther): Support annotations on the possible targets
// and used their parameter check policy here.
closedWorld
.annotationsData
.getParameterCheckPolicy(null)
.isEmitted) {
// TODO(johnniwinther): Support annotations on the possible targets
// and used their parameter check policy here.
closedWorld.annotationsData.getParameterCheckPolicy(null).isEmitted) {
// We want the right checked mode error.
return null;
}
@@ -22,7 +22,8 @@ readParameterInAnonymousClosure(/**/ parameter) {
/*member: readParameterInClosure:*/
readParameterInClosure(/**/ parameter) {
/*fields=[parameter],free=[parameter]*/ func() => parameter;
/*fields=[parameter],free=[parameter]*/
func() => parameter;
return func;
}
@@ -35,7 +36,8 @@ writeParameterInAnonymousClosure(/*boxed*/ parameter) {
/*member: writeParameterInClosure:box=(box0 which holds [parameter])*/
writeParameterInClosure(/*boxed*/ parameter) {
/*fields=[box0],free=[box0,parameter]*/ func() {
/*fields=[box0],free=[box0,parameter]*/
func() {
parameter = 43;
}
@@ -51,7 +53,8 @@ readLocalInAnonymousClosure(/**/ parameter) {
/*member: readLocalInClosure:*/
readLocalInClosure(/**/ parameter) {
var /**/ local = parameter;
/*fields=[local],free=[local]*/ func() => local;
/*fields=[local],free=[local]*/
func() => local;
return func;
}
@@ -68,7 +71,8 @@ writeLocalInAnonymousClosure(/**/ parameter) {
writeLocalInClosure(/**/ parameter) {
// ignore: UNUSED_LOCAL_VARIABLE
var /*boxed*/ local = parameter;
/*fields=[box0],free=[box0,local]*/ func() {
/*fields=[box0],free=[box0,local]*/
func() {
local = 45;
}
@@ -79,21 +83,26 @@ writeLocalInClosure(/**/ parameter) {
class Foo {
int /*member: Foo.bar:hasThis*/ bar = 4;
/*member: Foo.baz:hasThis*/ baz() {
/*fields=[this],free=[this],hasThis*/ func() => bar;
/*member: Foo.baz:hasThis*/
baz() {
/*fields=[this],free=[this],hasThis*/
func() => bar;
return func;
}
}
/*member: Repro.:hasThis*/
class Repro {
/*member: Repro.qux:hasThis*/ qux() {
/*fields=[this],free=[this],hasThis*/ threeNested(foo) =>
/*member: Repro.qux:hasThis*/
qux() {
/*fields=[this],free=[this],hasThis*/
threeNested(foo) =>
/*fields=[this],free=[this],hasThis*/ (bar) => someFunction();
return threeNested;
}
/*member: Repro.someFunction:hasThis*/ someFunction() => 3;
/*member: Repro.someFunction:hasThis*/
someFunction() => 3;
}
main() {
@@ -97,8 +97,7 @@ class Class4b implements Class4a {
emitted,
set=simple
*/
int?
field4;
int? field4;
}
/*member: method4:calls=[set$field4(1)],params=1*/
@@ -94,8 +94,7 @@ class Class4b implements Class4a {
elided,
set=simple
*/
int?
field4;
int? field4;
}
/*member: method4:calls=[set$field4(1)],params=1*/
@@ -103,9 +103,8 @@ returnIntOrNull() {
/*current: [exact=ArrayIterator]*/
/*moveNext: [exact=ArrayIterator]*/
for (
// ignore: unused_local_variable
var b
in [42]) {
// ignore: unused_local_variable
var b in [42]) {
int? bar = 42;
/*[null|exact=JSUInt31]*/
f() => bar;
@@ -18,22 +18,16 @@ main() {
class Class {
@pragma('dart2js:noInline')
/*2:Class.instancePositional1[function-entry$1]*/ instancePositional1(
a, [
b = 42,
c = 87,
]) {
/*2:Class.instancePositional1[function-entry$1]*/
instancePositional1(a, [b = 42, c = 87]) {
print('instancePositional1($a,$b,$c)');
/*3:Class.instancePositional1*/
instancePositional2(1, 2);
}
@pragma('dart2js:noInline')
/*4:Class.instancePositional2[function-entry$2]*/ instancePositional2(
a, [
b = 42,
c = 87,
]) {
/*4:Class.instancePositional2[function-entry$2]*/
instancePositional2(a, [b = 42, c = 87]) {
print('instancePositional2($a,$b,$c)');
/*5:Class.instancePositional2*/
instancePositional3(3, 4, 5);
@@ -47,48 +41,32 @@ class Class {
}
@pragma('dart2js:noInline')
/*7:Class.instanceNamed1[function-entry$1]*/ instanceNamed1(
a, {
b = 42,
c = 87,
d = 735,
}) {
/*7:Class.instanceNamed1[function-entry$1]*/
instanceNamed1(a, {b = 42, c = 87, d = 735}) {
print('instanceNamed1($a,b:$b,c:$c,d:$d)');
/*8:Class.instanceNamed1*/
instanceNamed2(1, b: 2);
}
@pragma('dart2js:noInline')
/*9:Class.instanceNamed2[function-entry$1$b]*/ instanceNamed2(
a, {
b = 42,
c = 87,
d = 735,
}) {
/*9:Class.instanceNamed2[function-entry$1$b]*/
instanceNamed2(a, {b = 42, c = 87, d = 735}) {
print('instanceNamed2($a,b:$b,c:$c,d:$d)');
/*10:Class.instanceNamed2*/
instanceNamed3(3, c: 123);
}
@pragma('dart2js:noInline')
/*11:Class.instanceNamed3[function-entry$1$c]*/ instanceNamed3(
a, {
b = 42,
c = 87,
d = 735,
}) {
/*11:Class.instanceNamed3[function-entry$1$c]*/
instanceNamed3(a, {b = 42, c = 87, d = 735}) {
print('instanceNamed3($a,b:$b,c:$c,d:$d)');
/*12:Class.instanceNamed3*/
instanceNamed4(4, c: 45, b: 76);
}
@pragma('dart2js:noInline')
/*13:Class.instanceNamed4[function-entry$1$b$c]*/ instanceNamed4(
a, {
b = 42,
c = 87,
d = 735,
}) {
/*13:Class.instanceNamed4[function-entry$1$b$c]*/
instanceNamed4(a, {b = 42, c = 87, d = 735}) {
print('instanceNamed4($a,b:$b,c:$c,d:$d)');
/*14:Class.instanceNamed4*/
instanceNamed5(5, c: 6, b: 7, d: 8);