Version 2.14.0-86.0.dev
Merge commit 'bc2cf88bac44d02a44b9c315a8fd05eca2ecbaa4' into 'dev'
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
index 0d0cf6c..ec3928d 100644
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
@@ -161,7 +161,7 @@
@override
jsAst.Expression visitLateSentinel(LateSentinelConstantValue constant, [_]) =>
- js('#', _namer.staticStateHolder);
+ _namer.globalObjectForStaticState();
@override
jsAst.Expression visitUnreachable(UnreachableConstantValue constant, [_]) {
diff --git a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
index 602ff08..f7e5ff1 100644
--- a/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
+++ b/pkg/compiler/lib/src/js_backend/deferred_holder_expression.dart
@@ -4,6 +4,7 @@
import 'package:js_ast/src/precedence.dart' as js show PRIMARY;
+import '../common_elements.dart' show JCommonElements;
import '../elements/entities.dart';
import '../js/js.dart' as js;
import '../serialization/serialization.dart';
@@ -15,12 +16,20 @@
// framework into this approach. For example, we are still creating ModularNames
// for the entity referenced in the DeferredHolderExpression.
enum DeferredHolderExpressionKind {
+ globalObjectForStaticState,
+ globalObjectForConstants,
globalObjectForLibrary,
globalObjectForClass,
globalObjectForType,
globalObjectForMember,
}
+/// A [DeferredHolderExpression] is a deferred JavaScript expression determined
+/// by the finalization of holders. It is the injection point for data or
+/// code to related to holders. The actual [Expression] contained within the
+/// [DeferredHolderExpression] is determined by the
+/// [DeferredHolderExpressionKind], eventually, most will be a [PropertyAccess]
+/// but currently all are [VariableUse]s.
class DeferredHolderExpression extends js.DeferredExpression
implements js.AstContainer {
static const String tag = 'deferred-holder-expression';
@@ -35,6 +44,15 @@
DeferredHolderExpression(this.kind, this.entity) : sourceInformation = null;
DeferredHolderExpression._(
this.kind, this.entity, this._value, this.sourceInformation);
+ factory DeferredHolderExpression.forConstants() {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForConstants, null);
+ }
+
+ factory DeferredHolderExpression.forStaticState() {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForStaticState, null);
+ }
factory DeferredHolderExpression.readFromDataSource(DataSource source) {
source.begin(tag);
@@ -53,6 +71,10 @@
case DeferredHolderExpressionKind.globalObjectForMember:
entity = source.readMember();
break;
+ case DeferredHolderExpressionKind.globalObjectForStaticState:
+ case DeferredHolderExpressionKind.globalObjectForConstants:
+ // no entity.
+ break;
}
source.end(tag);
return DeferredHolderExpression(kind, entity);
@@ -74,6 +96,10 @@
case DeferredHolderExpressionKind.globalObjectForMember:
sink.writeMember(entity);
break;
+ case DeferredHolderExpressionKind.globalObjectForStaticState:
+ case DeferredHolderExpressionKind.globalObjectForConstants:
+ // no entity.
+ break;
}
sink.end(tag);
}
@@ -129,6 +155,212 @@
Iterable<js.Node> get containedNodes => isFinalized ? [_value] : const [];
}
+/// A [DeferredHolderParameter] is a deferred JavaScript expression determined
+/// by the finalization of holders. It is the injection point for data or
+/// code to related to holders. This class does not support serialization.
+/// TODO(joshualitt): Today this exists just for the static state holder.
+/// Ideally we'd be able to treat the static state holder like other holders.
+class DeferredHolderParameter extends js.Expression implements js.Parameter {
+ String _name;
+
+ @override
+ final bool allowRename = false;
+
+ @override
+ final js.JavaScriptNodeSourceInformation sourceInformation;
+
+ DeferredHolderParameter() : sourceInformation = null;
+ DeferredHolderParameter._(this._name, this.sourceInformation);
+
+ set name(String name) {
+ assert(!isFinalized && name != null);
+ _name = name;
+ }
+
+ @override
+ String get name {
+ assert(isFinalized, '$this is unassigned');
+ return _name;
+ }
+
+ @override
+ bool get isFinalized => _name != null;
+
+ @override
+ DeferredHolderParameter withSourceInformation(
+ js.JavaScriptNodeSourceInformation newSourceInformation) {
+ if (newSourceInformation == sourceInformation) return this;
+ if (newSourceInformation == null) return this;
+ return DeferredHolderParameter._(_name, newSourceInformation);
+ }
+
+ @override
+ int get precedenceLevel => js.PRIMARY;
+
+ @override
+ T accept<T>(js.NodeVisitor<T> visitor) => visitor.visitParameter(this);
+
+ @override
+ R accept1<R, A>(js.NodeVisitor1<R, A> visitor, A arg) =>
+ visitor.visitParameter(this, arg);
+
+ @override
+ void visitChildren<T>(js.NodeVisitor<T> visitor) {}
+
+ @override
+ void visitChildren1<R, A>(js.NodeVisitor1<R, A> visitor, A arg) {}
+
+ @override
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.write('DeferredHolderParameter(name=$_name)');
+ return sb.toString();
+ }
+}
+
+enum DeferredHolderResourceKind {
+ declaration,
+ update,
+}
+
+/// A [DeferredHolderResource] is a deferred JavaScript statement determined by
+/// the finalization of holders. It is the injection point for data or
+/// code to holders. The actual [Statement] contained with the
+/// [DeferredHolderResource] will be determined by the
+/// [DeferredHolderResourceKind]. These [Statement]s differ considerably
+/// depending on where they are used in the AST. This class does not support
+/// serialization.
+class DeferredHolderResource extends js.DeferredStatement
+ implements js.AstContainer {
+ DeferredHolderResourceKind kind;
+ Map<Entity, List<js.Property>> holderCode;
+ bool initializeEmptyHolders;
+ js.Statement _statement;
+
+ @override
+ final js.JavaScriptNodeSourceInformation sourceInformation;
+
+ DeferredHolderResource(this.kind,
+ {this.holderCode: const {}, this.initializeEmptyHolders: false})
+ : sourceInformation = null;
+
+ DeferredHolderResource._(this.kind, this.holderCode,
+ this.initializeEmptyHolders, this._statement, this.sourceInformation);
+
+ set statement(js.Statement statement) {
+ assert(!isFinalized && statement != null);
+ _statement = statement;
+ }
+
+ @override
+ js.Statement get statement {
+ assert(isFinalized, 'DeferredHolderResource is unassigned');
+ return _statement;
+ }
+
+ @override
+ bool get isFinalized => _statement != null;
+
+ @override
+ DeferredHolderResource withSourceInformation(
+ js.JavaScriptNodeSourceInformation newSourceInformation) {
+ if (newSourceInformation == sourceInformation) return this;
+ if (newSourceInformation == null) return this;
+ return DeferredHolderResource._(kind, holderCode, initializeEmptyHolders,
+ _statement, newSourceInformation);
+ }
+
+ @override
+ Iterable<js.Node> get containedNodes => isFinalized ? [_statement] : const [];
+
+ @override
+ void visitChildren<T>(js.NodeVisitor<T> visitor) {
+ _statement?.accept<T>(visitor);
+ }
+
+ @override
+ void visitChildren1<R, A>(js.NodeVisitor1<R, A> visitor, A arg) {
+ _statement?.accept1<R, A>(visitor, arg);
+ }
+}
+
+enum DeferredHolderResourceExpressionKind {
+ constantHolderReference,
+}
+
+/// Similar to [DeferredHolderExpression], [DeferredHolderResourceExpression]
+/// is used by resources which want to insert a DeferredExpression into the
+/// ast. This class does not support serialization.
+class DeferredHolderResourceExpression extends js.DeferredExpression
+ implements js.AstContainer {
+ final DeferredHolderResourceExpressionKind kind;
+ final Entity entity;
+ js.Expression _value;
+
+ @override
+ final js.JavaScriptNodeSourceInformation sourceInformation;
+
+ DeferredHolderResourceExpression(this.kind, this.entity)
+ : sourceInformation = null;
+ DeferredHolderResourceExpression._(
+ this.kind, this.entity, this._value, this.sourceInformation);
+
+ factory DeferredHolderResourceExpression.constantHolderReference() {
+ return DeferredHolderResourceExpression(
+ DeferredHolderResourceExpressionKind.constantHolderReference, null);
+ }
+
+ set value(js.Expression value) {
+ assert(!isFinalized && value != null);
+ _value = value;
+ }
+
+ @override
+ js.Expression get value {
+ assert(isFinalized, '$this is unassigned');
+ return _value;
+ }
+
+ @override
+ bool get isFinalized => _value != null;
+
+ @override
+ DeferredHolderResourceExpression withSourceInformation(
+ js.JavaScriptNodeSourceInformation newSourceInformation) {
+ if (newSourceInformation == sourceInformation) return this;
+ if (newSourceInformation == null) return this;
+ return DeferredHolderResourceExpression._(
+ kind, entity, _value, newSourceInformation);
+ }
+
+ @override
+ int get precedenceLevel => _value?.precedenceLevel ?? js.PRIMARY;
+
+ @override
+ int get hashCode {
+ return Hashing.objectsHash(kind, entity);
+ }
+
+ @override
+ bool operator ==(Object other) {
+ if (identical(this, other)) return true;
+ return other is DeferredHolderExpression &&
+ kind == other.kind &&
+ entity == other.entity;
+ }
+
+ @override
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.write('DeferredHolderResourceExpression(kind=$kind,entity=$entity,');
+ sb.write('value=$_value)');
+ return sb.toString();
+ }
+
+ @override
+ Iterable<js.Node> get containedNodes => isFinalized ? [_value] : const [];
+}
+
abstract class DeferredHolderExpressionFinalizer {
/// Collects DeferredHolderExpressions from the JavaScript
/// AST [code];
@@ -139,13 +371,22 @@
void finalize();
}
+/// [DeferredHolderExpressionFinalizerImpl] finalizes
+/// [DeferredHolderExpression]s, [DeferredHolderParameter]s,
+/// [DeferredHolderResource]s, [DeferredHolderResourceExpression]s.
class DeferredHolderExpressionFinalizerImpl
implements DeferredHolderExpressionFinalizer {
_DeferredHolderExpressionCollectorVisitor _visitor;
final List<DeferredHolderExpression> holderReferences = [];
- final Namer _namer;
+ final List<DeferredHolderParameter> holderParameters = [];
+ final List<DeferredHolderResource> holderResources = [];
+ final List<DeferredHolderResourceExpression> holderResourceExpressions = [];
+ final Set<String> _uniqueHolders = {};
+ final List<String> _holders = [];
+ final Map<Entity, String> _entityMap = {};
+ final JCommonElements _commonElements;
- DeferredHolderExpressionFinalizerImpl(this._namer) {
+ DeferredHolderExpressionFinalizerImpl(this._commonElements) {
_visitor = _DeferredHolderExpressionCollectorVisitor(this);
}
@@ -154,41 +395,309 @@
code.accept(_visitor);
}
- @override
- void finalize() {
+ final List<String> userGlobalObjects =
+ new List.from(Namer.reservedGlobalObjectNames)
+ ..remove('C')
+ ..remove('H')
+ ..remove('J')
+ ..remove('P')
+ ..remove('W');
+
+ /// Returns the [reservedGlobalObjectNames] for [library].
+ String globalObjectForLibrary(LibraryEntity library) {
+ if (library == _commonElements.interceptorsLibrary) return 'J';
+ Uri uri = library.canonicalUri;
+ if (uri.scheme == 'dart') {
+ if (uri.path == 'html') return 'W';
+ if (uri.path.startsWith('_')) return 'H';
+ return 'P';
+ }
+ return userGlobalObjects[library.name.hashCode % userGlobalObjects.length];
+ }
+
+ /// Returns true if [element] is stored in the static state holder
+ /// ([staticStateHolder]). We intend to store only mutable static state
+ /// there, whereas constants are stored in 'C'. Functions, accessors,
+ /// classes, etc. are stored in one of the other objects in
+ /// [reservedGlobalObjectNames].
+ bool _isPropertyOfStaticStateHolder(MemberEntity element) {
+ // TODO(ahe): Make sure this method's documentation is always true and
+ // remove the word "intend".
+ return element.isField;
+ }
+
+ String globalObjectForMember(MemberEntity entity) {
+ if (_isPropertyOfStaticStateHolder(entity)) {
+ return globalObjectForStaticState();
+ } else {
+ return globalObjectForLibrary(entity.library);
+ }
+ }
+
+ String globalObjectForClass(ClassEntity entity) {
+ return globalObjectForLibrary(entity.library);
+ }
+
+ String globalObjectForType(Entity entity) {
+ return globalObjectForClass(entity);
+ }
+
+ String globalObjectForStaticState() => r'$';
+
+ String globalObjectForConstants() => 'C';
+
+ String globalObjectForEntity(Entity entity) {
+ if (entity is MemberEntity) {
+ return globalObjectForMember(entity);
+ } else if (entity is ClassEntity) {
+ return globalObjectForLibrary(entity.library);
+ } else {
+ assert(entity is LibraryEntity);
+ return globalObjectForLibrary(entity);
+ }
+ }
+
+ /// Registers an [Entity] with a specific [holder].
+ void registerHolderUse(String holder, Entity entity) {
+ if (_uniqueHolders.add(holder)) _holders.add(holder);
+ if (entity != null) {
+ assert(!_entityMap.containsKey(entity) || _entityMap[entity] == holder);
+ _entityMap[entity] = holder;
+ }
+ }
+
+ /// Returns a global object for a given [Entity] based on the
+ /// [DeferredHolderExpressionKind].
+ String kindToHolder(DeferredHolderExpressionKind kind, Entity entity) {
+ switch (kind) {
+ case DeferredHolderExpressionKind.globalObjectForLibrary:
+ return globalObjectForLibrary(entity);
+ case DeferredHolderExpressionKind.globalObjectForClass:
+ return globalObjectForClass(entity);
+ case DeferredHolderExpressionKind.globalObjectForType:
+ return globalObjectForType(entity);
+ case DeferredHolderExpressionKind.globalObjectForMember:
+ return globalObjectForMember(entity);
+ case DeferredHolderExpressionKind.globalObjectForConstants:
+ return globalObjectForConstants();
+ case DeferredHolderExpressionKind.globalObjectForStaticState:
+ return globalObjectForStaticState();
+ }
+ throw UnsupportedError("Unreachable");
+ }
+
+ /// Finalizes [DeferredHolderExpression]s [DeferredHolderParameter]s.
+ void finalizeReferences() {
+ // Finalize [DeferredHolderExpression]s and registers holder usage.
for (var reference in holderReferences) {
if (reference.isFinalized) continue;
- switch (reference.kind) {
- case DeferredHolderExpressionKind.globalObjectForLibrary:
- reference.value = _namer
- .readGlobalObjectForLibrary(reference.entity)
- .withSourceInformation(reference.sourceInformation);
+ Entity entity = reference.entity;
+ String holder = kindToHolder(reference.kind, entity);
+ js.Expression value = js.VariableUse(holder);
+ registerHolderUse(holder, entity);
+ reference.value =
+ value.withSourceInformation(reference.sourceInformation);
+ }
+
+ // Finalize [DeferredHolderParameter]s.
+ for (var parameter in holderParameters) {
+ if (parameter.isFinalized) continue;
+ parameter.name = globalObjectForStaticState();
+ }
+ }
+
+ /// Registers all of the holders used by a given [DeferredHolderResource].
+ void registerHolders(DeferredHolderResource resource) {
+ for (var entity in resource.holderCode.keys) {
+ var holder = globalObjectForEntity(entity);
+ registerHolderUse(holder, entity);
+ }
+ }
+
+ /// Returns a [List<String>] containing all of the holders except the static
+ /// state holder.
+ List<String> get nonStaticStateHolders {
+ return _holders
+ .where((holder) => holder != globalObjectForStaticState())
+ .toList(growable: false);
+ }
+
+ /// Generates code to declare holders.
+ HolderCode declareHolders(DeferredHolderResource resource) {
+ // Collect all holders except the static state holder. Then, create a map of
+ // holder to list of properties which are associated with that holder, but
+ // only with respect to a given [DeferredHolderResource]. Each fragment will
+ // have its own [DeferredHolderResource] and associated code.
+ Map<String, List<js.Property>> codePerHolder = {};
+ final holders = nonStaticStateHolders;
+ for (var holder in holders) {
+ codePerHolder[holder] = [];
+ }
+
+ final holderCode = resource.holderCode;
+ holderCode.forEach((entity, properties) {
+ assert(_entityMap.containsKey(entity));
+ var holder = _entityMap[entity];
+ assert(codePerHolder.containsKey(holder));
+ codePerHolder[holder].addAll(properties);
+ });
+
+ // Create holder initialization code based on the [codePerHolder]. If there
+ // are no properties associated with a given holder in this specific
+ // [DeferredHolderResource] then it will be omitted. However, in some cases,
+ // i.e. the main output unit, we still want to declare the holder with an
+ // empty object literal which will be filled in later by another
+ // [DeferredHolderResource], i.e. in a specific deferred fragment.
+ // The generated code looks like this:
+ //
+ // {
+ // var H = {...}, ..., G = {...};
+ // var holders = [ H, ..., G ]; // Main unit only.
+ // }
+
+ List<String> activeHolders = [];
+ List<js.VariableInitialization> holderInitializations = [];
+ for (var holder in holders) {
+ List<js.Property> properties = codePerHolder[holder];
+ if (properties.isEmpty) {
+ holderInitializations.add(js.VariableInitialization(
+ js.VariableDeclaration(holder, allowRename: false),
+ resource.initializeEmptyHolders
+ ? js.ObjectInitializer(properties)
+ : null));
+ } else {
+ activeHolders.add(holder);
+ holderInitializations.add(js.VariableInitialization(
+ js.VariableDeclaration(holder, allowRename: false),
+ js.ObjectInitializer(properties)));
+ }
+ }
+
+ List<js.Statement> statements = [];
+ statements.add(js.ExpressionStatement(js.VariableDeclarationList(
+ holderInitializations,
+ indentSplits: false)));
+ if (resource.initializeEmptyHolders) {
+ statements.add(js.js.statement(
+ 'var holders = #',
+ js.ArrayInitializer(holders
+ .map((holder) => js.VariableUse(holder))
+ .toList(growable: false))));
+ }
+ return HolderCode(activeHolders, statements);
+ }
+
+ /// Finalizes [resource] to code that updates holders. [resource] must be in
+ /// the AST of a deferred fragment.
+ void updateHolders(DeferredHolderResource resource) {
+ // Declare holders.
+ final holderCode = declareHolders(resource);
+
+ // Set names if necessary on deferred holders list.
+ js.Expression deferredHoldersList = js.ArrayInitializer(holderCode
+ .activeHolders
+ .map((holder) => js.js("#", holder))
+ .toList(growable: false));
+ js.Statement setNames = js.js.statement(
+ 'hunkHelpers.setFunctionNamesIfNecessary(#deferredHoldersList)',
+ {'deferredHoldersList': deferredHoldersList});
+
+ // Update holder assignments.
+ final holders = nonStaticStateHolders;
+ List<js.Statement> updateHolderAssignments = [setNames];
+ for (int i = 0; i < holders.length; i++) {
+ var holder = holders[i];
+ if (holderCode.activeHolders.contains(holder)) {
+ updateHolderAssignments.add(js.js.statement(
+ '#holder = hunkHelpers.updateHolder(holdersList[#index], #holder)',
+ {'index': js.number(i), 'holder': js.VariableUse(holder)}));
+ } else {
+ // TODO(sra): Change declaration followed by assignments to declarations
+ // with initialization.
+ updateHolderAssignments.add(js.js.statement(
+ '#holder = holdersList[#index]',
+ {'index': js.number(i), 'holder': js.VariableUse(holder)}));
+ }
+ }
+
+ // Create a single block of all statements.
+ List<js.Statement> statements = holderCode.statements
+ .followedBy(updateHolderAssignments)
+ .toList(growable: false);
+ resource.statement = js.Block(statements);
+ }
+
+ /// Creates a reference to the constant holder.
+ void allocateConstantHolderReference(
+ DeferredHolderResourceExpression resource) {
+ String constantHolder = _holders.firstWhere(
+ (holder) => holder == globalObjectForConstants(),
+ orElse: () => null);
+ resource.value = constantHolder == null
+ ? js.LiteralNull()
+ : js.VariableUse(constantHolder);
+ }
+
+ /// Allocates all [DeferredHolderResource]s and
+ /// [DeferredHolderResourceExpression]s.
+ void allocateResources() {
+ // First ensure all holders used in all [DeferredHolderResource]s have been
+ // allocated.
+ for (var resource in holderResources) {
+ registerHolders(resource);
+ }
+ _holders.sort();
+
+ // Next finalize all [DeferredHolderResource]s.
+ for (var resource in holderResources) {
+ switch (resource.kind) {
+ case DeferredHolderResourceKind.declaration:
+ var holderCode = declareHolders(resource);
+ resource.statement = js.Block(holderCode.statements);
break;
- case DeferredHolderExpressionKind.globalObjectForClass:
- reference.value = _namer
- .readGlobalObjectForClass(reference.entity)
- .withSourceInformation(reference.sourceInformation);
+ case DeferredHolderResourceKind.update:
+ updateHolders(resource);
break;
- case DeferredHolderExpressionKind.globalObjectForType:
- reference.value = _namer
- .readGlobalObjectForType(reference.entity)
- .withSourceInformation(reference.sourceInformation);
- break;
- case DeferredHolderExpressionKind.globalObjectForMember:
- reference.value = _namer
- .readGlobalObjectForMember(reference.entity)
- .withSourceInformation(reference.sourceInformation);
+ }
+ }
+
+ // Finally, finalize any [DeferredHolderResourceExpression]s.
+ for (var resource in holderResourceExpressions) {
+ switch (resource.kind) {
+ case DeferredHolderResourceExpressionKind.constantHolderReference:
+ allocateConstantHolderReference(resource);
break;
}
}
}
+ @override
+ void finalize() {
+ finalizeReferences();
+ allocateResources();
+ }
+
void _registerDeferredHolderExpression(DeferredHolderExpression node) {
holderReferences.add(node);
}
+
+ void _registerDeferredHolderResource(DeferredHolderResource node) {
+ holderResources.add(node);
+ }
+
+ void _registerDeferredHolderResourceExpression(
+ DeferredHolderResourceExpression node) {
+ holderResourceExpressions.add(node);
+ }
+
+ void _registerDeferredHolderParameter(DeferredHolderParameter node) {
+ holderParameters.add(node);
+ }
}
-/// Scans a JavaScript AST to collect all the DeferredHolderExpression nodes.
+/// Scans a JavaScript AST to collect all the [DeferredHolderExpression],
+/// [DeferredHolderParameter], [DeferredHolderResource], and
+/// [DeferredHolderResourceExpression] nodes.
///
/// The state is kept in the finalizer so that this scan could be extended to
/// look for other deferred expressions in one pass.
@@ -213,8 +722,34 @@
void visitDeferredExpression(js.DeferredExpression node) {
if (node is DeferredHolderExpression) {
_finalizer._registerDeferredHolderExpression(node);
+ } else if (node is DeferredHolderResourceExpression) {
+ _finalizer._registerDeferredHolderResourceExpression(node);
} else {
visitNode(node);
}
}
+
+ @override
+ void visitDeferredStatement(js.DeferredStatement node) {
+ if (node is DeferredHolderResource) {
+ _finalizer._registerDeferredHolderResource(node);
+ } else {
+ visitNode(node);
+ }
+ }
+
+ @override
+ void visitParameter(js.Parameter node) {
+ if (node is DeferredHolderParameter) {
+ _finalizer._registerDeferredHolderParameter(node);
+ } else {
+ visitNode(node);
+ }
+ }
+}
+
+class HolderCode {
+ final List<String> activeHolders;
+ final List<js.Statement> statements;
+ HolderCode(this.activeHolders, this.statements);
}
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 26707b5..645d026 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -364,6 +364,8 @@
"Map", "Set",
];
+ // TODO(joshualitt): Stop reserving these names after local naming is updated
+ // to use frequencies.
static const List<String> reservedGlobalObjectNames = const <String>[
"A",
"B",
@@ -1357,66 +1359,6 @@
: globalPropertyNameForMember(method);
}
- /// Returns true if [element] is stored in the static state holder
- /// ([staticStateHolder]). We intend to store only mutable static state
- /// there, whereas constants are stored in 'C'. Functions, accessors,
- /// classes, etc. are stored in one of the other objects in
- /// [reservedGlobalObjectNames].
- bool _isPropertyOfStaticStateHolder(MemberEntity element) {
- // TODO(ahe): Make sure this method's documentation is always true and
- // remove the word "intend".
- return element.isField;
- }
-
- /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames].
- String globalObjectForMember(MemberEntity element) {
- if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder;
- return globalObjectForLibrary(element.library);
- }
-
- @override
- jsAst.VariableUse readGlobalObjectForMember(MemberEntity element) {
- if (_isPropertyOfStaticStateHolder(element)) {
- return new jsAst.VariableUse(staticStateHolder);
- }
- return readGlobalObjectForLibrary(element.library);
- }
-
- String globalObjectForClass(ClassEntity element) {
- return globalObjectForLibrary(element.library);
- }
-
- @override
- jsAst.VariableUse readGlobalObjectForClass(ClassEntity element) {
- return readGlobalObjectForLibrary(element.library);
- }
-
- String globalObjectForType(Entity element) {
- return globalObjectForClass(element);
- }
-
- @override
- jsAst.VariableUse readGlobalObjectForType(Entity element) {
- return readGlobalObjectForClass(element);
- }
-
- /// Returns the [reservedGlobalObjectNames] for [library].
- String globalObjectForLibrary(LibraryEntity library) {
- if (library == _commonElements.interceptorsLibrary) return 'J';
- Uri uri = library.canonicalUri;
- if (uri.scheme == 'dart') {
- if (uri.path == 'html') return 'W';
- if (uri.path.startsWith('_')) return 'H';
- return 'P';
- }
- return userGlobalObjects[library.name.hashCode % userGlobalObjects.length];
- }
-
- @override
- jsAst.VariableUse readGlobalObjectForLibrary(LibraryEntity library) {
- return new jsAst.VariableUse(globalObjectForLibrary(library));
- }
-
@override
jsAst.Name lazyInitializerName(FieldEntity element) {
assert(element.isTopLevel || element.isStatic);
@@ -1445,8 +1387,6 @@
return "${libraryName}.${element.name}";
}
- String globalObjectForConstant(ConstantValue constant) => 'C';
-
String get genericInstantiationPrefix => r'$instantiate';
// The name of the variable used to offset function signatures in deferred
@@ -2146,26 +2086,45 @@
abstract class ModularNamer {
FixedNames get fixedNames;
+ /// Returns a variable use for accessing constants.
+ jsAst.Expression globalObjectForConstants() {
+ return DeferredHolderExpression.forConstants();
+ }
+
+ /// Returns a variable use for accessing static state.
+ jsAst.Expression globalObjectForStaticState() {
+ return DeferredHolderExpression.forStaticState();
+ }
+
/// Returns a variable use for accessing [library].
///
/// This is one of the [reservedGlobalObjectNames]
- jsAst.Expression readGlobalObjectForLibrary(LibraryEntity library);
+ jsAst.Expression readGlobalObjectForLibrary(LibraryEntity library) {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForLibrary, library);
+ }
/// Returns a variable use for accessing the class [element].
///
/// This is one of the [reservedGlobalObjectNames]
- jsAst.Expression readGlobalObjectForClass(ClassEntity element);
+ jsAst.Expression readGlobalObjectForClass(ClassEntity element) {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForClass, element);
+ }
/// Returns a variable use for accessing the type [element].
///
/// This is one of the [reservedGlobalObjectNames]
- jsAst.Expression readGlobalObjectForType(Entity element);
+ jsAst.Expression readGlobalObjectForType(Entity element) {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForType, element);
+ }
/// Returns a variable use for accessing the member [element].
- ///
- /// This is either the [staticStateHolder] or one of the
- /// [reservedGlobalObjectNames]
- jsAst.Expression readGlobalObjectForMember(MemberEntity element);
+ jsAst.Expression readGlobalObjectForMember(MemberEntity element) {
+ return DeferredHolderExpression(
+ DeferredHolderExpressionKind.globalObjectForMember, element);
+ }
/// Returns a JavaScript property name used to store the class [element] on
/// one of the global objects.
@@ -2287,11 +2246,6 @@
/// The prefix used for encoding async properties.
final String asyncPrefix = r"$async$";
- /// Returns the name for the holder of static state.
- ///
- /// This is used for mutable static fields.
- final String staticStateHolder = r'$';
-
jsAst.Name _literalAsyncPrefix;
ModularNamer() {
@@ -2460,30 +2414,6 @@
}
@override
- jsAst.Expression readGlobalObjectForLibrary(LibraryEntity library) {
- return DeferredHolderExpression(
- DeferredHolderExpressionKind.globalObjectForLibrary, library);
- }
-
- @override
- jsAst.Expression readGlobalObjectForClass(ClassEntity element) {
- return DeferredHolderExpression(
- DeferredHolderExpressionKind.globalObjectForClass, element);
- }
-
- @override
- jsAst.Expression readGlobalObjectForType(Entity element) {
- return DeferredHolderExpression(
- DeferredHolderExpressionKind.globalObjectForType, element);
- }
-
- @override
- jsAst.Expression readGlobalObjectForMember(MemberEntity element) {
- return DeferredHolderExpression(
- DeferredHolderExpressionKind.globalObjectForMember, element);
- }
-
- @override
jsAst.Name aliasedSuperMemberPropertyName(MemberEntity member) {
jsAst.Name name =
new ModularName(ModularNameKind.aliasedSuperMember, data: member);
diff --git a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
index b325c92..f49bf66 100644
--- a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
@@ -398,8 +398,8 @@
}
jsAst.Name invocationName = _namer.invocationName(selector);
- String globalObject =
- _namer.globalObjectForLibrary(_commonElements.interceptorsLibrary);
+ var globalObject =
+ _namer.readGlobalObjectForLibrary(_commonElements.interceptorsLibrary);
jsAst.Statement optimizedPath =
_fastPathForOneShotInterceptor(selector, classes);
diff --git a/pkg/compiler/lib/src/js_emitter/model.dart b/pkg/compiler/lib/src/js_emitter/model.dart
index 96b73e1..8a6db71 100644
--- a/pkg/compiler/lib/src/js_emitter/model.dart
+++ b/pkg/compiler/lib/src/js_emitter/model.dart
@@ -16,7 +16,6 @@
class Program {
final List<Fragment> fragments;
- final List<Holder> holders;
final bool outputContainsConstantList;
final bool needsNativeSupport;
@@ -29,8 +28,8 @@
final MetadataCollector _metadataCollector;
final Iterable<js.TokenFinalizer> finalizers;
- Program(this.fragments, this.holders, this.typeToInterceptorMap,
- this._metadataCollector, this.finalizers,
+ Program(this.fragments, this.typeToInterceptorMap, this._metadataCollector,
+ this.finalizers,
{this.needsNativeSupport, this.outputContainsConstantList}) {
assert(needsNativeSupport != null);
assert(outputContainsConstantList != null);
@@ -73,23 +72,6 @@
Fragment get mainFragment => fragments.first;
}
-/// This class represents a JavaScript object that contains static state, like
-/// classes or functions.
-class Holder {
- final String name;
- final int index;
- final bool isStaticStateHolder;
- final bool isConstantsHolder;
-
- Holder(this.name, this.index,
- {this.isStaticStateHolder: false, this.isConstantsHolder: false});
-
- @override
- String toString() {
- return 'Holder(name=${name})';
- }
-}
-
/// This class represents one output file.
///
/// If no library is deferred, there is only one [Fragment] of type
@@ -173,10 +155,9 @@
class Constant {
final js.Name name;
- final Holder holder;
final ConstantValue value;
- Constant(this.name, this.holder, this.value);
+ Constant(this.name, this.value);
@override
String toString() {
@@ -219,14 +200,13 @@
final js.Name getterName;
// TODO(floitsch): the holder for static fields is the isolate object. We
// could remove this field and use the isolate object directly.
- final Holder holder;
final js.Expression code;
final bool isFinal;
final bool isLazy;
final bool isInitializedByConstant;
final bool usesNonNullableInitialization;
- StaticField(this.element, this.name, this.getterName, this.holder, this.code,
+ StaticField(this.element, this.name, this.getterName, this.code,
{this.isFinal,
this.isLazy,
this.isInitializedByConstant: false,
@@ -264,7 +244,6 @@
final ClassTypeData typeData;
final js.Name name;
- final Holder holder;
Class _superclass;
Class _mixinClass;
final List<Method> methods;
@@ -308,7 +287,6 @@
this.element,
this.typeData,
this.name,
- this.holder,
this.methods,
this.fields,
this.staticFieldsForReflection,
@@ -347,9 +325,6 @@
js.Name get superclassName => superclass == null ? null : superclass.name;
- int get superclassHolderIndex =>
- (superclass == null) ? 0 : superclass.holder.index;
-
@override
String toString() => 'Class(name=${name.key},element=$element)';
}
@@ -359,7 +334,6 @@
ClassEntity element,
ClassTypeData typeData,
js.Name name,
- Holder holder,
List<Field> instanceFields,
List<Field> staticFieldsForReflection,
List<StubMethod> callStubs,
@@ -374,7 +348,6 @@
element,
typeData,
name,
- holder,
const <Method>[],
instanceFields,
staticFieldsForReflection,
@@ -615,21 +588,11 @@
}
}
-abstract class StaticMethod implements Method {
- Holder get holder;
-}
+abstract class StaticMethod implements Method {}
class StaticDartMethod extends DartMethod implements StaticMethod {
- @override
- final Holder holder;
-
- StaticDartMethod(
- FunctionEntity element,
- js.Name name,
- this.holder,
- js.Expression code,
- List<ParameterStubMethod> parameterStubs,
- js.Name callName,
+ StaticDartMethod(FunctionEntity element, js.Name name, js.Expression code,
+ List<ParameterStubMethod> parameterStubs, js.Name callName,
{bool needsTearOff,
js.Name tearOffName,
bool canBeApplied,
@@ -657,9 +620,8 @@
}
class StaticStubMethod extends StubMethod implements StaticMethod {
- @override
- Holder holder;
- StaticStubMethod(js.Name name, this.holder, js.Expression code)
+ LibraryEntity library;
+ StaticStubMethod(this.library, js.Name name, js.Expression code)
: super(name, code);
@override
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 708ee24..5eb2990 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -183,9 +183,6 @@
collector.outputConstantLists.forEach(_registerConstants);
collector.outputStaticNonFinalFieldLists.forEach(_registry.registerMembers);
- // We always add the current isolate holder.
- _registerStaticStateHolder();
-
// We need to run the native-preparation before we build the output. The
// preparation code, in turn needs the classes to be set up.
// We thus build the classes before building their containers.
@@ -248,8 +245,6 @@
associateNamedTypeVariablesNewRti();
- List<Holder> holders = _registry.holders.toList(growable: false);
-
bool needsNativeSupport =
_nativeCodegenEnqueuer.hasInstantiatedNativeClasses ||
_nativeData.isAllowInteropUsed;
@@ -262,7 +257,7 @@
finalizers.add(namingFinalizer as js.TokenFinalizer);
}
- return new Program(fragments, holders, _buildTypeToInterceptorMap(),
+ return new Program(fragments, _buildTypeToInterceptorMap(),
_task.metadataCollector, finalizers,
needsNativeSupport: needsNativeSupport,
outputContainsConstantList: collector.outputContainsConstantList);
@@ -338,10 +333,6 @@
ConstantValue initialValue = fieldData.initialValue;
js.Expression code;
if (initialValue != null) {
- // TODO(zarah): The holder should not be registered during building of
- // a static field.
- _registry.registerHolder(_namer.globalObjectForConstant(initialValue),
- isConstantsHolder: true);
code = _task.emitter.constantReference(initialValue);
} else {
assert(fieldData.isEager);
@@ -353,8 +344,7 @@
// building a static field. (Note that the static-state holder was
// already registered earlier, and that we just call the register to get
// the holder-instance.
- return new StaticField(
- element, name, null, _registerStaticStateHolder(), code,
+ return new StaticField(element, name, null, code,
isFinal: false,
isLazy: false,
isInitializedByConstant: initialValue != null,
@@ -385,8 +375,7 @@
// building a static field. (Note that the static-state holder was
// already registered earlier, and that we just call the register to get
// the holder-instance.
- return new StaticField(
- element, name, getterName, _registerStaticStateHolder(), code,
+ return new StaticField(element, name, getterName, code,
isFinal: !element.isAssignable,
isLazy: true,
usesNonNullableInitialization: element.library.isNonNullableByDefault);
@@ -717,10 +706,6 @@
}
js.Name name = _namer.className(cls);
- String holderName = _namer.globalObjectForClass(cls);
- // TODO(floitsch): we shouldn't update the registry in the middle of
- // building a class.
- Holder holder = _registry.registerHolder(holderName);
bool isInstantiated = !_nativeData.isJsInteropClass(cls) &&
_codegenWorld.directlyInstantiatedClasses.contains(cls);
@@ -736,7 +721,6 @@
cls,
typeData,
name,
- holder,
instanceFields,
staticFieldsForReflection,
callStubs,
@@ -752,7 +736,6 @@
cls,
typeData,
name,
- holder,
methods,
instanceFields,
staticFieldsForReflection,
@@ -1003,11 +986,6 @@
_codegenWorld,
_closedWorld);
- String holderName =
- _namer.globalObjectForLibrary(_commonElements.interceptorsLibrary);
- // TODO(floitsch): we shouldn't update the registry in the middle of
- // generating the interceptor methods.
- Holder holder = _registry.registerHolder(holderName);
List<js.Name> names = [];
Map<js.Name, SpecializedGetInterceptor> interceptorMap = {};
for (SpecializedGetInterceptor interceptor
@@ -1025,7 +1003,8 @@
SpecializedGetInterceptor interceptor = interceptorMap[name];
js.Expression code =
stubGenerator.generateGetInterceptorMethod(interceptor);
- return new StaticStubMethod(name, holder, code);
+ return new StaticStubMethod(
+ _commonElements.interceptorsLibrary, name, code);
});
}
@@ -1107,11 +1086,6 @@
_codegenWorld,
_closedWorld);
- String holderName =
- _namer.globalObjectForLibrary(_commonElements.interceptorsLibrary);
- // TODO(floitsch): we shouldn't update the registry in the middle of
- // generating the interceptor methods.
- Holder holder = _registry.registerHolder(holderName);
List<js.Name> names = [];
Map<js.Name, OneShotInterceptor> interceptorMap = {};
for (OneShotInterceptor interceptor
@@ -1130,13 +1104,13 @@
OneShotInterceptor interceptor = interceptorMap[name];
js.Expression code =
stubGenerator.generateOneShotInterceptor(interceptor);
- return new StaticStubMethod(name, holder, code);
+ return new StaticStubMethod(
+ _commonElements.interceptorsLibrary, name, code);
});
}
StaticDartMethod _buildStaticMethod(FunctionEntity element) {
js.Name name = _namer.methodPropertyName(element);
- String holder = _namer.globalObjectForMember(element);
js.Expression code = _generatedCode[element];
bool isApplyTarget =
@@ -1175,15 +1149,8 @@
}
}
- // TODO(floitsch): we shouldn't update the registry in the middle of
- // building a static method.
- return new StaticDartMethod(
- element,
- name,
- _registry.registerHolder(holder),
- code,
- _generateParameterStubs(element, needsTearOff, canBeApplied),
- callName,
+ return new StaticDartMethod(element, name, code,
+ _generateParameterStubs(element, needsTearOff, canBeApplied), callName,
needsTearOff: needsTearOff,
tearOffName: tearOffName,
canBeApplied: canBeApplied,
@@ -1201,16 +1168,8 @@
_registry.registerConstant(outputUnit, constantValue);
assert(!_constants.containsKey(constantValue));
js.Name name = _namer.constantName(constantValue);
- String constantObject = _namer.globalObjectForConstant(constantValue);
- Holder holder =
- _registry.registerHolder(constantObject, isConstantsHolder: true);
- Constant constant = new Constant(name, holder, constantValue);
+ Constant constant = new Constant(name, constantValue);
_constants[constantValue] = constant;
}
}
-
- Holder _registerStaticStateHolder() {
- return _registry.registerHolder(_namer.staticStateHolder,
- isStaticStateHolder: true);
- }
}
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart b/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart
index c738517..2e28a01 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/registry.dart
@@ -78,7 +78,6 @@
class Registry {
final OutputUnit _mainOutputUnit;
final Sorter _sorter;
- final Map<String, Holder> _holdersMap = <String, Holder>{};
final Map<OutputUnit, LibrariesMap> _deferredLibrariesMap =
<OutputUnit, LibrariesMap>{};
@@ -86,7 +85,6 @@
OutputUnit _lastOutputUnit;
LibrariesMap _lastLibrariesMap;
- Iterable<Holder> get holders => _holdersMap.values;
Iterable<LibrariesMap> get deferredLibrariesMap =>
_deferredLibrariesMap.values;
@@ -153,17 +151,4 @@
void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) {
// Ignore for now.
}
-
- Holder registerHolder(String name,
- {bool isStaticStateHolder: false, bool isConstantsHolder: false}) {
- assert(_holdersMap[name] == null ||
- (_holdersMap[name].isStaticStateHolder == isStaticStateHolder &&
- _holdersMap[name].isConstantsHolder == isConstantsHolder));
-
- return _holdersMap.putIfAbsent(name, () {
- return new Holder(name, _holdersMap.length,
- isStaticStateHolder: isStaticStateHolder,
- isConstantsHolder: isConstantsHolder);
- });
- }
}
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index cafefe7..ef83ff6 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -541,13 +541,9 @@
function(hunkHelpers, #embeddedGlobalsObject, holdersList, #staticState) {
// Builds the holders. They only contain the data for new holders.
-#holders;
-
-// If the name is not set on the functions, do it now.
-hunkHelpers.setFunctionNamesIfNecessary(#deferredHoldersList);
-
-// Updates the holders of the main-fragment. Uses the provided holdersList to
-// access the main holders.
+// If names are not set on functions, we do it now. Finally, updates the
+// holders of the main-fragment. Uses the provided holdersList to access the
+// main holders.
// The local holders are replaced by the combined holders. This is necessary
// for the inheritance setup below.
#updateHolders;
@@ -606,6 +602,7 @@
final CodegenWorld _codegenWorld;
RecipeEncoder _recipeEncoder;
RulesetEncoder _rulesetEncoder;
+ DeferredHolderExpressionFinalizer _holderFinalizer;
ClassHierarchy get _classHierarchy => _closedWorld.classHierarchy;
CommonElements get _commonElements => _closedWorld.commonElements;
@@ -631,7 +628,9 @@
this._modelEmitter,
this._nativeEmitter,
this._closedWorld,
- this._codegenWorld) {
+ this._codegenWorld)
+ : _holderFinalizer =
+ DeferredHolderExpressionFinalizerImpl(_closedWorld.commonElements) {
_recipeEncoder = RecipeEncoderImpl(
_closedWorld,
_options.disableRtiOptimization
@@ -650,7 +649,10 @@
_modelEmitter.generateConstantReference(value);
js.Expression classReference(Class cls) {
- return js.js('#.#', [cls.holder.name, cls.name]);
+ // TODO(joshualitt): This should be generated by
+ // [DeferredHolderExpressionFinalizer].
+ return js
+ .js('#.#', [_namer.readGlobalObjectForClass(cls.element), cls.name]);
}
void registerEntityAst(Entity entity, js.Node code, {LibraryEntity library}) {
@@ -712,9 +714,12 @@
DeferredLoadingState deferredLoadingState) {
MainFragment fragment = program.fragments.first;
- HolderCode holderCode = emitHolders(program.holders, fragment.libraries,
+ // Emit holder code.
+ var holderCode = emitHolderCode(fragment.libraries);
+ var holderDeclaration = DeferredHolderResource(
+ DeferredHolderResourceKind.declaration,
+ holderCode: holderCode,
initializeEmptyHolders: true);
-
js.Statement mainCode = js.js.statement(_mainBoilerplate, {
// TODO(29455): 'hunkHelpers' displaces other names, so don't minify it.
'hunkHelpers': js.VariableDeclaration('hunkHelpers', allowRename: false),
@@ -731,12 +736,11 @@
generateEmbeddedGlobalAccess(INTERCEPTORS_BY_TAG),
'embeddedLeafTags': generateEmbeddedGlobalAccess(LEAF_TAGS),
'embeddedGlobalsObject': js.js("init"),
- 'staticStateDeclaration': new js.VariableDeclaration(
- _namer.staticStateHolder,
- allowRename: false),
- 'staticState': js.js('#', _namer.staticStateHolder),
- 'constantHolderReference': buildConstantHolderReference(program),
- 'holders': holderCode.statements,
+ 'staticStateDeclaration': DeferredHolderParameter(),
+ 'staticState': DeferredHolderParameter(),
+ 'constantHolderReference':
+ DeferredHolderResourceExpression.constantHolderReference(),
+ 'holders': holderDeclaration,
'callName': js.string(_namer.fixedNames.callNameField),
'stubName': js.string(_namer.stubNameField),
'argumentCount': js.string(_namer.fixedNames.requiredParameterField),
@@ -768,38 +772,13 @@
'call1selector': js.quoteName(call1Name),
'call2selector': js.quoteName(call2Name)
});
- finalizeCode(mainCode);
+ // We assume emitMainFragment will be the last piece of code we emit.
+ finalizeCode(mainCode, holderCode, finalizeHolders: true);
return mainCode;
}
- js.Expression emitCodeFragment(CodeFragment fragment, List<Holder> holders) {
- HolderCode holderCode =
- emitHolders(holders, fragment.libraries, initializeEmptyHolders: false);
-
- List<Holder> nonStaticStateHolders = holders
- .where((Holder holder) => !holder.isStaticStateHolder)
- .toList(growable: false);
-
- List<js.Statement> updateHolderAssignments = [];
- for (int i = 0; i < nonStaticStateHolders.length; i++) {
- Holder holder = nonStaticStateHolders[i];
- if (holderCode.activeHolders.contains(holder)) {
- updateHolderAssignments.add(js.js.statement(
- '#holder = hunkHelpers.updateHolder(holdersList[#index], #holder)',
- {
- 'index': js.number(i),
- 'holder': new js.VariableUse(holder.name)
- }));
- } else {
- // TODO(sra): Change declaration followed by assignments to declarations
- // with initialization.
- updateHolderAssignments.add(js.js.statement(
- '#holder = holdersList[#index]', {
- 'index': js.number(i),
- 'holder': new js.VariableUse(holder.name)
- }));
- }
- }
+ js.Expression emitCodeFragment(CodeFragment fragment) {
+ var holderCode = emitHolderCode(fragment.libraries);
// TODO(sra): How do we tell if [deferredTypes] is empty? It is filled-in
// later via the program finalizers. So we should defer the decision on the
@@ -810,19 +789,18 @@
// not emit any functions, then we probably did not use the signature types
// in the OutputUnit's types, leaving them unused and tree-shaken.
- if (holderCode.activeHolders.isEmpty && fragment.isEmpty) {
+ if (holderCode.isEmpty && fragment.isEmpty) {
return null;
}
+ var updateHolders = DeferredHolderResource(
+ DeferredHolderResourceKind.update,
+ holderCode: holderCode);
js.Expression code = js.js(_deferredBoilerplate, {
// TODO(floitsch): don't just reference 'init'.
'embeddedGlobalsObject': new js.Parameter('init'),
- 'staticState': new js.Parameter(_namer.staticStateHolder),
- 'holders': holderCode.statements,
- 'deferredHoldersList': new js.ArrayInitializer(holderCode.activeHolders
- .map((holder) => js.js("#", holder.name))
- .toList(growable: false)),
- 'updateHolders': new js.Block(updateHolderAssignments),
+ 'staticState': DeferredHolderParameter(),
+ 'updateHolders': updateHolders,
'prototypes': fragment.classPrototypes,
'closures': fragment.closurePrototypes,
'inheritance': fragment.inheritance,
@@ -843,114 +821,72 @@
if (_options.experimentStartupFunctions) {
code = js.Parentheses(code);
}
- finalizeCode(code);
+ finalizeCode(code, holderCode);
return code;
}
- void finalizeCode(js.Node code) {
- StringReferenceFinalizer stringFinalizer =
- StringReferenceFinalizerImpl(_options.enableMinification);
- stringFinalizer.addCode(code);
- stringFinalizer.finalize();
- TypeReferenceFinalizer finalizer = TypeReferenceFinalizerImpl(
- _emitter, _commonElements, _recipeEncoder, _options.enableMinification);
- finalizer.addCode(code);
- finalizer.finalize();
-
- // DeferredHolders need to be finalized last.
- DeferredHolderExpressionFinalizer holderFinalizer =
- DeferredHolderExpressionFinalizerImpl(_namer);
- holderFinalizer.addCode(code);
- holderFinalizer.finalize();
+ /// Adds code to a finalizer.
+ void addCodeToFinalizer(void Function(js.Node) addCode, js.Node fragmentCode,
+ Map<Entity, List<js.Property>> holderCode) {
+ addCode(fragmentCode);
+ for (var properties in holderCode.values) {
+ for (var property in properties) {
+ addCode(property);
+ }
+ }
}
- /// Emits all holders, except for the static-state holder.
- ///
- /// The emitted holders contain classes (only the constructors) and all
- /// static functions.
- HolderCode emitHolders(List<Holder> holders, List<Library> libraries,
- {bool initializeEmptyHolders}) {
- assert(initializeEmptyHolders != null);
- // Skip the static-state holder in this function.
- holders = holders
- .where((Holder holder) => !holder.isStaticStateHolder)
- .toList(growable: false);
+ /// Finalizes the code for a fragment, and optionally finalizes holders.
+ /// Finalizing holders must be the last step of the emitter.
+ void finalizeCode(js.Node code, Map<Entity, List<js.Property>> holderCode,
+ {bool finalizeHolders: false}) {
+ StringReferenceFinalizer stringFinalizer =
+ StringReferenceFinalizerImpl(_options.enableMinification);
+ addCodeToFinalizer(stringFinalizer.addCode, code, holderCode);
+ stringFinalizer.finalize();
+ TypeReferenceFinalizer typeFinalizer = TypeReferenceFinalizerImpl(
+ _emitter, _commonElements, _recipeEncoder, _options.enableMinification);
+ addCodeToFinalizer(typeFinalizer.addCode, code, holderCode);
+ typeFinalizer.finalize();
- Map<Holder, List<js.Property>> holderCode = {};
-
- for (Holder holder in holders) {
- holderCode[holder] = <js.Property>[];
+ // DeferredHolders need to be finalized last. In addition, finalizing
+ // holders needs to be the very last thing the [FragmentEmitter] does before
+ // we actually emit code. This is to ensure all holders are registered.
+ // Note: Unlike the above finalizers, which are created and finalized
+ // per output unit, the holderFinalizer is a whole-program finalizer,
+ // which collects deferred [Node]s from each call to `finalizeCode`
+ // before begin finalized once for the last (main) unit.
+ addCodeToFinalizer(_holderFinalizer.addCode, code, holderCode);
+ if (finalizeHolders) {
+ _holderFinalizer.finalize();
}
+ }
+ /// Emits holder code for a list of libraries. We emit [Property]s directly
+ /// into a map keyed by [Entity] because we don't yet know anything about the
+ /// structure of the underlying holders and thus we cannot emit this code
+ /// directly into the ast.
+ Map<Entity, List<js.Property>> emitHolderCode(List<Library> libraries) {
+ Map<Entity, List<js.Property>> holderCode = {};
for (Library library in libraries) {
for (StaticMethod method in library.statics) {
- assert(!method.holder.isStaticStateHolder);
Map<js.Name, js.Expression> propertyMap = emitStaticMethod(method);
propertyMap.forEach((js.Name key, js.Expression value) {
var property = new js.Property(js.quoteName(key), value);
- holderCode[method.holder].add(property);
+ Entity holderKey =
+ method is StaticStubMethod ? method.library : method.element;
+ (holderCode[holderKey] ??= []).add(property);
registerEntityAst(method.element, property, library: library.element);
});
}
for (Class cls in library.classes) {
- assert(!cls.holder.isStaticStateHolder);
js.Expression constructor = emitConstructor(cls);
var property = new js.Property(js.quoteName(cls.name), constructor);
+ (holderCode[cls.element] ??= []).add(property);
registerEntityAst(cls.element, property, library: library.element);
- holderCode[cls.holder].add(property);
}
}
-
- List<js.VariableInitialization> holderInitializations = [];
- List<Holder> activeHolders = [];
-
- for (Holder holder in holders) {
- List<js.Property> properties = holderCode[holder];
- if (properties.isEmpty) {
- holderInitializations.add(new js.VariableInitialization(
- new js.VariableDeclaration(holder.name, allowRename: false),
- initializeEmptyHolders
- ? new js.ObjectInitializer(properties)
- : null));
- } else {
- activeHolders.add(holder);
- holderInitializations.add(new js.VariableInitialization(
- new js.VariableDeclaration(holder.name, allowRename: false),
- new js.ObjectInitializer(properties)));
- }
- }
-
- // The generated code looks like this:
- //
- // {
- // var H = {...}, ..., G = {...};
- // var holders = [ H, ..., G ]; // Main unit only.
- // }
-
- List<js.Statement> statements = [];
- statements.add(new js.ExpressionStatement(new js.VariableDeclarationList(
- holderInitializations,
- indentSplits: false)));
- if (initializeEmptyHolders) {
- statements.add(js.js.statement(
- 'var holders = #',
- new js.ArrayInitializer(holders
- .map((holder) => new js.VariableUse(holder.name))
- .toList(growable: false))));
- }
- return new HolderCode(
- activeHolders: activeHolders,
- statements: new js.Block(statements),
- );
- }
-
- /// Returns a reference to the constant holder, or the JS-literal `null`.
- js.Expression buildConstantHolderReference(Program program) {
- Holder constantHolder = program.holders.firstWhere(
- (Holder holder) => holder.isConstantsHolder,
- orElse: () => null);
- if (constantHolder == null) return new js.LiteralNull();
- return new js.VariableUse(constantHolder.name);
+ return holderCode;
}
/// Emits the given [method].
@@ -1594,9 +1530,8 @@
// TODO(floitsch): can there be anything else than a StaticDartMethod?
if (method is StaticDartMethod) {
if (method.needsTearOff) {
- Holder holder = method.holder;
- js.Statement statement =
- emitInstallTearOff(new js.VariableUse(holder.name), method);
+ js.Statement statement = emitInstallTearOff(
+ _namer.readGlobalObjectForMember(method.element), method);
registerEntityAst(method.element, statement,
library: library.element);
inits.add(statement);
@@ -1639,7 +1574,7 @@
// TODO(25230): We only need to name constants that are used from function
// bodies or from other constants in a different part.
var assignment = js.js.statement('#.# = #', [
- constant.holder.name,
+ _namer.globalObjectForConstants(),
constant.name,
_constantEmitter.generate(constant.value)
]);
@@ -1667,11 +1602,13 @@
// $.z = $.y = $.x = null;
//
Iterable<js.Statement> statements = fields.map((StaticField field) {
- assert(field.holder.isStaticStateHolder);
+ // TODO(joshualitt): Distribute fields into per-unit holders and use a
+ // deferred holder expression for the field assignment left-hand-side.
+ js.Expression location =
+ js.js('#.#', [_namer.globalObjectForStaticState(), field.name]);
js.Statement statement;
if (field.isInitializedByConstant) {
- statement = js.js
- .statement("#.# = #;", [field.holder.name, field.name, field.code]);
+ statement = js.js.statement("# = #;", [location, field.code]);
} else {
// This is a bit of a hack. Field initializers are generated as a
// function ending with a return statement. We replace the function
@@ -1697,13 +1634,11 @@
// To avoid unforeseen consequences of having parameters and locals
// in the initializer code.
js.Return last = code.body.statements.last;
- statement = js.js.statement(
- "#.# = #;", [field.holder.name, field.name, last.value]);
+ statement = js.js.statement("# = #;", [location, last.value]);
} else {
// Safe fallback in the event of a field initializer with no return
// statement as the last statement.
- statement = js.js
- .statement("#.# = #();", [field.holder.name, field.name, code]);
+ statement = js.js.statement("# = #();", [location, code]);
}
}
registerEntityAst(field.element, statement,
@@ -1722,7 +1657,6 @@
List<js.Statement> statements = [];
LocalAliases locals = LocalAliases();
for (StaticField field in fields) {
- assert(field.holder.isStaticStateHolder);
String helper = field.usesNonNullableInitialization
? field.isFinal
? locals.find('_lazyFinal', 'hunkHelpers.lazyFinal')
@@ -1730,7 +1664,7 @@
: locals.find('_lazyOld', 'hunkHelpers.lazyOld');
js.Statement statement = js.js.statement("#(#, #, #, #);", [
helper,
- field.holder.name,
+ _namer.globalObjectForStaticState(),
js.quoteName(field.name),
js.quoteName(field.getterName),
field.code,
@@ -2214,13 +2148,6 @@
}
}
-/// Code to initialize holder with ancillary information.
-class HolderCode {
- final List<Holder> activeHolders;
- js.Statement statements;
- HolderCode({this.activeHolders, this.statements});
-}
-
class DeferredLoadingState {
final deferredLibraryParts = new DeferredPrimaryExpression();
final deferredPartUris = new DeferredPrimaryExpression();
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
index f564f09..52434c7 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
@@ -63,7 +63,11 @@
import '../../js_backend/deferred_holder_expression.dart'
show
DeferredHolderExpressionFinalizer,
- DeferredHolderExpressionFinalizerImpl;
+ DeferredHolderExpressionFinalizerImpl,
+ DeferredHolderParameter,
+ DeferredHolderResource,
+ DeferredHolderResourceExpression,
+ DeferredHolderResourceKind;
import '../../js_backend/type_reference.dart'
show
TypeReferenceFinalizer,
@@ -216,8 +220,8 @@
if (isConstantInlinedOrAlreadyEmitted(value)) {
return constantEmitter.generate(value);
}
- return js.js('#.#',
- [_namer.globalObjectForConstant(value), _namer.constantName(value)]);
+ return js.js(
+ '#.#', [_namer.globalObjectForConstants(), _namer.constantName(value)]);
}
bool get shouldMergeFragments => _options.mergeFragmentsThreshold != null;
@@ -280,7 +284,7 @@
preDeferredFragment.finalize(program, outputUnitMap, codeFragmentMap);
for (var codeFragment in finalizedFragment.codeFragments) {
js.Expression fragmentCode =
- fragmentEmitter.emitCodeFragment(codeFragment, program.holders);
+ fragmentEmitter.emitCodeFragment(codeFragment);
if (fragmentCode != null) {
(deferredFragmentsCode[finalizedFragment] ??= [])
.add(EmittedCodeFragment(codeFragment, fragmentCode));
diff --git a/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart b/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart
index e9ddf00..d0dc2d3 100644
--- a/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart
+++ b/pkg/compiler/test/deferred_loading/data/dont_inline_deferred_constants/main.dart
@@ -16,21 +16,7 @@
lib2=(f3, f2)]
*/
-/*three-frag.library:
- a_pre_fragments=[
- p1: {units: [1{lib1}], usedBy: [p3], needs: []},
- p2: {units: [3{lib2}], usedBy: [p3], needs: []},
- p3: {units: [2{lib1, lib2}], usedBy: [], needs: [p1, p2]}],
- b_finalized_fragments=[
- f1: [1{lib1}],
- f2: [3{lib2}],
- f3: [2{lib1, lib2}]],
- c_steps=[
- lib1=(f3, f1),
- lib2=(f3, f2)]
-*/
-
-/*two-frag.library:
+/*two-frag|three-frag.library:
a_pre_fragments=[
p1: {units: [1{lib1}], usedBy: [p2], needs: []},
p2: {units: [2{lib1, lib2}, 3{lib2}], usedBy: [], needs: [p1]}],
diff --git a/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart b/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart
index fb34862..a5d40ab 100644
--- a/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart
+++ b/pkg/compiler/test/deferred_loading/data/lazy_types/main.dart
@@ -23,17 +23,17 @@
/*two-frag.library:
a_pre_fragments=[
- p1: {units: [6{libA}], usedBy: [p3], needs: []},
- p2: {units: [1{libB}], usedBy: [p3], needs: []},
- p3: {units: [3{libA, libB, libC}, 5{libB, libC}, 4{libA, libC}, 2{libC}], usedBy: [], needs: [p2, p1]}],
+ p1: {units: [1{libB}, 6{libA}], usedBy: [p2], needs: []},
+ p2: {units: [5{libB, libC}, 4{libA, libC}, 2{libC}], usedBy: [p3], needs: [p1]},
+ p3: {units: [3{libA, libB, libC}], usedBy: [], needs: [p2]}],
b_finalized_fragments=[
- f1: [6{libA}],
- f2: [1{libB}],
- f3: [3{libA, libB, libC}, 2{libC}]],
+ f1: [1{libB}, 6{libA}],
+ f2: [2{libC}],
+ f3: [3{libA, libB, libC}]],
c_steps=[
libA=(f3, f1),
- libB=(f3, f2),
- libC=(f3)]
+ libB=(f3, f1),
+ libC=(f3, f2)]
*/
/*three-frag.library:
diff --git a/pkg/compiler/test/deferred_loading/data/many_parts/main.dart b/pkg/compiler/test/deferred_loading/data/many_parts/main.dart
index 3dfb374..cbb56aa 100644
--- a/pkg/compiler/test/deferred_loading/data/many_parts/main.dart
+++ b/pkg/compiler/test/deferred_loading/data/many_parts/main.dart
@@ -96,12 +96,12 @@
/*two-frag.library:
a_pre_fragments=[
- p1: {units: [8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [p2], needs: []},
- p2: {units: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}], usedBy: [p3], needs: [p1]},
+ p1: {units: [12{b1, b3, b5}, 8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}], usedBy: [p2], needs: []},
+ p2: {units: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}], usedBy: [p3], needs: [p1]},
p3: {units: [1{b1, b2, b3, b4, b5}], usedBy: [], needs: [p2]}],
b_finalized_fragments=[
- f1: [8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}],
- f2: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}, 12{b1, b3, b5}],
+ f1: [12{b1, b3, b5}, 8{b1, b3, b4}, 11{b1, b2, b5}, 7{b1, b2, b4}, 5{b1, b2, b3}, 30{b4, b5}, 27{b3, b5}, 26{b3, b4}, 21{b2, b5}, 19{b2, b4}, 18{b2, b3}, 10{b1, b5}, 6{b1, b4}, 4{b1, b3}, 3{b1, b2}, 31{b5}, 29{b4}, 25{b3}, 17{b2}, 2{b1}],
+ f2: [24{b2, b3, b4, b5}, 16{b1, b3, b4, b5}, 15{b1, b2, b4, b5}, 13{b1, b2, b3, b5}, 9{b1, b2, b3, b4}, 28{b3, b4, b5}, 23{b2, b4, b5}, 22{b2, b3, b5}, 20{b2, b3, b4}, 14{b1, b4, b5}],
f3: [1{b1, b2, b3, b4, b5}]],
c_steps=[
b1=(f3, f2, f1),
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index 18478d0..7f5e6c9 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -1122,8 +1122,7 @@
node.arguments.positional.forEach(visitExpression);
node.arguments.named
.forEach((NamedExpression n) => visitExpression(n.value));
- // TODO(johnniwinther): Return the correct result type.
- return const DynamicType();
+ return node.functionType?.returnType ?? const DynamicType();
}
@override
@@ -1190,8 +1189,7 @@
node.arguments.positional.forEach(visitExpression);
node.arguments.named
.forEach((NamedExpression n) => visitExpression(n.value));
- // TODO(johnniwinther): Return the correct result type.
- return const DynamicType();
+ return node.functionType.returnType;
}
@override
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index e60f6c8..b002ab8 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -470,6 +470,8 @@
SSLCertContext::set_root_certs_cache(Options::root_certs_cache());
SSLCertContext::set_long_ssl_cert_evaluation(
Options::long_ssl_cert_evaluation());
+ SSLCertContext::set_bypass_trusting_system_roots(
+ Options::bypass_trusting_system_roots());
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
// The arguments to the VM are at positions 1 through i-1 in argv.
diff --git a/runtime/bin/main_options.h b/runtime/bin/main_options.h
index 658cea3..a0fc972 100644
--- a/runtime/bin/main_options.h
+++ b/runtime/bin/main_options.h
@@ -48,7 +48,8 @@
V(suppress_core_dump, suppress_core_dump) \
V(enable_service_port_fallback, enable_service_port_fallback) \
V(disable_dart_dev, disable_dart_dev) \
- V(long_ssl_cert_evaluation, long_ssl_cert_evaluation)
+ V(long_ssl_cert_evaluation, long_ssl_cert_evaluation) \
+ V(bypass_trusting_system_roots, bypass_trusting_system_roots)
// Boolean flags that have a short form.
#define SHORT_BOOL_OPTIONS_LIST(V) \
diff --git a/runtime/bin/secure_socket_utils.cc b/runtime/bin/secure_socket_utils.cc
index e3cdbf4..ce38f8f 100644
--- a/runtime/bin/secure_socket_utils.cc
+++ b/runtime/bin/secure_socket_utils.cc
@@ -75,10 +75,10 @@
}
if (SSL_LOG_STATUS) {
int error = ERR_get_error();
- Syslog::PrintErr("Failed: %s status %d", message, status);
+ Syslog::PrintErr("Failed: %s status: %d ", message, status);
char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE];
ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE);
- Syslog::PrintErr("ERROR: %d %s\n", error, error_string);
+ Syslog::PrintErr("%s\n", error_string);
}
SecureSocketUtils::ThrowIOException(status, type, message, ssl);
}
diff --git a/runtime/bin/security_context.cc b/runtime/bin/security_context.cc
index f5d3a00..4ea0f10 100644
--- a/runtime/bin/security_context.cc
+++ b/runtime/bin/security_context.cc
@@ -35,6 +35,7 @@
const char* SSLCertContext::root_certs_file_ = NULL;
const char* SSLCertContext::root_certs_cache_ = NULL;
bool SSLCertContext::long_ssl_cert_evaluation_ = false;
+bool SSLCertContext::bypass_trusting_system_roots_ = false;
int SSLCertContext::CertificateCallback(int preverify_ok,
X509_STORE_CTX* store_ctx) {
diff --git a/runtime/bin/security_context.h b/runtime/bin/security_context.h
index 5090cdb..e8800e2 100644
--- a/runtime/bin/security_context.h
+++ b/runtime/bin/security_context.h
@@ -93,6 +93,14 @@
long_ssl_cert_evaluation_ = long_ssl_cert_evaluation;
}
+ static bool bypass_trusting_system_roots() {
+ return bypass_trusting_system_roots_;
+ }
+ static void set_bypass_trusting_system_roots(
+ bool bypass_trusting_system_roots) {
+ bypass_trusting_system_roots_ = bypass_trusting_system_roots;
+ }
+
private:
void AddCompiledInCerts();
void LoadRootCertFile(const char* file);
@@ -107,6 +115,7 @@
bool trust_builtin_;
static bool long_ssl_cert_evaluation_;
+ static bool bypass_trusting_system_roots_;
DISALLOW_COPY_AND_ASSIGN(SSLCertContext);
};
diff --git a/runtime/bin/security_context_linux.cc b/runtime/bin/security_context_linux.cc
index e4a9312..b251a0a 100644
--- a/runtime/bin/security_context_linux.cc
+++ b/runtime/bin/security_context_linux.cc
@@ -40,21 +40,27 @@
return;
}
- // On Linux, we use the compiled-in trusted certs as a last resort. First,
- // we try to find the trusted certs in various standard locations. A good
- // discussion of the complexities of this endeavor can be found here:
- //
- // https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/
- const char* bundle = "/etc/pki/tls/certs/ca-bundle.crt";
- const char* cachedir = "/etc/ssl/certs";
- if (File::Exists(NULL, bundle)) {
- LoadRootCertFile(bundle);
- return;
- }
+ if (bypass_trusting_system_roots()) {
+ if (SSL_LOG_STATUS) {
+ Syslog::Print("Bypass trusting Linux built-in roots\n");
+ }
+ } else {
+ // On Linux, we use the compiled-in trusted certs as a last resort. First,
+ // we try to find the trusted certs in various standard locations. A good
+ // discussion of the complexities of this endeavor can be found here:
+ //
+ // https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/
+ const char* bundle = "/etc/pki/tls/certs/ca-bundle.crt";
+ const char* cachedir = "/etc/ssl/certs";
+ if (File::Exists(NULL, bundle)) {
+ LoadRootCertFile(bundle);
+ return;
+ }
- if (Directory::Exists(NULL, cachedir) == Directory::EXISTS) {
- LoadRootCertCache(cachedir);
- return;
+ if (Directory::Exists(NULL, cachedir) == Directory::EXISTS) {
+ LoadRootCertCache(cachedir);
+ return;
+ }
}
// Fall back on the compiled-in certs if the standard locations don't exist,
diff --git a/runtime/bin/security_context_win.cc b/runtime/bin/security_context_win.cc
index effdc5e..6b19a89 100644
--- a/runtime/bin/security_context_win.cc
+++ b/runtime/bin/security_context_win.cc
@@ -39,24 +39,35 @@
char error_string[SecureSocketUtils::SSL_ERROR_MESSAGE_BUFFER_SIZE];
ERR_error_string_n(error, error_string,
SecureSocketUtils::SSL_ERROR_MESSAGE_BUFFER_SIZE);
- Syslog::PrintErr("%s ERROR: %d %s\n", str, error, error_string);
+ Syslog::PrintErr("%s %s\n", str, error_string);
}
-// Add certificates from Windows trusted root store.
-static bool AddCertificatesFromRootStore(X509_STORE* store) {
-// The UWP platform doesn't support CertEnumCertificatesInStore hence
-// this function cannot work when compiled in UWP mode.
-#ifdef TARGET_OS_WINDOWS_UWP
- return false;
-#else
- // Open root system store.
- // Note that only current user certificates are accessible using this method,
- // not the local machine store.
- HCERTSTORE cert_store = CertOpenSystemStore(NULL, L"ROOT");
+#ifndef TARGET_OS_WINDOWS_UWP
+static bool AddCertificatesFromNamedSystemStore(const wchar_t* name,
+ DWORD store_type,
+ X509_STORE* store) {
+ ASSERT(store_type == CERT_SYSTEM_STORE_CURRENT_USER ||
+ store_type == CERT_SYSTEM_STORE_LOCAL_MACHINE);
+
+ if (SSL_LOG_STATUS) {
+ Syslog::Print("AddCertificatesFromNamedSystemStore %ls type: %s\n", name,
+ store_type == CERT_SYSTEM_STORE_CURRENT_USER
+ ? "Current User"
+ : "Local Machine");
+ }
+
+ HCERTSTORE cert_store =
+ CertOpenStore(CERT_STORE_PROV_SYSTEM,
+ 0, // the encoding type is not needed
+ NULL, // use the default HCRYPTPROV
+ store_type | CERT_STORE_READONLY_FLAG, name);
+
if (cert_store == NULL) {
if (SSL_LOG_STATUS) {
DWORD error = GetLastError();
- Syslog::PrintErr("Failed to open Windows root store due to %d\n", error);
+ Syslog::PrintErr(
+ "Failed to open Windows root store %ls type %d due to %d\n", name,
+ store_type, error);
}
return false;
}
@@ -84,10 +95,34 @@
continue;
}
BIO_free(root_cert_bio);
+
+ if (SSL_LOG_STATUS) {
+ auto s_name = X509_get_subject_name(root_cert);
+ auto s_issuer_name = X509_get_issuer_name(root_cert);
+ auto serial_number = X509_get_serialNumber(root_cert);
+ BIGNUM* bn = ASN1_INTEGER_to_BN(serial_number, nullptr);
+ char* hex = BN_bn2hex(bn);
+ Syslog::Print("Considering root certificate serial: %s subject name: ",
+ hex);
+ OPENSSL_free(hex);
+ X509_NAME_print_ex_fp(stdout, s_name, 4, 0);
+ Syslog::Print(" issuer:");
+ X509_NAME_print_ex_fp(stdout, s_issuer_name, 4, 0);
+ Syslog::Print("\n");
+ }
+
int status = X509_STORE_add_cert(store, root_cert);
if (status == 0) {
+ int error = ERR_get_error();
+ if (ERR_GET_REASON(error) == X509_R_CERT_ALREADY_IN_HASH_TABLE) {
+ if (SSL_LOG_STATUS) {
+ Syslog::Print("...duplicate\n");
+ }
+ X509_free(root_cert);
+ continue;
+ }
if (SSL_LOG_STATUS) {
- PrintSSLErr("Fail to add certificate to trust store");
+ PrintSSLErr("Failed to add certificate to x509 trust store");
}
X509_free(root_cert);
CertFreeCertificateContext(cert_context);
@@ -105,6 +140,42 @@
return false;
}
return true;
+}
+
+static bool AddCertificatesFromSystemStore(DWORD store_type,
+ X509_STORE* store) {
+ if (!AddCertificatesFromNamedSystemStore(L"ROOT", store_type, store)) {
+ return false;
+ }
+ if (!AddCertificatesFromNamedSystemStore(L"CA", store_type, store)) {
+ return false;
+ }
+ if (!AddCertificatesFromNamedSystemStore(L"TRUST", store_type, store)) {
+ return false;
+ }
+ if (!AddCertificatesFromNamedSystemStore(L"MY", store_type, store)) {
+ return false;
+ }
+ return true;
+}
+#endif // ifdef TARGET_OS_WINDOWS_UWP
+
+// Add certificates from Windows trusted root store.
+static bool AddCertificatesFromRootStore(X509_STORE* store) {
+// The UWP platform doesn't support CertEnumCertificatesInStore hence
+// this function cannot work when compiled in UWP mode.
+#ifdef TARGET_OS_WINDOWS_UWP
+ return false;
+#else
+ if (!AddCertificatesFromSystemStore(CERT_SYSTEM_STORE_CURRENT_USER, store)) {
+ return false;
+ }
+
+ if (!AddCertificatesFromSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, store)) {
+ return false;
+ }
+
+ return true;
#endif // ifdef TARGET_OS_WINDOWS_UWP
}
@@ -119,12 +190,18 @@
return;
}
- if (SSL_LOG_STATUS) {
- Syslog::Print("Trusting Windows built-in roots\n");
- }
- X509_STORE* store = SSL_CTX_get_cert_store(context());
- if (AddCertificatesFromRootStore(store)) {
- return;
+ if (bypass_trusting_system_roots()) {
+ if (SSL_LOG_STATUS) {
+ Syslog::Print("Bypass trusting Windows built-in roots\n");
+ }
+ } else {
+ if (SSL_LOG_STATUS) {
+ Syslog::Print("Trusting Windows built-in roots\n");
+ }
+ X509_STORE* store = SSL_CTX_get_cert_store(context());
+ if (AddCertificatesFromRootStore(store)) {
+ return;
+ }
}
// Reset store. SSL_CTX_set_cert_store will take ownership of store. A manual
// free is not needed.
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index dfbeeef..6705857 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -191,7 +191,7 @@
const Instance& owner_mirror) {
const Array& args = Array::Handle(Array::New(3));
args.SetAt(0, param);
- args.SetAt(1, String::Handle(param.name()));
+ args.SetAt(1, String::Handle(param.UserVisibleName()));
args.SetAt(2, owner_mirror);
return CreateMirror(Symbols::_TypeVariableMirror(), args);
}
@@ -199,18 +199,17 @@
// We create a list in native code and let Dart code create the type mirror
// object and the ordered map.
static InstancePtr CreateTypeVariableList(const Class& cls) {
- const TypeArguments& args = TypeArguments::Handle(cls.type_parameters());
- if (args.IsNull()) {
+ const intptr_t num_type_params = cls.NumTypeParameters();
+ if (num_type_params == 0) {
return Object::empty_array().ptr();
}
- const Array& result = Array::Handle(Array::New(args.Length() * 2));
+ const Array& result = Array::Handle(Array::New(num_type_params * 2));
TypeParameter& type = TypeParameter::Handle();
String& name = String::Handle();
- for (intptr_t i = 0; i < args.Length(); i++) {
- type ^= args.TypeAt(i);
- ASSERT(type.IsTypeParameter());
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ type = cls.TypeParameterAt(i, Nullability::kLegacy);
ASSERT(type.IsFinalized());
- name = type.name();
+ name = type.UserVisibleName();
result.SetAt(2 * i, name);
result.SetAt(2 * i + 1, type);
}
diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc
index 6b0e86c..fb999cf 100644
--- a/runtime/lib/object.cc
+++ b/runtime/lib/object.cc
@@ -449,18 +449,19 @@
const Closure& closure =
Closure::CheckedHandle(zone, arguments->NativeArgAt(0));
const Function& target = Function::Handle(zone, closure.function());
- const TypeArguments& bounds =
- TypeArguments::Handle(zone, target.type_parameters());
-
- // Either the bounds are all-dynamic or the function is not generic.
- if (bounds.IsNull()) return Object::null();
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, target.type_parameters());
+ if (type_params.IsNull() || type_params.AllDynamicBounds()) {
+ // The function is not generic or the bounds are all dynamic.
+ return Object::null();
+ }
const TypeArguments& type_args_to_check =
TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
// This should be guaranteed by the front-end.
ASSERT(type_args_to_check.IsNull() ||
- bounds.Length() <= type_args_to_check.Length());
+ type_params.Length() <= type_args_to_check.Length());
// The bounds on the closure may need instantiation.
const TypeArguments& instantiator_type_args =
@@ -470,10 +471,8 @@
AbstractType& supertype = AbstractType::Handle(zone);
AbstractType& subtype = AbstractType::Handle(zone);
- TypeParameter& parameter = TypeParameter::Handle(zone);
- for (intptr_t i = 0; i < bounds.Length(); ++i) {
- parameter ^= bounds.TypeAt(i);
- supertype = parameter.bound();
+ for (intptr_t i = 0; i < type_params.Length(); ++i) {
+ supertype = type_params.BoundAt(i);
subtype = type_args_to_check.IsNull() ? Object::dynamic_type().ptr()
: type_args_to_check.TypeAt(i);
@@ -492,7 +491,7 @@
ASSERT(caller_frame != NULL);
location = caller_frame->GetTokenPos();
}
- String& parameter_name = String::Handle(zone, parameter.Name());
+ const auto& parameter_name = String::Handle(zone, type_params.NameAt(i));
Exceptions::CreateAndThrowTypeError(location, subtype, supertype,
parameter_name);
UNREACHABLE();
diff --git a/runtime/vm/canonical_tables.cc b/runtime/vm/canonical_tables.cc
index 13c9470..bfdc140 100644
--- a/runtime/vm/canonical_tables.cc
+++ b/runtime/vm/canonical_tables.cc
@@ -40,11 +40,6 @@
const Object& owner_b = Object::Handle(Field::Cast(b).Owner());
return IsMatch(owner_a, owner_b);
} else if (a.IsTypeParameter() && b.IsTypeParameter()) {
- const String& name_a = String::Handle(TypeParameter::Cast(a).name());
- const String& name_b = String::Handle(TypeParameter::Cast(b).name());
- if (!name_a.Equals(name_b)) {
- return false;
- }
if (TypeParameter::Cast(a).index() != TypeParameter::Cast(b).index() ||
TypeParameter::Cast(a).base() != TypeParameter::Cast(b).base()) {
return false;
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index e429842..eff5ead 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -294,31 +294,41 @@
}
IsolateGroup::Current()->heap()->Verify();
}
+#endif // defined(DART_PRECOMPILED_RUNTIME)
-void ClassFinalizer::FinalizeTypeParameters(const Class& cls,
- FinalizationKind finalization) {
+void ClassFinalizer::FinalizeTypeParameters(Zone* zone,
+ const Class& cls,
+ const FunctionType& signature,
+ FinalizationKind finalization,
+ PendingTypes* pending_types) {
if (FLAG_trace_type_finalization) {
- THR_Print("%s type parameters of '%s'\n",
- String::Handle(cls.Name()).ToCString(),
- finalization == kFinalize ? "Finalizing" : "Canonicalizing");
+ THR_Print(
+ "%s type parameters of %s '%s'\n",
+ finalization == kFinalize ? "Finalizing" : "Canonicalizing",
+ !cls.IsNull() ? "class" : "signature",
+ String::Handle(zone, !cls.IsNull() ? cls.Name() : signature.Name())
+ .ToCString());
}
- const TypeArguments& type_params =
- TypeArguments::Handle(cls.type_parameters());
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, !cls.IsNull() ? cls.type_parameters()
+ : signature.type_parameters());
if (!type_params.IsNull()) {
- const intptr_t num_type_params = type_params.Length();
- TypeParameter& type_param = TypeParameter::Handle();
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- if (!type_param.IsBeingFinalized()) {
- type_param ^= FinalizeType(type_param, finalization);
- type_params.SetTypeAt(i, type_param);
- }
- }
+ TypeArguments& type_args = TypeArguments::Handle(zone);
+
+ type_args = type_params.bounds();
+ type_args =
+ FinalizeTypeArguments(zone, type_args, finalization, pending_types);
+ type_params.set_bounds(type_args);
+
+ type_args = type_params.defaults();
+ type_args =
+ FinalizeTypeArguments(zone, type_args, finalization, pending_types);
+ type_params.set_defaults(type_args);
+
+ type_params.OptimizeFlags();
}
}
-#endif // defined(DART_PRECOMPILED_RUNTIME)
-
// This function reports a compilation error if the recursive 'type' T being
// finalized is a non-contractive type, i.e. if the induced type set S of P is
// not finite, where P is the instantiation of T with its own type parameters.
@@ -407,9 +417,9 @@
// Expand the type arguments of the given type and finalize its full type
// argument vector. Return the number of type arguments (0 for a raw type).
intptr_t ClassFinalizer::ExpandAndFinalizeTypeArguments(
+ Zone* zone,
const AbstractType& type,
PendingTypes* pending_types) {
- Zone* zone = Thread::Current()->zone();
// The type class does not need to be finalized in order to finalize the type.
// Also, the type parameters of the type class must be finalized.
Class& type_class = Class::Handle(zone, type.type_class());
@@ -483,8 +493,8 @@
}
if (offset > 0) {
TrailPtr trail = new Trail(zone, 4);
- FinalizeTypeArguments(type_class, full_arguments, offset, pending_types,
- trail);
+ FillAndFinalizeTypeArguments(zone, type_class, full_arguments, offset,
+ pending_types, trail);
}
if (full_arguments.IsRaw(0, num_type_arguments)) {
// The parameterized_type is raw. Set its argument vector to null, which
@@ -535,22 +545,24 @@
// same time. Canonicalization happens when pending types are processed.
// The trail is required to correctly instantiate a recursive type argument
// of the super type.
-void ClassFinalizer::FinalizeTypeArguments(const Class& cls,
- const TypeArguments& arguments,
- intptr_t num_uninitialized_arguments,
- PendingTypes* pending_types,
- TrailPtr trail) {
+void ClassFinalizer::FillAndFinalizeTypeArguments(
+ Zone* zone,
+ const Class& cls,
+ const TypeArguments& arguments,
+ intptr_t num_uninitialized_arguments,
+ PendingTypes* pending_types,
+ TrailPtr trail) {
ASSERT(arguments.Length() >= cls.NumTypeArguments());
if (!cls.is_type_finalized()) {
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
- FinalizeTypeParameters(cls, kFinalize);
+ FinalizeTypeParameters(zone, cls, Object::null_function_type(), kFinalize);
#endif // defined(DART_PRECOMPILED_RUNTIME)
}
- AbstractType& super_type = AbstractType::Handle(cls.super_type());
+ AbstractType& super_type = AbstractType::Handle(zone, cls.super_type());
if (!super_type.IsNull()) {
- const Class& super_class = Class::Handle(super_type.type_class());
+ const Class& super_class = Class::Handle(zone, super_type.type_class());
const intptr_t num_super_type_params = super_class.NumTypeParameters();
const intptr_t num_super_type_args = super_class.NumTypeArguments();
if (!super_type.IsFinalized() && !super_type.IsBeingFinalized()) {
@@ -558,11 +570,12 @@
cls.set_super_type(super_type);
}
TypeArguments& super_type_args =
- TypeArguments::Handle(super_type.arguments());
+ TypeArguments::Handle(zone, super_type.arguments());
// Offset of super type's type parameters in cls' type argument vector.
const intptr_t super_offset = num_super_type_args - num_super_type_params;
// If the super type is raw (i.e. super_type_args is null), set to dynamic.
- AbstractType& super_type_arg = AbstractType::Handle(Type::DynamicType());
+ AbstractType& super_type_arg =
+ AbstractType::Handle(zone, Type::DynamicType());
for (intptr_t i = super_offset; i < num_uninitialized_arguments; i++) {
if (!super_type_args.IsNull()) {
super_type_arg = super_type_args.TypeAt(i);
@@ -581,9 +594,10 @@
ASSERT(super_type_arg.IsFunctionType());
}
if (FLAG_trace_type_finalization) {
- THR_Print("Creating TypeRef '%s': '%s'\n",
- String::Handle(super_type_arg.Name()).ToCString(),
- super_type_arg.ToCString());
+ THR_Print(
+ "Creating TypeRef '%s': '%s'\n",
+ String::Handle(zone, super_type_arg.Name()).ToCString(),
+ super_type_arg.ToCString());
}
super_type_arg = TypeRef::New(super_type_arg);
}
@@ -601,12 +615,12 @@
// Instantiate super_type_arg with the current argument vector.
if (!super_type_arg.IsInstantiated()) {
if (FLAG_trace_type_finalization && super_type_arg.IsTypeRef()) {
- AbstractType& ref_type =
- AbstractType::Handle(TypeRef::Cast(super_type_arg).type());
+ AbstractType& ref_type = AbstractType::Handle(
+ zone, TypeRef::Cast(super_type_arg).type());
THR_Print(
"Instantiating TypeRef '%s': '%s'\n"
" instantiator: '%s'\n",
- String::Handle(super_type_arg.Name()).ToCString(),
+ String::Handle(zone, super_type_arg.Name()).ToCString(),
ref_type.ToCString(), arguments.ToCString());
}
// In the typical case of an F-bounded type, the instantiation of the
@@ -628,7 +642,7 @@
// The super_type_arg was instantiated from a type being finalized.
// We need to finish finalizing its type arguments, unless it is a
// type parameter, in which case there is nothing more to do.
- AbstractType& unfinalized_type = AbstractType::Handle();
+ AbstractType& unfinalized_type = AbstractType::Handle(zone);
if (super_type_arg.IsTypeRef()) {
unfinalized_type = TypeRef::Cast(super_type_arg).type();
} else {
@@ -636,18 +650,19 @@
unfinalized_type = super_type_arg.ptr();
}
if (FLAG_trace_type_finalization) {
- THR_Print("Instantiated unfinalized '%s': '%s'\n",
- String::Handle(unfinalized_type.Name()).ToCString(),
- unfinalized_type.ToCString());
+ THR_Print(
+ "Instantiated unfinalized '%s': '%s'\n",
+ String::Handle(zone, unfinalized_type.Name()).ToCString(),
+ unfinalized_type.ToCString());
}
if (unfinalized_type.IsType()) {
CheckRecursiveType(unfinalized_type, pending_types);
pending_types->Add(unfinalized_type);
}
const Class& super_cls =
- Class::Handle(unfinalized_type.type_class());
+ Class::Handle(zone, unfinalized_type.type_class());
const TypeArguments& super_args =
- TypeArguments::Handle(unfinalized_type.arguments());
+ TypeArguments::Handle(zone, unfinalized_type.arguments());
// Mark as finalized before finalizing to avoid cycles.
unfinalized_type.SetIsFinalized();
// Although the instantiator is different between cls and super_cls,
@@ -655,25 +670,53 @@
// divergence. Finalizing the type arguments of super_cls may indeed
// recursively require instantiating the same type_refs already
// present in the trail (see issue #29949).
- FinalizeTypeArguments(
- super_cls, super_args,
+ FillAndFinalizeTypeArguments(
+ zone, super_cls, super_args,
super_cls.NumTypeArguments() - super_cls.NumTypeParameters(),
pending_types, trail);
if (FLAG_trace_type_finalization) {
- THR_Print("Finalized instantiated '%s': '%s'\n",
- String::Handle(unfinalized_type.Name()).ToCString(),
- unfinalized_type.ToCString());
+ THR_Print(
+ "Finalized instantiated '%s': '%s'\n",
+ String::Handle(zone, unfinalized_type.Name()).ToCString(),
+ unfinalized_type.ToCString());
}
}
}
}
arguments.SetTypeAt(i, super_type_arg);
}
- FinalizeTypeArguments(super_class, arguments, super_offset, pending_types,
- trail);
+ FillAndFinalizeTypeArguments(zone, super_class, arguments, super_offset,
+ pending_types, trail);
}
}
+TypeArgumentsPtr ClassFinalizer::FinalizeTypeArguments(
+ Zone* zone,
+ const TypeArguments& type_args,
+ FinalizationKind finalization,
+ PendingTypes* pending_types) {
+ if (type_args.IsNull()) return TypeArguments::null();
+ ASSERT(type_args.ptr() != Object::empty_type_arguments().ptr());
+ const intptr_t len = type_args.Length();
+ AbstractType& type = AbstractType::Handle(zone);
+ AbstractType& finalized_type = AbstractType::Handle(zone);
+ for (intptr_t i = 0; i < len; i++) {
+ type = type_args.TypeAt(i);
+ if (type.IsBeingFinalized()) {
+ ASSERT(finalization < kCanonicalize);
+ continue;
+ }
+ finalized_type = FinalizeType(type, kFinalize, pending_types);
+ if (type.ptr() != finalized_type.ptr()) {
+ type_args.SetTypeAt(i, finalized_type);
+ }
+ }
+ if (finalization >= kCanonicalize) {
+ return type_args.Canonicalize(Thread::Current(), nullptr);
+ }
+ return type_args.ptr();
+}
+
AbstractTypePtr ClassFinalizer::FinalizeType(const AbstractType& type,
FinalizationKind finalization,
PendingTypes* pending_types) {
@@ -701,8 +744,8 @@
return type.ptr();
}
- // Recursive types must be processed in FinalizeTypeArguments() and cannot be
- // encountered here.
+ // Recursive types must be processed in FillAndFinalizeTypeArguments() and
+ // cannot be encountered here.
ASSERT(!type.IsBeingFinalized());
// Mark the type as being finalized in order to detect self reference.
@@ -737,17 +780,20 @@
type_parameter.set_parameterized_class_id(kClassCid);
}
- AbstractType& t = AbstractType::Handle(zone);
- t = type_parameter.bound();
- if (!t.IsBeingFinalized()) {
- t = FinalizeType(t, kFinalize);
- type_parameter.set_bound(t);
+ AbstractType& upper_bound = AbstractType::Handle(zone);
+ upper_bound = type_parameter.bound();
+ if (upper_bound.IsBeingFinalized()) {
+ if (upper_bound.IsTypeRef()) {
+ // Nothing to do.
+ } else {
+ upper_bound = TypeRef::New(upper_bound);
+ type_parameter.set_bound(upper_bound);
+ upper_bound = FinalizeType(upper_bound, kFinalize);
+ }
+ } else {
+ upper_bound = FinalizeType(upper_bound, kFinalize);
+ type_parameter.set_bound(upper_bound);
}
- t = type_parameter.default_argument();
- // The default argument cannot create a cycle with the type parameter.
- t = FinalizeType(t, kFinalize);
- type_parameter.set_default_argument(t);
-
type_parameter.SetIsFinalized();
if (FLAG_trace_type_finalization) {
@@ -781,7 +827,7 @@
pending_types->Add(type);
const intptr_t num_expanded_type_arguments =
- ExpandAndFinalizeTypeArguments(type, pending_types);
+ ExpandAndFinalizeTypeArguments(zone, type, pending_types);
// Self referencing types may get finalized indirectly.
if (!type.IsFinalized()) {
@@ -819,23 +865,12 @@
const FunctionType& signature,
FinalizationKind finalization,
PendingTypes* pending_types) {
+ // Finalize signature type parameter upper bounds and default args.
+ FinalizeTypeParameters(zone, Object::null_class(), signature, finalization,
+ pending_types);
+
AbstractType& type = AbstractType::Handle(zone);
AbstractType& finalized_type = AbstractType::Handle(zone);
- // Finalize signature type parameters, their upper bounds and default args.
- const intptr_t num_type_params = signature.NumTypeParameters();
- if (num_type_params > 0) {
- TypeParameter& type_param = TypeParameter::Handle(zone);
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, signature.type_parameters());
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- finalized_type ^= FinalizeType(type_param, kFinalize, pending_types);
- if (type_param.ptr() != finalized_type.ptr()) {
- type_params.SetTypeAt(i, TypeParameter::Cast(finalized_type));
- }
- }
- }
-
// Finalize result type.
type = signature.result_type();
finalized_type = FinalizeType(type, kFinalize, pending_types);
@@ -984,6 +1019,7 @@
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
+ Zone* zone = thread->zone();
SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
if (cls.is_type_finalized()) {
return;
@@ -993,24 +1029,24 @@
THR_Print("Finalize types in %s\n", cls.ToCString());
}
// Finalize super class.
- Class& super_class = Class::Handle(cls.SuperClass());
+ Class& super_class = Class::Handle(zone, cls.SuperClass());
if (!super_class.IsNull()) {
FinalizeTypesInClass(super_class);
}
// Finalize type parameters before finalizing the super type.
- FinalizeTypeParameters(cls, kFinalize);
+ FinalizeTypeParameters(zone, cls, Object::null_function_type(),
+ kCanonicalize);
ASSERT(super_class.ptr() == cls.SuperClass()); // Not modified.
ASSERT(super_class.IsNull() || super_class.is_type_finalized());
- FinalizeTypeParameters(cls, kCanonicalize);
// Finalize super type.
- AbstractType& super_type = AbstractType::Handle(cls.super_type());
+ AbstractType& super_type = AbstractType::Handle(zone, cls.super_type());
if (!super_type.IsNull()) {
super_type = FinalizeType(super_type);
cls.set_super_type(super_type);
}
// Finalize interface types (but not necessarily interface classes).
- Array& interface_types = Array::Handle(cls.interfaces());
- AbstractType& interface_type = AbstractType::Handle();
+ Array& interface_types = Array::Handle(zone, cls.interfaces());
+ AbstractType& interface_type = AbstractType::Handle(zone);
for (intptr_t i = 0; i < interface_types.Length(); i++) {
interface_type ^= interface_types.At(i);
interface_type = FinalizeType(interface_type);
@@ -1343,8 +1379,7 @@
error = cls.EnsureIsFinalized(thread);
ASSERT(error.IsNull());
ASSERT(cls.NumTypeParameters() == 1);
- type_param ^= TypeParameter::RawCast(
- TypeArguments::Handle(cls.type_parameters()).TypeAt(0));
+ type_param = cls.TypeParameterAt(0);
ASSERT(Pointer::kNativeTypeArgPos == type_param.index());
#endif
}
@@ -1660,7 +1695,8 @@
for (intptr_t i = 0; i < typeparams.Length(); i++) {
typeparam ^= typeparams.At(i);
bool present = typeparams_table.Insert(typeparam);
- ASSERT(!present);
+ // Two recursive types with different topology (and hashes) may be equal.
+ ASSERT(!present || typeparam.IsRecursive());
}
object_store->set_canonical_type_parameters(typeparams_table.Release());
diff --git a/runtime/vm/class_finalizer.h b/runtime/vm/class_finalizer.h
index db2b973..3f7775d 100644
--- a/runtime/vm/class_finalizer.h
+++ b/runtime/vm/class_finalizer.h
@@ -79,6 +79,13 @@
#endif // !defined(DART_PRECOMPILED_RUNTIME)
private:
+ // Finalize given type argument vector.
+ static TypeArgumentsPtr FinalizeTypeArguments(
+ Zone* zone,
+ const TypeArguments& type_args,
+ FinalizationKind finalization = kCanonicalize,
+ PendingTypes* pending_types = NULL);
+
// Finalize the types in the signature and the signature itself.
static AbstractTypePtr FinalizeSignature(
Zone* zone,
@@ -88,18 +95,24 @@
#if !defined(DART_PRECOMPILED_RUNTIME)
static void AllocateEnumValues(const Class& enum_cls);
- static void FinalizeTypeParameters(
- const Class& cls,
- FinalizationKind finalization = kCanonicalize);
#endif // !defined(DART_PRECOMPILED_RUNTIME)
- static intptr_t ExpandAndFinalizeTypeArguments(const AbstractType& type,
+ static void FinalizeTypeParameters(
+ Zone* zone,
+ const Class& cls,
+ const FunctionType& signature,
+ FinalizationKind finalization = kCanonicalize,
+ PendingTypes* pending_types = NULL);
+
+ static intptr_t ExpandAndFinalizeTypeArguments(Zone* zone,
+ const AbstractType& type,
PendingTypes* pending_types);
- static void FinalizeTypeArguments(const Class& cls,
- const TypeArguments& arguments,
- intptr_t num_uninitialized_arguments,
- PendingTypes* pending_types,
- TrailPtr trail);
+ static void FillAndFinalizeTypeArguments(Zone* zone,
+ const Class& cls,
+ const TypeArguments& arguments,
+ intptr_t num_uninitialized_arguments,
+ PendingTypes* pending_types,
+ TrailPtr trail);
static void CheckRecursiveType(const AbstractType& type,
PendingTypes* pending_types);
diff --git a/runtime/vm/class_id.h b/runtime/vm/class_id.h
index cb1b9f0..5e2b4c7 100644
--- a/runtime/vm/class_id.h
+++ b/runtime/vm/class_id.h
@@ -21,6 +21,7 @@
V(Class) \
V(PatchClass) \
V(Function) \
+ V(TypeParameters) \
V(ClosureData) \
V(FfiTrampolineData) \
V(Field) \
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 3de7da8..b99bc8a 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -533,8 +533,14 @@
element ^= ptr;
intptr_t entry = -1;
const bool present = table.FindKeyOrDeletedOrUnused(element, &entry);
- ASSERT(!present);
- table.InsertKey(entry, element);
+ if (!present) {
+ table.InsertKey(entry, element);
+ } else {
+ // Two recursive types with different topology (and hashes)
+ // may be equal.
+ ASSERT(element.IsRecursive());
+ objects_[num_occupied++] = ptr;
+ }
} else {
objects_[num_occupied++] = ptr;
}
@@ -686,6 +692,74 @@
};
#if !defined(DART_PRECOMPILED_RUNTIME)
+class TypeParametersSerializationCluster : public SerializationCluster {
+ public:
+ TypeParametersSerializationCluster()
+ : SerializationCluster("TypeParameters",
+ kTypeParametersCid,
+ compiler::target::TypeParameters::InstanceSize()) {
+ }
+ ~TypeParametersSerializationCluster() {}
+
+ void Trace(Serializer* s, ObjectPtr object) {
+ TypeParametersPtr type_params = TypeParameters::RawCast(object);
+ objects_.Add(type_params);
+ PushFromTo(type_params);
+ }
+
+ void WriteAlloc(Serializer* s) {
+ const intptr_t count = objects_.length();
+ s->WriteUnsigned(count);
+ for (intptr_t i = 0; i < count; i++) {
+ TypeParametersPtr type_params = objects_[i];
+ s->AssignRef(type_params);
+ }
+ }
+
+ void WriteFill(Serializer* s) {
+ const intptr_t count = objects_.length();
+ for (intptr_t i = 0; i < count; i++) {
+ TypeParametersPtr type_params = objects_[i];
+ AutoTraceObject(type_params);
+ WriteFromTo(type_params);
+ }
+ }
+
+ private:
+ GrowableArray<TypeParametersPtr> objects_;
+};
+#endif // !DART_PRECOMPILED_RUNTIME
+
+class TypeParametersDeserializationCluster : public DeserializationCluster {
+ public:
+ TypeParametersDeserializationCluster()
+ : DeserializationCluster("TypeParameters") {}
+ ~TypeParametersDeserializationCluster() {}
+
+ void ReadAlloc(Deserializer* d) {
+ start_index_ = d->next_index();
+ PageSpace* old_space = d->heap()->old_space();
+ const intptr_t count = d->ReadUnsigned();
+ for (intptr_t i = 0; i < count; i++) {
+ d->AssignRef(
+ AllocateUninitialized(old_space, TypeParameters::InstanceSize()));
+ }
+ stop_index_ = d->next_index();
+ }
+
+ void ReadFill(Deserializer* d, bool primary) {
+ ASSERT(!is_canonical()); // Never canonical.
+ for (intptr_t id = start_index_; id < stop_index_; id++) {
+ TypeParametersPtr type_params =
+ static_cast<TypeParametersPtr>(d->Ref(id));
+ Deserializer::InitializeHeader(type_params, kTypeParametersCid,
+ TypeParameters::InstanceSize());
+ ReadFromTo(type_params);
+ }
+ }
+};
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
class TypeArgumentsSerializationCluster
: public CanonicalSetSerializationCluster<CanonicalTypeArgumentsSet,
TypeArguments,
@@ -1088,7 +1162,6 @@
}
s->Push(data->untag()->parent_function());
s->Push(data->untag()->closure());
- s->Push(data->untag()->default_type_arguments());
}
void WriteAlloc(Serializer* s) {
@@ -1110,7 +1183,6 @@
}
WriteCompressedField(data, parent_function);
WriteCompressedField(data, closure);
- WriteCompressedField(data, default_type_arguments);
s->WriteUnsigned(
static_cast<intptr_t>(data->untag()->default_type_arguments_kind_));
}
@@ -1151,8 +1223,6 @@
}
data->untag()->parent_function_ = static_cast<FunctionPtr>(d->ReadRef());
data->untag()->closure_ = static_cast<InstancePtr>(d->ReadRef());
- data->untag()->default_type_arguments_ =
- static_cast<TypeArgumentsPtr>(d->ReadRef());
data->untag()->default_type_arguments_kind_ =
static_cast<ClosureData::DefaultTypeArgumentsKind>(d->ReadUnsigned());
}
@@ -4218,8 +4288,8 @@
AutoTraceObject(type);
WriteFromTo(type);
s->Write<int32_t>(type->untag()->parameterized_class_id_);
- s->Write<uint16_t>(type->untag()->base_);
- s->Write<uint16_t>(type->untag()->index_);
+ s->Write<uint8_t>(type->untag()->base_);
+ s->Write<uint8_t>(type->untag()->index_);
ASSERT(type->untag()->flags_ < (1 << UntaggedTypeParameter::kFlagsBitSize));
ASSERT(type->untag()->nullability_ < (1 << kNullabilityBitSize));
static_assert(UntaggedTypeParameter::kFlagsBitSize + kNullabilityBitSize <=
@@ -4264,8 +4334,8 @@
primary && is_canonical());
ReadFromTo(type);
type->untag()->parameterized_class_id_ = d->Read<int32_t>();
- type->untag()->base_ = d->Read<uint16_t>();
- type->untag()->index_ = d->Read<uint16_t>();
+ type->untag()->base_ = d->Read<uint8_t>();
+ type->untag()->index_ = d->Read<uint8_t>();
const uint8_t combined = d->Read<uint8_t>();
type->untag()->flags_ = combined >> kNullabilityBitSize;
type->untag()->nullability_ = combined & kNullabilityBitMask;
@@ -6536,6 +6606,8 @@
switch (cid) {
case kClassCid:
return new (Z) ClassSerializationCluster(num_cids_ + num_tlc_cids_);
+ case kTypeParametersCid:
+ return new (Z) TypeParametersSerializationCluster();
case kTypeArgumentsCid:
return new (Z) TypeArgumentsSerializationCluster(
is_canonical, cluster_represents_canonical_set);
@@ -7388,6 +7460,8 @@
case kClassCid:
ASSERT(!is_canonical);
return new (Z) ClassDeserializationCluster();
+ case kTypeParametersCid:
+ return new (Z) TypeParametersDeserializationCluster();
case kTypeArgumentsCid:
return new (Z)
TypeArgumentsDeserializationCluster(is_canonical, !is_non_root_unit_);
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 1910b15..56c13e8 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -962,7 +962,7 @@
AddType(type);
}
- AddTypeArguments(TypeArguments::Handle(Z, cls.type_parameters()));
+ AddTypeParameters(TypeParameters::Handle(Z, cls.type_parameters()));
type = cls.super_type();
AddType(type);
@@ -991,15 +991,6 @@
const FunctionType& signature = FunctionType::Handle(Z, function.signature());
AddType(signature);
- // At this point, ensure any cached default type arguments are canonicalized.
- function.UpdateCachedDefaultTypeArguments(thread());
- if (function.CachesDefaultTypeArguments()) {
- const auto& defaults = TypeArguments::Handle(
- Z, function.default_type_arguments(/*kind_out=*/nullptr));
- ASSERT(defaults.IsCanonical());
- AddTypeArguments(defaults);
- }
-
// A class may have all functions inlined except a local function.
const Class& owner = Class::Handle(Z, function.Owner());
AddTypesOf(owner);
@@ -1054,10 +1045,8 @@
if (typeparams_to_retain_.HasKey(¶m)) return;
typeparams_to_retain_.Insert(&TypeParameter::ZoneHandle(Z, param.ptr()));
- auto& type = AbstractType::Handle(Z, param.bound());
- AddType(type);
- type = param.default_argument();
- AddType(type);
+ auto& bound = AbstractType::Handle(Z, param.bound());
+ AddType(bound);
return;
}
@@ -1067,7 +1056,7 @@
FunctionType::ZoneHandle(Z, FunctionType::Cast(abstype).ptr());
functiontypes_to_retain_.Insert(&signature);
- AddTypeArguments(TypeArguments::Handle(Z, signature.type_parameters()));
+ AddTypeParameters(TypeParameters::Handle(Z, signature.type_parameters()));
AbstractType& type = AbstractType::Handle(Z);
type = signature.result_type();
@@ -1095,6 +1084,16 @@
}
}
+void Precompiler::AddTypeParameters(const TypeParameters& params) {
+ if (params.IsNull()) return;
+
+ TypeArguments& args = TypeArguments::Handle();
+ args = params.bounds();
+ AddTypeArguments(args);
+ args = params.defaults();
+ AddTypeArguments(args);
+}
+
void Precompiler::AddTypeArguments(const TypeArguments& args) {
if (args.IsNull()) return;
diff --git a/runtime/vm/compiler/aot/precompiler.h b/runtime/vm/compiler/aot/precompiler.h
index 24bebca..fba9413 100644
--- a/runtime/vm/compiler/aot/precompiler.h
+++ b/runtime/vm/compiler/aot/precompiler.h
@@ -298,6 +298,7 @@
void AddType(const AbstractType& type);
void AddTypesOf(const Class& cls);
void AddTypesOf(const Function& function);
+ void AddTypeParameters(const TypeParameters& params);
void AddTypeArguments(const TypeArguments& args);
void AddCalleesOf(const Function& function, intptr_t gop_offset);
void AddCalleesOfHelper(const Object& entry,
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index f6b9929..5737444 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -2694,7 +2694,6 @@
case Slot::Kind::kClosure_function_type_arguments:
case Slot::Kind::kClosure_instantiator_type_arguments:
case Slot::Kind::kClosure_hash:
- case Slot::Kind::kClosureData_default_type_arguments:
case Slot::Kind::kCapturedVariable:
case Slot::Kind::kDartField:
case Slot::Kind::kFunction_data:
@@ -2705,8 +2704,11 @@
case Slot::Kind::kPointerBase_data_field:
case Slot::Kind::kType_arguments:
case Slot::Kind::kTypeArgumentsIndex:
+ case Slot::Kind::kTypeParameters_names:
+ case Slot::Kind::kTypeParameters_flags:
+ case Slot::Kind::kTypeParameters_bounds:
+ case Slot::Kind::kTypeParameters_defaults:
case Slot::Kind::kTypeParameter_bound:
- case Slot::Kind::kTypeParameter_name:
case Slot::Kind::kUnhandledException_exception:
case Slot::Kind::kUnhandledException_stacktrace:
case Slot::Kind::kWeakProperty_key:
diff --git a/runtime/vm/compiler/backend/il_test_helper.cc b/runtime/vm/compiler/backend/il_test_helper.cc
index a99374c..de02bc4 100644
--- a/runtime/vm/compiler/backend/il_test_helper.cc
+++ b/runtime/vm/compiler/backend/il_test_helper.cc
@@ -52,18 +52,14 @@
return cls.ptr();
}
-TypeParameterPtr GetClassTypeParameter(const Class& klass, const char* name) {
- const auto& param = TypeParameter::Handle(
- klass.LookupTypeParameter(String::Handle(String::New(name))));
+TypeParameterPtr GetClassTypeParameter(const Class& klass, intptr_t index) {
+ const auto& param = TypeParameter::Handle(klass.TypeParameterAt(index));
EXPECT(!param.IsNull());
return param.ptr();
}
-TypeParameterPtr GetFunctionTypeParameter(const Function& fun,
- const char* name) {
- intptr_t fun_level = 0;
- const auto& param = TypeParameter::Handle(
- fun.LookupTypeParameter(String::Handle(String::New(name)), &fun_level));
+TypeParameterPtr GetFunctionTypeParameter(const Function& fun, intptr_t index) {
+ const auto& param = TypeParameter::Handle(fun.TypeParameterAt(index));
EXPECT(!param.IsNull());
return param.ptr();
}
diff --git a/runtime/vm/compiler/backend/il_test_helper.h b/runtime/vm/compiler/backend/il_test_helper.h
index 7ef8db3..b42febd 100644
--- a/runtime/vm/compiler/backend/il_test_helper.h
+++ b/runtime/vm/compiler/backend/il_test_helper.h
@@ -58,9 +58,8 @@
FunctionPtr GetFunction(const Library& lib, const char* name);
ClassPtr GetClass(const Library& lib, const char* name);
-TypeParameterPtr GetClassTypeParameter(const Class& klass, const char* name);
-TypeParameterPtr GetFunctionTypeParameter(const Function& fun,
- const char* name);
+TypeParameterPtr GetClassTypeParameter(const Class& klass, intptr_t index);
+TypeParameterPtr GetFunctionTypeParameter(const Function& fun, intptr_t index);
ObjectPtr Invoke(const Library& lib, const char* name);
diff --git a/runtime/vm/compiler/backend/range_analysis.cc b/runtime/vm/compiler/backend/range_analysis.cc
index 3992c8b..b65bdf1 100644
--- a/runtime/vm/compiler/backend/range_analysis.cc
+++ b/runtime/vm/compiler/backend/range_analysis.cc
@@ -2797,7 +2797,6 @@
case Slot::Kind::kClosure_function:
case Slot::Kind::kClosure_function_type_arguments:
case Slot::Kind::kClosure_instantiator_type_arguments:
- case Slot::Kind::kClosureData_default_type_arguments:
case Slot::Kind::kFunction_data:
case Slot::Kind::kFunction_signature:
case Slot::Kind::kFunctionType_parameter_names:
@@ -2807,8 +2806,11 @@
case Slot::Kind::kTypedDataView_data:
case Slot::Kind::kType_arguments:
case Slot::Kind::kTypeArgumentsIndex:
+ case Slot::Kind::kTypeParameters_names:
+ case Slot::Kind::kTypeParameters_flags:
+ case Slot::Kind::kTypeParameters_bounds:
+ case Slot::Kind::kTypeParameters_defaults:
case Slot::Kind::kTypeParameter_bound:
- case Slot::Kind::kTypeParameter_name:
case Slot::Kind::kUnhandledException_exception:
case Slot::Kind::kUnhandledException_stacktrace:
case Slot::Kind::kWeakProperty_key:
diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h
index 3292e7f..a9ff524 100644
--- a/runtime/vm/compiler/backend/slot.h
+++ b/runtime/vm/compiler/backend/slot.h
@@ -58,10 +58,13 @@
FINAL) \
V(Closure, UntaggedClosure, delayed_type_arguments, TypeArguments, FINAL) \
V(Closure, UntaggedClosure, function_type_arguments, TypeArguments, FINAL) \
- V(ClosureData, UntaggedClosureData, default_type_arguments, TypeArguments, \
- FINAL_COMPRESSED) \
V(Type, UntaggedType, arguments, TypeArguments, FINAL_COMPRESSED) \
- V(FunctionType, UntaggedFunctionType, type_parameters, TypeArguments, \
+ V(FunctionType, UntaggedFunctionType, type_parameters, TypeParameters, \
+ FINAL_COMPRESSED) \
+ V(TypeParameters, UntaggedTypeParameters, flags, Array, FINAL_COMPRESSED) \
+ V(TypeParameters, UntaggedTypeParameters, bounds, TypeArguments, \
+ FINAL_COMPRESSED) \
+ V(TypeParameters, UntaggedTypeParameters, defaults, TypeArguments, \
FINAL_COMPRESSED) \
V(WeakProperty, UntaggedWeakProperty, key, Dynamic, VAR) \
V(WeakProperty, UntaggedWeakProperty, value, Dynamic, VAR)
@@ -107,8 +110,8 @@
V(ArgumentsDescriptor, UntaggedArray, size, Smi, FINAL) \
V(PointerBase, UntaggedPointerBase, data_field, Dynamic, FINAL) \
V(TypeArguments, UntaggedTypeArguments, length, Smi, FINAL_COMPRESSED) \
+ V(TypeParameters, UntaggedTypeParameters, names, Array, FINAL_COMPRESSED) \
V(TypeParameter, UntaggedTypeParameter, bound, Dynamic, FINAL_COMPRESSED) \
- V(TypeParameter, UntaggedTypeParameter, name, Dynamic, FINAL_COMPRESSED) \
V(UnhandledException, UntaggedUnhandledException, exception, Dynamic, \
FINAL_COMPRESSED) \
V(UnhandledException, UntaggedUnhandledException, stacktrace, Dynamic, \
diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc
index 3d4e86f..49b36d8 100644
--- a/runtime/vm/compiler/frontend/kernel_to_il.cc
+++ b/runtime/vm/compiler/frontend/kernel_to_il.cc
@@ -1387,14 +1387,12 @@
ASSERT(class_table->HasValidClassAt(kFfiPointerCid));
const auto& pointer_class =
Class::ZoneHandle(H.zone(), class_table->At(kFfiPointerCid));
- const auto& pointer_type_args =
- TypeArguments::Handle(pointer_class.type_parameters());
- const auto& pointer_type_arg =
- AbstractType::ZoneHandle(pointer_type_args.TypeAt(0));
+ const auto& pointer_type_param =
+ TypeParameter::ZoneHandle(pointer_class.TypeParameterAt(0));
// But we type check it as a method on a generic class at runtime.
- body += LoadLocal(arg_value); // value.
- body += Constant(pointer_type_arg); // dst_type.
+ body += LoadLocal(arg_value); // value.
+ body += Constant(pointer_type_param); // dst_type.
// We pass the Pointer type argument as instantiator_type_args.
//
// Call sites to this recognized method are guaranteed to pass a
@@ -1767,26 +1765,27 @@
ASSERT(!forwarding_target->IsNull());
}
- TypeArguments& type_parameters = TypeArguments::Handle(Z);
+ TypeParameters& type_parameters = TypeParameters::Handle(Z);
if (dart_function.IsFactory()) {
type_parameters = Class::Handle(Z, dart_function.Owner()).type_parameters();
} else {
type_parameters = dart_function.type_parameters();
}
- intptr_t num_type_params = type_parameters.Length();
+ const intptr_t num_type_params = type_parameters.Length();
+ if (num_type_params == 0) return;
if (forwarding_target != nullptr) {
type_parameters = forwarding_target->type_parameters();
ASSERT(type_parameters.Length() == num_type_params);
}
-
+ if (type_parameters.AllDynamicBounds()) {
+ return; // All bounds are dynamic.
+ }
TypeParameter& type_param = TypeParameter::Handle(Z);
String& name = String::Handle(Z);
AbstractType& bound = AbstractType::Handle(Z);
Fragment check_bounds;
for (intptr_t i = 0; i < num_type_params; ++i) {
- type_param ^= type_parameters.TypeAt(i);
-
- bound = type_param.bound();
+ bound = type_parameters.BoundAt(i);
if (bound.IsTopTypeForSubtyping()) {
continue;
}
@@ -1795,19 +1794,26 @@
case TypeChecksToBuild::kCheckAllTypeParameterBounds:
break;
case TypeChecksToBuild::kCheckCovariantTypeParameterBounds:
- if (!type_param.IsGenericCovariantImpl()) {
+ if (!type_parameters.IsGenericCovariantImplAt(i)) {
continue;
}
break;
case TypeChecksToBuild::kCheckNonCovariantTypeParameterBounds:
- if (type_param.IsGenericCovariantImpl()) {
+ if (type_parameters.IsGenericCovariantImplAt(i)) {
continue;
}
break;
}
- name = type_param.name();
+ name = type_parameters.NameAt(i);
+ if (forwarding_target != nullptr) {
+ type_param = forwarding_target->TypeParameterAt(i);
+ } else if (dart_function.IsFactory()) {
+ type_param = Class::Handle(Z, dart_function.Owner()).TypeParameterAt(i);
+ } else {
+ type_param = dart_function.TypeParameterAt(i);
+ }
ASSERT(type_param.IsFinalized());
check_bounds +=
AssertSubtype(TokenPosition::kNoSource, type_param, bound, name);
@@ -2076,8 +2082,8 @@
const ArgumentsDescriptor descriptor;
ParsedFunction::DynamicClosureCallVars* const vars;
- // Set up by BuildDynamicCallChecks() when needed. These values are
- // read-only, so they don't need real local variables and are created
+ // Set up by BuildClosureCallDefaultTypeHandling() when needed. These values
+ // are read-only, so they don't need real local variables and are created
// using MakeTemporary().
LocalVariable* signature = nullptr;
LocalVariable* num_fixed_params = nullptr;
@@ -2087,8 +2093,11 @@
LocalVariable* parameter_names = nullptr;
LocalVariable* parameter_types = nullptr;
LocalVariable* type_parameters = nullptr;
+ LocalVariable* num_type_parameters = nullptr;
+ LocalVariable* type_parameter_flags = nullptr;
LocalVariable* instantiator_type_args = nullptr;
LocalVariable* parent_function_type_args = nullptr;
+ LocalVariable* num_parent_type_args = nullptr;
};
Fragment FlowGraphBuilder::TestClosureFunctionGeneric(
@@ -2239,8 +2248,8 @@
store_default += BranchIfEqual(&can_share_instantiator, &can_share_function);
Fragment instantiated(is_instantiated);
- instantiated += LoadLocal(closure_data);
- instantiated += LoadNativeField(Slot::ClosureData_default_type_arguments());
+ instantiated += LoadLocal(info.type_parameters);
+ instantiated += LoadNativeField(Slot::TypeParameters_defaults());
instantiated += StoreLocal(info.vars->function_type_args);
instantiated += Drop();
instantiated += Goto(done);
@@ -2252,9 +2261,8 @@
// can be used within the defaults).
do_instantiation += LoadLocal(info.parent_function_type_args);
// Load the default type arguments to instantiate.
- do_instantiation += LoadLocal(closure_data);
- do_instantiation +=
- LoadNativeField(Slot::ClosureData_default_type_arguments());
+ do_instantiation += LoadLocal(info.type_parameters);
+ do_instantiation += LoadNativeField(Slot::TypeParameters_defaults());
do_instantiation += InstantiateDynamicTypeArguments();
do_instantiation += StoreLocal(info.vars->function_type_args);
do_instantiation += Drop();
@@ -2433,7 +2441,8 @@
check_type_args_length += BranchIfNull(&null, ¬_null);
check_type_args_length.current = not_null; // Continue in non-error case.
check_type_args_length += LoadLocal(info.type_parameters);
- check_type_args_length += LoadNativeField(Slot::TypeArguments_length());
+ check_type_args_length += LoadNativeField(Slot::TypeParameters_names());
+ check_type_args_length += LoadNativeField(Slot::Array_length());
check_type_args_length += IntConstant(info.descriptor.TypeArgsLen());
TargetEntryInstr *equal, *not_equal;
check_type_args_length += BranchIfEqual(&equal, ¬_equal);
@@ -2522,6 +2531,16 @@
// We assume that the value stored in :t_type_parameters is not null (i.e.,
// the function stored in :t_function is generic).
Fragment loop_init;
+
+ // A null bounds vector represents a vector of dynamic and no check is needed.
+ loop_init += LoadLocal(info.type_parameters);
+ loop_init += LoadNativeField(Slot::TypeParameters_bounds());
+ TargetEntryInstr *null_bounds, *non_null_bounds;
+ loop_init += BranchIfNull(&null_bounds, &non_null_bounds);
+
+ Fragment(null_bounds) + Goto(done);
+
+ loop_init.current = non_null_bounds;
// Loop over the type parameters array.
loop_init += IntConstant(0);
loop_init += StoreLocal(info.vars->current_param_index);
@@ -2530,54 +2549,93 @@
Fragment loop_check(loop);
loop_check += LoadLocal(info.vars->current_param_index);
- loop_check += LoadLocal(info.type_parameters);
- loop_check += LoadNativeField(Slot::TypeArguments_length());
+ loop_check += LoadLocal(info.num_type_parameters);
loop_check += SmiRelationalOp(Token::kLT);
TargetEntryInstr *more, *no_more;
loop_check += BranchIfTrue(&more, &no_more);
Fragment(no_more) + Goto(done);
- Fragment loop_body(more);
- loop_body += LoadLocal(info.type_parameters);
- loop_body += LoadLocal(info.vars->current_param_index);
- loop_body += LoadIndexed(
- kTypeArgumentsCid, /*index_scale*/ compiler::target::kCompressedWordSize);
- LocalVariable* current_param = MakeTemporary("current_param"); // Read-only.
-
- // One read-only local variable on stack (param) to drop after joining.
+ Fragment loop_test_flag(more);
JoinEntryInstr* next = BuildJoinEntry();
+ JoinEntryInstr* check = BuildJoinEntry();
+ loop_test_flag += LoadLocal(info.type_parameter_flags);
+ TargetEntryInstr *null_flags, *non_null_flags;
+ loop_test_flag += BranchIfNull(&null_flags, &non_null_flags);
- loop_body += LoadLocal(current_param);
- loop_body += LoadNativeField(Slot::TypeParameter_flags());
- loop_body += Box(kUnboxedUint8);
- loop_body += IntConstant(
- UntaggedTypeParameter::GenericCovariantImplBit::mask_in_place());
- loop_body += SmiBinaryOp(Token::kBIT_AND);
- loop_body += IntConstant(0);
+ Fragment(null_flags) + Goto(check); // Check type if null (non-covariant).
+
+ loop_test_flag.current = non_null_flags; // Test flags if not null.
+ loop_test_flag += LoadLocal(info.type_parameter_flags);
+ loop_test_flag += LoadLocal(info.vars->current_param_index);
+ loop_test_flag += IntConstant(TypeParameters::kFlagsPerSmiShift);
+ loop_test_flag += SmiBinaryOp(Token::kSHR);
+ loop_test_flag += LoadIndexed(kArrayCid);
+ loop_test_flag += LoadLocal(info.vars->current_param_index);
+ loop_test_flag += IntConstant(TypeParameters::kFlagsPerSmiMask);
+ loop_test_flag += SmiBinaryOp(Token::kBIT_AND);
+ loop_test_flag += SmiBinaryOp(Token::kSHR);
+ loop_test_flag += IntConstant(1);
+ loop_test_flag += SmiBinaryOp(Token::kBIT_AND);
+ loop_test_flag += IntConstant(0);
TargetEntryInstr *is_noncovariant, *is_covariant;
- loop_body += BranchIfEqual(&is_noncovariant, &is_covariant);
+ loop_test_flag += BranchIfEqual(&is_noncovariant, &is_covariant);
Fragment(is_covariant) + Goto(next); // Continue if covariant.
+ Fragment(is_noncovariant) + Goto(check); // Check type if non-covariant.
- loop_body.current = is_noncovariant; // Type check if non-covariant.
- loop_body += LoadLocal(info.instantiator_type_args);
- loop_body += LoadLocal(info.vars->function_type_args);
- // Load parameter.
- loop_body += LoadLocal(current_param);
- // Load bounds from parameter.
- loop_body += LoadLocal(current_param);
- loop_body += LoadNativeField(Slot::TypeParameter_bound());
- // Load name from parameter.
- loop_body += LoadLocal(current_param);
- loop_body += LoadNativeField(Slot::TypeParameter_name());
- // Assert that the type the parameter is instantiated as is consistent with
- // the bounds of the parameter.
- loop_body += AssertSubtype(TokenPosition::kNoSource);
- loop_body += Goto(next);
+ Fragment loop_prep_type_param(check);
+ JoinEntryInstr* dynamic_type_param = BuildJoinEntry();
+ JoinEntryInstr* call = BuildJoinEntry();
+
+ // Load type argument already stored in function_type_args if non null.
+ loop_prep_type_param += LoadLocal(info.vars->function_type_args);
+ TargetEntryInstr *null_ftav, *non_null_ftav;
+ loop_prep_type_param += BranchIfNull(&null_ftav, &non_null_ftav);
+
+ Fragment(null_ftav) + Goto(dynamic_type_param);
+
+ loop_prep_type_param.current = non_null_ftav;
+ loop_prep_type_param += LoadLocal(info.vars->function_type_args);
+ loop_prep_type_param += LoadLocal(info.vars->current_param_index);
+ loop_prep_type_param += LoadLocal(info.num_parent_type_args);
+ loop_prep_type_param += SmiBinaryOp(Token::kADD, /*is_truncating=*/true);
+ loop_prep_type_param += LoadIndexed(
+ kTypeArgumentsCid, /*index_scale*/ compiler::target::kCompressedWordSize);
+ loop_prep_type_param += StoreLocal(info.vars->current_type_param);
+ loop_prep_type_param += Drop();
+ loop_prep_type_param += Goto(call);
+
+ Fragment loop_dynamic_type_param(dynamic_type_param);
+ // If function_type_args is null, the instantiated type param is dynamic.
+ loop_dynamic_type_param += Constant(Type::ZoneHandle(Type::DynamicType()));
+ loop_dynamic_type_param += StoreLocal(info.vars->current_type_param);
+ loop_dynamic_type_param += Drop();
+ loop_dynamic_type_param += Goto(call);
+
+ Fragment loop_call_check(call);
+ // Load instantiators.
+ loop_call_check += LoadLocal(info.instantiator_type_args);
+ loop_call_check += LoadLocal(info.vars->function_type_args);
+ // Load instantiated type parameter.
+ loop_call_check += LoadLocal(info.vars->current_type_param);
+ // Load bound from type parameters.
+ loop_call_check += LoadLocal(info.type_parameters);
+ loop_call_check += LoadNativeField(Slot::TypeParameters_bounds());
+ loop_call_check += LoadLocal(info.vars->current_param_index);
+ loop_call_check += LoadIndexed(
+ kTypeArgumentsCid, /*index_scale*/ compiler::target::kCompressedWordSize);
+ // Load (canonicalized) name of type parameter in signature.
+ loop_call_check += LoadLocal(info.type_parameters);
+ loop_call_check += LoadNativeField(Slot::TypeParameters_names());
+ loop_call_check += LoadLocal(info.vars->current_param_index);
+ loop_call_check += LoadIndexed(kArrayCid);
+ // Assert that the passed-in type argument is consistent with the bound of
+ // the corresponding type parameter.
+ loop_call_check += AssertSubtype(TokenPosition::kNoSource);
+ loop_call_check += Goto(next);
Fragment loop_incr(next);
- loop_incr += DropTemporary(¤t_param);
loop_incr += LoadLocal(info.vars->current_param_index);
loop_incr += IntConstant(1);
loop_incr += SmiBinaryOp(Token::kADD, /*is_truncating=*/true);
@@ -2717,23 +2775,38 @@
// full set of function type arguments, then check the local function type
// arguments against the closure function's type parameter bounds.
Fragment generic;
+ // Calculate the number of parent type arguments and store them in
+ // info.num_parent_type_args.
+ generic += LoadLocal(info.signature);
+ generic += BuildExtractUnboxedSlotBitFieldIntoSmi<
+ UntaggedFunctionType::PackedNumParentTypeArguments>(
+ Slot::FunctionType_packed_fields());
+ info.num_parent_type_args = MakeTemporary("num_parent_type_args");
+
+ // Hoist number of type parameters.
+ generic += LoadLocal(info.type_parameters);
+ generic += LoadNativeField(Slot::TypeParameters_names());
+ generic += LoadNativeField(Slot::Array_length());
+ info.num_type_parameters = MakeTemporary("num_type_parameters");
+
+ // Hoist type parameter flags.
+ generic += LoadLocal(info.type_parameters);
+ generic += LoadNativeField(Slot::TypeParameters_flags());
+ info.type_parameter_flags = MakeTemporary("type_parameter_flags");
+
// Calculate the local function type arguments and store them in
// info.vars->function_type_args.
generic += BuildClosureCallDefaultTypeHandling(info);
+
// Load the local function type args.
generic += LoadLocal(info.vars->function_type_args);
// Load the parent function type args.
generic += LoadLocal(info.parent_function_type_args);
// Load the number of parent type parameters.
- generic += LoadLocal(info.signature);
- generic += BuildExtractUnboxedSlotBitFieldIntoSmi<
- UntaggedFunctionType::PackedNumParentTypeArguments>(
- Slot::FunctionType_packed_fields());
+ generic += LoadLocal(info.num_parent_type_args);
// Load the number of total type parameters.
- LocalVariable* num_parents = MakeTemporary();
- generic += LoadLocal(info.type_parameters);
- generic += LoadNativeField(Slot::TypeArguments_length());
- generic += LoadLocal(num_parents);
+ generic += LoadLocal(info.num_parent_type_args);
+ generic += LoadLocal(info.num_type_parameters);
generic += SmiBinaryOp(Token::kADD, /*is_truncating=*/true);
// Call the static function for prepending type arguments.
@@ -2753,6 +2826,9 @@
} else {
generic += check_bounds;
}
+ generic += DropTemporary(&info.type_parameter_flags);
+ generic += DropTemporary(&info.num_type_parameters);
+ generic += DropTemporary(&info.num_parent_type_args);
// Call the appropriate fragment for setting up the function type arguments
// and performing any needed type argument checking.
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.cc b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
index 8dd8f8a..5dddbea 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.cc
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
@@ -710,7 +710,18 @@
type = klass.DeclarationType();
} else {
// Note that the type argument vector is not yet extended.
- type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()));
+ TypeArguments& type_args = TypeArguments::Handle(Z);
+ const intptr_t num_type_params = klass.NumTypeParameters();
+ if (num_type_params > 0) {
+ type_args = TypeArguments::New(num_type_params);
+ TypeParameter& type_param = TypeParameter::Handle();
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ type_param = klass.TypeParameterAt(i);
+ ASSERT(type_param.bound() != AbstractType::null());
+ type_args.SetTypeAt(i, type_param);
+ }
+ }
+ type = Type::New(klass, type_args, Nullability::kNonNullable);
}
return type;
}
@@ -2916,19 +2927,13 @@
intptr_t ActiveClass::MemberTypeParameterCount(Zone* zone) {
ASSERT(member != NULL);
if (member->IsFactory()) {
- TypeArguments& class_types =
- TypeArguments::Handle(zone, klass->type_parameters());
- return class_types.Length();
+ return klass->NumTypeParameters();
} else if (member->IsMethodExtractor()) {
Function& extracted =
Function::Handle(zone, member->extracted_method_closure());
- TypeArguments& function_types =
- TypeArguments::Handle(zone, extracted.type_parameters());
- return function_types.Length();
+ return extracted.NumTypeParameters();
} else {
- TypeArguments& function_types =
- TypeArguments::Handle(zone, member->type_parameters());
- return function_types.Length();
+ return member->NumTypeParameters();
}
}
@@ -2937,17 +2942,15 @@
const Function& innermost,
const FunctionType* innermost_signature,
Zone* Z)
- : active_class_(active_class), saved_(*active_class) {
+ : active_class_(active_class), saved_(*active_class), zone_(Z) {
active_class_->enclosing = innermost_signature;
intptr_t num_params = 0;
Function& f = Function::Handle(Z);
- TypeArguments& f_params = TypeArguments::Handle(Z);
for (f = innermost.ptr(); f.parent_function() != Object::null();
f = f.parent_function()) {
- f_params = f.type_parameters();
- num_params += f_params.Length();
+ num_params += f.NumTypeParameters();
}
if (num_params == 0) return;
@@ -2957,9 +2960,10 @@
intptr_t index = num_params;
for (f = innermost.ptr(); f.parent_function() != Object::null();
f = f.parent_function()) {
- f_params = f.type_parameters();
- for (intptr_t j = f_params.Length() - 1; j >= 0; --j) {
- params.SetTypeAt(--index, AbstractType::Handle(Z, f_params.TypeAt(j)));
+ for (intptr_t j = f.NumTypeParameters() - 1; j >= 0; --j) {
+ const auto& type_param = TypeParameter::Handle(Z, f.TypeParameterAt(j));
+ params.SetTypeAt(--index, type_param);
+ active_class_->RecordDerivedTypeParameter(Z, type_param);
}
}
@@ -2969,32 +2973,55 @@
ActiveTypeParametersScope::ActiveTypeParametersScope(
ActiveClass* active_class,
const FunctionType* innermost_signature,
- const TypeArguments& new_params,
Zone* Z)
- : active_class_(active_class), saved_(*active_class) {
+ : active_class_(active_class), saved_(*active_class), zone_(Z) {
active_class_->enclosing = innermost_signature;
- if (new_params.IsNull()) return;
+ const intptr_t num_new_params =
+ innermost_signature == nullptr ? active_class->klass->NumTypeParameters()
+ : innermost_signature->NumTypeParameters();
+ if (num_new_params == 0) return;
const TypeArguments* old_params = active_class->local_type_parameters;
const intptr_t old_param_count =
old_params == NULL ? 0 : old_params->Length();
const TypeArguments& extended_params = TypeArguments::Handle(
- Z, TypeArguments::New(old_param_count + new_params.Length()));
+ Z, TypeArguments::New(old_param_count + num_new_params));
intptr_t index = 0;
for (intptr_t i = 0; i < old_param_count; ++i) {
- extended_params.SetTypeAt(
- index++, AbstractType::ZoneHandle(Z, old_params->TypeAt(i)));
+ extended_params.SetTypeAt(index++,
+ AbstractType::Handle(Z, old_params->TypeAt(i)));
}
- for (intptr_t i = 0; i < new_params.Length(); ++i) {
- extended_params.SetTypeAt(
- index++, AbstractType::ZoneHandle(Z, new_params.TypeAt(i)));
+ for (intptr_t i = 0; i < num_new_params; ++i) {
+ const auto& type_param =
+ TypeParameter::Handle(Z, innermost_signature == nullptr
+ ? active_class->klass->TypeParameterAt(i)
+ : innermost_signature->TypeParameterAt(i));
+ extended_params.SetTypeAt(index++, type_param);
+ active_class->RecordDerivedTypeParameter(Z, type_param);
}
active_class_->local_type_parameters = &extended_params;
}
+ActiveTypeParametersScope::~ActiveTypeParametersScope() {
+ GrowableObjectArray* dropped = active_class_->derived_type_parameters;
+ const bool preserve_unpatched =
+ dropped != nullptr && saved_.derived_type_parameters == nullptr;
+ *active_class_ = saved_;
+ if (preserve_unpatched) {
+ // Preserve still unpatched derived type parameters that would be dropped.
+ auto& derived = TypeParameter::Handle(Z);
+ for (intptr_t i = 0, n = dropped->Length(); i < n; ++i) {
+ derived ^= dropped->At(i);
+ if (derived.bound() == AbstractType::null()) {
+ active_class_->RecordDerivedTypeParameter(Z, derived);
+ }
+ }
+ }
+}
+
TypeTranslator::TypeTranslator(KernelReaderHelper* helper,
ConstantReader* constant_reader,
ActiveClass* active_class,
@@ -3135,14 +3162,12 @@
if (!simple) {
type_parameter_count = helper_->ReadListLength();
- LoadAndSetupTypeParameters(
- active_class_, Object::null_function(), Object::null_class(), signature,
- type_parameter_count, active_class_->klass->nnbd_mode());
+ LoadAndSetupTypeParameters(active_class_, Object::null_function(),
+ Object::null_class(), signature,
+ type_parameter_count);
}
- ActiveTypeParametersScope scope(
- active_class_, &signature,
- TypeArguments::Handle(Z, signature.type_parameters()), Z);
+ ActiveTypeParametersScope scope(active_class_, &signature, Z);
if (!simple) {
LoadAndSetupBounds(active_class_, Object::null_function(),
@@ -3230,19 +3255,16 @@
// If the type is from a constant, the parameter index isn't offset by the
// enclosing context.
if (!in_constant_context_) {
- const TypeArguments& class_types =
- TypeArguments::Handle(Z, active_class_->klass->type_parameters());
- if (parameter_index < class_types.Length()) {
- // The index of the type parameter in [parameters] is
- // the same index into the `klass->type_parameters()` array.
- const auto& type_param =
- TypeParameter::CheckedHandle(Z, class_types.TypeAt(parameter_index));
- result_ = type_param.ToNullability(nullability, Heap::kOld);
- active_class_->RecordDerivedTypeParameter(Z, type_param,
+ const intptr_t class_type_parameter_count =
+ active_class_->klass->NumTypeParameters();
+ if (class_type_parameter_count > parameter_index) {
+ result_ =
+ active_class_->klass->TypeParameterAt(parameter_index, nullability);
+ active_class_->RecordDerivedTypeParameter(Z,
TypeParameter::Cast(result_));
return;
}
- parameter_index -= class_types.Length();
+ parameter_index -= class_type_parameter_count;
if (active_class_->HasMember()) {
if (active_class_->MemberIsFactoryProcedure()) {
@@ -3263,33 +3285,32 @@
// static A.x<T'>() { return new B<T'>(); }
// }
//
- if (class_types.Length() > parameter_index) {
- const auto& type_param = TypeParameter::CheckedHandle(
- Z, class_types.TypeAt(parameter_index));
- result_ = type_param.ToNullability(nullability, Heap::kOld);
+ if (class_type_parameter_count > parameter_index) {
+ result_ = active_class_->klass->TypeParameterAt(parameter_index,
+ nullability);
active_class_->RecordDerivedTypeParameter(
- Z, type_param, TypeParameter::Cast(result_));
+ Z, TypeParameter::Cast(result_));
return;
}
- parameter_index -= class_types.Length();
+ parameter_index -= class_type_parameter_count;
}
// Factory function should not be considered as procedure.
- intptr_t procedure_type_parameter_count =
+ const intptr_t procedure_type_parameter_count =
(active_class_->MemberIsProcedure() &&
!active_class_->MemberIsFactoryProcedure())
? active_class_->MemberTypeParameterCount(Z)
: 0;
if (procedure_type_parameter_count > 0) {
if (procedure_type_parameter_count > parameter_index) {
- const auto& type_param = TypeParameter::CheckedHandle(
- Z,
- TypeArguments::Handle(Z, active_class_->member->type_parameters())
- .TypeAt(parameter_index));
- result_ = type_param.ToNullability(nullability, Heap::kOld);
- active_class_->RecordDerivedTypeParameter(
- Z, type_param, TypeParameter::Cast(result_));
+ result_ = active_class_->member->TypeParameterAt(parameter_index,
+ nullability);
if (finalize_) {
+ ASSERT(TypeParameter::Cast(result_).bound() !=
+ AbstractType::null());
result_ = ClassFinalizer::FinalizeType(result_);
+ } else {
+ active_class_->RecordDerivedTypeParameter(
+ Z, TypeParameter::Cast(result_));
}
return;
}
@@ -3302,10 +3323,12 @@
const auto& type_param = TypeParameter::CheckedHandle(
Z, active_class_->local_type_parameters->TypeAt(parameter_index));
result_ = type_param.ToNullability(nullability, Heap::kOld);
- active_class_->RecordDerivedTypeParameter(Z, type_param,
- TypeParameter::Cast(result_));
if (finalize_) {
+ ASSERT(TypeParameter::Cast(result_).bound() != AbstractType::null());
result_ = ClassFinalizer::FinalizeType(result_);
+ } else {
+ active_class_->RecordDerivedTypeParameter(Z,
+ TypeParameter::Cast(result_));
}
return;
}
@@ -3381,8 +3404,7 @@
const Function& function,
const Class& parameterized_class,
const FunctionType& parameterized_signature,
- intptr_t type_parameter_count,
- const NNBDMode nnbd_mode) {
+ intptr_t type_parameter_count) {
ASSERT(parameterized_class.IsNull() != parameterized_signature.IsNull());
ASSERT(type_parameter_count >= 0);
if (type_parameter_count == 0) {
@@ -3398,23 +3420,18 @@
// First setup the type parameters, so if any of the following code uses it
// (in a recursive way) we're fine.
- TypeArguments& type_parameters = TypeArguments::Handle(Z);
- TypeParameter& parameter = TypeParameter::Handle(Z);
+
+ // - Create a [ TypeParameters ] object.
+ const TypeParameters& type_parameters =
+ TypeParameters::Handle(Z, TypeParameters::New(type_parameter_count));
const Type& null_bound = Type::Handle(Z);
- const Nullability nullability = (nnbd_mode == NNBDMode::kOptedInLib)
- ? Nullability::kNonNullable
- : Nullability::kLegacy;
-
- // - Create array of [TypeParameter] objects (without bound).
- // - Create array of [String] objects.
- type_parameters = TypeArguments::New(type_parameter_count);
intptr_t offset = 0;
if (!parameterized_class.IsNull()) {
- ASSERT(parameterized_class.type_parameters() == TypeArguments::null());
+ ASSERT(parameterized_class.type_parameters() == TypeParameters::null());
parameterized_class.set_type_parameters(type_parameters);
} else {
- ASSERT(parameterized_signature.type_parameters() == TypeArguments::null());
+ ASSERT(parameterized_signature.type_parameters() == TypeParameters::null());
parameterized_signature.set_type_parameters(type_parameters);
offset = parameterized_signature.NumParentTypeArguments();
if (!function.IsNull()) {
@@ -3425,22 +3442,15 @@
const Library& lib = Library::Handle(Z, active_class->klass->library());
{
AlternativeReadingScope alt(&helper_->reader_);
- String& name = String::Handle(Z);
for (intptr_t i = 0; i < type_parameter_count; i++) {
TypeParameterHelper helper(helper_);
helper.Finish();
- if (parameterized_class.IsNull() && function.IsNull()) {
- // Erase provided name and use a canonical one instead.
- name = Symbols::NewFormatted(H.thread(), "X%" Pd, offset + i);
- } else {
- name = H.DartIdentifier(lib, helper.name_index_).ptr();
- }
+ type_parameters.SetNameAt(i, H.DartIdentifier(lib, helper.name_index_));
+ type_parameters.SetIsGenericCovariantImplAt(
+ i, helper.IsGenericCovariantImpl());
// Bounds are filled later in LoadAndSetupBounds as bound types may
// reference type parameters which are not created yet.
- parameter = TypeParameter::New(
- parameterized_class, offset, offset + i, name, null_bound,
- helper.IsGenericCovariantImpl(), nullability);
- type_parameters.SetTypeAt(i, parameter);
+ type_parameters.SetBoundAt(i, null_bound);
}
}
}
@@ -3457,52 +3467,45 @@
return;
}
- const TypeArguments& type_parameters =
- TypeArguments::Handle(Z, !parameterized_class.IsNull()
- ? parameterized_class.type_parameters()
- : parameterized_signature.type_parameters());
- TypeParameter& parameter = TypeParameter::Handle(Z);
+ const TypeParameters& type_parameters = TypeParameters::Handle(
+ Z, !parameterized_class.IsNull()
+ ? parameterized_class.type_parameters()
+ : parameterized_signature.type_parameters());
// Fill in the bounds and default arguments of all [TypeParameter]s.
for (intptr_t i = 0; i < type_parameter_count; i++) {
TypeParameterHelper helper(helper_);
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kBound);
- parameter ^= type_parameters.TypeAt(i);
AbstractType& bound = BuildTypeWithoutFinalization(); // read ith bound.
- parameter.set_bound(bound);
+ ASSERT(!bound.IsNull());
+ type_parameters.SetBoundAt(i, bound);
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kDefaultType);
AbstractType& default_arg = BuildTypeWithoutFinalization();
- parameter.set_default_argument(default_arg);
+ ASSERT(!default_arg.IsNull());
+ type_parameters.SetDefaultAt(i, default_arg);
helper.Finish();
}
- // Note that function.UpdateCachedDefaultTypeArguments() is called in
- // function.set_signature() and is not required here.
-
- // Fix bounds and default arguments in all derived type parameters (with
- // different nullabilities).
+ // Fix bounds in all derived type parameters.
const intptr_t offset = !parameterized_signature.IsNull()
? parameterized_signature.NumParentTypeArguments()
: 0;
if (active_class->derived_type_parameters != nullptr) {
auto& derived = TypeParameter::Handle(Z);
- auto& type = AbstractType::Handle(Z);
+ auto& bound = AbstractType::Handle(Z);
for (intptr_t i = 0, n = active_class->derived_type_parameters->Length();
i < n; ++i) {
derived ^= active_class->derived_type_parameters->At(i);
if (derived.bound() == AbstractType::null() &&
((!parameterized_class.IsNull() &&
- derived.parameterized_class() == parameterized_class.ptr()) ||
+ derived.parameterized_class_id() == parameterized_class.id()) ||
(!parameterized_signature.IsNull() &&
- derived.parameterized_class() == Class::null() &&
+ derived.parameterized_class_id() == kFunctionCid &&
derived.index() >= offset &&
derived.index() < offset + type_parameter_count))) {
- parameter ^= type_parameters.TypeAt(derived.index() - offset);
- type = parameter.bound();
- derived.set_bound(type);
- type = parameter.default_argument();
- derived.set_default_argument(type);
+ bound = type_parameters.BoundAt(derived.index() - offset);
+ derived.set_bound(bound);
}
}
}
@@ -3516,8 +3519,18 @@
if (finalize_ || klass.is_type_finalized()) {
type = klass.DeclarationType();
} else {
- type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()),
- Nullability::kNonNullable);
+ TypeArguments& type_args = TypeArguments::Handle(Z);
+ const intptr_t num_type_params = klass.NumTypeParameters();
+ if (num_type_params > 0) {
+ type_args = TypeArguments::New(num_type_params);
+ TypeParameter& type_param = TypeParameter::Handle();
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ type_param = klass.TypeParameterAt(i);
+ ASSERT(type_param.bound() != AbstractType::null());
+ type_args.SetTypeAt(i, type_param);
+ }
+ }
+ type = Type::New(klass, type_args, Nullability::kNonNullable);
}
return type;
}
@@ -3631,8 +3644,8 @@
if (!is_factory) {
type_parameter_count = helper_->ReadListLength();
LoadAndSetupTypeParameters(active_class_, function, Class::Handle(Z),
- signature, type_parameter_count,
- function.nnbd_mode());
+ signature, type_parameter_count);
+ function_node_helper->SetJustRead(FunctionNodeHelper::kTypeParameters);
}
ActiveTypeParametersScope scope(active_class_, function, &signature, Z);
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.h b/runtime/vm/compiler/frontend/kernel_translation_helper.h
index 087b9c1..1bed607 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.h
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.h
@@ -1344,11 +1344,8 @@
return klass->NumTypeArguments();
}
- void RecordDerivedTypeParameter(Zone* zone,
- const TypeParameter& original,
- const TypeParameter& derived) {
- if (original.ptr() != derived.ptr() &&
- original.bound() == AbstractType::null()) {
+ void RecordDerivedTypeParameter(Zone* zone, const TypeParameter& derived) {
+ if (derived.bound() == AbstractType::null()) {
if (derived_type_parameters == nullptr) {
derived_type_parameters = &GrowableObjectArray::Handle(
zone, GrowableObjectArray::New(Heap::kOld));
@@ -1442,14 +1439,14 @@
// Also, the enclosing signature is set to 'signature'.
ActiveTypeParametersScope(ActiveClass* active_class,
const FunctionType* innermost_signature,
- const TypeArguments& new_params,
Zone* Z);
- ~ActiveTypeParametersScope() { *active_class_ = saved_; }
+ ~ActiveTypeParametersScope();
private:
ActiveClass* active_class_;
ActiveClass saved_;
+ Zone* zone_;
DISALLOW_COPY_AND_ASSIGN(ActiveTypeParametersScope);
};
@@ -1476,8 +1473,7 @@
const Function& function,
const Class& parameterized_class,
const FunctionType& parameterized_signature,
- intptr_t type_parameter_count,
- const NNBDMode nnbd_mode);
+ intptr_t type_parameter_count);
void LoadAndSetupBounds(ActiveClass* active_class,
const Function& function,
diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc
index c84b23c..b3edbc9 100644
--- a/runtime/vm/compiler/runtime_api.cc
+++ b/runtime/vm/compiler/runtime_api.cc
@@ -1180,6 +1180,10 @@
return -kWordSize;
}
+word TypeParameters::NextFieldOffset() {
+ return -kWordSize;
+}
+
word TypeArguments::NextFieldOffset() {
return -kWordSize;
}
diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h
index 6c7d6db..c8cbc06 100644
--- a/runtime/vm/compiler/runtime_api.h
+++ b/runtime/vm/compiler/runtime_api.h
@@ -922,7 +922,6 @@
public:
static word bound_offset();
static word flags_offset();
- static word name_offset();
static word InstanceSize();
static word NextFieldOffset();
static word parameterized_class_id_offset();
@@ -1303,7 +1302,6 @@
class ClosureData : public AllStatic {
public:
- static word default_type_arguments_offset();
static word default_type_arguments_kind_offset();
static word InstanceSize();
static word NextFieldOffset();
@@ -1373,6 +1371,16 @@
static word NextFieldOffset();
};
+class TypeParameters : public AllStatic {
+ public:
+ static word names_offset();
+ static word flags_offset();
+ static word bounds_offset();
+ static word defaults_offset();
+ static word InstanceSize();
+ static word NextFieldOffset();
+};
+
class TypeArguments : public AllStatic {
public:
static word instantiations_offset();
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index abe8cc9..653ef92 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -134,9 +134,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 20;
+ ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
24;
@@ -429,19 +427,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 32;
+ TypeParameter_parameterized_class_id_offset = 20;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 23;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 35;
+ 25;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
16;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 34;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 4;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 16;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 16;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 24;
static constexpr dart::compiler::target::word TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 8;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 12;
@@ -473,7 +475,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 112;
static constexpr dart::compiler::target::word Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
8;
@@ -536,7 +538,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word Type_InstanceSize = 28;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 36;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 28;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 20;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 12;
@@ -670,9 +673,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 40;
+ ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -970,19 +971,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 40;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 43;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 45;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 32;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 32;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 44;
static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
@@ -1015,7 +1020,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 192;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -1079,7 +1084,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 56;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -1211,9 +1217,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 20;
+ ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
24;
@@ -1506,19 +1510,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 32;
+ TypeParameter_parameterized_class_id_offset = 20;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 23;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 35;
+ 25;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
16;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 34;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 4;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 16;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 16;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 24;
static constexpr dart::compiler::target::word TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 8;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 12;
@@ -1547,7 +1555,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 112;
static constexpr dart::compiler::target::word Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
8;
@@ -1610,7 +1618,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word Type_InstanceSize = 28;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 36;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 28;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 20;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 12;
@@ -1744,9 +1753,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 40;
+ ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -2044,19 +2051,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 40;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 43;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 45;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 32;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 32;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 44;
static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
@@ -2090,7 +2101,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 192;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -2154,7 +2165,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 56;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -2286,9 +2298,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 24;
+ ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -2586,19 +2596,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 36;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
+ TypeParameter_parameterized_class_id_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 31;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 43;
+ 33;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
20;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 20;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 32;
static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
@@ -2631,7 +2645,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 120;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -2695,7 +2709,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -2827,9 +2842,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 24;
+ ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -3127,19 +3140,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 36;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
+ TypeParameter_parameterized_class_id_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 31;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 43;
+ 33;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
20;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 20;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 32;
static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
@@ -3173,7 +3190,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 120;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -3237,7 +3254,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -3366,9 +3384,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 20;
+ ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
24;
@@ -3660,19 +3676,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 32;
+ TypeParameter_parameterized_class_id_offset = 20;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 23;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 35;
+ 25;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
16;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 34;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 4;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 16;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 16;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 24;
static constexpr dart::compiler::target::word TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 8;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 12;
@@ -3704,7 +3724,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 108;
static constexpr dart::compiler::target::word Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
8;
@@ -3767,7 +3787,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word Type_InstanceSize = 28;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 36;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 28;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 20;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 12;
@@ -3896,9 +3917,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 40;
+ ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -4195,19 +4214,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 40;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 43;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 45;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 32;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 32;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 44;
static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
@@ -4240,7 +4263,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 184;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -4304,7 +4327,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 56;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -4431,9 +4455,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 20;
+ ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
24;
@@ -4725,19 +4747,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 32;
+ TypeParameter_parameterized_class_id_offset = 20;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 23;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 35;
+ 25;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
16;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 20;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 34;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 4;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 16;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 16;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 24;
static constexpr dart::compiler::target::word TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 8;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 12;
@@ -4766,7 +4792,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 108;
static constexpr dart::compiler::target::word Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
8;
@@ -4829,7 +4855,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word Type_InstanceSize = 28;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 36;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 28;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 20;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 12;
@@ -4958,9 +4985,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 40;
+ ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -5257,19 +5282,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 40;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 43;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 45;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 24;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 32;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 32;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 44;
static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
@@ -5303,7 +5332,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 184;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -5367,7 +5396,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 56;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -5494,9 +5524,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 24;
+ ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -5793,19 +5821,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 36;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
+ TypeParameter_parameterized_class_id_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 31;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 43;
+ 33;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
20;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 20;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 32;
static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
@@ -5838,7 +5870,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 112;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -5902,7 +5934,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -6029,9 +6062,7 @@
static constexpr dart::compiler::target::word
Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- ClosureData_default_type_arguments_kind_offset = 24;
+ ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word Code_saved_instructions_offset =
48;
@@ -6328,19 +6359,23 @@
static constexpr dart::compiler::target::word
FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 36;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
+ TypeParameter_parameterized_class_id_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 31;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 43;
+ 33;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 12;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
20;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 24;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeParameters_names_offset = 8;
+static constexpr dart::compiler::target::word TypeParameters_flags_offset = 12;
+static constexpr dart::compiler::target::word TypeParameters_bounds_offset = 16;
+static constexpr dart::compiler::target::word TypeParameters_defaults_offset =
+ 20;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 32;
static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
@@ -6374,7 +6409,7 @@
static constexpr dart::compiler::target::word Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word Class_InstanceSize = 112;
static constexpr dart::compiler::target::word Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word CompressedStackMaps_HeaderSize =
16;
@@ -6438,7 +6473,8 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word Type_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypeParameters_InstanceSize = 24;
static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
@@ -6580,9 +6616,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 20;
+ AOT_ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 24;
@@ -6908,11 +6942,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 28;
+ AOT_TypeParameter_parameterized_class_id_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 32;
+ 23;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 35;
+ AOT_TypeParameter_nullability_offset = 25;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -6921,12 +6955,18 @@
AOT_TypeArguments_nullability_offset = 16;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
20;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 20;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 34;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 4;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
12;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 16;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
8;
@@ -6961,7 +7001,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 92;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 8;
@@ -7033,7 +7073,9 @@
AOT_TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 36;
+ 28;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 20;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -7176,9 +7218,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 40;
+ AOT_ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -7505,11 +7545,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 43;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 45;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -7518,12 +7558,18 @@
AOT_TypeArguments_nullability_offset = 32;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
24;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 44;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -7560,7 +7606,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 160;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -7632,7 +7678,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 40;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -7778,9 +7826,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 40;
+ AOT_ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -8107,11 +8153,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 43;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 45;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -8120,12 +8166,18 @@
AOT_TypeArguments_nullability_offset = 32;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
24;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 44;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -8163,7 +8215,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 160;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -8235,7 +8287,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 40;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -8378,9 +8432,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 24;
+ AOT_ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -8707,11 +8759,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 36;
+ AOT_TypeParameter_parameterized_class_id_offset = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 40;
+ 31;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 43;
+ AOT_TypeParameter_nullability_offset = 33;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -8720,12 +8772,18 @@
AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
24;
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 12;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
+ 16;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 28;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 42;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 20;
+ 32;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -8762,7 +8820,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -8834,7 +8892,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 48;
+ 40;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -8977,9 +9037,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 24;
+ AOT_ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -9306,11 +9364,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 36;
+ AOT_TypeParameter_parameterized_class_id_offset = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 40;
+ 31;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 43;
+ AOT_TypeParameter_nullability_offset = 33;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -9319,12 +9377,18 @@
AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
24;
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 12;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
+ 16;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 28;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 42;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 20;
+ 32;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -9362,7 +9426,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -9434,7 +9498,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 48;
+ 40;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -9573,9 +9639,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 4;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 16;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 20;
+ AOT_ClosureData_default_type_arguments_kind_offset = 16;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 20;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 24;
@@ -9899,11 +9963,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 12;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 28;
+ AOT_TypeParameter_parameterized_class_id_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 32;
+ 23;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 35;
+ AOT_TypeParameter_nullability_offset = 25;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 4;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -9912,12 +9976,18 @@
AOT_TypeArguments_nullability_offset = 16;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
20;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 20;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 34;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 4;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
12;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 16;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 12;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
8;
@@ -9952,7 +10022,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 28;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 20;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 8;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 8;
@@ -10024,7 +10094,9 @@
AOT_TransferableTypedData_InstanceSize = 4;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 36;
+ 28;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 20;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 12;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -10162,9 +10234,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 40;
+ AOT_ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -10489,11 +10559,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 43;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 45;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -10502,12 +10572,18 @@
AOT_TypeArguments_nullability_offset = 32;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
24;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 44;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -10544,7 +10620,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 136;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -10616,7 +10692,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 40;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -10757,9 +10835,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 32;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 40;
+ AOT_ClosureData_default_type_arguments_kind_offset = 32;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -11084,11 +11160,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 24;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 43;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 45;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -11097,12 +11173,18 @@
AOT_TypeArguments_nullability_offset = 32;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
-static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 16;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
24;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
+ 32;
+static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
+ 44;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -11140,7 +11222,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 136;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 48;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -11212,7 +11294,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 40;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -11350,9 +11434,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 24;
+ AOT_ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -11677,11 +11759,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 36;
+ AOT_TypeParameter_parameterized_class_id_offset = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 40;
+ 31;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 43;
+ AOT_TypeParameter_nullability_offset = 33;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -11690,12 +11772,18 @@
AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
24;
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 12;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
+ 16;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 28;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 42;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 20;
+ 32;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -11732,7 +11820,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -11804,7 +11892,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 48;
+ 40;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
@@ -11942,9 +12032,7 @@
static constexpr dart::compiler::target::word
AOT_Closure_instantiator_type_arguments_offset = 8;
static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_offset = 20;
-static constexpr dart::compiler::target::word
- AOT_ClosureData_default_type_arguments_kind_offset = 24;
+ AOT_ClosureData_default_type_arguments_kind_offset = 20;
static constexpr dart::compiler::target::word AOT_Code_object_pool_offset = 40;
static constexpr dart::compiler::target::word
AOT_Code_saved_instructions_offset = 48;
@@ -12269,11 +12357,11 @@
static constexpr dart::compiler::target::word
AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 36;
+ AOT_TypeParameter_parameterized_class_id_offset = 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 40;
+ 31;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 43;
+ AOT_TypeParameter_nullability_offset = 33;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -12282,12 +12370,18 @@
AOT_TypeArguments_nullability_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
24;
+static constexpr dart::compiler::target::word AOT_TypeParameters_names_offset =
+ 8;
+static constexpr dart::compiler::target::word AOT_TypeParameters_flags_offset =
+ 12;
+static constexpr dart::compiler::target::word AOT_TypeParameters_bounds_offset =
+ 16;
+static constexpr dart::compiler::target::word
+ AOT_TypeParameters_defaults_offset = 20;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 28;
+ 24;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 42;
-static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 20;
+ 32;
static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
@@ -12325,7 +12419,7 @@
static constexpr dart::compiler::target::word AOT_Capability_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_Class_InstanceSize = 88;
static constexpr dart::compiler::target::word AOT_Closure_InstanceSize = 56;
-static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 32;
+static constexpr dart::compiler::target::word AOT_ClosureData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_CodeSourceMap_HeaderSize = 16;
static constexpr dart::compiler::target::word
AOT_CompressedStackMaps_HeaderSize = 16;
@@ -12397,7 +12491,9 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 48;
+ 40;
+static constexpr dart::compiler::target::word AOT_TypeParameters_InstanceSize =
+ 24;
static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_HeaderSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
diff --git a/runtime/vm/compiler/runtime_offsets_list.h b/runtime/vm/compiler/runtime_offsets_list.h
index 75e1b54..0af1b9e 100644
--- a/runtime/vm/compiler/runtime_offsets_list.h
+++ b/runtime/vm/compiler/runtime_offsets_list.h
@@ -110,7 +110,6 @@
FIELD(Closure, function_type_arguments_offset) \
FIELD(Closure, hash_offset) \
FIELD(Closure, instantiator_type_arguments_offset) \
- FIELD(ClosureData, default_type_arguments_offset) \
FIELD(ClosureData, default_type_arguments_kind_offset) \
FIELD(Code, object_pool_offset) \
FIELD(Code, saved_instructions_offset) \
@@ -301,9 +300,12 @@
FIELD(TypeArguments, length_offset) \
FIELD(TypeArguments, nullability_offset) \
FIELD(TypeArguments, types_offset) \
+ FIELD(TypeParameters, names_offset) \
+ FIELD(TypeParameters, flags_offset) \
+ FIELD(TypeParameters, bounds_offset) \
+ FIELD(TypeParameters, defaults_offset) \
FIELD(TypeParameter, bound_offset) \
FIELD(TypeParameter, flags_offset) \
- FIELD(TypeParameter, name_offset) \
FIELD(TypeRef, type_offset) \
FIELD(TypedDataBase, length_offset) \
FIELD(TypedDataView, data_offset) \
@@ -384,6 +386,7 @@
SIZEOF(TransferableTypedData, InstanceSize, UntaggedTransferableTypedData) \
SIZEOF(Type, InstanceSize, UntaggedType) \
SIZEOF(TypeParameter, InstanceSize, UntaggedTypeParameter) \
+ SIZEOF(TypeParameters, InstanceSize, UntaggedTypeParameters) \
SIZEOF(TypeRef, InstanceSize, UntaggedTypeRef) \
SIZEOF(TypedData, HeaderSize, UntaggedTypedData) \
SIZEOF(TypedDataBase, InstanceSize, UntaggedTypedDataBase) \
diff --git a/runtime/vm/compiler/stub_code_compiler.cc b/runtime/vm/compiler/stub_code_compiler.cc
index 604aeaa..ea11574 100644
--- a/runtime/vm/compiler/stub_code_compiler.cc
+++ b/runtime/vm/compiler/stub_code_compiler.cc
@@ -482,7 +482,8 @@
__ BranchIf(EQUAL, &is_assignable, Assembler::kNearJump);
// Resolve the type parameter to its instantiated type and loop.
__ LoadFieldFromOffset(kIndexReg, kCurrentTypeReg,
- target::TypeParameter::index_offset(), kTwoBytes);
+ target::TypeParameter::index_offset(),
+ kUnsignedByte);
__ LoadIndexedCompressed(kCurrentTypeReg, tav,
target::TypeArguments::types_offset(),
kIndexReg);
@@ -597,7 +598,8 @@
// Resolve the type parameter to its instantiated type and tail call the
// instantiated type's TTS.
__ LoadFieldFromOffset(TypeTestABI::kScratchReg, TypeTestABI::kDstTypeReg,
- target::TypeParameter::index_offset(), kTwoBytes);
+ target::TypeParameter::index_offset(),
+ kUnsignedByte);
__ LoadIndexedCompressed(TypeTestABI::kScratchReg, tav,
target::TypeArguments::types_offset(),
TypeTestABI::kScratchReg);
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index 6d1de7d..dc9d048 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -1328,20 +1328,19 @@
intptr_t num_vars = function().NumTypeArguments();
type_params_names.Grow(num_vars);
type_params_names.SetLength(num_vars);
- TypeArguments& type_params = TypeArguments::Handle();
- TypeParameter& type_param = TypeParameter::Handle();
+ TypeParameters& type_params = TypeParameters::Handle();
Function& current = Function::Handle(function().ptr());
intptr_t mapping_offset = num_vars;
for (intptr_t i = 0; !current.IsNull(); i += current.NumTypeParameters(),
current = current.parent_function()) {
type_params = current.type_parameters();
+ if (type_params.IsNull()) continue;
intptr_t size = current.NumTypeParameters();
- ASSERT(size == 0 || type_params.Length() == size);
+ ASSERT(size > 0 && type_params.Length() == size);
ASSERT(mapping_offset >= size);
mapping_offset -= size;
for (intptr_t j = 0; j < size; ++j) {
- type_param = TypeParameter::RawCast(type_params.TypeAt(j));
- name = type_param.name();
+ name = type_params.NameAt(j);
// Write the names in backwards in terms of chain of functions.
// But keep the order of names within the same function. so they
// match up with the order of the types in 'type_arguments'.
diff --git a/runtime/vm/kernel.cc b/runtime/vm/kernel.cc
index 442f8ce..1256780 100644
--- a/runtime/vm/kernel.cc
+++ b/runtime/vm/kernel.cc
@@ -703,15 +703,13 @@
}
const auto& type_params =
- TypeArguments::Handle(zone, function.type_parameters());
+ TypeParameters::Handle(zone, function.type_parameters());
if (!type_params.IsNull()) {
- auto& type_param = TypeParameter::Handle(zone);
auto& bound = AbstractType::Handle(zone);
for (intptr_t i = 0, n = type_params.Length(); i < n; ++i) {
- type_param ^= type_params.TypeAt(i);
- bound = type_param.bound();
+ bound = type_params.BoundAt(i);
if (!bound.IsTopTypeForSubtyping() &&
- !type_param.IsGenericCovariantImpl()) {
+ !type_params.IsGenericCovariantImplAt(i)) {
return true;
}
}
diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc
index f48bdaf..4b39508 100644
--- a/runtime/vm/kernel_loader.cc
+++ b/runtime/vm/kernel_loader.cc
@@ -830,6 +830,18 @@
function.set_owner(real_class);
+ ASSERT(real_class.is_finalized());
+ // The owner class has already been marked as finalized so the signature of
+ // this added function must be finalized here, since finalization of member
+ // types will not be called anymore.
+ FunctionType& signature = FunctionType::Handle(Z, function.signature());
+ if (!function.is_static()) {
+ // Patch the illegal receiver type (type class with kIllegalCid) to dynamic.
+ signature.SetParameterTypeAt(0, Object::dynamic_type());
+ }
+ signature ^= ClassFinalizer::FinalizeType(signature);
+ function.set_signature(signature);
+
return function.ptr();
}
@@ -1425,7 +1437,9 @@
// Set type parameters.
T.LoadAndSetupTypeParameters(&active_class_, Object::null_function(), *klass,
Object::null_function_type(),
- type_parameter_count, klass->nnbd_mode());
+ type_parameter_count);
+
+ ActiveTypeParametersScope scope(&active_class_, nullptr, Z);
T.LoadAndSetupBounds(&active_class_, Object::null_function(), *klass,
Object::null_function_type(), type_parameter_count);
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 64be54c..b013c63 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -143,6 +143,7 @@
ClassPtr Object::class_class_ = static_cast<ClassPtr>(RAW_NULL);
ClassPtr Object::dynamic_class_ = static_cast<ClassPtr>(RAW_NULL);
ClassPtr Object::void_class_ = static_cast<ClassPtr>(RAW_NULL);
+ClassPtr Object::type_parameters_class_ = static_cast<ClassPtr>(RAW_NULL);
ClassPtr Object::type_arguments_class_ = static_cast<ClassPtr>(RAW_NULL);
ClassPtr Object::patch_class_class_ = static_cast<ClassPtr>(RAW_NULL);
ClassPtr Object::function_class_ = static_cast<ClassPtr>(RAW_NULL);
@@ -785,6 +786,9 @@
}
// Allocate the remaining VM internal classes.
+ cls = Class::New<TypeParameters, RTN::TypeParameters>(isolate_group);
+ type_parameters_class_ = cls.ptr();
+
cls = Class::New<TypeArguments, RTN::TypeArguments>(isolate_group);
type_arguments_class_ = cls.ptr();
@@ -1236,6 +1240,7 @@
class_class_ = static_cast<ClassPtr>(RAW_NULL);
dynamic_class_ = static_cast<ClassPtr>(RAW_NULL);
void_class_ = static_cast<ClassPtr>(RAW_NULL);
+ type_parameters_class_ = static_cast<ClassPtr>(RAW_NULL);
type_arguments_class_ = static_cast<ClassPtr>(RAW_NULL);
patch_class_class_ = static_cast<ClassPtr>(RAW_NULL);
function_class_ = static_cast<ClassPtr>(RAW_NULL);
@@ -1336,6 +1341,7 @@
SET_CLASS_NAME(class, Class);
SET_CLASS_NAME(dynamic, Dynamic);
SET_CLASS_NAME(void, Void);
+ SET_CLASS_NAME(type_parameters, TypeParameters);
SET_CLASS_NAME(type_arguments, TypeArguments);
SET_CLASS_NAME(patch_class, PatchClass);
SET_CLASS_NAME(function, Function);
@@ -2169,6 +2175,7 @@
type.SetIsFinalized();
type ^= type.Canonicalize(thread, nullptr);
object_store->set_null_type(type);
+ cls.set_declaration_type(type);
ASSERT(type.IsNullable());
// Consider removing when/if Null becomes an ordinary class.
@@ -3150,7 +3157,7 @@
untag()->set_library(value.ptr());
}
-void Class::set_type_parameters(const TypeArguments& value) const {
+void Class::set_type_parameters(const TypeParameters& value) const {
ASSERT((num_type_arguments() == kUnknownNumTypeArguments) ||
is_prefinalized());
untag()->set_type_parameters(value.ptr());
@@ -3185,11 +3192,11 @@
}
return 0;
}
- if (type_parameters() == TypeArguments::null()) {
+ if (type_parameters() == TypeParameters::null()) {
return 0;
}
REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
- TypeArguments& type_params = thread->TypeArgumentsHandle();
+ TypeParameters& type_params = thread->TypeParametersHandle();
type_params = type_parameters();
return type_params.Length();
}
@@ -3287,31 +3294,13 @@
#endif // defined(DART_PRECOMPILED_RUNTIME)
}
-static TypeArgumentsPtr InstantiateTypeArgumentsToBounds(
- Thread* thread,
- const TypeArguments& parameters) {
- ASSERT(thread != nullptr);
- if (parameters.IsNull()) {
- return Object::empty_type_arguments().ptr();
- }
- auto const zone = thread->zone();
- const auto& result = TypeArguments::Handle(
- zone, TypeArguments::New(parameters.Length(), Heap::kNew));
- auto& param = TypeParameter::Handle(zone);
- auto& type = AbstractType::Handle(zone);
- for (intptr_t i = 0, n = parameters.Length(); i < n; i++) {
- param ^= parameters.TypeAt(i);
- type = param.default_argument();
- ASSERT(type.IsFinalized());
- result.SetTypeAt(i, type);
- }
- return result.Canonicalize(thread);
-}
-
TypeArgumentsPtr Class::InstantiateToBounds(Thread* thread) const {
const auto& type_params =
- TypeArguments::Handle(thread->zone(), type_parameters());
- return InstantiateTypeArgumentsToBounds(thread, type_params);
+ TypeParameters::Handle(thread->zone(), type_parameters());
+ if (type_params.IsNull()) {
+ return Object::empty_type_arguments().ptr();
+ }
+ return type_params.defaults();
}
ClassPtr Class::SuperClass(bool original_classes) const {
@@ -3339,28 +3328,19 @@
untag()->set_super_type(value.ptr());
}
-TypeParameterPtr Class::LookupTypeParameter(const String& type_name) const {
- ASSERT(!type_name.IsNull());
- Thread* thread = Thread::Current();
- REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
- REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread);
- REUSABLE_STRING_HANDLESCOPE(thread);
- TypeArguments& type_params = thread->TypeArgumentsHandle();
- TypeParameter& type_param = thread->TypeParameterHandle();
- String& type_param_name = thread->StringHandle();
-
- type_params = type_parameters();
- if (!type_params.IsNull()) {
- const intptr_t num_type_params = type_params.Length();
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- type_param_name = type_param.name();
- if (type_param_name.Equals(type_name)) {
- return type_param.ptr();
- }
- }
+TypeParameterPtr Class::TypeParameterAt(intptr_t index,
+ Nullability nullability) const {
+ ASSERT(index >= 0 && index < NumTypeParameters());
+ const TypeParameters& type_params = TypeParameters::Handle(type_parameters());
+ const TypeArguments& bounds = TypeArguments::Handle(type_params.bounds());
+ const AbstractType& bound = AbstractType::Handle(
+ bounds.IsNull() ? Type::DynamicType() : bounds.TypeAt(index));
+ TypeParameter& type_param = TypeParameter::Handle(
+ TypeParameter::New(*this, 0, index, bound, nullability));
+ if (is_type_finalized()) {
+ type_param ^= ClassFinalizer::FinalizeType(type_param);
}
- return TypeParameter::null();
+ return type_param.ptr();
}
UnboxedFieldBitmap Class::CalculateFieldOffsets() const {
@@ -3401,9 +3381,7 @@
// parameterized, introduce a new type_arguments field.
if (host_type_args_field_offset == kNoTypeArguments) {
ASSERT(target_type_args_field_offset == RTN::Class::kNoTypeArguments);
- const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
- if (!type_params.IsNull()) {
- ASSERT(type_params.Length() > 0);
+ if (IsGeneric()) {
// The instance needs a type_arguments field.
host_type_args_field_offset = host_offset;
target_type_args_field_offset = target_offset;
@@ -4867,6 +4845,8 @@
return Symbols::Never().ToCString();
case kClassCid:
return Symbols::Class().ToCString();
+ case kTypeParametersCid:
+ return Symbols::TypeParameters().ToCString();
case kTypeArgumentsCid:
return Symbols::TypeArguments().ToCString();
case kPatchClassCid:
@@ -5193,9 +5173,18 @@
// DeclarationType without checking its nullability. Therefore, we
// consistently cache the kNonNullable version of the type.
// The exception is type Null which is stored as kNullable.
+ TypeArguments& type_args = TypeArguments::Handle();
+ const intptr_t num_type_params = NumTypeParameters();
+ if (num_type_params > 0) {
+ type_args = TypeArguments::New(num_type_params);
+ TypeParameter& type_param = TypeParameter::Handle();
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ type_param = TypeParameterAt(i);
+ type_args.SetTypeAt(i, type_param);
+ }
+ }
Type& type =
- Type::Handle(Type::New(*this, TypeArguments::Handle(type_parameters()),
- Nullability::kNonNullable));
+ Type::Handle(Type::New(*this, type_args, Nullability::kNonNullable));
type ^= ClassFinalizer::FinalizeType(type);
set_declaration_type(type);
return type.ptr();
@@ -6019,6 +6008,191 @@
return result;
}
+intptr_t TypeParameters::Length() const {
+ if (IsNull() || untag()->names() == Array::null()) return 0;
+ return Smi::Value(untag()->names()->untag()->length());
+}
+
+void TypeParameters::set_names(const Array& value) const {
+ ASSERT(!value.IsNull());
+ untag()->set_names(value.ptr());
+}
+
+StringPtr TypeParameters::NameAt(intptr_t index) const {
+ const Array& names_array = Array::Handle(names());
+ return String::RawCast(names_array.At(index));
+}
+
+void TypeParameters::SetNameAt(intptr_t index, const String& value) const {
+ const Array& names_array = Array::Handle(names());
+ names_array.SetAt(index, value);
+}
+
+void TypeParameters::set_flags(const Array& value) const {
+ untag()->set_flags(value.ptr());
+}
+
+void TypeParameters::set_bounds(const TypeArguments& value) const {
+ // A null value represents a vector of dynamic.
+ untag()->set_bounds(value.ptr());
+}
+
+AbstractTypePtr TypeParameters::BoundAt(intptr_t index) const {
+ const TypeArguments& upper_bounds = TypeArguments::Handle(bounds());
+ return upper_bounds.IsNull() ? Type::DynamicType()
+ : upper_bounds.TypeAt(index);
+}
+
+void TypeParameters::SetBoundAt(intptr_t index,
+ const AbstractType& value) const {
+ const TypeArguments& upper_bounds = TypeArguments::Handle(bounds());
+ upper_bounds.SetTypeAt(index, value);
+}
+
+bool TypeParameters::AllDynamicBounds() const {
+ return bounds() == TypeArguments::null();
+}
+
+void TypeParameters::set_defaults(const TypeArguments& value) const {
+ // The null value represents a vector of dynamic.
+ untag()->set_defaults(value.ptr());
+}
+
+AbstractTypePtr TypeParameters::DefaultAt(intptr_t index) const {
+ const TypeArguments& default_type_args = TypeArguments::Handle(defaults());
+ return default_type_args.IsNull() ? Type::DynamicType()
+ : default_type_args.TypeAt(index);
+}
+
+void TypeParameters::SetDefaultAt(intptr_t index,
+ const AbstractType& value) const {
+ const TypeArguments& default_type_args = TypeArguments::Handle(defaults());
+ default_type_args.SetTypeAt(index, value);
+}
+
+bool TypeParameters::AllDynamicDefaults() const {
+ return defaults() == TypeArguments::null();
+}
+
+void TypeParameters::AllocateFlags(Heap::Space space) const {
+ const intptr_t len = (Length() + kFlagsPerSmiMask) >> kFlagsPerSmiShift;
+ const Array& flags_array = Array::Handle(Array::New(len, space));
+ // Initialize flags to 0.
+ const Smi& zero = Smi::Handle(Smi::New(0));
+ for (intptr_t i = 0; i < len; i++) {
+ flags_array.SetAt(i, zero);
+ }
+ set_flags(flags_array);
+}
+
+void TypeParameters::OptimizeFlags() const {
+ if (untag()->flags() == Array::null()) return; // Already optimized.
+ const intptr_t len = (Length() + kFlagsPerSmiMask) >> kFlagsPerSmiShift;
+ const Array& flags_array = Array::Handle(flags());
+ const Smi& zero = Smi::Handle(Smi::New(0));
+ for (intptr_t i = 0; i < len; i++) {
+ if (flags_array.At(i) != zero.ptr()) return;
+ }
+ set_flags(Object::null_array());
+}
+
+bool TypeParameters::IsGenericCovariantImplAt(intptr_t index) const {
+ if (untag()->flags() == Array::null()) return false;
+ const intptr_t flag = Smi::Value(
+ Smi::RawCast(Array::Handle(flags()).At(index >> kFlagsPerSmiShift)));
+ return (flag >> (index & kFlagsPerSmiMask)) != 0;
+}
+
+void TypeParameters::SetIsGenericCovariantImplAt(intptr_t index,
+ bool value) const {
+ const Array& flg = Array::Handle(flags());
+ intptr_t flag = Smi::Value(Smi::RawCast(flg.At(index >> kFlagsPerSmiShift)));
+ if (value) {
+ flag |= 1 << (index % kFlagsPerSmiMask);
+ } else {
+ flag &= ~(1 << (index % kFlagsPerSmiMask));
+ }
+ flg.SetAt(index >> kFlagsPerSmiShift, Smi::Handle(Smi::New(flag)));
+}
+
+void TypeParameters::Print(Thread* thread,
+ Zone* zone,
+ bool are_class_type_parameters,
+ intptr_t base,
+ NameVisibility name_visibility,
+ BaseTextBuffer* printer) const {
+ String& name = String::Handle(zone);
+ AbstractType& type = AbstractType::Handle(zone);
+ const intptr_t num_type_params = Length();
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ if (are_class_type_parameters) {
+ name = NameAt(i);
+ printer->AddString(name.ToCString());
+ } else {
+ printer->AddString(TypeParameter::CanonicalNameCString(
+ are_class_type_parameters, base, base + i));
+ }
+ if (!AllDynamicBounds()) {
+ type = BoundAt(i);
+ // Do not print default bound or non-nullable Object bound in weak mode.
+ if (!type.IsNull() &&
+ (!type.IsObjectType() ||
+ (thread->isolate_group()->null_safety() && type.IsNonNullable()))) {
+ printer->AddString(" extends ");
+ type.PrintName(name_visibility, printer);
+ if (FLAG_show_internal_names && !AllDynamicDefaults()) {
+ type = DefaultAt(i);
+ if (!type.IsNull() && !type.IsDynamicType()) {
+ printer->AddString(" defaults to ");
+ type.PrintName(name_visibility, printer);
+ }
+ }
+ }
+ }
+ if (i != num_type_params - 1) {
+ printer->AddString(", ");
+ }
+ }
+}
+
+const char* TypeParameters::ToCString() const {
+ if (IsNull()) {
+ return "TypeParameters: null";
+ }
+ auto thread = Thread::Current();
+ auto zone = thread->zone();
+ ZoneTextBuffer buffer(zone);
+ buffer.AddString("TypeParameters: ");
+ Print(thread, zone, true, 0, kInternalName, &buffer);
+ return buffer.buffer();
+}
+
+TypeParametersPtr TypeParameters::New(Heap::Space space) {
+ ASSERT(Object::type_parameters_class() != Class::null());
+ ObjectPtr ptr = Object::Allocate(TypeParameters::kClassId,
+ TypeParameters::InstanceSize(), space,
+ /*compressed*/ false);
+ return static_cast<TypeParametersPtr>(ptr);
+}
+
+TypeParametersPtr TypeParameters::New(intptr_t count, Heap::Space space) {
+ const TypeParameters& result =
+ TypeParameters::Handle(TypeParameters::New(space));
+ // Create an [ Array ] of [ String ] objects to represent the names.
+ // Create a [ TypeArguments ] vector representing the bounds.
+ // Create a [ TypeArguments ] vector representing the defaults.
+ // Create an [ Array ] of [ Smi] objects to represent the flags.
+ const Array& names_array = Array::Handle(Array::New(count, space));
+ result.set_names(names_array);
+ TypeArguments& type_args = TypeArguments::Handle();
+ type_args = TypeArguments::New(count, Heap::kNew); // Will get canonicalized.
+ result.set_bounds(type_args);
+ type_args = TypeArguments::New(count, Heap::kNew); // Will get canonicalized.
+ result.set_defaults(type_args);
+ result.AllocateFlags(space); // Will get optimized.
+ return result.ptr();
+}
+
intptr_t TypeArguments::ComputeNullability() const {
if (IsNull()) return 0;
const intptr_t num_types = Length();
@@ -7143,97 +7317,47 @@
TypeArgumentsPtr Function::InstantiateToBounds(
Thread* thread,
DefaultTypeArgumentsKind* kind_out) const {
- if (CachesDefaultTypeArguments()) {
- // Always use the cached version, even if the type parameters are null,
- // to catch cases where the cache isn't properly initialized.
- return default_type_arguments(kind_out);
- }
- // No cached version, so just retrieve from the type parameters and return
- // a canonicalized version..
- if (type_parameters() == TypeArguments::null()) {
+ if (type_parameters() == TypeParameters::null()) {
if (kind_out != nullptr) {
*kind_out = DefaultTypeArgumentsKind::kIsInstantiated;
}
return Object::empty_type_arguments().ptr();
}
- auto& result = TypeArguments::Handle(thread->zone(), type_parameters());
- result = InstantiateTypeArgumentsToBounds(thread, result);
+ auto& type_params = TypeParameters::Handle(thread->zone(), type_parameters());
+ auto& result = TypeArguments::Handle(thread->zone(), type_params.defaults());
if (kind_out != nullptr) {
- // We just return is/is not instantiated if the value isn't cached, as
- // the other checks may be more overhead at runtime than just doing the
- // instantiation.
- *kind_out = result.IsNull() || result.IsInstantiated()
- ? DefaultTypeArgumentsKind::kIsInstantiated
- : DefaultTypeArgumentsKind::kNeedsInstantiation;
+ if (IsClosureFunction()) {
+ *kind_out = default_type_arguments_kind();
+ } else {
+ // We just return is/is not instantiated if the value isn't cached, as
+ // the other checks may be more overhead at runtime than just doing the
+ // instantiation.
+ *kind_out = result.IsNull() || result.IsInstantiated()
+ ? DefaultTypeArgumentsKind::kIsInstantiated
+ : DefaultTypeArgumentsKind::kNeedsInstantiation;
+ }
}
return result.ptr();
}
-void Function::UpdateCachedDefaultTypeArguments(Thread* thread) const {
- auto const zone = thread->zone();
- auto& closure_function = Function::Handle(zone);
- if (HasImplicitClosureFunction()) {
- closure_function = ImplicitClosureFunction();
- }
- if (CachesDefaultTypeArguments()) {
- auto defaults = &Object::empty_type_arguments();
- const FunctionType& sig = FunctionType::Handle(zone, signature());
- if (sig.NumTypeParameters(thread) > 0) {
- const auto& params = TypeArguments::Handle(zone, sig.type_parameters());
- const intptr_t num_params = params.Length();
- auto& new_defaults = TypeArguments::Handle(
- zone, TypeArguments::New(num_params, Heap::kNew));
- // Only canonicalize the result if all the default arguments have been
- // canonicalized, to avoid premature canonicalization of the arguments.
- bool all_canonical = true;
- auto& type = AbstractType::Handle(zone);
- for (intptr_t i = 0; i < num_params; i++) {
- type = params.TypeAt(i);
- type = TypeParameter::Cast(type).default_argument();
- if (!type.IsCanonical()) {
- all_canonical = false;
- }
- new_defaults.SetTypeAt(i, type);
- }
- if (all_canonical) {
- new_defaults = new_defaults.Canonicalize(thread);
- }
- defaults = &new_defaults;
- }
- set_default_type_arguments(*defaults);
- if (!closure_function.IsNull()) {
- closure_function.set_default_type_arguments(*defaults);
- }
- } else if (!closure_function.IsNull()) {
- closure_function.UpdateCachedDefaultTypeArguments(thread);
- }
-}
-
-TypeArgumentsPtr Function::default_type_arguments(
- DefaultTypeArgumentsKind* kind_out) const {
- if (!CachesDefaultTypeArguments()) {
+Function::DefaultTypeArgumentsKind Function::default_type_arguments_kind()
+ const {
+ if (!IsClosureFunction()) {
UNREACHABLE();
}
const auto& closure_data = ClosureData::Handle(ClosureData::RawCast(data()));
ASSERT(!closure_data.IsNull());
- if (kind_out != nullptr) {
- *kind_out = closure_data.default_type_arguments_kind();
- }
- return closure_data.default_type_arguments();
+ return closure_data.default_type_arguments_kind();
}
-void Function::set_default_type_arguments(const TypeArguments& value) const {
- if (!CachesDefaultTypeArguments()) {
+void Function::set_default_type_arguments_kind(
+ Function::DefaultTypeArgumentsKind value) const {
+ if (!IsClosureFunction()) {
UNREACHABLE();
}
const auto& closure_data = ClosureData::Handle(ClosureData::RawCast(data()));
ASSERT(!closure_data.IsNull());
- auto kind = DefaultTypeArgumentsKindFor(value);
- ASSERT(kind != DefaultTypeArgumentsKind::kInvalid);
- closure_data.set_default_type_arguments_kind(kind);
- // We could just store null for the ksharesFunction/kSharesInstantiator cases,
- // assuming all clients retrieve the DefaultTypeArgumentsKind to distinguish.
- closure_data.set_default_type_arguments(value);
+ closure_data.set_default_type_arguments_kind(value);
}
Function::DefaultTypeArgumentsKind Function::DefaultTypeArgumentsKindFor(
@@ -7512,10 +7636,32 @@
untag()->set_signature(value.ptr());
if (!value.IsNull()) {
ASSERT(NumImplicitParameters() == value.num_implicit_parameters());
- UpdateCachedDefaultTypeArguments(Thread::Current());
+ if (IsClosureFunction() && value.IsGeneric()) {
+ const TypeParameters& type_params =
+ TypeParameters::Handle(value.type_parameters());
+ const TypeArguments& defaults =
+ TypeArguments::Handle(type_params.defaults());
+ auto kind = DefaultTypeArgumentsKindFor(defaults);
+ ASSERT(kind != DefaultTypeArgumentsKind::kInvalid);
+ set_default_type_arguments_kind(kind);
+ }
}
}
+TypeParameterPtr FunctionType::TypeParameterAt(intptr_t index,
+ Nullability nullability) const {
+ ASSERT(index >= 0 && index < NumTypeParameters());
+ const TypeParameters& type_params = TypeParameters::Handle(type_parameters());
+ const AbstractType& bound = AbstractType::Handle(type_params.BoundAt(index));
+ TypeParameter& type_param = TypeParameter::Handle(
+ TypeParameter::New(Object::null_class(), NumParentTypeArguments(),
+ NumParentTypeArguments() + index, bound, nullability));
+ if (IsFinalized()) {
+ type_param ^= ClassFinalizer::FinalizeType(type_param);
+ }
+ return type_param.ptr();
+}
+
void FunctionType::set_result_type(const AbstractType& value) const {
ASSERT(!value.IsNull());
untag()->set_result_type(value.ptr());
@@ -7703,7 +7849,7 @@
}
}
-void FunctionType::set_type_parameters(const TypeArguments& value) const {
+void FunctionType::set_type_parameters(const TypeParameters& value) const {
untag()->set_type_parameters(value.ptr());
}
@@ -7747,11 +7893,11 @@
}
intptr_t FunctionType::NumTypeParameters(Thread* thread) const {
- if (type_parameters() == TypeArguments::null()) {
+ if (type_parameters() == TypeParameters::null()) {
return 0;
}
- REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
- TypeArguments& type_params = thread->TypeArgumentsHandle();
+ REUSABLE_TYPE_PARAMETERS_HANDLESCOPE(thread);
+ TypeParameters& type_params = thread->TypeParametersHandle();
type_params = type_parameters();
// We require null to represent a non-generic signature.
ASSERT(type_params.Length() != 0);
@@ -7764,45 +7910,10 @@
return FunctionType::Handle(signature()).NumParentTypeArguments();
}
-TypeParameterPtr Function::LookupTypeParameter(const String& type_name,
- intptr_t* function_level) const {
- ASSERT(!type_name.IsNull());
- Thread* thread = Thread::Current();
- REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
- REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread);
- REUSABLE_STRING_HANDLESCOPE(thread);
- REUSABLE_FUNCTION_HANDLESCOPE(thread);
- TypeArguments& type_params = thread->TypeArgumentsHandle();
- TypeParameter& type_param = thread->TypeParameterHandle();
- String& type_param_name = thread->StringHandle();
- Function& function = thread->FunctionHandle();
-
- function = this->ptr();
- while (!function.IsNull()) {
- if (function.signature() != FunctionType::null()) {
- type_params = function.type_parameters();
- if (!type_params.IsNull()) {
- const intptr_t num_type_params = type_params.Length();
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- type_param_name = type_param.name();
- if (type_param_name.Equals(type_name)) {
- return type_param.ptr();
- }
- }
- }
- }
- if (function.IsImplicitClosureFunction()) {
- // The parent function is not the enclosing function, but the closurized
- // function with identical type parameters.
- break;
- }
- function = function.parent_function();
- if (function_level != NULL) {
- (*function_level)--;
- }
- }
- return TypeParameter::null();
+TypeParameterPtr Function::TypeParameterAt(intptr_t index,
+ Nullability nullability) const {
+ const FunctionType& sig = FunctionType::Handle(signature());
+ return sig.TypeParameterAt(index, nullability);
}
void Function::set_kind(UntaggedFunction::Kind value) const {
@@ -8084,7 +8195,6 @@
const Function& function,
const Instance& receiver,
const TypeArguments& instantiator_type_args,
- const TypeArguments& type_params,
const Array& args,
const ArgumentsDescriptor& args_desc) {
ASSERT(!function.IsNull());
@@ -8216,11 +8326,10 @@
receiver ^= args.At(args_desc.FirstArgIndex());
}
- const auto& params = TypeArguments::Handle(zone, type_parameters());
const auto& function_type_arguments = TypeArguments::Handle(
zone, RetrieveFunctionTypeArguments(thread, zone, *this, receiver,
- instantiator_type_arguments, params,
- args, args_desc));
+ instantiator_type_arguments, args,
+ args_desc));
return Function::DoArgumentTypesMatch(
args, args_desc, instantiator_type_arguments, function_type_arguments);
}
@@ -8246,23 +8355,29 @@
const intptr_t kNumParentTypeArgs = NumParentTypeArguments();
ASSERT(function_type_arguments.HasCount(kNumParentTypeArgs +
kNumLocalTypeArgs));
- const auto& params = TypeArguments::Handle(zone, type_parameters());
- auto& parameter = TypeParameter::Handle(zone);
- auto& type = AbstractType::Handle(zone);
- auto& bound = AbstractType::Handle(zone);
- for (intptr_t i = 0; i < kNumLocalTypeArgs; i++) {
- parameter ^= params.TypeAt(i);
- type = parameter.ptr();
- bound = parameter.bound();
- // Only perform non-covariant checks where the bound is not the top type.
- if (parameter.IsGenericCovariantImpl() || bound.IsTopTypeForSubtyping()) {
- continue;
- }
- if (!AbstractType::InstantiateAndTestSubtype(&type, &bound,
- instantiator_type_arguments,
- function_type_arguments)) {
- const auto& name = String::Handle(zone, parameter.name());
- return Error::RawCast(ThrowTypeError(token_pos(), type, bound, name));
+ const auto& params = TypeParameters::Handle(zone, type_parameters());
+ // No checks are needed if all bounds are dynamic.
+ if (!params.AllDynamicBounds()) {
+ auto& param = AbstractType::Handle(zone);
+ auto& bound = AbstractType::Handle(zone);
+ for (intptr_t i = 0; i < kNumLocalTypeArgs; i++) {
+ bound = params.BoundAt(i);
+ // Only perform non-covariant checks where the bound is not
+ // the top type.
+ if (params.IsGenericCovariantImplAt(i) ||
+ bound.IsTopTypeForSubtyping()) {
+ continue;
+ }
+ param = TypeParameterAt(i);
+ if (!AbstractType::InstantiateAndTestSubtype(
+ ¶m, &bound, instantiator_type_arguments,
+ function_type_arguments)) {
+ const auto& names = Array::Handle(zone, params.names());
+ auto& name = String::Handle(zone);
+ name ^= names.At(i);
+ return Error::RawCast(
+ ThrowTypeError(token_pos(), param, bound, name));
+ }
}
}
} else {
@@ -8482,49 +8597,35 @@
FunctionType::New(remaining_parent_type_params, nullability(), space));
AbstractType& type = AbstractType::Handle(zone);
- // Copy the type parameters and instantiate their bounds (if necessary).
+ // Copy the type parameters and instantiate their bounds and defaults.
if (!delete_type_parameters) {
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, type_parameters());
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, type_parameters());
if (!type_params.IsNull()) {
- TypeArguments& instantiated_type_params = TypeArguments::Handle(zone);
- TypeParameter& type_param = TypeParameter::Handle(zone);
- String& param_name = String::Handle(zone);
- for (intptr_t i = 0; i < type_params.Length(); ++i) {
- type_param ^= type_params.TypeAt(i);
- ASSERT(type_param.index() == num_parent_type_args + i);
- type = type_param.bound();
- if (!type.IsInstantiated(kAny, num_free_fun_type_params)) {
- type = type.InstantiateFrom(instantiator_type_arguments,
- function_type_arguments,
- num_free_fun_type_params, space, trail);
- // A returned null type indicates a failed instantiation in dead code
- // that must be propagated up to the caller, the optimizing compiler.
- if (type.IsNull()) {
- return FunctionType::null();
- }
- ASSERT(type_param.IsFinalized());
- param_name = type_param.name();
- type_param = TypeParameter::New(
- Object::null_class(), type_param.base(), type_param.index(),
- param_name, type, type_param.IsGenericCovariantImpl(),
- type_param.nullability());
- type_param.SetIsFinalized();
- if (instantiated_type_params.IsNull()) {
- instantiated_type_params = TypeArguments::New(type_params.Length());
- for (intptr_t j = 0; j < i; ++j) {
- type = type_params.TypeAt(j);
- instantiated_type_params.SetTypeAt(j, type);
- }
- }
- instantiated_type_params.SetTypeAt(i, type_param);
- } else if (!instantiated_type_params.IsNull()) {
- instantiated_type_params.SetTypeAt(i, type_param);
- }
+ const TypeParameters& sig_type_params =
+ TypeParameters::Handle(zone, TypeParameters::New());
+ // No need to set names that are ignored in a signature, however, the
+ // length of the names array defines the number of type parameters.
+ sig_type_params.set_names(Array::Handle(zone, type_params.names()));
+ sig_type_params.set_flags(Array::Handle(zone, type_params.flags()));
+ TypeArguments& type_args = TypeArguments::Handle(zone);
+ type_args = type_params.bounds();
+ if (!type_args.IsNull() &&
+ !type_args.IsInstantiated(kAny, num_free_fun_type_params)) {
+ type_args = type_args.InstantiateFrom(
+ instantiator_type_arguments, function_type_arguments,
+ num_free_fun_type_params, space, trail);
}
- sig.set_type_parameters(instantiated_type_params.IsNull()
- ? type_params
- : instantiated_type_params);
+ sig_type_params.set_bounds(type_args);
+ type_args = type_params.defaults();
+ if (!type_args.IsNull() &&
+ !type_args.IsInstantiated(kAny, num_free_fun_type_params)) {
+ type_args = type_args.InstantiateFrom(
+ instantiator_type_arguments, function_type_arguments,
+ num_free_fun_type_params, space, trail);
+ }
+ sig_type_params.set_defaults(type_args);
+ sig.set_type_parameters(sig_type_params);
}
}
@@ -8607,20 +8708,56 @@
return false;
}
if (num_type_params > 0) {
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, type_parameters());
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, type_parameters());
ASSERT(!type_params.IsNull());
- const TypeArguments& other_type_params =
- TypeArguments::Handle(zone, other.type_parameters());
+ const TypeParameters& other_type_params =
+ TypeParameters::Handle(zone, other.type_parameters());
ASSERT(!other_type_params.IsNull());
- TypeParameter& type_param = TypeParameter::Handle(zone);
- TypeParameter& other_type_param = TypeParameter::Handle(zone);
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- other_type_param ^= other_type_params.TypeAt(i);
- if (!type_param.IsEquivalent(other_type_param, kind, trail)) {
+ if (kind == TypeEquality::kInSubtypeTest) {
+ if (!type_params.AllDynamicBounds() ||
+ !other_type_params.AllDynamicBounds()) {
+ AbstractType& bound = AbstractType::Handle(zone);
+ AbstractType& other_bound = AbstractType::Handle(zone);
+ for (intptr_t i = 0; i < num_type_params; i++) {
+ bound = type_params.BoundAt(i);
+ other_bound = other_type_params.BoundAt(i);
+ // Bounds that are mutual subtypes are considered equal.
+ if (!bound.IsSubtypeOf(other_bound, Heap::kOld) ||
+ !other_bound.IsSubtypeOf(bound, Heap::kOld)) {
+ return false;
+ }
+ }
+ }
+ } else {
+ if (NumParentTypeArguments() != other.NumParentTypeArguments()) {
return false;
}
+ const TypeArguments& bounds =
+ TypeArguments::Handle(zone, type_params.bounds());
+ const TypeArguments& other_bounds =
+ TypeArguments::Handle(zone, other_type_params.bounds());
+ if (!bounds.IsEquivalent(other_bounds, kind, trail)) {
+ return false;
+ }
+ if (kind == TypeEquality::kCanonical) {
+ // Compare default arguments.
+ const TypeArguments& defaults =
+ TypeArguments::Handle(zone, type_params.defaults());
+ const TypeArguments& other_defaults =
+ TypeArguments::Handle(zone, other_type_params.defaults());
+ if (defaults.IsNull()) {
+ if (!other_defaults.IsNull()) {
+ return false;
+ }
+ } else if (!defaults.IsEquivalent(other_defaults, kind, trail)) {
+ return false;
+ }
+ }
+ }
+ // Compare flags (IsGenericCovariantImpl).
+ if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
+ return false;
}
}
return true;
@@ -8812,11 +8949,6 @@
// in new space.
ASSERT(space == Heap::kOld);
}
- if (result.CachesDefaultTypeArguments()) {
- // Make sure the default type arguments are set consistently with the
- // function type parameters (currently null).
- result.set_default_type_arguments(Object::empty_type_arguments());
- }
// Force-optimized functions are not debuggable because they cannot
// deoptimize.
@@ -8932,9 +9064,8 @@
// Its implicit closure function therefore has no generic parent function
// either. That is why it is safe to simply copy the type parameters.
closure_signature.set_type_parameters(
- TypeArguments::Handle(zone, type_parameters()));
+ TypeParameters::Handle(zone, type_parameters()));
closure_function.SetNumTypeParameters(NumTypeParameters());
- closure_function.UpdateCachedDefaultTypeArguments(thread);
// Set closure function's result type to this result type.
closure_signature.set_result_type(AbstractType::Handle(zone, result_type()));
@@ -9168,39 +9299,15 @@
}
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
- auto isolate_group = thread->isolate_group();
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, type_parameters());
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, type_parameters());
if (!type_params.IsNull()) {
- const intptr_t num_type_params = type_params.Length();
- ASSERT(num_type_params > 0);
- TypeParameter& type_param = TypeParameter::Handle(zone);
- String& name = String::Handle(zone);
- AbstractType& bound = AbstractType::Handle(zone);
printer->AddString("<");
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- name = type_param.name();
- printer->AddString(name.ToCString());
- bound = type_param.bound();
- // Do not print default bound or non-nullable Object bound in weak mode.
- if (!bound.IsNull() &&
- (!bound.IsObjectType() ||
- (isolate_group->null_safety() && bound.IsNonNullable()))) {
- printer->AddString(" extends ");
- bound.PrintName(name_visibility, printer);
- if (FLAG_show_internal_names) {
- bound = type_param.default_argument();
- if (!bound.IsNull() && !bound.IsDynamicType()) {
- printer->AddString(" defaults to ");
- bound.PrintName(name_visibility, printer);
- }
- }
- }
- if (i < num_type_params - 1) {
- printer->AddString(", ");
- }
- }
+ const intptr_t base = NumParentTypeArguments();
+ const bool kIsClassTypeParameter = false;
+ // Type parameter names are meaningless after canonicalization.
+ type_params.Print(thread, zone, kIsClassTypeParameter, base,
+ name_visibility, printer);
printer->AddString(">");
}
printer->AddString("(");
@@ -9248,13 +9355,16 @@
return false;
}
}
- TypeArguments& type_params = TypeArguments::Handle(type_parameters());
- TypeParameter& type_param = TypeParameter::Handle();
- for (intptr_t i = 0; i < type_params.Length(); ++i) {
- type_param ^= type_params.TypeAt(i);
- type = type_param.bound();
- if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) {
- return false;
+ const intptr_t num_type_params = NumTypeParameters();
+ if (num_type_params > 0) {
+ TypeParameters& type_params = TypeParameters::Handle(type_parameters());
+ if (!type_params.AllDynamicBounds()) {
+ for (intptr_t i = 0; i < type_params.Length(); ++i) {
+ type = type_params.BoundAt(i);
+ if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) {
+ return false;
+ }
+ }
}
}
return true;
@@ -9948,10 +10058,6 @@
value, *original));
}
-void ClosureData::set_default_type_arguments(const TypeArguments& value) const {
- untag()->set_default_type_arguments(value.ptr());
-}
-
ClosureData::DefaultTypeArgumentsKind ClosureData::default_type_arguments_kind()
const {
return LoadNonPointer(&untag()->default_type_arguments_kind_);
@@ -9986,13 +10092,6 @@
}
buffer.Printf(" implicit_static_closure: 0x%" Px "",
static_cast<uword>(implicit_static_closure()));
- buffer.AddString(" default_type_arguments: ");
- if (default_type_arguments() == TypeArguments::null()) {
- buffer.AddString("null");
- } else {
- buffer.AddString(
- TypeArguments::Handle(zone, default_type_arguments()).ToCString());
- }
return buffer.buffer();
}
@@ -19576,16 +19675,9 @@
} else {
const intptr_t len = (*trail)->length();
ASSERT((len % 2) == 0);
- const bool this_is_typeref = IsTypeRef();
- const bool buddy_is_typeref = buddy.IsTypeRef();
- // Note that at least one of 'this' and 'buddy' should be a typeref, with
- // one exception, when the class of the 'this' type implements the 'call'
- // method, thereby possibly creating a recursive type (see regress_29405).
for (intptr_t i = 0; i < len; i += 2) {
- if ((((*trail)->At(i).ptr() == this->ptr()) ||
- (buddy_is_typeref && (*trail)->At(i).Equals(*this))) &&
- (((*trail)->At(i + 1).ptr() == buddy.ptr()) ||
- (this_is_typeref && (*trail)->At(i + 1).Equals(buddy)))) {
+ if ((*trail)->At(i).ptr() == this->ptr() &&
+ (*trail)->At(i + 1).ptr() == buddy.ptr()) {
return true;
}
}
@@ -19697,7 +19789,8 @@
Class& cls = Class::Handle(zone);
if (IsTypeParameter()) {
const TypeParameter& type_param = TypeParameter::Cast(*this);
- printer->AddString(String::Handle(type_param.name()).ToCString());
+ // Type parameter names are meaningless after canonicalization.
+ printer->AddString(type_param.CanonicalNameCString());
printer->AddString(NullabilitySuffix(name_visibility));
return;
}
@@ -19935,10 +20028,6 @@
}
const AbstractType& bound = AbstractType::Handle(zone, type_param.bound());
ASSERT(bound.IsFinalized());
- // Avoid cycles with F-bounded types.
- if (TestAndAddBuddyToTrail(&trail, other)) {
- return true;
- }
if (bound.IsSubtypeOf(other, space, trail)) {
return true;
}
@@ -20765,12 +20854,12 @@
AbstractType& type = AbstractType::Handle();
const intptr_t num_type_params = NumTypeParameters();
if (num_type_params > 0) {
- const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
- for (intptr_t i = 0; i < num_type_params; i++) {
- type = type_params.TypeAt(i);
- type = TypeParameter::Cast(type).bound();
- result = CombineHashes(result, type.Hash());
- }
+ const TypeParameters& type_params =
+ TypeParameters::Handle(type_parameters());
+ const TypeArguments& bounds = TypeArguments::Handle(type_params.bounds());
+ result = CombineHashes(result, bounds.Hash());
+ // Since the default arguments are ignored when comparing two generic
+ // function types for type equality, the hash does not depend on them.
}
type = result_type();
result = CombineHashes(result, type.Hash());
@@ -20859,17 +20948,20 @@
}
bool FunctionType::IsRecursive(TrailPtr trail) const {
- AbstractType& type = AbstractType::Handle();
- const intptr_t num_type_params = NumTypeParameters();
- if (num_type_params > 0) {
- const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
- for (intptr_t i = 0; i < num_type_params; i++) {
- type = type_params.TypeAt(i);
- if (type.IsRecursive(trail)) {
- return true;
- }
+ if (IsGeneric()) {
+ const TypeParameters& type_params =
+ TypeParameters::Handle(type_parameters());
+ TypeArguments& type_args = TypeArguments::Handle();
+ type_args = type_params.bounds();
+ if (type_args.IsRecursive(trail)) {
+ return true;
+ }
+ type_args = type_params.defaults();
+ if (type_args.IsRecursive(trail)) {
+ return true;
}
}
+ AbstractType& type = AbstractType::Handle();
type = result_type();
if (type.IsRecursive(trail)) {
return true;
@@ -20894,23 +20986,23 @@
// its signature.
return false;
}
- AbstractType& type = AbstractType::Handle(zone);
const intptr_t num_type_params = NumTypeParameters();
if (num_type_params > 0) {
- const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
- TypeParameter& type_param = TypeParameter::Handle(zone);
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- type = type_param.bound();
- if (type.RequireConstCanonicalTypeErasure(zone, trail)) {
- return true;
- }
- type = type_param.default_argument();
- if (type.RequireConstCanonicalTypeErasure(zone, trail)) {
- return true;
- }
+ const TypeParameters& type_params =
+ TypeParameters::Handle(type_parameters());
+ TypeArguments& type_args = TypeArguments::Handle();
+ type_args = type_params.bounds();
+ if (type_args.RequireConstCanonicalTypeErasure(zone, 0, num_type_params,
+ trail)) {
+ return true;
+ }
+ type_args = type_params.defaults();
+ if (type_args.RequireConstCanonicalTypeErasure(zone, 0, num_type_params,
+ trail)) {
+ return true;
}
}
+ AbstractType& type = AbstractType::Handle(zone);
type = result_type();
if (type.RequireConstCanonicalTypeErasure(zone, trail)) {
return true;
@@ -20932,18 +21024,19 @@
if (IsCanonical()) {
#ifdef DEBUG
// Verify that all fields are allocated in old space and are canonical.
- AbstractType& type = AbstractType::Handle(zone);
- const intptr_t num_type_params = NumTypeParameters();
- if (num_type_params > 0) {
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, type_parameters());
+ if (IsGeneric()) {
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, type_parameters());
ASSERT(type_params.IsOld());
- for (intptr_t i = 0; i < num_type_params; i++) {
- type = type_params.TypeAt(i);
- ASSERT(type.IsOld());
- ASSERT(type.IsCanonical());
- }
+ TypeArguments& type_args = TypeArguments::Handle(zone);
+ type_args = type_params.bounds();
+ ASSERT(type_args.IsOld());
+ ASSERT(type_args.IsCanonical());
+ type_args = type_params.defaults();
+ ASSERT(type_args.IsOld());
+ ASSERT(type_args.IsCanonical());
}
+ AbstractType& type = AbstractType::Handle(zone);
type = result_type();
ASSERT(type.IsOld());
ASSERT(type.IsCanonical());
@@ -20971,19 +21064,22 @@
if (sig.IsNull()) {
// The function type was not found in the table. It is not canonical yet.
// Canonicalize its type parameters and types.
- const intptr_t num_type_params = NumTypeParameters();
- if (num_type_params > 0) {
- const TypeArguments& type_params =
- TypeArguments::Handle(zone, type_parameters());
+ if (IsGeneric()) {
+ const TypeParameters& type_params =
+ TypeParameters::Handle(zone, type_parameters());
ASSERT(type_params.IsOld());
- TypeParameter& type_param = TypeParameter::Handle(zone);
- for (intptr_t i = 0; i < num_type_params; i++) {
- type_param ^= type_params.TypeAt(i);
- if (!type_param.IsCanonical()) {
- type_param ^= type_param.Canonicalize(thread, trail);
- type_params.SetTypeAt(i, type_param);
- SetHash(0);
- }
+ TypeArguments& type_args = TypeArguments::Handle(zone);
+ type_args = type_params.bounds();
+ if (!type_args.IsCanonical()) {
+ type_args = type_args.Canonicalize(thread, trail);
+ type_params.set_bounds(type_args);
+ SetHash(0);
+ }
+ type_args = type_params.defaults();
+ if (!type_args.IsCanonical()) {
+ type_args = type_args.Canonicalize(thread, trail);
+ type_params.set_defaults(type_args);
+ SetHash(0);
}
}
AbstractType& type = AbstractType::Handle(zone);
@@ -21135,7 +21231,7 @@
}
void TypeRef::set_type(const AbstractType& value) const {
- ASSERT(value.IsNull() || value.IsType() || value.IsFunctionType());
+ ASSERT(!value.IsTypeRef());
untag()->set_type(value.ptr());
}
@@ -21186,7 +21282,14 @@
// type arguments are set).
const AbstractType& ref_type = AbstractType::Handle(type());
ASSERT(!ref_type.IsNull());
- uint32_t result = ref_type.type_class_id();
+ uint32_t result;
+ if (ref_type.IsTypeParameter()) {
+ result = TypeParameter::Cast(ref_type).parameterized_class_id();
+ result = CombineHashes(result, TypeParameter::Cast(ref_type).index());
+ } else {
+ ASSERT(ref_type.IsType() || ref_type.IsFunctionType());
+ result = ref_type.type_class_id();
+ }
// A legacy type should have the same hash as its non-nullable version to be
// consistent with the definition of type equality in Dart code.
Nullability ref_type_nullability = ref_type.nullability();
@@ -21242,11 +21345,6 @@
UntaggedTypeParameter::BeingFinalizedBit::update(true, untag()->flags_));
}
-void TypeParameter::SetGenericCovariantImpl(bool value) const {
- set_flags(UntaggedTypeParameter::GenericCovariantImplBit::update(
- value, untag()->flags_));
-}
-
void TypeParameter::set_nullability(Nullability value) const {
StoreNonPointer(&untag()->nullability_, static_cast<uint8_t>(value));
}
@@ -21286,15 +21384,9 @@
}
// Although the type parameter is instantiated, its bound may not be.
const AbstractType& upper_bound = AbstractType::Handle(bound());
- ASSERT(!upper_bound.IsTypeRef());
- if (upper_bound.IsTypeParameter() || upper_bound.IsFunctionType() ||
- upper_bound.arguments() != TypeArguments::null()) {
- // Use trail to break cycles created by bound referring to type parameter.
- if (!TestAndAddToTrail(&trail) &&
- !upper_bound.IsInstantiated(genericity, num_free_fun_type_params,
- trail)) {
- return false;
- }
+ if (!upper_bound.IsInstantiated(genericity, num_free_fun_type_params,
+ trail)) {
+ return false;
}
return true;
}
@@ -21345,34 +21437,11 @@
index() != other_type_param.index()) {
return false;
}
- // Compare bounds.
- if (TestAndAddBuddyToTrail(&trail, other_type_param)) {
- return true;
- }
AbstractType& type = AbstractType::Handle(bound());
AbstractType& other_type = AbstractType::Handle(other_type_param.bound());
if (!type.IsEquivalent(other_type, kind, trail)) {
return false;
}
- if (kind == TypeEquality::kCanonical) {
- // Compare names.
- if (name() != other_type_param.name()) {
- return false;
- }
- // Compare default arguments.
- type = default_argument();
- other_type = other_type_param.default_argument();
- if (type.IsNull()) {
- if (!other_type.IsNull()) {
- return false;
- }
- } else if (!type.IsEquivalent(other_type, kind, trail)) {
- return false;
- }
- }
- }
- if (IsGenericCovariantImpl() != other_type_param.IsGenericCovariantImpl()) {
- return false;
}
} else {
if (!other_type_param.IsClassTypeParameter()) {
@@ -21385,8 +21454,7 @@
return false;
}
if (base() != other_type_param.base() ||
- index() != other_type_param.index() ||
- name() != other_type_param.name()) {
+ index() != other_type_param.index()) {
return false;
}
} else {
@@ -21394,10 +21462,6 @@
return false;
}
}
- // Compare bounds.
- if (TestAndAddBuddyToTrail(&trail, other_type_param)) {
- return true;
- }
AbstractType& upper_bound = AbstractType::Handle(bound());
AbstractType& other_type_param_upper_bound =
AbstractType::Handle(other_type_param.bound());
@@ -21433,16 +21497,7 @@
}
bool TypeParameter::IsRecursive(TrailPtr trail) const {
- if (TestAndAddToTrail(&trail)) {
- return true;
- }
- AbstractType& type = AbstractType::Handle();
- type = bound();
- if (type.IsRecursive(trail)) {
- return true;
- }
- type = default_argument();
- if (type.IsRecursive(trail)) {
+ if (AbstractType::Handle(bound()).IsRecursive(trail)) {
return true;
}
return false;
@@ -21486,21 +21541,11 @@
StoreNonPointer(&untag()->index_, value);
}
-void TypeParameter::set_name(const String& value) const {
- ASSERT(value.IsSymbol());
- untag()->set_name(value.ptr());
-}
-
void TypeParameter::set_bound(const AbstractType& value) const {
ASSERT(!IsCanonical());
untag()->set_bound(value.ptr());
}
-void TypeParameter::set_default_argument(const AbstractType& value) const {
- ASSERT(!IsCanonical());
- untag()->set_default_argument(value.ptr());
-}
-
AbstractTypePtr TypeParameter::GetFromTypeArguments(
const TypeArguments& instantiator_type_arguments,
const TypeArguments& function_type_arguments) const {
@@ -21526,13 +21571,6 @@
AbstractType& upper_bound = AbstractType::Handle(bound());
if (!upper_bound.IsInstantiated(kAny, num_free_fun_type_params,
nullptr)) {
- // Use trail to break cycles created by bound referring to type param.
- // The instantiation trail must contain pairs, so add itself as buddy.
- if (TestAndAddBuddyToTrail(&trail, *this)) {
- // If the type parameter is already in the trail, it is returned
- // unchanged here and will be processed when returning from recursion.
- return ptr();
- }
upper_bound = upper_bound.InstantiateFrom(
instantiator_type_arguments, function_type_arguments,
num_free_fun_type_params, space, trail);
@@ -21582,13 +21620,9 @@
if (IsCanonical()) {
#ifdef DEBUG
// Verify that all fields are allocated in old space and are canonical.
- AbstractType& type = AbstractType::Handle(zone);
- type = bound();
- ASSERT(type.IsOld());
- ASSERT(type.IsCanonical());
- type = default_argument();
- ASSERT(type.IsOld());
- ASSERT(type.IsCanonical());
+ const AbstractType& upper_bound = AbstractType::Handle(zone, bound());
+ ASSERT(upper_bound.IsOld());
+ ASSERT(upper_bound.IsCanonical() || upper_bound.IsTypeRef());
#endif
return this->ptr();
}
@@ -21603,33 +21637,15 @@
ASSERT(object_store->canonical_type_parameters() == table.Release().ptr());
}
if (type_parameter.IsNull()) {
- // The type parameter was not found in the table. It is not canonical yet.
- // Canonicalize its bound and default argument.
- // However, if the type parameter is already being canonicalized, it is part
- // of a cycle via its bound. Return it now and let the caller finish
- // canonicalizing it.
- if (TestAndAddToTrail(&trail)) {
- return ptr();
- }
- AbstractType& type = AbstractType::Handle(zone);
- type = bound();
- type = type.Canonicalize(thread, trail);
+ AbstractType& upper_bound = AbstractType::Handle(zone, bound());
+ upper_bound = upper_bound.Canonicalize(thread, trail);
if (IsCanonical()) {
- // Canonicalizing bound or default argument canonicalized this type
- // parameter as a side effect.
+ // Canonicalizing the bound canonicalized this type parameter
+ // as a side effect.
ASSERT(IsRecursive()); // Self-referring bound or default argument.
return ptr();
}
- set_bound(type);
- type = default_argument();
- type = type.Canonicalize(thread, trail);
- if (IsCanonical()) {
- // Canonicalizing bound or default argument canonicalized this type
- // parameter as a side effect.
- ASSERT(IsRecursive()); // Self-referring bound or default argument.
- return this->ptr();
- }
- set_default_argument(type);
+ set_bound(upper_bound);
// Check to see if the type parameter got added to canonical table as part
// of the canonicalization of its bound and default argument.
SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
@@ -21655,6 +21671,9 @@
#if defined(DEBUG)
bool TypeParameter::CheckIsCanonical(Thread* thread) const {
+ if (IsRecursive()) {
+ return true;
+ }
Zone* zone = thread->zone();
auto isolate_group = thread->isolate_group();
@@ -21674,23 +21693,10 @@
uword TypeParameter::ComputeHash() const {
ASSERT(IsFinalized() || IsBeingFinalized()); // Bound may not be finalized.
uint32_t result = parameterized_class_id();
- // Hashing the bound reduces collisions, but may also create cycles.
- // Therefore, we only hash the type_class_id of the bound,
- // and do not use its full hash, as we do for TypeRef.
const AbstractType& upper_bound = AbstractType::Handle(bound());
- if (upper_bound.IsTypeParameter()) {
- ASSERT(upper_bound.IsFinalized() || upper_bound.IsBeingFinalized());
- result = CombineHashes(result, TypeParameter::Cast(upper_bound).index());
- } else {
- // Note that the bound may not be finalized yet.
- result = CombineHashes(result, upper_bound.type_class_id());
- }
- // Since the default argument is ignored when comparing two generic function
- // types for type equality, the hash does not depend on it.
- result = CombineHashes(result, IsGenericCovariantImpl() ? 1 : 0);
+ result = CombineHashes(result, upper_bound.Hash()); // May be a TypeRef.
result = CombineHashes(result, base());
result = CombineHashes(result, index());
- result = CombineHashes(result, String::Handle(name()).Hash());
// A legacy type should have the same hash as its non-nullable version to be
// consistent with the definition of type equality in Dart code.
Nullability type_param_nullability = nullability();
@@ -21713,21 +21719,16 @@
TypeParameterPtr TypeParameter::New(const Class& parameterized_class,
intptr_t base,
intptr_t index,
- const String& name,
const AbstractType& bound,
- bool is_generic_covariant_impl,
Nullability nullability) {
Zone* Z = Thread::Current()->zone();
const TypeParameter& result = TypeParameter::Handle(Z, TypeParameter::New());
result.set_parameterized_class(parameterized_class);
result.set_base(base);
result.set_index(index);
- result.set_name(name);
result.set_bound(bound);
- result.set_default_argument(Object::dynamic_type());
result.set_flags(0);
result.set_nullability(nullability);
- result.SetGenericCovariantImpl(is_generic_covariant_impl);
result.SetHash(0);
result.SetTypeTestingStub(
@@ -21739,12 +21740,28 @@
StoreNonPointer(&untag()->flags_, flags);
}
-const char* TypeParameter::ToCString() const {
+const char* TypeParameter::CanonicalNameCString(bool is_class_type_parameter,
+ intptr_t base,
+ intptr_t index) {
Thread* thread = Thread::Current();
- Zone* zone = thread->zone();
- ZoneTextBuffer printer(zone);
+ ZoneTextBuffer printer(thread->zone());
+ const char* base_fmt = is_class_type_parameter ? "C%" Pd : "F%" Pd;
+ const char* index_fmt = is_class_type_parameter ? "X%" Pd : "Y%" Pd;
+ if (base != 0) {
+ printer.Printf(base_fmt, base);
+ }
+ printer.Printf(index_fmt, index - base);
+ return printer.buffer();
+}
+
+const char* TypeParameter::ToCString() const {
+ if (IsNull()) {
+ return "TypeParameter: null";
+ }
+ Thread* thread = Thread::Current();
+ ZoneTextBuffer printer(thread->zone());
printer.Printf("TypeParameter: ");
- printer.AddString(String::Handle(zone, name()).ToCString());
+ printer.AddString(CanonicalNameCString());
printer.AddString(NullabilitySuffix(kInternalName));
printer.Printf("; bound: ");
const AbstractType& upper_bound = AbstractType::Handle(bound());
@@ -21753,15 +21770,6 @@
} else {
upper_bound.PrintName(kInternalName, &printer);
}
- if (FLAG_show_internal_names) {
- printer.Printf("; default: ");
- const AbstractType& default_arg = AbstractType::Handle(default_argument());
- if (default_arg.IsNull()) {
- printer.AddString("<null>");
- } else {
- default_arg.PrintName(kInternalName, &printer);
- }
- }
return printer.buffer();
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 0a54c9d..29ed4b3 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -460,6 +460,7 @@
static ClassPtr class_class() { return class_class_; }
static ClassPtr dynamic_class() { return dynamic_class_; }
static ClassPtr void_class() { return void_class_; }
+ static ClassPtr type_parameters_class() { return type_parameters_class_; }
static ClassPtr type_arguments_class() { return type_arguments_class_; }
static ClassPtr patch_class_class() { return patch_class_class_; }
static ClassPtr function_class() { return function_class_; }
@@ -774,13 +775,14 @@
static BoolPtr true_;
static BoolPtr false_;
- static ClassPtr class_class_; // Class of the Class vm object.
- static ClassPtr dynamic_class_; // Class of the 'dynamic' type.
- static ClassPtr void_class_; // Class of the 'void' type.
- static ClassPtr type_arguments_class_; // Class of TypeArguments vm object.
- static ClassPtr patch_class_class_; // Class of the PatchClass vm object.
- static ClassPtr function_class_; // Class of the Function vm object.
- static ClassPtr closure_data_class_; // Class of ClosureData vm obj.
+ static ClassPtr class_class_; // Class of the Class vm object.
+ static ClassPtr dynamic_class_; // Class of the 'dynamic' type.
+ static ClassPtr void_class_; // Class of the 'void' type.
+ static ClassPtr type_parameters_class_; // Class of TypeParameters vm object.
+ static ClassPtr type_arguments_class_; // Class of TypeArguments vm object.
+ static ClassPtr patch_class_class_; // Class of the PatchClass vm object.
+ static ClassPtr function_class_; // Class of the Function vm object.
+ static ClassPtr closure_data_class_; // Class of ClosureData vm obj.
static ClassPtr ffi_trampoline_data_class_; // Class of FfiTrampolineData
// vm obj.
static ClassPtr field_class_; // Class of the Field vm object.
@@ -1103,21 +1105,22 @@
LibraryPtr library() const { return untag()->library(); }
void set_library(const Library& value) const;
- // The type parameters (and their bounds) are specified as an array of
- // TypeParameter.
- TypeArgumentsPtr type_parameters() const {
+ // The formal type parameters and their bounds (no defaults), are specified as
+ // an object of type TypeParameters.
+ TypeParametersPtr type_parameters() const {
ASSERT(is_declaration_loaded());
return untag()->type_parameters();
}
- void set_type_parameters(const TypeArguments& value) const;
+ void set_type_parameters(const TypeParameters& value) const;
intptr_t NumTypeParameters(Thread* thread) const;
intptr_t NumTypeParameters() const {
return NumTypeParameters(Thread::Current());
}
- // Return a TypeParameter if the type_name is a type parameter of this class.
- // Return null otherwise.
- TypeParameterPtr LookupTypeParameter(const String& type_name) const;
+ // Return the type parameter declared at index.
+ TypeParameterPtr TypeParameterAt(
+ intptr_t index,
+ Nullability nullability = Nullability::kNonNullable) const;
// The type argument vector is flattened and includes the type arguments of
// the super class.
@@ -2614,9 +2617,9 @@
// are packed into SMIs, but omitted if they're 0.
bool IsRequiredAt(intptr_t index) const;
- // The type parameters (and their bounds) are specified as an array of
- // TypeParameter stored in the signature. They are part of the function type.
- TypeArgumentsPtr type_parameters() const {
+ // The formal type parameters, their bounds, and defaults, are specified as an
+ // object of type TypeParameters stored in the signature.
+ TypeParametersPtr type_parameters() const {
return untag()->signature()->untag()->type_parameters();
}
@@ -2635,12 +2638,10 @@
return NumParentTypeArguments() + NumTypeParameters();
}
- // Return a TypeParameter if the type_name is a type parameter of this
- // function or of one of its parent functions.
- // Unless NULL, adjust function_level accordingly (in and out parameter).
- // Return null otherwise.
- TypeParameterPtr LookupTypeParameter(const String& type_name,
- intptr_t* function_level) const;
+ // Return the type parameter declared at index.
+ TypeParameterPtr TypeParameterAt(
+ intptr_t index,
+ Nullability nullability = Nullability::kNonNullable) const;
// Return true if this function declares type parameters.
// Generic dispatchers only set the number without actual type parameters.
@@ -2735,21 +2736,9 @@
Thread* thread,
DefaultTypeArgumentsKind* kind_out = nullptr) const;
- // Whether this function should have a cached type arguments vector for the
- // instantiated-to-bounds version of the type parameters.
- bool CachesDefaultTypeArguments() const { return IsClosureFunction(); }
-
- // Updates the cached default type arguments vector for this function if it
- // caches and for its implicit closure function if it has one. If the
- // default arguments are all canonical, the cached default type arguments
- // vector is canonicalized. Should be run any time the type parameters vector
- // is changed or if the default arguments of any type parameters are updated.
- void UpdateCachedDefaultTypeArguments(Thread* thread) const;
-
- // These are only usable for functions that cache the default type arguments.
- TypeArgumentsPtr default_type_arguments(
- DefaultTypeArgumentsKind* kind_out = nullptr) const;
- void set_default_type_arguments(const TypeArguments& value) const;
+ // Only usable for closure functions.
+ DefaultTypeArgumentsKind default_type_arguments_kind() const;
+ void set_default_type_arguments_kind(DefaultTypeArgumentsKind value) const;
// Enclosing outermost function of this local function.
FunctionPtr GetOutermostFunction() const;
@@ -3787,9 +3776,6 @@
return RoundedAllocationSize(sizeof(UntaggedClosureData));
}
- static intptr_t default_type_arguments_offset() {
- return OFFSET_OF(UntaggedClosureData, default_type_arguments_);
- }
static intptr_t default_type_arguments_kind_offset() {
return OFFSET_OF(UntaggedClosureData, default_type_arguments_kind_);
}
@@ -3816,11 +3802,6 @@
}
void set_implicit_static_closure(const Instance& closure) const;
- TypeArgumentsPtr default_type_arguments() const {
- return untag()->default_type_arguments();
- }
- void set_default_type_arguments(const TypeArguments& value) const;
-
DefaultTypeArgumentsKind default_type_arguments_kind() const;
void set_default_type_arguments_kind(DefaultTypeArgumentsKind value) const;
@@ -4222,7 +4203,7 @@
// Returns false if any value read from this field is guaranteed to be
// not null.
// Internally we is_nullable_ field contains either kNullCid (nullable) or
- // kInvalidCid (non-nullable) instead of boolean. This is done to simplify
+ // kIllegalCid (non-nullable) instead of boolean. This is done to simplify
// guarding sequence in the generated code.
bool is_nullable() const;
void set_is_nullable(bool val) const {
@@ -7483,6 +7464,90 @@
friend class Class;
};
+// TypeParameters represents a list of formal type parameters with their bounds
+// and their default values as calculated by CFE.
+class TypeParameters : public Object {
+ public:
+ intptr_t Length() const;
+
+ static intptr_t names_offset() {
+ return OFFSET_OF(UntaggedTypeParameters, names_);
+ }
+ StringPtr NameAt(intptr_t index) const;
+ void SetNameAt(intptr_t index, const String& value) const;
+
+ static intptr_t flags_offset() {
+ return OFFSET_OF(UntaggedTypeParameters, flags_);
+ }
+
+ static intptr_t bounds_offset() {
+ return OFFSET_OF(UntaggedTypeParameters, bounds_);
+ }
+ AbstractTypePtr BoundAt(intptr_t index) const;
+ void SetBoundAt(intptr_t index, const AbstractType& value) const;
+ bool AllDynamicBounds() const;
+
+ static intptr_t defaults_offset() {
+ return OFFSET_OF(UntaggedTypeParameters, defaults_);
+ }
+ AbstractTypePtr DefaultAt(intptr_t index) const;
+ void SetDefaultAt(intptr_t index, const AbstractType& value) const;
+ bool AllDynamicDefaults() const;
+
+ // The isGenericCovariantImpl bits are packed into SMIs in the flags array,
+ // but omitted if they're 0.
+ bool IsGenericCovariantImplAt(intptr_t index) const;
+ void SetIsGenericCovariantImplAt(intptr_t index, bool value) const;
+
+ // The number of flags per Smi should be a power of 2 in order to simplify the
+ // generated code accessing the flags array.
+#if !defined(DART_COMPRESSED_POINTERS)
+ static const intptr_t kFlagsPerSmiShift = kBitsPerWordLog2 - 1;
+#else
+ static const intptr_t kFlagsPerSmiShift = kBitsPerWordLog2 - 2;
+#endif
+ static const intptr_t kFlagsPerSmi = 1LL << kFlagsPerSmiShift;
+ COMPILE_ASSERT(kFlagsPerSmi < kSmiBits);
+ static const intptr_t kFlagsPerSmiMask = kFlagsPerSmi - 1;
+
+ void Print(Thread* thread,
+ Zone* zone,
+ bool are_class_type_parameters,
+ intptr_t base,
+ NameVisibility name_visibility,
+ BaseTextBuffer* printer) const;
+
+ static intptr_t InstanceSize() {
+ return RoundedAllocationSize(sizeof(UntaggedTypeParameters));
+ }
+
+ static TypeParametersPtr New(Heap::Space space = Heap::kOld);
+ static TypeParametersPtr New(intptr_t count, Heap::Space space = Heap::kOld);
+
+ private:
+ ArrayPtr names() const { return untag()->names(); }
+ void set_names(const Array& value) const;
+ ArrayPtr flags() const { return untag()->flags(); }
+ void set_flags(const Array& value) const;
+ TypeArgumentsPtr bounds() const { return untag()->bounds(); }
+ void set_bounds(const TypeArguments& value) const;
+ TypeArgumentsPtr defaults() const { return untag()->defaults(); }
+ void set_defaults(const TypeArguments& value) const;
+
+ // Allocate and initialize the flags array to zero.
+ void AllocateFlags(Heap::Space space) const;
+ // Reset the flags array to null if all flags are zero.
+ void OptimizeFlags() const;
+
+ FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameters, Object);
+ friend class Class;
+ friend class ClassFinalizer;
+ friend class Function;
+ friend class FunctionType;
+ friend class Object;
+ friend class Precompiler;
+};
+
// A TypeArguments is an array of AbstractType.
class TypeArguments : public Instance {
public:
@@ -8307,6 +8372,8 @@
}
// Reexported so they can be used by the flow graph builders.
+ using PackedNumParentTypeArguments =
+ UntaggedFunctionType::PackedNumParentTypeArguments;
using PackedHasNamedOptionalParameters =
UntaggedFunctionType::PackedHasNamedOptionalParameters;
using PackedNumFixedParameters =
@@ -8314,6 +8381,11 @@
using PackedNumOptionalParameters =
UntaggedFunctionType::PackedNumOptionalParameters;
+ // Return the type parameter declared at index.
+ TypeParameterPtr TypeParameterAt(
+ intptr_t index,
+ Nullability nullability = Nullability::kNonNullable) const;
+
AbstractTypePtr result_type() const { return untag()->result_type(); }
void set_result_type(const AbstractType& value) const;
@@ -8369,12 +8441,12 @@
// parameters don't have flags.
static intptr_t NameArrayLengthIncludingFlags(intptr_t num_parameters);
- // The type parameters (and their bounds) are specified as an array of
- // TypeParameter.
- TypeArgumentsPtr type_parameters() const {
+ // The formal type parameters, their bounds, and defaults, are specified as an
+ // object of type TypeParameters.
+ TypeParametersPtr type_parameters() const {
return untag()->type_parameters();
}
- void set_type_parameters(const TypeArguments& value) const;
+ void set_type_parameters(const TypeParameters& value) const;
static intptr_t type_parameters_offset() {
return OFFSET_OF(UntaggedFunctionType, type_parameters_);
}
@@ -8536,11 +8608,6 @@
return UntaggedTypeParameter::BeingFinalizedBit::decode(untag()->flags_);
}
virtual void SetIsBeingFinalized() const;
- bool IsGenericCovariantImpl() const {
- return UntaggedTypeParameter::GenericCovariantImplBit::decode(
- untag()->flags_);
- }
- void SetGenericCovariantImpl(bool value) const;
static intptr_t flags_offset() {
return OFFSET_OF(UntaggedTypeParameter, flags_);
}
@@ -8575,21 +8642,12 @@
return OFFSET_OF(UntaggedTypeParameter, index_);
}
- StringPtr name() const { return untag()->name(); }
- static intptr_t name_offset() {
- return OFFSET_OF(UntaggedTypeParameter, name_);
- }
AbstractTypePtr bound() const { return untag()->bound(); }
void set_bound(const AbstractType& value) const;
static intptr_t bound_offset() {
return OFFSET_OF(UntaggedTypeParameter, bound_);
}
- AbstractTypePtr default_argument() const {
- return untag()->default_argument();
- }
- void set_default_argument(const AbstractType& value) const;
-
virtual bool IsInstantiated(Genericity genericity = kAny,
intptr_t num_free_fun_type_params = kAllFree,
TrailPtr trail = nullptr) const;
@@ -8625,6 +8683,15 @@
const TypeArguments& instantiator_type_arguments,
const TypeArguments& function_type_arguments) const;
+ // Return a constructed name for this nameless type parameter.
+ const char* CanonicalNameCString() const {
+ return CanonicalNameCString(IsClassTypeParameter(), base(), index());
+ }
+
+ static const char* CanonicalNameCString(bool is_class_type_parameter,
+ intptr_t base,
+ intptr_t index);
+
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(UntaggedTypeParameter));
}
@@ -8633,9 +8700,7 @@
static TypeParameterPtr New(const Class& parameterized_class,
intptr_t base,
intptr_t index,
- const String& name,
const AbstractType& bound,
- bool is_generic_covariant_impl,
Nullability nullability);
private:
@@ -8993,6 +9058,8 @@
return GetCachedHash(ptr()) != 0;
}
+ bool IsRecursive() const { return false; } // Required by HashSet templates.
+
static intptr_t hash_offset() {
#if defined(HASH_IN_OBJECT_HEADER)
COMPILE_ASSERT(UntaggedObject::kHashTagPos % kBitsPerByte == 0);
diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc
index 7f3da19..cc858f5 100644
--- a/runtime/vm/object_service.cc
+++ b/runtime/vm/object_service.cc
@@ -169,6 +169,15 @@
}
}
+void TypeParameters::PrintJSONImpl(JSONStream* stream, bool ref) const {
+ JSONObject jsobj(stream);
+ jsobj.AddProperty("kind", "TypeParameters");
+ jsobj.AddProperty("flags", Array::Handle(flags()));
+ jsobj.AddProperty("names", Array::Handle(names()));
+ jsobj.AddProperty("bounds", TypeArguments::Handle(bounds()));
+ jsobj.AddProperty("defaults", TypeArguments::Handle(defaults()));
+}
+
void TypeArguments::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
// The index in the canonical_type_arguments table cannot be used as part of
diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h
index 2aa73d8..0916e2a 100644
--- a/runtime/vm/parser.h
+++ b/runtime/vm/parser.h
@@ -244,6 +244,7 @@
V(current_function, Function, CurrentFunction) \
V(current_num_processed, Smi, CurrentNumProcessed) \
V(current_param_index, Smi, CurrentParamIndex) \
+ V(current_type_param, Dynamic, CurrentTypeParam) \
V(function_type_args, Dynamic, FunctionTypeArgs)
#define DEFINE_FIELD(Name, _, __) LocalVariable* Name = nullptr;
diff --git a/runtime/vm/raw_object.cc b/runtime/vm/raw_object.cc
index d99acc8..1cdaff0 100644
--- a/runtime/vm/raw_object.cc
+++ b/runtime/vm/raw_object.cc
@@ -572,6 +572,7 @@
COMPRESSED_VISITOR(UserTag)
REGULAR_VISITOR(SubtypeTestCache)
COMPRESSED_VISITOR(LoadingUnit)
+COMPRESSED_VISITOR(TypeParameters)
VARIABLE_COMPRESSED_VISITOR(TypeArguments,
Smi::Value(raw_obj->untag()->length()))
VARIABLE_COMPRESSED_VISITOR(LocalVarDescriptors, raw_obj->untag()->num_entries_)
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index b1d5767..7c62065 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -954,8 +954,7 @@
COMPRESSED_POINTER_FIELD(ArrayPtr, interfaces) // Array of AbstractType.
COMPRESSED_POINTER_FIELD(ScriptPtr, script)
COMPRESSED_POINTER_FIELD(LibraryPtr, library)
- // Array of TypeParameter.
- COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, type_parameters)
+ COMPRESSED_POINTER_FIELD(TypeParametersPtr, type_parameters)
COMPRESSED_POINTER_FIELD(AbstractTypePtr, super_type)
// Canonicalized const instances of this class.
COMPRESSED_POINTER_FIELD(ArrayPtr, constants)
@@ -1358,9 +1357,7 @@
#endif
// Closure object for static implicit closures.
COMPRESSED_POINTER_FIELD(InstancePtr, closure)
- // Instantiate-to-bounds TAV for use when no TAV is provided.
- COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, default_type_arguments)
- VISIT_TO(CompressedObjectPtr, default_type_arguments)
+ VISIT_TO(CompressedObjectPtr, closure)
enum class DefaultTypeArgumentsKind : uint8_t {
// Only here to make sure it's explicitly set appropriately.
@@ -1458,7 +1455,7 @@
TokenPosition end_token_pos_;
ClassIdTagType guarded_cid_;
ClassIdTagType is_nullable_; // kNullCid if field can contain null value and
- // kInvalidCid otherwise.
+ // kIllegalCid otherwise.
#if !defined(DART_PRECOMPILED_RUNTIME)
uint32_t kernel_offset_;
@@ -2503,6 +2500,25 @@
friend class SnapshotReader;
};
+class UntaggedTypeParameters : public UntaggedObject {
+ private:
+ RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameters);
+
+ VISIT_FROM(CompressedObjectPtr, names)
+ // Length of names reflects the number of type parameters.
+ COMPRESSED_POINTER_FIELD(ArrayPtr, names)
+ // flags: isGenericCovariantImpl and (todo) variance.
+ COMPRESSED_POINTER_FIELD(ArrayPtr, flags)
+ COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, bounds)
+ // defaults is the instantiation to bounds (calculated by CFE).
+ COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, defaults)
+ VISIT_TO(CompressedObjectPtr, defaults)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+
+ friend class Object;
+ friend class SnapshotReader;
+};
+
class UntaggedAbstractType : public UntaggedInstance {
public:
enum TypeState {
@@ -2551,8 +2567,7 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType);
VISIT_FROM(CompressedObjectPtr, type_test_stub)
- // Array of TypeParameter.
- COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, type_parameters)
+ COMPRESSED_POINTER_FIELD(TypeParametersPtr, type_parameters)
COMPRESSED_POINTER_FIELD(AbstractTypePtr, result_type)
COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_types)
COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_names);
@@ -2624,21 +2639,13 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
VISIT_FROM(CompressedObjectPtr, type_test_stub)
- COMPRESSED_POINTER_FIELD(StringPtr, name)
COMPRESSED_POINTER_FIELD(SmiPtr, hash)
// ObjectType if no explicit bound specified.
COMPRESSED_POINTER_FIELD(AbstractTypePtr, bound)
- // The instantiation to bounds of this parameter as calculated by the CFE.
- //
- // TODO(dartbug.com/43901): Once a separate TypeParameters class has been
- // added, move these there and remove them from TypeParameter objects.
- COMPRESSED_POINTER_FIELD(AbstractTypePtr, default_argument)
- VISIT_TO(CompressedObjectPtr, default_argument)
+ VISIT_TO(CompressedObjectPtr, bound)
ClassIdTagType parameterized_class_id_; // Or kFunctionCid for function tp.
- // TODO(regis): Can we use uint8_t twice below? Or keep uint16_t?
- // Warning: BuildTypeParameterTypeTestStub assumes uint16_t.
- uint16_t base_; // Number of enclosing function type parameters.
- uint16_t index_;
+ uint8_t base_; // Number of enclosing function type parameters.
+ uint8_t index_; // Keep size in sync with BuildTypeParameterTypeTestStub.
uint8_t flags_;
uint8_t nullability_;
@@ -2646,9 +2653,7 @@
using BeingFinalizedBit = BitField<decltype(flags_), bool, 0, 1>;
using FinalizedBit =
BitField<decltype(flags_), bool, BeingFinalizedBit::kNextBit, 1>;
- using GenericCovariantImplBit =
- BitField<decltype(flags_), bool, FinalizedBit::kNextBit, 1>;
- static constexpr intptr_t kFlagsBitSize = GenericCovariantImplBit::kNextBit;
+ static constexpr intptr_t kFlagsBitSize = FinalizedBit::kNextBit;
private:
CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
diff --git a/runtime/vm/raw_object_fields.cc b/runtime/vm/raw_object_fields.cc
index faea10f..629d62b 100644
--- a/runtime/vm/raw_object_fields.cc
+++ b/runtime/vm/raw_object_fields.cc
@@ -136,9 +136,12 @@
F(TypeRef, type_test_stub_) \
F(TypeRef, type_) \
F(TypeParameter, type_test_stub_) \
- F(TypeParameter, name_) \
F(TypeParameter, hash_) \
F(TypeParameter, bound_) \
+ F(TypeParameters, names_) \
+ F(TypeParameters, flags_) \
+ F(TypeParameters, bounds_) \
+ F(TypeParameters, defaults_) \
F(Closure, instantiator_type_arguments_) \
F(Closure, function_type_arguments_) \
F(Closure, delayed_type_arguments_) \
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 924f0a4..606d930 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -230,6 +230,8 @@
reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
// Set all non object fields.
+ type_parameter.set_base(reader->Read<uint8_t>());
+ type_parameter.set_index(reader->Read<uint8_t>());
const uint8_t combined = reader->Read<uint8_t>();
type_parameter.set_flags(combined >> 4);
type_parameter.set_nullability(static_cast<Nullability>(combined & 0xf));
@@ -279,8 +281,8 @@
writer->WriteTags(writer->GetObjectTags(this));
// Write out all the non object pointer fields.
- writer->Write<uint16_t>(base_);
- writer->Write<uint16_t>(index_);
+ writer->Write<uint8_t>(base_);
+ writer->Write<uint8_t>(index_);
const uint8_t combined = (flags_ << 4) | nullability_;
ASSERT(flags_ == (combined >> 4));
ASSERT(nullability_ == (combined & 0xf));
@@ -296,6 +298,43 @@
writer->WriteObjectImpl(param_class, kAsReference);
}
+TypeParametersPtr TypeParameters::ReadFrom(SnapshotReader* reader,
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind,
+ bool as_reference) {
+ ASSERT(reader != NULL);
+
+ TypeParameters& type_parameters =
+ TypeParameters::ZoneHandle(reader->zone(), TypeParameters::New());
+ reader->AddBackRef(object_id, &type_parameters, kIsDeserialized);
+
+ // Set all the object fields.
+ READ_COMPRESSED_OBJECT_FIELDS(
+ type_parameters, type_parameters.ptr()->untag()->from(),
+ type_parameters.ptr()->untag()->to(), kAsReference);
+
+ return type_parameters.ptr();
+}
+
+void UntaggedTypeParameters::WriteTo(SnapshotWriter* writer,
+ intptr_t object_id,
+ Snapshot::Kind kind,
+ bool as_reference) {
+ ASSERT(writer != NULL);
+
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+
+ // Write out the class and tags information.
+ writer->WriteVMIsolateObject(kTypeParametersCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+
+ // Write out all the object pointer fields.
+ SnapshotWriterVisitor visitor(writer, kAsReference);
+ visitor.VisitCompressedPointers(heap_base(), from(), to());
+}
+
TypeArgumentsPtr TypeArguments::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
diff --git a/runtime/vm/reusable_handles.h b/runtime/vm/reusable_handles.h
index 5b05ecc..e2ac116 100644
--- a/runtime/vm/reusable_handles.h
+++ b/runtime/vm/reusable_handles.h
@@ -109,6 +109,8 @@
ReusableSmiHandleScope reused_smi_handle(thread);
#define REUSABLE_STRING_HANDLESCOPE(thread) \
ReusableStringHandleScope reused_string_handle(thread);
+#define REUSABLE_TYPE_PARAMETERS_HANDLESCOPE(thread) \
+ ReusableTypeArgumentsHandleScope reused_type_parameters_handle(thread);
#define REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread) \
ReusableTypeArgumentsHandleScope reused_type_arguments_handle(thread);
#define REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread) \
diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc
index 2345290..1e2b0de 100644
--- a/runtime/vm/runtime_entry.cc
+++ b/runtime/vm/runtime_entry.cc
@@ -531,13 +531,20 @@
AbstractType::CheckedHandle(zone, arguments.ArgAt(3));
const String& dst_name = String::CheckedHandle(zone, arguments.ArgAt(4));
- ASSERT(!subtype.IsNull() && !subtype.IsTypeRef());
+ if (supertype.IsTypeRef()) {
+ supertype = TypeRef::Cast(supertype).type();
+ }
ASSERT(!supertype.IsNull() && !supertype.IsTypeRef());
// Now that AssertSubtype may be checking types only available at runtime,
// we can't guarantee the supertype isn't the top type.
if (supertype.IsTopTypeForSubtyping()) return;
+ if (subtype.IsTypeRef()) {
+ subtype = TypeRef::Cast(subtype).type();
+ }
+ ASSERT(!subtype.IsNull() && !subtype.IsTypeRef());
+
// TODO(regis): Support for FLAG_trace_type_checks is missing here. Is it
// still useful or should we remove it everywhere?
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index ba3f9a9..2eb5417 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -416,6 +416,7 @@
friend class Type;
friend class FunctionType;
friend class TypedDataView;
+ friend class TypeParameters;
friend class TypeArguments;
friend class TypeParameter;
friend class TypeRef;
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index fd790e9..ef0270b 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -106,6 +106,7 @@
V(DynamicCallCurrentNumProcessedVar, ":dyn_call_current_num_processed") \
V(DynamicCallCurrentFunctionVar, ":dyn_call_current_function") \
V(DynamicCallCurrentParamIndexVar, ":dyn_call_current_param_index") \
+ V(DynamicCallCurrentTypeParamVar, ":dyn_call_current_type_param") \
V(DynamicCallFunctionTypeArgsVar, ":dyn_call_function_type_args") \
V(DynamicPrefix, "dyn:") \
V(EntryPointsTemp, ":entry_points_temp") \
@@ -286,6 +287,7 @@
V(TypeArguments, "TypeArguments") \
V(TypeArgumentsParameter, ":type_arguments") \
V(TypeError, "_TypeError") \
+ V(TypeParameters, "TypeParameters") \
V(TypeQuote, "type '") \
V(Uint16List, "Uint16List") \
V(Uint32List, "Uint32List") \
diff --git a/runtime/vm/tagged_pointer.h b/runtime/vm/tagged_pointer.h
index 4df36b4..582e207 100644
--- a/runtime/vm/tagged_pointer.h
+++ b/runtime/vm/tagged_pointer.h
@@ -324,6 +324,7 @@
DEFINE_TAGGED_POINTER(Instance, Object)
DEFINE_TAGGED_POINTER(LibraryPrefix, Instance)
DEFINE_TAGGED_POINTER(TypeArguments, Instance)
+DEFINE_TAGGED_POINTER(TypeParameters, Object)
DEFINE_TAGGED_POINTER(AbstractType, Instance)
DEFINE_TAGGED_POINTER(Type, AbstractType)
DEFINE_TAGGED_POINTER(FunctionType, AbstractType)
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index 9b4dfe3..abbddba 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -83,6 +83,7 @@
V(PcDescriptors) \
V(Smi) \
V(String) \
+ V(TypeParameters) \
V(TypeArguments) \
V(TypeParameter)
diff --git a/runtime/vm/type_testing_stubs.cc b/runtime/vm/type_testing_stubs.cc
index 7b6f703..260517b 100644
--- a/runtime/vm/type_testing_stubs.cc
+++ b/runtime/vm/type_testing_stubs.cc
@@ -72,8 +72,8 @@
return concatenated;
} else if (type.IsTypeParameter()) {
- string_ = TypeParameter::Cast(type).name();
- return AssemblerSafeName(OS::SCreate(Z, "%s", string_.ToCString()));
+ return AssemblerSafeName(
+ OS::SCreate(Z, "%s", TypeParameter::Cast(type).CanonicalNameCString()));
} else {
return AssemblerSafeName(OS::SCreate(Z, "%s", type.ToCString()));
}
@@ -359,18 +359,13 @@
} else {
ASSERT(hi->CanUseGenericSubtypeRangeCheckFor(type));
- const intptr_t num_type_parameters = type_class.NumTypeParameters();
const intptr_t num_type_arguments = type_class.NumTypeArguments();
- const TypeArguments& tp =
- TypeArguments::Handle(type_class.type_parameters());
- ASSERT(tp.Length() == num_type_parameters);
-
const TypeArguments& ta = TypeArguments::Handle(type.arguments());
ASSERT(ta.Length() == num_type_arguments);
BuildOptimizedSubclassRangeCheckWithTypeArguments(assembler, hi, type,
- type_class, tp, ta);
+ type_class, ta);
}
if (Instance::NullIsAssignableTo(type)) {
@@ -411,7 +406,6 @@
HierarchyInfo* hi,
const Type& type,
const Class& type_class,
- const TypeArguments& tp,
const TypeArguments& ta) {
// a) First we make a quick sub*class* cid-range check.
compiler::Label check_failed;
@@ -941,7 +935,6 @@
TypeParameterSet* parameters_tested_against) {
Class& klass = Class::Handle(zone_);
TypeParameter& param = TypeParameter::Handle(zone_);
- TypeArguments& params = TypeArguments::Handle(zone_);
AbstractType& type = AbstractType::Handle(zone_);
// Because Object/dynamic are common values for type parameters, we add them
@@ -961,9 +954,8 @@
}
const intptr_t num_parameters = klass.NumTypeParameters();
- params = klass.type_parameters();
for (intptr_t i = 0; i < num_parameters; ++i) {
- param ^= params.TypeAt(i);
+ param = klass.TypeParameterAt(i);
if (parameters_tested_against->HasKey(¶m)) {
TypeArgumentsSet& ta_set = instance_creation_arguments_[cid];
auto it = ta_set.GetIterator();
diff --git a/runtime/vm/type_testing_stubs.h b/runtime/vm/type_testing_stubs.h
index d8307b8..7f97d5d 100644
--- a/runtime/vm/type_testing_stubs.h
+++ b/runtime/vm/type_testing_stubs.h
@@ -80,7 +80,6 @@
HierarchyInfo* hi,
const Type& type,
const Class& type_class,
- const TypeArguments& type_parameters,
const TypeArguments& type_arguments);
static void BuildOptimizedSubclassRangeCheckWithTypeArguments(
@@ -88,7 +87,6 @@
HierarchyInfo* hi,
const Type& type,
const Class& type_class,
- const TypeArguments& type_parameters,
const TypeArguments& type_arguments,
const Register class_id_reg,
const Register instance_type_args_reg);
diff --git a/runtime/vm/type_testing_stubs_test.cc b/runtime/vm/type_testing_stubs_test.cc
index 18c90d1..15c1682 100644
--- a/runtime/vm/type_testing_stubs_test.cc
+++ b/runtime/vm/type_testing_stubs_test.cc
@@ -461,7 +461,7 @@
auto& tav_dynamic_t = TypeArguments::Handle(TypeArguments::New(2));
tav_dynamic_t.SetTypeAt(0, type_dynamic);
tav_dynamic_t.SetTypeAt(
- 1, TypeParameter::Handle(GetClassTypeParameter(class_base, "T")));
+ 1, TypeParameter::Handle(GetClassTypeParameter(class_base, 0)));
CanonicalizeTAV(&tav_dynamic_t);
// We will generate specialized TTS for instantiated interface types
@@ -750,7 +750,7 @@
// <...> as Base<T> with T instantiantiator type parameter (T == int)
const auto& tav_baset = TypeArguments::Handle(TypeArguments::New(1));
tav_baset.SetTypeAt(
- 0, TypeParameter::Handle(GetClassTypeParameter(class_base, "T")));
+ 0, TypeParameter::Handle(GetClassTypeParameter(class_base, 0)));
auto& type_base_t = AbstractType::Handle(Type::New(class_base, tav_baset));
FinalizeAndCanonicalize(&type_base_t);
RunTTSTest(obj_base_int, type_base_t, tav_int, tav_null,
@@ -761,7 +761,7 @@
// <...> as Base<B> with B function type parameter
const auto& tav_baseb = TypeArguments::Handle(TypeArguments::New(1));
tav_baseb.SetTypeAt(
- 0, TypeParameter::Handle(GetFunctionTypeParameter(fun_generic, "B")));
+ 0, TypeParameter::Handle(GetFunctionTypeParameter(fun_generic, 1)));
auto& type_base_b = AbstractType::Handle(Type::New(class_base, tav_baseb));
FinalizeAndCanonicalize(&type_base_b);
// With B == int
@@ -797,8 +797,8 @@
// <...> as Base<A2<T>>
const auto& tav_t = TypeArguments::Handle(TypeArguments::New(1));
- tav_t.SetTypeAt(
- 0, TypeParameter::Handle(GetClassTypeParameter(class_base, "T")));
+ tav_t.SetTypeAt(0,
+ TypeParameter::Handle(GetClassTypeParameter(class_base, 0)));
auto& type_a2_t = Type::Handle(Type::New(class_a2, tav_t));
type_a2_t = type_a2_t.ToNullability(Nullability::kLegacy, Heap::kNew);
FinalizeAndCanonicalize(&type_a2_t);
@@ -855,7 +855,7 @@
// dst_type = B<T>
const auto& dst_tav = TypeArguments::Handle(TypeArguments::New(1));
dst_tav.SetTypeAt(0,
- TypeParameter::Handle(GetClassTypeParameter(class_b, "T")));
+ TypeParameter::Handle(GetClassTypeParameter(class_b, 0)));
auto& dst_type = Type::Handle(Type::New(class_b, dst_tav));
FinalizeAndCanonicalize(&dst_type);
const auto& cint_tav =
@@ -891,10 +891,10 @@
Function::Handle(GetFunction(root_library, "genericFun"));
const auto& dst_type_t =
- TypeParameter::Handle(GetClassTypeParameter(class_a, "T"));
+ TypeParameter::Handle(GetClassTypeParameter(class_a, 0));
const auto& dst_type_h =
- TypeParameter::Handle(GetFunctionTypeParameter(fun_generic, "H"));
+ TypeParameter::Handle(GetFunctionTypeParameter(fun_generic, 0));
const auto& aint = Object::Handle(Invoke(root_library, "createAInt"));
const auto& astring = Object::Handle(Invoke(root_library, "createAString"));
diff --git a/tests/language/regress/regress45763_test.dart b/tests/language/regress/regress45763_test.dart
new file mode 100644
index 0000000..1efd68d
--- /dev/null
+++ b/tests/language/regress/regress45763_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// SharedOptions=--enable-experiment=generic-metadata
+
+import "package:expect/expect.dart";
+
+Type? capturedTypeArgument;
+Type typeOf<X>() => X;
+
+X captureTypeArgument<X>() {
+ capturedTypeArgument = X;
+ throw "";
+}
+
+typedef check = void Function<T>();
+
+void main() {
+ void f(check Function<T>() g) => g();
+ try {
+ f(<T>() => captureTypeArgument());
+ } catch (e) {}
+ Expect.equals(typeOf<void Function<T>()>(), capturedTypeArgument);
+}
diff --git a/tests/lib/mirrors/class_mirror_type_variables_expect.dart b/tests/lib/mirrors/class_mirror_type_variables_expect.dart
index 847bd7f..3326b08 100644
--- a/tests/lib/mirrors/class_mirror_type_variables_expect.dart
+++ b/tests/lib/mirrors/class_mirror_type_variables_expect.dart
@@ -96,9 +96,6 @@
values.forEach((e) {
Expect.equals(true, e is TypeVariableMirror);
});
- Expect.equals(#R, values.elementAt(0).simpleName);
- Expect.equals(#S, values.elementAt(1).simpleName);
- Expect.equals(#T, values.elementAt(2).simpleName);
}
void testE(Env env) {
diff --git a/tests/lib/mirrors/generic_bounded_by_type_parameter_test.dart b/tests/lib/mirrors/generic_bounded_by_type_parameter_test.dart
index 46e731f..fd7c9e9 100644
--- a/tests/lib/mirrors/generic_bounded_by_type_parameter_test.dart
+++ b/tests/lib/mirrors/generic_bounded_by_type_parameter_test.dart
@@ -50,13 +50,6 @@
Expect.equals(reflectClass(Object), xFromGeneric.upperBound); // //# 02: continued
Expect.equals(reflectClass(Object), yFromGeneric.upperBound); // //# 02: continued
- typeParameters(superDecl, [#T, #R]);
- typeParameters(superOfNumAndInt, [#T, #R]);
- typeParameters(genericDecl, [#X, #Y]); // //# 02: continued
- typeParameters(superOfXAndY, [#T, #R]); // //# 02: continued
- typeParameters(genericOfNumAndDouble, [#X, #Y]); // //# 02: continued
- typeParameters(superOfNumAndDouble, [#T, #R]); // //# 02: continued
-
typeArguments(superDecl, []);
typeArguments(superOfNumAndInt, [reflectClass(num), reflectClass(int)]);
typeArguments(genericDecl, []); // //# 02: continued
diff --git a/tests/lib/mirrors/generic_bounded_test.dart b/tests/lib/mirrors/generic_bounded_test.dart
index 01301fb..062780e 100644
--- a/tests/lib/mirrors/generic_bounded_test.dart
+++ b/tests/lib/mirrors/generic_bounded_test.dart
@@ -49,14 +49,6 @@
Expect.equals(reflectClass(num), tFromSuper.upperBound);
Expect.equals(reflectClass(Object), rFromGeneric.upperBound); // //# 02: continued
- typeParameters(superDecl, [#T]);
- typeParameters(superOfInt, [#T]);
- typeParameters(genericDecl, [#R]); // //# 02: continued
- typeParameters(superOfR, [#T]); // //# 02: continued
- typeParameters(genericOfDouble, [#R]); // //# 02: continued
- typeParameters(superOfDouble, [#T]); // //# 02: continued
- typeParameters(superOfString, [#T]); // //# 01: continued
-
typeArguments(superDecl, []);
typeArguments(superOfInt, [reflectClass(int)]);
typeArguments(genericDecl, []); // //# 02: continued
diff --git a/tests/lib/mirrors/generic_class_declaration_test.dart b/tests/lib/mirrors/generic_class_declaration_test.dart
index 79ebee1..2a2e4c6 100644
--- a/tests/lib/mirrors/generic_class_declaration_test.dart
+++ b/tests/lib/mirrors/generic_class_declaration_test.dart
@@ -81,14 +81,4 @@
.where((dm) => dm is MethodMirror && dm.isConstructor)
.map(stringify),
'constructors');
-
- Expect.setEquals(
- [
- 'TypeVariable(s(T) in s(A), upperBound = Class(s(Object) in '
- 's(dart.core), top-level))'
- ],
- cm.declarations.values
- .where((dm) => dm is TypeVariableMirror)
- .map(stringify),
- 'type variables');
}
diff --git a/tests/lib/mirrors/generic_f_bounded_test.dart b/tests/lib/mirrors/generic_f_bounded_test.dart
index 5f84435..408a8a3 100644
--- a/tests/lib/mirrors/generic_f_bounded_test.dart
+++ b/tests/lib/mirrors/generic_f_bounded_test.dart
@@ -43,13 +43,8 @@
Expect.equals(magnitudeDecl, magnitudeOfR.originalDeclaration);
Expect.equals(rFromSorter, magnitudeOfR.typeArguments.single);
- typeParameters(magnitudeDecl, [#T]);
typeParameters(realDecl, []);
- typeParameters(sorterDecl, [#R]);
typeParameters(realSorterDecl, []);
- typeParameters(magnitudeOfReal, [#T]);
- typeParameters(sorterOfReal, [#R]);
- typeParameters(magnitudeOfR, [#T]);
typeArguments(magnitudeDecl, []);
typeArguments(realDecl, []);
diff --git a/tests/lib/mirrors/generic_interface_test.dart b/tests/lib/mirrors/generic_interface_test.dart
index 8b38a3b..061685d 100644
--- a/tests/lib/mirrors/generic_interface_test.dart
+++ b/tests/lib/mirrors/generic_interface_test.dart
@@ -91,21 +91,6 @@
Expect.equals(reflectClass(Object), xFromGenericMixinApplication.upperBound);
Expect.equals(reflectClass(Object), yFromGenericClass.upperBound);
- typeParameters(interfaceDecl, [#T]);
- typeParameters(boundedDecl, [#S]);
- typeParameters(interfaceOfInt, [#T]);
- typeParameters(interfaceOfR, [#T]);
- typeParameters(interfaceOfBool, [#T]);
- typeParameters(boundedOfInt, [#S]);
- typeParameters(boundedOfString, [#S]); // //# 01: continued
- typeParameters(interfaceOfFBounded, [#T]);
- typeParameters(interfaceOfInt2, [#T]);
- typeParameters(interfaceOfX, [#T]);
- typeParameters(interfaceOfDouble, [#T]);
- typeParameters(interfaceOfInt3, [#T]);
- typeParameters(interfaceOfY, [#T]);
- typeParameters(interfaceOfDouble2, [#T]);
-
typeArguments(interfaceDecl, []);
typeArguments(boundedDecl, []);
typeArguments(interfaceOfInt, [reflectClass(int)]);
diff --git a/tests/lib/mirrors/generic_mixin_test.dart b/tests/lib/mirrors/generic_mixin_test.dart
index 238689b..c52c756 100644
--- a/tests/lib/mirrors/generic_mixin_test.dart
+++ b/tests/lib/mirrors/generic_mixin_test.dart
@@ -35,30 +35,6 @@
main() {
TypeMirror dynamicMirror = currentMirrorSystem().dynamicType;
- typeParameters(reflectClass(NonGenericMixinApplication1).mixin, [#M]);
- typeParameters(reflectClass(NonGenericMixinApplication2).mixin, [#M]);
- typeParameters(reflectClass(GenericMixinApplication1).mixin, [#M]);
- typeParameters(reflectClass(GenericMixinApplication2).mixin, [#M]);
- typeParameters(reflectClass(NonGenericClass1).mixin, []);
- typeParameters(reflectClass(NonGenericClass2).mixin, []);
- typeParameters(reflectClass(GenericClass1).mixin, [#C]);
- typeParameters(reflectClass(GenericClass2).mixin, [#C]);
- typeParameters(reflectClass(NonGenericClass1).superclass!.mixin, [#M]);
- typeParameters(reflectClass(NonGenericClass2).superclass!.mixin, [#M]);
- typeParameters(reflectClass(GenericClass1).superclass!.mixin, [#M]);
- typeParameters(reflectClass(GenericClass2).superclass!.mixin, [#M]);
- typeParameters(reflectClass(GenericMultipleMixins).mixin, [#A, #B, #C]);
- typeParameters(reflectClass(GenericMultipleMixins).superclass!.mixin, [#N]);
- typeParameters(
- reflectClass(GenericMultipleMixins).superclass!.superclass!.mixin, [#M]);
- typeParameters(
- reflectClass(GenericMultipleMixins)
- .superclass!
- .superclass!
- .superclass!
- .mixin,
- [#S]);
-
typeArguments(
reflectClass(NonGenericMixinApplication1).mixin, [dynamicMirror]);
typeArguments(
@@ -93,46 +69,8 @@
.mixin,
[reflectClass(GenericMultipleMixins).typeVariables[0]]);
- typeParameters(reflect(new NonGenericMixinApplication1()).type.mixin, [#M]);
- typeParameters(reflect(new NonGenericMixinApplication2()).type.mixin, [#M]);
- typeParameters(
- reflect(new GenericMixinApplication1<bool>()).type.mixin, [#M]);
- typeParameters(
- reflect(new GenericMixinApplication2<bool>()).type.mixin, [#M]);
typeParameters(reflect(new NonGenericClass1()).type.mixin, []);
typeParameters(reflect(new NonGenericClass2()).type.mixin, []);
- typeParameters(reflect(new GenericClass1<bool>()).type.mixin, [#C]);
- typeParameters(reflect(new GenericClass2<bool>()).type.mixin, [#C]);
- typeParameters(reflect(new NonGenericClass1()).type.superclass!.mixin, [#M]);
- typeParameters(reflect(new NonGenericClass2()).type.superclass!.mixin, [#M]);
- typeParameters(
- reflect(new GenericClass1<bool>()).type.superclass!.mixin, [#M]);
- typeParameters(
- reflect(new GenericClass2<bool>()).type.superclass!.mixin, [#M]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin,
- [#A, #B, #C]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass!
- .mixin,
- [#N]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass!
- .superclass!
- .mixin,
- [#M]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass!
- .superclass!
- .superclass!
- .mixin,
- [#S]);
typeArguments(
reflect(new NonGenericMixinApplication1()).type.mixin, [dynamicMirror]);
diff --git a/tests/lib/mirrors/generics_substitution_test.dart b/tests/lib/mirrors/generics_substitution_test.dart
index 9c2c0ae..6ca6c54 100644
--- a/tests/lib/mirrors/generics_substitution_test.dart
+++ b/tests/lib/mirrors/generics_substitution_test.dart
@@ -36,18 +36,12 @@
Symbol t(ClassMirror cm) =>
(cm.declarations[#t] as MethodMirror).returnType.simpleName;
- Expect.equals(#T, r(genericDecl.superclass!));
Expect.equals(#int, s(genericDecl.superclass!));
- Expect.equals(#T, t(genericDecl));
Expect.equals(#String, r(genericOfString.superclass!));
Expect.equals(#int, s(genericOfString.superclass!));
Expect.equals(#String, t(genericOfString));
- Expect.equals(#R, r(superGenericDecl));
- Expect.equals(#S, s(superGenericDecl));
-
- Expect.equals(#T, r(superOfTAndInt));
Expect.equals(#int, s(superOfTAndInt));
Expect.equals(#String, r(superOfStringAndInt));
diff --git a/tests/lib/mirrors/generics_test.dart b/tests/lib/mirrors/generics_test.dart
index ce9d8f0..be1ea8a 100644
--- a/tests/lib/mirrors/generics_test.dart
+++ b/tests/lib/mirrors/generics_test.dart
@@ -33,15 +33,11 @@
main() {
// Declarations.
- typeParameters(reflectClass(A), [#T]);
typeParameters(reflectClass(G), []);
typeParameters(reflectClass(B), []);
typeParameters(reflectClass(C), []);
typeParameters(reflectClass(D), []);
- typeParameters(reflectClass(E), [#S]);
- typeParameters(reflectClass(F), [#R]);
typeParameters(reflectClass(G), []);
- typeParameters(reflectClass(H), [#A, #B, #C]);
typeParameters(reflectClass(I), []);
typeArguments(reflectClass(A), []);
@@ -75,14 +71,10 @@
Expect.equals(reflectClass(I), reflectClass(I).originalDeclaration);
// Instantiations.
- typeParameters(reflect(new A<num>()).type, [#T]);
typeParameters(reflect(new B()).type, []);
typeParameters(reflect(new C()).type, []);
typeParameters(reflect(new D()).type, []);
- typeParameters(reflect(new E()).type, [#S]);
- typeParameters(reflect(new F<num>()).type, [#R]);
typeParameters(reflect(new G()).type, []);
- typeParameters(reflect(new H()).type, [#A, #B, #C]);
typeParameters(reflect(new I()).type, []);
var numMirror = reflectClass(num);
diff --git a/tests/lib/mirrors/parameter_test.dart b/tests/lib/mirrors/parameter_test.dart
index 2a5eff6..2d9418f 100644
--- a/tests/lib/mirrors/parameter_test.dart
+++ b/tests/lib/mirrors/parameter_test.dart
@@ -180,24 +180,7 @@
MethodMirror fooInC = cm.declarations[#foo] as MethodMirror;
expect('Method(s(foo) in s(C))', fooInC);
- expect(
- '[Parameter(s(a) in s(foo),'
- ' type = Class(s(int) in s(dart.core), top-level)), '
- 'Parameter(s(b) in s(foo),'
- ' type = TypeVariable(s(S) in s(Null),'
- ' upperBound = Class(s(int) in s(dart.core), top-level)))]',
- fooInC.parameters);
MethodMirror barInC = cm.declarations[#bar] as MethodMirror;
expect('Method(s(bar) in s(C))', barInC);
- expect(
- '[Parameter(s(a) in s(bar),'
- ' type = TypeVariable(s(S) in s(Null),'
- ' upperBound = Class(s(int) in s(dart.core), top-level))), '
- 'Parameter(s(b) in s(bar),'
- ' type = TypeVariable(s(T) in s(Null),'
- ' upperBound = Class(s(Object) in s(dart.core), top-level))), '
- 'Parameter(s(c) in s(bar),'
- ' type = Class(s(num) in s(dart.core), top-level))]',
- barInC.parameters);
}
diff --git a/tests/lib/mirrors/type_argument_is_type_variable_test.dart b/tests/lib/mirrors/type_argument_is_type_variable_test.dart
index 2aa7118..d26d803 100644
--- a/tests/lib/mirrors/type_argument_is_type_variable_test.dart
+++ b/tests/lib/mirrors/type_argument_is_type_variable_test.dart
@@ -27,14 +27,6 @@
TypeVariableMirror ssFromSuperSuper =
superOfSuperOfGeneric.typeVariables.single;
- Expect.equals(#G, gFromGeneric.simpleName);
- Expect.equals(#S, sFromSuper.simpleName);
- Expect.equals(#SS, ssFromSuperSuper.simpleName);
-
- typeParameters(generic, [#G]);
- typeParameters(superOfGeneric, [#S]);
- typeParameters(superOfSuperOfGeneric, [#SS]);
-
typeArguments(generic, []);
typeArguments(superOfGeneric, [gFromGeneric]);
typeArguments(superOfSuperOfGeneric, [gFromGeneric]);
@@ -44,10 +36,6 @@
ClassMirror superOfGenericWithInt = genericWithInt.superclass!;
ClassMirror superOfSuperOfGenericWithInt = superOfGenericWithInt.superclass!;
- typeParameters(genericWithInt, [#G]);
- typeParameters(superOfGenericWithInt, [#S]);
- typeParameters(superOfSuperOfGenericWithInt, [#SS]);
-
typeArguments(genericWithInt, [reflectClass(int)]);
typeArguments(superOfGenericWithInt, [reflectClass(int)]);
typeArguments(superOfSuperOfGenericWithInt, [reflectClass(int)]);
diff --git a/tests/lib_2/mirrors/class_mirror_type_variables_expect.dart b/tests/lib_2/mirrors/class_mirror_type_variables_expect.dart
index cf30d1c..5adbd2d 100644
--- a/tests/lib_2/mirrors/class_mirror_type_variables_expect.dart
+++ b/tests/lib_2/mirrors/class_mirror_type_variables_expect.dart
@@ -98,9 +98,9 @@
values.forEach((e) {
Expect.equals(true, e is TypeVariableMirror);
});
- Expect.equals(#R, values.elementAt(0).simpleName);
- Expect.equals(#S, values.elementAt(1).simpleName);
- Expect.equals(#T, values.elementAt(2).simpleName);
+
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
}
void testE(Env env) {
diff --git a/tests/lib_2/mirrors/generic_bounded_by_type_parameter_test.dart b/tests/lib_2/mirrors/generic_bounded_by_type_parameter_test.dart
index 8edb952..c4dbb66 100644
--- a/tests/lib_2/mirrors/generic_bounded_by_type_parameter_test.dart
+++ b/tests/lib_2/mirrors/generic_bounded_by_type_parameter_test.dart
@@ -52,12 +52,8 @@
Expect.equals(reflectClass(Object), xFromGeneric.upperBound); // //# 02: continued
Expect.equals(reflectClass(Object), yFromGeneric.upperBound); // //# 02: continued
- typeParameters(superDecl, [#T, #R]);
- typeParameters(superOfNumAndInt, [#T, #R]);
- typeParameters(genericDecl, [#X, #Y]); // //# 02: continued
- typeParameters(superOfXAndY, [#T, #R]); // //# 02: continued
- typeParameters(genericOfNumAndDouble, [#X, #Y]); // //# 02: continued
- typeParameters(superOfNumAndDouble, [#T, #R]); // //# 02: continued
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(superDecl, []);
typeArguments(superOfNumAndInt, [reflectClass(num), reflectClass(int)]);
diff --git a/tests/lib_2/mirrors/generic_bounded_test.dart b/tests/lib_2/mirrors/generic_bounded_test.dart
index 4e47e13..3cd16fa 100644
--- a/tests/lib_2/mirrors/generic_bounded_test.dart
+++ b/tests/lib_2/mirrors/generic_bounded_test.dart
@@ -51,13 +51,8 @@
Expect.equals(reflectClass(num), tFromSuper.upperBound);
Expect.equals(reflectClass(Object), rFromGeneric.upperBound); // //# 02: continued
- typeParameters(superDecl, [#T]);
- typeParameters(superOfInt, [#T]);
- typeParameters(genericDecl, [#R]); // //# 02: continued
- typeParameters(superOfR, [#T]); // //# 02: continued
- typeParameters(genericOfDouble, [#R]); // //# 02: continued
- typeParameters(superOfDouble, [#T]); // //# 02: continued
- typeParameters(superOfString, [#T]); // //# 01: continued
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(superDecl, []);
typeArguments(superOfInt, [reflectClass(int)]);
diff --git a/tests/lib_2/mirrors/generic_class_declaration_test.dart b/tests/lib_2/mirrors/generic_class_declaration_test.dart
index 76b1c19..353b48f 100644
--- a/tests/lib_2/mirrors/generic_class_declaration_test.dart
+++ b/tests/lib_2/mirrors/generic_class_declaration_test.dart
@@ -84,13 +84,6 @@
.map(stringify),
'constructors');
- Expect.setEquals(
- [
- 'TypeVariable(s(T) in s(A), upperBound = Class(s(Object) in '
- 's(dart.core), top-level))'
- ],
- cm.declarations.values
- .where((dm) => dm is TypeVariableMirror)
- .map(stringify),
- 'type variables');
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
}
diff --git a/tests/lib_2/mirrors/generic_f_bounded_test.dart b/tests/lib_2/mirrors/generic_f_bounded_test.dart
index ff86355..ccde8ae 100644
--- a/tests/lib_2/mirrors/generic_f_bounded_test.dart
+++ b/tests/lib_2/mirrors/generic_f_bounded_test.dart
@@ -45,13 +45,14 @@
Expect.equals(magnitudeDecl, magnitudeOfR.originalDeclaration);
Expect.equals(rFromSorter, magnitudeOfR.typeArguments.single);
- typeParameters(magnitudeDecl, [#T]);
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
+
typeParameters(realDecl, []);
- typeParameters(sorterDecl, [#R]);
typeParameters(realSorterDecl, []);
- typeParameters(magnitudeOfReal, [#T]);
- typeParameters(sorterOfReal, [#R]);
- typeParameters(magnitudeOfR, [#T]);
+
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(magnitudeDecl, []);
typeArguments(realDecl, []);
diff --git a/tests/lib_2/mirrors/generic_interface_test.dart b/tests/lib_2/mirrors/generic_interface_test.dart
index a9ad011..7480523 100644
--- a/tests/lib_2/mirrors/generic_interface_test.dart
+++ b/tests/lib_2/mirrors/generic_interface_test.dart
@@ -93,20 +93,8 @@
Expect.equals(reflectClass(Object), xFromGenericMixinApplication.upperBound);
Expect.equals(reflectClass(Object), yFromGenericClass.upperBound);
- typeParameters(interfaceDecl, [#T]);
- typeParameters(boundedDecl, [#S]);
- typeParameters(interfaceOfInt, [#T]);
- typeParameters(interfaceOfR, [#T]);
- typeParameters(interfaceOfBool, [#T]);
- typeParameters(boundedOfInt, [#S]);
- typeParameters(boundedOfString, [#S]); // //# 01: continued
- typeParameters(interfaceOfFBounded, [#T]);
- typeParameters(interfaceOfInt2, [#T]);
- typeParameters(interfaceOfX, [#T]);
- typeParameters(interfaceOfDouble, [#T]);
- typeParameters(interfaceOfInt3, [#T]);
- typeParameters(interfaceOfY, [#T]);
- typeParameters(interfaceOfDouble2, [#T]);
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(interfaceDecl, []);
typeArguments(boundedDecl, []);
diff --git a/tests/lib_2/mirrors/generic_mixin_test.dart b/tests/lib_2/mirrors/generic_mixin_test.dart
index 7ea8b4e..ccde91b 100644
--- a/tests/lib_2/mirrors/generic_mixin_test.dart
+++ b/tests/lib_2/mirrors/generic_mixin_test.dart
@@ -37,29 +37,8 @@
main() {
TypeMirror dynamicMirror = currentMirrorSystem().dynamicType;
- typeParameters(reflectClass(NonGenericMixinApplication1).mixin, [#M]);
- typeParameters(reflectClass(NonGenericMixinApplication2).mixin, [#M]);
- typeParameters(reflectClass(GenericMixinApplication1).mixin, [#M]);
- typeParameters(reflectClass(GenericMixinApplication2).mixin, [#M]);
- typeParameters(reflectClass(NonGenericClass1).mixin, []);
- typeParameters(reflectClass(NonGenericClass2).mixin, []);
- typeParameters(reflectClass(GenericClass1).mixin, [#C]);
- typeParameters(reflectClass(GenericClass2).mixin, [#C]);
- typeParameters(reflectClass(NonGenericClass1).superclass.mixin, [#M]);
- typeParameters(reflectClass(NonGenericClass2).superclass.mixin, [#M]);
- typeParameters(reflectClass(GenericClass1).superclass.mixin, [#M]);
- typeParameters(reflectClass(GenericClass2).superclass.mixin, [#M]);
- typeParameters(reflectClass(GenericMultipleMixins).mixin, [#A, #B, #C]);
- typeParameters(reflectClass(GenericMultipleMixins).superclass.mixin, [#N]);
- typeParameters(
- reflectClass(GenericMultipleMixins).superclass.superclass.mixin, [#M]);
- typeParameters(
- reflectClass(GenericMultipleMixins)
- .superclass
- .superclass
- .superclass
- .mixin,
- [#S]);
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(
reflectClass(NonGenericMixinApplication1).mixin, [dynamicMirror]);
@@ -94,46 +73,8 @@
.mixin,
[reflectClass(GenericMultipleMixins).typeVariables[0]]);
- typeParameters(reflect(new NonGenericMixinApplication1()).type.mixin, [#M]);
- typeParameters(reflect(new NonGenericMixinApplication2()).type.mixin, [#M]);
- typeParameters(
- reflect(new GenericMixinApplication1<bool>()).type.mixin, [#M]);
- typeParameters(
- reflect(new GenericMixinApplication2<bool>()).type.mixin, [#M]);
typeParameters(reflect(new NonGenericClass1()).type.mixin, []);
typeParameters(reflect(new NonGenericClass2()).type.mixin, []);
- typeParameters(reflect(new GenericClass1<bool>()).type.mixin, [#C]);
- typeParameters(reflect(new GenericClass2<bool>()).type.mixin, [#C]);
- typeParameters(reflect(new NonGenericClass1()).type.superclass.mixin, [#M]);
- typeParameters(reflect(new NonGenericClass2()).type.superclass.mixin, [#M]);
- typeParameters(
- reflect(new GenericClass1<bool>()).type.superclass.mixin, [#M]);
- typeParameters(
- reflect(new GenericClass2<bool>()).type.superclass.mixin, [#M]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>()).type.mixin,
- [#A, #B, #C]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass
- .mixin,
- [#N]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass
- .superclass
- .mixin,
- [#M]);
- typeParameters(
- reflect(new GenericMultipleMixins<bool, String, int>())
- .type
- .superclass
- .superclass
- .superclass
- .mixin,
- [#S]);
typeArguments(
reflect(new NonGenericMixinApplication1()).type.mixin, [dynamicMirror]);
diff --git a/tests/lib_2/mirrors/generics_substitution_test.dart b/tests/lib_2/mirrors/generics_substitution_test.dart
index 8c89b03..b07f509 100644
--- a/tests/lib_2/mirrors/generics_substitution_test.dart
+++ b/tests/lib_2/mirrors/generics_substitution_test.dart
@@ -38,18 +38,15 @@
Symbol t(ClassMirror cm) =>
(cm.declarations[#t] as MethodMirror).returnType.simpleName;
- Expect.equals(#T, r(genericDecl.superclass));
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
+
Expect.equals(#int, s(genericDecl.superclass));
- Expect.equals(#T, t(genericDecl));
Expect.equals(#String, r(genericOfString.superclass));
Expect.equals(#int, s(genericOfString.superclass));
Expect.equals(#String, t(genericOfString));
- Expect.equals(#R, r(superGenericDecl));
- Expect.equals(#S, s(superGenericDecl));
-
- Expect.equals(#T, r(superOfTAndInt));
Expect.equals(#int, s(superOfTAndInt));
Expect.equals(#String, r(superOfStringAndInt));
diff --git a/tests/lib_2/mirrors/generics_test.dart b/tests/lib_2/mirrors/generics_test.dart
index c0ec7fa..a9dfb79 100644
--- a/tests/lib_2/mirrors/generics_test.dart
+++ b/tests/lib_2/mirrors/generics_test.dart
@@ -35,15 +35,15 @@
main() {
// Declarations.
- typeParameters(reflectClass(A), [#T]);
+
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
+
typeParameters(reflectClass(G), []);
typeParameters(reflectClass(B), []);
typeParameters(reflectClass(C), []);
typeParameters(reflectClass(D), []);
- typeParameters(reflectClass(E), [#S]);
- typeParameters(reflectClass(F), [#R]);
typeParameters(reflectClass(G), []);
- typeParameters(reflectClass(H), [#A, #B, #C]);
typeParameters(reflectClass(I), []);
typeArguments(reflectClass(A), []);
@@ -77,14 +77,10 @@
Expect.equals(reflectClass(I), reflectClass(I).originalDeclaration);
// Instantiations.
- typeParameters(reflect(new A<num>()).type, [#T]);
typeParameters(reflect(new B()).type, []);
typeParameters(reflect(new C()).type, []);
typeParameters(reflect(new D()).type, []);
- typeParameters(reflect(new E()).type, [#S]);
- typeParameters(reflect(new F<num>()).type, [#R]);
typeParameters(reflect(new G()).type, []);
- typeParameters(reflect(new H()).type, [#A, #B, #C]);
typeParameters(reflect(new I()).type, []);
var numMirror = reflectClass(num);
diff --git a/tests/lib_2/mirrors/parameter_test.dart b/tests/lib_2/mirrors/parameter_test.dart
index 47095dd..fe1b77a 100644
--- a/tests/lib_2/mirrors/parameter_test.dart
+++ b/tests/lib_2/mirrors/parameter_test.dart
@@ -182,24 +182,11 @@
MethodMirror fooInC = cm.declarations[#foo] as MethodMirror;
expect('Method(s(foo) in s(C))', fooInC);
- expect(
- '[Parameter(s(a) in s(foo),'
- ' type = Class(s(int) in s(dart.core), top-level)), '
- 'Parameter(s(b) in s(foo),'
- ' type = TypeVariable(s(S) in s(Null),'
- ' upperBound = Class(s(int) in s(dart.core), top-level)))]',
- fooInC.parameters);
+
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
+
MethodMirror barInC = cm.declarations[#bar] as MethodMirror;
expect('Method(s(bar) in s(C))', barInC);
- expect(
- '[Parameter(s(a) in s(bar),'
- ' type = TypeVariable(s(S) in s(Null),'
- ' upperBound = Class(s(int) in s(dart.core), top-level))), '
- 'Parameter(s(b) in s(bar),'
- ' type = TypeVariable(s(T) in s(Null),'
- ' upperBound = Class(s(Object) in s(dart.core), top-level))), '
- 'Parameter(s(c) in s(bar),'
- ' type = Class(s(num) in s(dart.core), top-level))]',
- barInC.parameters);
}
diff --git a/tests/lib_2/mirrors/type_argument_is_type_variable_test.dart b/tests/lib_2/mirrors/type_argument_is_type_variable_test.dart
index ca11b17..733e575 100644
--- a/tests/lib_2/mirrors/type_argument_is_type_variable_test.dart
+++ b/tests/lib_2/mirrors/type_argument_is_type_variable_test.dart
@@ -29,13 +29,8 @@
TypeVariableMirror ssFromSuperSuper =
superOfSuperOfGeneric.typeVariables.single;
- Expect.equals(#G, gFromGeneric.simpleName);
- Expect.equals(#S, sFromSuper.simpleName);
- Expect.equals(#SS, ssFromSuperSuper.simpleName);
-
- typeParameters(generic, [#G]);
- typeParameters(superOfGeneric, [#S]);
- typeParameters(superOfSuperOfGeneric, [#SS]);
+ // Names of type variables are not preserved after type canonicalization
+ // and are therefore not compared to expected names.
typeArguments(generic, []);
typeArguments(superOfGeneric, [gFromGeneric]);
@@ -46,10 +41,6 @@
ClassMirror superOfGenericWithInt = genericWithInt.superclass;
ClassMirror superOfSuperOfGenericWithInt = superOfGenericWithInt.superclass;
- typeParameters(genericWithInt, [#G]);
- typeParameters(superOfGenericWithInt, [#S]);
- typeParameters(superOfSuperOfGenericWithInt, [#SS]);
-
typeArguments(genericWithInt, [reflectClass(int)]);
typeArguments(superOfGenericWithInt, [reflectClass(int)]);
typeArguments(superOfSuperOfGenericWithInt, [reflectClass(int)]);
diff --git a/tools/VERSION b/tools/VERSION
index 22a5d08..875ff19 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 85
+PRERELEASE 86
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/create_timestamp_file.py b/tools/create_timestamp_file.py
new file mode 100755
index 0000000..bb48e7f
--- /dev/null
+++ b/tools/create_timestamp_file.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+import sys
+import os
+
+
+def main(args):
+ for file_name in args[1:]:
+ dir_name = os.path.dirname(file_name)
+ if not os.path.exists(dir_name):
+ os.mkdir(dir_name)
+ open(file_name, 'w').close()
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/tools/list_dart_files_as_depfile.py b/tools/list_dart_files_as_depfile.py
deleted file mode 100644
index f03e7ad..0000000
--- a/tools/list_dart_files_as_depfile.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-"""Tool for listing Dart source files.
-
-If the first argument is 'relative', the script produces paths relative to the
-current working directory. If the first argument is 'absolute', the script
-produces absolute paths.
-
-Usage:
- python3 tools/list_dart_files_as_depfile.py <depfile> <directory> <pattern>
-"""
-
-import os
-import re
-import sys
-
-
-def main(argv):
- depfile = argv[1]
- directory = argv[2]
- if not os.path.isabs(directory):
- directory = os.path.realpath(directory)
-
- pattern = None
- if len(argv) > 3:
- pattern = re.compile(argv[3])
-
- # Output a GN depfile, whose format is a Makefile with one target.
- out = open(depfile, 'w')
- out.write(depfile)
- out.write(":")
-
- for root, directories, files in os.walk(directory):
- # We only care about actual source files, not generated code or tests.
- for skip_dir in ['.git', 'gen', 'test']:
- if skip_dir in directories:
- directories.remove(skip_dir)
-
- # If we are looking at the root directory, filter the immediate
- # subdirectories by the given pattern.
- if pattern and root == directory:
- directories[:] = filter(pattern.match, directories)
-
- for filename in files:
- if filename.endswith(
- '.dart') and not filename.endswith('_test.dart'):
- fullname = os.path.join(directory, root, filename)
- fullname = fullname.replace(os.sep, '/')
- out.write(" \"")
- out.write(fullname)
- out.write("\"")
-
- out.write("\n")
- out.close()
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/utils/create_timestamp.gni b/utils/create_timestamp.gni
index 3b39299..835700a 100644
--- a/utils/create_timestamp.gni
+++ b/utils/create_timestamp.gni
@@ -10,15 +10,16 @@
path = invoker.path
output = invoker.output
action(target_name) {
- script = "$_dart_root/tools/list_dart_files_as_depfile.py"
- args = [
- rebase_path(output),
- path,
- ]
+ list_args = [ path ]
if (defined(invoker.pattern)) {
- args += [ invoker.pattern ]
+ list_args += [ invoker.pattern ]
}
- depfile = output
+ files = exec_script("$_dart_root/tools/list_dart_files.py",
+ [ "absolute" ] + list_args,
+ "list lines")
+ inputs = [ "$_dart_root/tools/list_dart_files.py" ] + files
outputs = [ output ]
+ script = "$_dart_root/tools/create_timestamp_file.py"
+ args = [ rebase_path(output) ]
}
}