Skip to content

Commit

Permalink
Version 3.3.0-7.0.dev
Browse files Browse the repository at this point in the history
Merge 2cbb5ea into dev
  • Loading branch information
Dart CI committed Oct 10, 2023
2 parents 0732be6 + 2cbb5ea commit 7f8bb52
Show file tree
Hide file tree
Showing 43 changed files with 503 additions and 197 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vars = {

# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
# hashes.
"co19_rev": "6ec024498b3546c775b65cd2d964eb3c6ff0fb2f",
"co19_rev": "c1ab21bb5424c3695307ec30a89af1d800d2e90f",
# This line prevents conflicts when both packages are rolled simultaneously.
"co19_2_rev": "d87f9096ec0a14cd7c32c33316fb2378b89d6a45",

Expand Down
16 changes: 9 additions & 7 deletions pkg/dart2wasm/lib/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ class _ExceptionHandlerStack {

codeGen.b.catch_(codeGen.translator.exceptionTag);

final stackTraceLocal =
codeGen.addLocal(codeGen.translator.stackTraceInfo.nonNullableType);
final stackTraceLocal = codeGen
.addLocal(codeGen.translator.stackTraceInfo.repr.nonNullableType);
codeGen.b.local_set(stackTraceLocal);

final exceptionLocal =
Expand Down Expand Up @@ -573,8 +573,8 @@ class AsyncCodeGenerator extends CodeGenerator {
asyncSuspendStateInfo.nonNullableType, // _AsyncSuspendState
translator.topInfo.nullableType, // Object?, await value
translator.topInfo.nullableType, // Object?, error value
translator
.stackTraceInfo.nullableType // StackTrace?, error stack trace
translator.stackTraceInfo.repr
.nullableType // StackTrace?, error stack trace
], [
// Inner function does not return a value, but it's Dart type is
// `void Function(...)` and all Dart functions return a value, so we
Expand Down Expand Up @@ -647,7 +647,7 @@ class AsyncCodeGenerator extends CodeGenerator {
b.local_get(asyncStateLocal);
b.ref_null(translator.topInfo.struct); // await value
b.ref_null(translator.topInfo.struct); // error value
b.ref_null(translator.stackTraceInfo.struct); // stack trace
b.ref_null(translator.stackTraceInfo.repr.struct); // stack trace
b.call(resumeFun);
b.drop(); // drop null

Expand Down Expand Up @@ -783,7 +783,8 @@ class AsyncCodeGenerator extends CodeGenerator {

b.catch_(translator.exceptionTag);

final stackTraceLocal = addLocal(translator.stackTraceInfo.nonNullableType);
final stackTraceLocal =
addLocal(translator.stackTraceInfo.repr.nonNullableType);
b.local_set(stackTraceLocal);

final exceptionLocal = addLocal(translator.topInfo.nonNullableType);
Expand Down Expand Up @@ -1291,7 +1292,8 @@ class AsyncCodeGenerator extends CodeGenerator {
wrap(node.expression, translator.topInfo.nonNullableType);
b.local_set(exceptionLocal);

final stackTraceLocal = addLocal(translator.stackTraceInfo.nonNullableType);
final stackTraceLocal =
addLocal(translator.stackTraceInfo.repr.nonNullableType);
call(translator.stackTraceCurrent.reference);
b.local_set(stackTraceLocal);

Expand Down
23 changes: 3 additions & 20 deletions pkg/dart2wasm/lib/class_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,8 @@ class ClassInfoCollector {
}
}

// A class can reuse the Wasm struct of the superclass if it doesn't
// declare any Wasm fields of its own. This is the case when three
// conditions are met:
// 1. All type parameters can reuse a type parameter field of the
// superclass.
// 2. The class declares no Dart fields of its own.
// 3. The class is not a special class that contains hidden fields.
bool canReuseSuperStruct =
typeParameterMatch.length == cls.typeParameters.length &&
cls.fields.where((f) => f.isInstanceMember).isEmpty;
w.StructType struct = canReuseSuperStruct
? superInfo.struct
: m.types.defineStruct(cls.name, superType: superInfo.struct);
w.StructType struct =
m.types.defineStruct(cls.name, superType: superInfo.struct);
info = ClassInfo(
cls, _nextClassId++, superInfo.depth + 1, struct, superInfo,
typeParameterMatch: typeParameterMatch);
Expand Down Expand Up @@ -447,7 +436,7 @@ class ClassInfoCollector {
// Top - add class id field
info._addField(
w.FieldType(w.NumType.i32, mutable: false), FieldIndex.classId);
} else if (info.struct != superInfo.struct) {
} else {
// Copy fields from superclass
for (w.FieldType fieldType in superInfo.struct.fields) {
info._addField(fieldType);
Expand Down Expand Up @@ -476,12 +465,6 @@ class ClassInfoCollector {
info._addField(w.FieldType(wasmType, mutable: !field.isFinal));
}
}
} else {
for (TypeParameter parameter in info.cls!.typeParameters) {
// Reuse supertype type variable
translator.typeParameterIndex[parameter] =
translator.typeParameterIndex[info.typeParameterMatch[parameter]]!;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/dart2wasm/lib/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
// stack after each type test. Also, store the stack trace in a local.
w.Local thrownException = addLocal(translator.topInfo.nonNullableType);
w.Local thrownStackTrace =
addLocal(translator.stackTraceInfo.nonNullableType);
addLocal(translator.stackTraceInfo.repr.nonNullableType);

void emitCatchBlock(Catch catch_, bool emitGuard) {
// For each catch node:
Expand Down Expand Up @@ -1864,7 +1864,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
translator.types.makeType(this, typeArguments[elementIdx]);
}, isGrowable: true);
final typeArgsLocal = function.addLocal(
translator.classInfo[translator.fixedLengthListClass]!.nonNullableType);
translator.classInfo[translator.growableListClass]!.nonNullableType);
b.local_set(typeArgsLocal);

// Evaluate positional arguments
Expand Down
47 changes: 31 additions & 16 deletions pkg/dart2wasm/lib/dispatch_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class SelectorInfo {
/// Is this an implicit or explicit setter?
final bool isSetter;

/// Does this method have any tear-off uses?
bool hasTearOffUses = false;

/// Maps class IDs to the selector's member in the class. The member can be
/// abstract.
final Map<int, Reference> targets = {};
Expand Down Expand Up @@ -113,28 +116,39 @@ class SelectorInfo {
named = const {};
returns = [function.computeFunctionType(Nullability.nonNullable)];
} else {
DartType typeForParam(VariableDeclaration param, int index) {
if (param.isCovariantByClass) {
// The type argument of a static type is not required to conform
// to the bounds of the type variable. Thus, any object can be
// passed to a parameter that is covariant by class.
return translator.coreTypes.objectNullableRawType;
}
if (param.isCovariantByDeclaration) {
if (hasTearOffUses) {
// The type of a covariant parameter in the runtime function
// type of a tear-off is always `Object?`. Thus, if the method
// has any tear-off uses, any object could be passed into the
// parameter.
return translator.coreTypes.objectNullableRawType;
}
if (!translator.options.omitTypeChecks) {
// A runtime type check of the parameter will be generated.
// The value therefore must be boxed.
ensureBoxed[index] = true;
}
}
return param.type;
}

positional = [
for (VariableDeclaration param in function.positionalParameters)
param.type
for (int i = 0; i < function.positionalParameters.length; i++)
typeForParam(function.positionalParameters[i], 1 + i)
];
named = {
for (VariableDeclaration param in function.namedParameters)
param.name!: param.type
param.name!: typeForParam(param, 1 + nameIndex[param.name!]!)
};
returns = target.isSetter ? const [] : [function.returnType];

// Box parameters that need covariance checks
if (!translator.options.omitTypeChecks) {
for (int i = 0; i < function.positionalParameters.length; i += 1) {
final param = function.positionalParameters[i];
ensureBoxed[1 + i] |=
param.isCovariantByClass || param.isCovariantByDeclaration;
}
for (VariableDeclaration param in function.namedParameters) {
ensureBoxed[1 + nameIndex[param.name!]!] |=
param.isCovariantByClass || param.isCovariantByDeclaration;
}
}
}
}
assert(returns.length <= outputSets.length);
Expand Down Expand Up @@ -287,6 +301,7 @@ class DispatchTable {
_selectorMetadata[selectorId].callCount, paramInfo,
isSetter: isSetter));
assert(selector.isSetter == isSetter);
selector.hasTearOffUses |= metadata.hasTearOffUses;
selector.paramInfo.merge(paramInfo);
if (calledDynamically) {
if (isGetter) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/dart2wasm/lib/sync_star.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SyncStarCodeGenerator extends CodeGenerator {
m.types.defineFunction([
suspendStateInfo.nonNullableType,
translator.topInfo.nullableType,
translator.stackTraceInfo.nullableType
translator.stackTraceInfo.repr.nullableType
], const [
w.NumType.i32
]),
Expand Down
15 changes: 8 additions & 7 deletions pkg/dart2wasm/lib/translator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ class Translator with KernelNodes {
w.RefType.def(closureLayouter.closureBaseStruct, nullable: false),

// Type arguments
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,

// Positional arguments
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,

// Named arguments, represented as array of symbol and object pairs
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,
], [
topInfo.nullableType
]);
Expand All @@ -191,13 +191,13 @@ class Translator with KernelNodes {
topInfo.nonNullableType,

// Type arguments
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,

// Positional arguments
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,

// Named arguments, represented as array of symbol and object pairs
classInfo[fixedLengthListClass]!.nonNullableType,
classInfo[listBaseClass]!.nonNullableType,
], [
topInfo.nullableType
]);
Expand Down Expand Up @@ -465,7 +465,8 @@ class Translator with KernelNodes {
/// exception tag is used to throw and catch all Dart exceptions.
w.Tag createExceptionTag() {
w.FunctionType tagType = m.types.defineFunction(
[topInfo.nonNullableType, stackTraceInfo.nonNullableType], const []);
[topInfo.nonNullableType, stackTraceInfo.repr.nonNullableType],
const []);
w.Tag tag = m.tags.define(tagType);
return tag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ library fasta.constructor_reference_builder;

import '../messages.dart' show noLength, templateConstructorNotFound;

import '../identifiers.dart' show Identifier, QualifiedName, flattenName;

import '../scope.dart';

import 'builder.dart';
Expand All @@ -21,7 +19,7 @@ class ConstructorReferenceBuilder {

final Uri fileUri;

final Object name;
final TypeName typeName;

final List<TypeBuilder>? typeArguments;

Expand All @@ -30,45 +28,39 @@ class ConstructorReferenceBuilder {

Builder? target;

ConstructorReferenceBuilder(this.name, this.typeArguments, this.suffix,
ConstructorReferenceBuilder(this.typeName, this.typeArguments, this.suffix,
Builder parent, this.charOffset)
: fileUri = parent.fileUri!;

String get fullNameForErrors {
return "${flattenName(name, charOffset, fileUri)}"
return "${typeName.fullName}"
"${suffix == null ? '' : '.$suffix'}";
}

void resolveIn(Scope scope, LibraryBuilder accessingLibrary) {
final Object name = this.name;
Builder? declaration;
if (name is QualifiedName) {
String prefix = (name.qualifier as Identifier).name;
String middle = name.name;
String? qualifier = typeName.qualifier;
if (qualifier != null) {
String prefix = qualifier;
String middle = typeName.name;
declaration = scope.lookup(prefix, charOffset, fileUri);
if (declaration is TypeAliasBuilder) {
TypeAliasBuilder aliasBuilder = declaration;
declaration = aliasBuilder.unaliasDeclaration(typeArguments);
}
if (declaration is PrefixBuilder) {
PrefixBuilder prefix = declaration;
declaration = prefix.lookup(middle, name.charOffset, fileUri);
declaration = prefix.lookup(middle, typeName.nameOffset, fileUri);
} else if (declaration is DeclarationBuilder) {
declaration = declaration.findConstructorOrFactory(
middle, name.charOffset, fileUri, accessingLibrary);
middle, typeName.nameOffset, fileUri, accessingLibrary);
if (suffix == null) {
target = declaration;
return;
}
}
} else if (name is Identifier) {
declaration = scope.lookup(name.name, charOffset, fileUri);
if (declaration is TypeAliasBuilder) {
TypeAliasBuilder aliasBuilder = declaration;
declaration = aliasBuilder.unaliasDeclaration(typeArguments);
}
} else {
declaration = scope.lookup(name as String, charOffset, fileUri);
declaration = scope.lookup(typeName.name, charOffset, fileUri);
if (declaration is TypeAliasBuilder) {
TypeAliasBuilder aliasBuilder = declaration;
declaration = aliasBuilder.unaliasDeclaration(typeArguments);
Expand Down
Loading

0 comments on commit 7f8bb52

Please sign in to comment.