Version 2.14.0-75.0.dev
Merge commit 'fa7d56e7fb6b06c6fdedf781762b7dc6eb96f1eb' into 'dev'
diff --git a/DEPS b/DEPS
index 606c3e7..2c75fde 100644
--- a/DEPS
+++ b/DEPS
@@ -39,7 +39,7 @@
# Checked-in SDK version. The checked-in SDK is a Dart SDK distribution in a
# cipd package used to run Dart scripts in the build and test infrastructure.
- "sdk_tag": "version:2.12.0",
+ "sdk_tag": "version:2.13.0-211.14.beta",
# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
# hashes. It requires access to the dart-build-access group, which EngProd
diff --git a/pkg/front_end/testcases/general/invalid_operator.dart.weak.expect b/pkg/front_end/testcases/general/invalid_operator.dart.weak.expect
index c65d2ea..85568b7 100644
--- a/pkg/front_end/testcases/general/invalid_operator.dart.weak.expect
+++ b/pkg/front_end/testcases/general/invalid_operator.dart.weak.expect
@@ -564,35 +564,35 @@
// Try adding explicit types.
// operator ==<T>(a) => true;
// ^^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is one of the overridden members.
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is one of the overridden members.
// bool operator ==(Object other) native "Object_equals";
// ^^
//
// pkg/front_end/testcases/general/invalid_operator.dart:6:12: Error: The method 'Operators1.==' has fewer positional arguments than those of overridden method 'Object.=='.
// operator ==() => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:27:12: Error: The method 'Operators2.==' has more required arguments than those of overridden method 'Object.=='.
// operator ==(a, b) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:71:12: Error: The method 'Operators4.==' has fewer positional arguments than those of overridden method 'Object.=='.
// operator ==({a}) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:137:12: Error: Declared type variables of 'Operators7.==' doesn't match those on overridden method 'Object.=='.
// operator ==<T>(a) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
diff --git a/pkg/front_end/testcases/general/invalid_operator.dart.weak.outline.expect b/pkg/front_end/testcases/general/invalid_operator.dart.weak.outline.expect
index 63dfbeb..9474e68 100644
--- a/pkg/front_end/testcases/general/invalid_operator.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/invalid_operator.dart.weak.outline.expect
@@ -564,35 +564,35 @@
// Try adding explicit types.
// operator ==<T>(a) => true;
// ^^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is one of the overridden members.
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is one of the overridden members.
// bool operator ==(Object other) native "Object_equals";
// ^^
//
// pkg/front_end/testcases/general/invalid_operator.dart:6:12: Error: The method 'Operators1.==' has fewer positional arguments than those of overridden method 'Object.=='.
// operator ==() => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:27:12: Error: The method 'Operators2.==' has more required arguments than those of overridden method 'Object.=='.
// operator ==(a, b) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:71:12: Error: The method 'Operators4.==' has fewer positional arguments than those of overridden method 'Object.=='.
// operator ==({a}) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
// pkg/front_end/testcases/general/invalid_operator.dart:137:12: Error: Declared type variables of 'Operators7.==' doesn't match those on overridden method 'Object.=='.
// operator ==<T>(a) => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue42603.dart.strong.expect b/pkg/front_end/testcases/nnbd/issue42603.dart.strong.expect
index 12f52a0..734823f 100644
--- a/pkg/front_end/testcases/nnbd/issue42603.dart.strong.expect
+++ b/pkg/front_end/testcases/nnbd/issue42603.dart.strong.expect
@@ -9,7 +9,7 @@
// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Error: The method 'E.==' has fewer positional arguments than those of overridden method 'Object.=='.
// bool operator ==() => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue42603.dart.weak.expect b/pkg/front_end/testcases/nnbd/issue42603.dart.weak.expect
index 12f52a0..734823f 100644
--- a/pkg/front_end/testcases/nnbd/issue42603.dart.weak.expect
+++ b/pkg/front_end/testcases/nnbd/issue42603.dart.weak.expect
@@ -9,7 +9,7 @@
// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Error: The method 'E.==' has fewer positional arguments than those of overridden method 'Object.=='.
// bool operator ==() => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
diff --git a/pkg/front_end/testcases/nnbd/issue42603.dart.weak.outline.expect b/pkg/front_end/testcases/nnbd/issue42603.dart.weak.outline.expect
index 926252c..7475e9f 100644
--- a/pkg/front_end/testcases/nnbd/issue42603.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue42603.dart.weak.outline.expect
@@ -9,7 +9,7 @@
// pkg/front_end/testcases/nnbd/issue42603.dart:18:17: Error: The method 'E.==' has fewer positional arguments than those of overridden method 'Object.=='.
// bool operator ==() => true;
// ^
-// sdk/lib/_internal/vm/lib/object_patch.dart:21:17: Context: This is the overridden method ('==').
+// sdk/lib/_internal/vm/lib/object_patch.dart:26:17: Context: This is the overridden method ('==').
// bool operator ==(Object other) native "Object_equals";
// ^
//
diff --git a/pkg/kernel/lib/core_types.dart b/pkg/kernel/lib/core_types.dart
index 4123eec..30c0329 100644
--- a/pkg/kernel/lib/core_types.dart
+++ b/pkg/kernel/lib/core_types.dart
@@ -119,8 +119,8 @@
CoreTypes(Component component)
: index = new LibraryIndex.coreLibraries(component);
- late final Procedure asyncErrorWrapperHelperProcedure = index
- .getTopLevelMember('dart:async', '_asyncErrorWrapperHelper') as Procedure;
+ late final Procedure asyncErrorWrapperHelperProcedure =
+ index.getTopLevelProcedure('dart:async', '_asyncErrorWrapperHelper');
late final Library asyncLibrary = index.getLibrary('dart:async');
@@ -139,33 +139,33 @@
late final Member asyncStarStreamControllerClose =
index.getMember('dart:async', '_AsyncStarStreamController', 'close');
- late final Constructor asyncStarStreamControllerDefaultConstructor = index
- .getMember('dart:async', '_AsyncStarStreamController', '') as Constructor;
+ late final Constructor asyncStarStreamControllerDefaultConstructor =
+ index.getConstructor('dart:async', '_AsyncStarStreamController', '');
late final Member asyncStarStreamControllerStream =
index.getMember('dart:async', '_AsyncStarStreamController', 'get:stream');
- late final Procedure asyncStarMoveNextHelper = index.getTopLevelMember(
- 'dart:async', '_asyncStarMoveNextHelper') as Procedure;
+ late final Procedure asyncStarMoveNextHelper =
+ index.getTopLevelProcedure('dart:async', '_asyncStarMoveNextHelper');
- late final Procedure asyncThenWrapperHelperProcedure = index
- .getTopLevelMember('dart:async', '_asyncThenWrapperHelper') as Procedure;
+ late final Procedure asyncThenWrapperHelperProcedure =
+ index.getTopLevelProcedure('dart:async', '_asyncThenWrapperHelper');
late final Procedure awaitHelperProcedure =
- index.getTopLevelMember('dart:async', '_awaitHelper') as Procedure;
+ index.getTopLevelProcedure('dart:async', '_awaitHelper');
late final Class boolClass = index.getClass('dart:core', 'bool');
late final Class futureImplClass = index.getClass('dart:async', '_Future');
late final Constructor futureImplConstructor =
- index.getMember('dart:async', '_Future', '') as Constructor;
+ index.getConstructor('dart:async', '_Future', '');
- late final Procedure completeOnAsyncReturn = index.getTopLevelMember(
- 'dart:async', '_completeOnAsyncReturn') as Procedure;
+ late final Procedure completeOnAsyncReturn =
+ index.getTopLevelProcedure('dart:async', '_completeOnAsyncReturn');
- late final Procedure completeOnAsyncError = index.getTopLevelMember(
- 'dart:async', '_completeOnAsyncError') as Procedure;
+ late final Procedure completeOnAsyncError =
+ index.getTopLevelProcedure('dart:async', '_completeOnAsyncError');
late final Library coreLibrary = index.getLibrary('dart:core');
@@ -180,7 +180,7 @@
index.getClass('dart:async', 'FutureOr');
late final Procedure identicalProcedure =
- index.getTopLevelMember('dart:core', 'identical') as Procedure;
+ index.getTopLevelProcedure('dart:core', 'identical');
late final Class intClass = index.getClass('dart:core', 'int');
@@ -192,47 +192,46 @@
late final Class invocationMirrorClass =
index.getClass('dart:core', '_InvocationMirror');
- late final Constructor invocationMirrorWithTypeConstructor = index.getMember(
- 'dart:core', '_InvocationMirror', '_withType') as Constructor;
+ late final Constructor invocationMirrorWithTypeConstructor =
+ index.getConstructor('dart:core', '_InvocationMirror', '_withType');
late final Class iterableClass = index.getClass('dart:core', 'Iterable');
late final Procedure iterableGetIterator =
- index.getMember('dart:core', 'Iterable', 'get:iterator') as Procedure;
+ index.getProcedure('dart:core', 'Iterable', 'get:iterator');
late final Class iteratorClass = index.getClass('dart:core', 'Iterator');
late final Procedure iteratorMoveNext =
- index.getMember('dart:core', 'Iterator', 'moveNext') as Procedure;
+ index.getProcedure('dart:core', 'Iterator', 'moveNext');
late final Procedure iteratorGetCurrent =
- index.getMember('dart:core', 'Iterator', 'get:current') as Procedure;
+ index.getProcedure('dart:core', 'Iterator', 'get:current');
late final Class listClass = index.getClass('dart:core', 'List');
late final Procedure listDefaultConstructor =
- index.getMember('dart:core', 'List', '') as Procedure;
+ index.getProcedure('dart:core', 'List', '');
late final Procedure listFromConstructor =
- index.getMember('dart:core', 'List', 'from') as Procedure;
+ index.getProcedure('dart:core', 'List', 'from');
late final Procedure listUnmodifiableConstructor =
- index.getMember('dart:core', 'List', 'unmodifiable') as Procedure;
+ index.getProcedure('dart:core', 'List', 'unmodifiable');
late final Class setClass = index.getClass('dart:core', 'Set');
late final Class mapClass = index.getClass('dart:core', 'Map');
late final Procedure mapUnmodifiable =
- index.getMember('dart:core', 'Map', 'unmodifiable') as Procedure;
+ index.getProcedure('dart:core', 'Map', 'unmodifiable');
/// The `dart:mirrors` library, or `null` if the component does not use it.
late final Library? mirrorsLibrary = index.tryGetLibrary('dart:mirrors');
late final Constructor noSuchMethodErrorDefaultConstructor =
// TODO(regis): Replace 'withInvocation' with '' after dart2js is fixed.
- index.getMember('dart:core', 'NoSuchMethodError', 'withInvocation')
- as Constructor;
+ index.getConstructor('dart:core', 'NoSuchMethodError', 'withInvocation');
late final Class deprecatedNullClass = index.getClass('dart:core', 'Null');
@@ -241,18 +240,17 @@
late final Class objectClass = index.getClass('dart:core', 'Object');
late final Procedure objectEquals =
- index.getMember('dart:core', 'Object', '==') as Procedure;
+ index.getProcedure('dart:core', 'Object', '==');
late final Class pragmaClass = index.getClass('dart:core', 'pragma');
- late final Field pragmaName =
- index.getMember('dart:core', 'pragma', 'name') as Field;
+ late final Field pragmaName = index.getField('dart:core', 'pragma', 'name');
late final Field pragmaOptions =
- index.getMember('dart:core', 'pragma', 'options') as Field;
+ index.getField('dart:core', 'pragma', 'options');
late final Constructor pragmaConstructor =
- index.getMember('dart:core', 'pragma', '_') as Constructor;
+ index.getConstructor('dart:core', 'pragma', '_');
late final Class stackTraceClass = index.getClass('dart:core', 'StackTrace');
@@ -268,7 +266,7 @@
index.getClass('dart:async', '_StreamIterator');
late final Constructor streamIteratorDefaultConstructor =
- index.getMember('dart:async', '_StreamIterator', '') as Constructor;
+ index.getConstructor('dart:async', '_StreamIterator', '');
late final Member streamIteratorMoveNext =
index.getMember('dart:async', '_StreamIterator', 'moveNext');
@@ -281,7 +279,7 @@
late final Class symbolClass = index.getClass('dart:core', 'Symbol');
late final Constructor syncIterableDefaultConstructor =
- index.getMember('dart:core', '_SyncIterable', '') as Constructor;
+ index.getConstructor('dart:core', '_SyncIterable', '');
late final Class syncIteratorClass =
index.getClass('dart:core', '_SyncIterator');
@@ -294,40 +292,40 @@
late final Class typeClass = index.getClass('dart:core', 'Type');
- late final Constructor fallThroughErrorUrlAndLineConstructor = index
- .getMember('dart:core', 'FallThroughError', '_create') as Constructor;
+ late final Constructor fallThroughErrorUrlAndLineConstructor =
+ index.getConstructor('dart:core', 'FallThroughError', '_create');
late final Procedure boolFromEnvironment =
- index.getMember('dart:core', 'bool', 'fromEnvironment') as Procedure;
+ index.getProcedure('dart:core', 'bool', 'fromEnvironment');
late final Procedure createSentinelMethod =
- index.getTopLevelMember('dart:_internal', 'createSentinel') as Procedure;
+ index.getTopLevelProcedure('dart:_internal', 'createSentinel');
late final Procedure isSentinelMethod =
- index.getTopLevelMember('dart:_internal', 'isSentinel') as Procedure;
+ index.getTopLevelProcedure('dart:_internal', 'isSentinel');
late final Constructor
lateInitializationFieldAssignedDuringInitializationConstructor =
- index.getMember('dart:_internal', 'LateError', 'fieldADI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'fieldADI');
late final Constructor
lateInitializationLocalAssignedDuringInitializationConstructor =
- index.getMember('dart:_internal', 'LateError', 'localADI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'localADI');
late final Constructor lateInitializationFieldNotInitializedConstructor =
- index.getMember('dart:_internal', 'LateError', 'fieldNI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'fieldNI');
late final Constructor lateInitializationLocalNotInitializedConstructor =
- index.getMember('dart:_internal', 'LateError', 'localNI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'localNI');
late final Constructor lateInitializationFieldAlreadyInitializedConstructor =
- index.getMember('dart:_internal', 'LateError', 'fieldAI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'fieldAI');
late final Constructor lateInitializationLocalAlreadyInitializedConstructor =
- index.getMember('dart:_internal', 'LateError', 'localAI') as Constructor;
+ index.getConstructor('dart:_internal', 'LateError', 'localAI');
late final Constructor reachabilityErrorConstructor =
- index.getMember('dart:_internal', 'ReachabilityError', '') as Constructor;
+ index.getConstructor('dart:_internal', 'ReachabilityError', '');
late final Class cellClass = index.getClass('dart:_late_helper', '_Cell');
diff --git a/pkg/kernel/lib/library_index.dart b/pkg/kernel/lib/library_index.dart
index 6ee654d..e2f89df 100644
--- a/pkg/kernel/lib/library_index.dart
+++ b/pkg/kernel/lib/library_index.dart
@@ -108,6 +108,19 @@
return _libraries[library]?.tryGetMember(className, memberName);
}
+ Constructor getConstructor(
+ String library, String className, String memberName) {
+ return _getLibraryIndex(library).getConstructor(className, memberName);
+ }
+
+ Procedure getProcedure(String library, String className, String memberName) {
+ return _getLibraryIndex(library).getProcedure(className, memberName);
+ }
+
+ Field getField(String library, String className, String memberName) {
+ return _getLibraryIndex(library).getField(className, memberName);
+ }
+
/// Returns the top-level member with the given name, in the given library.
///
/// If a getter or setter is wanted, the `get:` or `set:` prefix must be
@@ -127,6 +140,14 @@
String library, String className, String memberName) {
return tryGetMember(library, topLevel, memberName);
}
+
+ Procedure getTopLevelProcedure(String library, String memberName) {
+ return getProcedure(library, topLevel, memberName);
+ }
+
+ Field getTopLevelField(String library, String memberName) {
+ return getField(library, topLevel, memberName);
+ }
}
class _ClassTable {
@@ -186,6 +207,18 @@
Member? tryGetMember(String className, String memberName) {
return classes[className]?.tryGetMember(memberName);
}
+
+ Constructor getConstructor(String className, String memberName) {
+ return _getClassIndex(className).getConstructor(memberName);
+ }
+
+ Procedure getProcedure(String className, String memberName) {
+ return _getClassIndex(className).getProcedure(memberName);
+ }
+
+ Field getField(String className, String memberName) {
+ return _getClassIndex(className).getField(memberName);
+ }
}
class _MemberTable {
@@ -290,4 +323,31 @@
}
Member? tryGetMember(String name) => members[name];
+
+ Constructor getConstructor(String name) {
+ Member member = getMember(name);
+ if (member is! Constructor) {
+ throw "Member '$name' in $containerName is not a Constructor: "
+ "${member} (${member.runtimeType}).";
+ }
+ return member;
+ }
+
+ Procedure getProcedure(String name) {
+ Member member = getMember(name);
+ if (member is! Procedure) {
+ throw "Member '$name' in $containerName is not a Procedure: "
+ "${member} (${member.runtimeType}).";
+ }
+ return member;
+ }
+
+ Field getField(String name) {
+ Member member = getMember(name);
+ if (member is! Field) {
+ throw "Member '$name' in $containerName is not a Field: "
+ "${member} (${member.runtimeType}).";
+ }
+ return member;
+ }
}
diff --git a/pkg/kernel/lib/vm/constants_native_effects.dart b/pkg/kernel/lib/vm/constants_native_effects.dart
index f4efb71..911f2cc 100644
--- a/pkg/kernel/lib/vm/constants_native_effects.dart
+++ b/pkg/kernel/lib/vm/constants_native_effects.dart
@@ -25,8 +25,8 @@
.firstWhere((Class klass) => klass.name == '_ImmutableMap');
// ignore: unnecessary_null_comparison
assert(immutableMapClass != null);
- Field unmodifiableSetMap = coreTypes.index
- .getMember('dart:collection', '_UnmodifiableSet', '_map') as Field;
+ Field unmodifiableSetMap =
+ coreTypes.index.getField('dart:collection', '_UnmodifiableSet', '_map');
return new VmConstantsBackend._(immutableMapClass, unmodifiableSetMap,
unmodifiableSetMap.enclosingClass!);
diff --git a/pkg/vm/lib/metadata/call_site_attributes.dart b/pkg/vm/lib/metadata/call_site_attributes.dart
index 10acd75..7ef8c93 100644
--- a/pkg/vm/lib/metadata/call_site_attributes.dart
+++ b/pkg/vm/lib/metadata/call_site_attributes.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
library vm.metadata.call_site_attributes;
import 'package:kernel/ast.dart';
@@ -11,7 +13,7 @@
class CallSiteAttributesMetadata {
final DartType receiverType;
- const CallSiteAttributesMetadata({this.receiverType});
+ const CallSiteAttributesMetadata({required this.receiverType});
@override
String toString() =>
diff --git a/pkg/vm/lib/transformations/call_site_annotator.dart b/pkg/vm/lib/transformations/call_site_annotator.dart
index 8a45c5a..e3722a1 100644
--- a/pkg/vm/lib/transformations/call_site_annotator.dart
+++ b/pkg/vm/lib/transformations/call_site_annotator.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
// This transformation annotates call sites with the receiver type.
// This is done to avoid reimplementing [Expression.getStaticType] in
// C++.
@@ -19,8 +21,9 @@
CallSiteAttributesMetadataRepository addRepositoryTo(Component component) {
return component.metadata.putIfAbsent(
- CallSiteAttributesMetadataRepository.repositoryTag,
- () => new CallSiteAttributesMetadataRepository());
+ CallSiteAttributesMetadataRepository.repositoryTag,
+ () => new CallSiteAttributesMetadataRepository())
+ as CallSiteAttributesMetadataRepository;
}
void transformLibraries(Component component, List<Library> libraries,
@@ -33,7 +36,7 @@
class AnnotateWithStaticTypes extends RecursiveVisitor {
final CallSiteAttributesMetadataRepository _metadata;
final TypeEnvironment env;
- StaticTypeContext _staticTypeContext;
+ StaticTypeContext? _staticTypeContext;
AnnotateWithStaticTypes(
Component component, CoreTypes coreTypes, ClassHierarchy hierarchy)
@@ -49,7 +52,7 @@
void annotateWithType(TreeNode node, Expression receiver) {
_metadata.mapping[node] = new CallSiteAttributesMetadata(
- receiverType: receiver.getStaticType(_staticTypeContext));
+ receiverType: receiver.getStaticType(_staticTypeContext!));
}
@override
@@ -80,7 +83,7 @@
/// Returns [true] if the given [member] has any parameters annotated with
/// generic-covariant-impl attribute.
- static bool hasGenericCovariantParameters(Member member) {
+ static bool hasGenericCovariantParameters(Member? member) {
if (member is Procedure) {
return containsGenericCovariantImpl(
member.function.positionalParameters) ||
diff --git a/pkg/vm/lib/transformations/ffi.dart b/pkg/vm/lib/transformations/ffi.dart
index 3012c7a..f4bc7eb 100644
--- a/pkg/vm/lib/transformations/ffi.dart
+++ b/pkg/vm/lib/transformations/ffi.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
// This file contains logic which is shared between the ffi_definition and
// ffi_use_site transformers.
@@ -195,7 +197,7 @@
final LibraryIndex index;
final ClassHierarchy hierarchy;
final DiagnosticReporter diagnosticReporter;
- final ReferenceFromIndex referenceFromIndex;
+ final ReferenceFromIndex? referenceFromIndex;
final Class objectClass;
final Class intClass;
@@ -288,8 +290,8 @@
/// Classes corresponding to [NativeType], indexed by [NativeType].
final List<Class> nativeTypesClasses;
- Library currentLibrary;
- IndexedLibrary currentLibraryIndex;
+ Library? currentLibrary;
+ IndexedLibrary? currentLibraryIndex;
FfiTransformer(this.index, this.coreTypes, this.hierarchy,
this.diagnosticReporter, this.referenceFromIndex)
@@ -300,23 +302,25 @@
listClass = coreTypes.listClass,
typeClass = coreTypes.typeClass,
unsafeCastMethod =
- index.getTopLevelMember('dart:_internal', 'unsafeCast'),
+ index.getTopLevelProcedure('dart:_internal', 'unsafeCast'),
nativeEffectMethod =
- index.getTopLevelMember('dart:_internal', '_nativeEffect'),
+ index.getTopLevelProcedure('dart:_internal', '_nativeEffect'),
typedDataClass = index.getClass('dart:typed_data', 'TypedData'),
typedDataBufferGetter =
- index.getMember('dart:typed_data', 'TypedData', 'get:buffer'),
- typedDataOffsetInBytesGetter = index.getMember(
+ index.getProcedure('dart:typed_data', 'TypedData', 'get:buffer'),
+ typedDataOffsetInBytesGetter = index.getProcedure(
'dart:typed_data', 'TypedData', 'get:offsetInBytes'),
byteBufferAsUint8List =
- index.getMember('dart:typed_data', 'ByteBuffer', 'asUint8List'),
- uint8ListFactory = index.getMember('dart:typed_data', 'Uint8List', ''),
+ index.getProcedure('dart:typed_data', 'ByteBuffer', 'asUint8List'),
+ uint8ListFactory =
+ index.getProcedure('dart:typed_data', 'Uint8List', ''),
pragmaClass = coreTypes.pragmaClass,
pragmaName = coreTypes.pragmaName,
pragmaOptions = coreTypes.pragmaOptions,
- listElementAt = coreTypes.index.getMember('dart:core', 'List', '[]'),
- numAddition = coreTypes.index.getMember('dart:core', 'num', '+'),
- numMultiplication = coreTypes.index.getMember('dart:core', 'num', '*'),
+ listElementAt = coreTypes.index.getProcedure('dart:core', 'List', '[]'),
+ numAddition = coreTypes.index.getProcedure('dart:core', 'num', '+'),
+ numMultiplication =
+ coreTypes.index.getProcedure('dart:core', 'num', '*'),
ffiLibrary = index.getLibrary('dart:ffi'),
allocatorClass = index.getClass('dart:ffi', 'Allocator'),
nativeFunctionClass = index.getClass('dart:ffi', 'NativeFunction'),
@@ -324,120 +328,128 @@
arrayClass = index.getClass('dart:ffi', 'Array'),
arraySizeClass = index.getClass('dart:ffi', '_ArraySize'),
arraySizeDimension1Field =
- index.getMember('dart:ffi', '_ArraySize', 'dimension1'),
+ index.getField('dart:ffi', '_ArraySize', 'dimension1'),
arraySizeDimension2Field =
- index.getMember('dart:ffi', '_ArraySize', 'dimension2'),
+ index.getField('dart:ffi', '_ArraySize', 'dimension2'),
arraySizeDimension3Field =
- index.getMember('dart:ffi', '_ArraySize', 'dimension3'),
+ index.getField('dart:ffi', '_ArraySize', 'dimension3'),
arraySizeDimension4Field =
- index.getMember('dart:ffi', '_ArraySize', 'dimension4'),
+ index.getField('dart:ffi', '_ArraySize', 'dimension4'),
arraySizeDimension5Field =
- index.getMember('dart:ffi', '_ArraySize', 'dimension5'),
+ index.getField('dart:ffi', '_ArraySize', 'dimension5'),
arraySizeDimensionsField =
- index.getMember('dart:ffi', '_ArraySize', 'dimensions'),
+ index.getField('dart:ffi', '_ArraySize', 'dimensions'),
pointerClass = index.getClass('dart:ffi', 'Pointer'),
compoundClass = index.getClass('dart:ffi', '_Compound'),
structClass = index.getClass('dart:ffi', 'Struct'),
unionClass = index.getClass('dart:ffi', 'Union'),
ffiStructLayoutClass = index.getClass('dart:ffi', '_FfiStructLayout'),
ffiStructLayoutTypesField =
- index.getMember('dart:ffi', '_FfiStructLayout', 'fieldTypes'),
+ index.getField('dart:ffi', '_FfiStructLayout', 'fieldTypes'),
ffiStructLayoutPackingField =
- index.getMember('dart:ffi', '_FfiStructLayout', 'packing'),
+ index.getField('dart:ffi', '_FfiStructLayout', 'packing'),
ffiInlineArrayClass = index.getClass('dart:ffi', '_FfiInlineArray'),
ffiInlineArrayElementTypeField =
- index.getMember('dart:ffi', '_FfiInlineArray', 'elementType'),
+ index.getField('dart:ffi', '_FfiInlineArray', 'elementType'),
ffiInlineArrayLengthField =
- index.getMember('dart:ffi', '_FfiInlineArray', 'length'),
+ index.getField('dart:ffi', '_FfiInlineArray', 'length'),
packedClass = index.getClass('dart:ffi', 'Packed'),
packedMemberAlignmentField =
- index.getMember('dart:ffi', 'Packed', 'memberAlignment'),
- allocateMethod = index.getMember('dart:ffi', 'AllocatorAlloc', 'call'),
+ index.getField('dart:ffi', 'Packed', 'memberAlignment'),
+ allocateMethod =
+ index.getProcedure('dart:ffi', 'AllocatorAlloc', 'call'),
allocatorAllocateMethod =
- index.getMember('dart:ffi', 'Allocator', 'allocate'),
- castMethod = index.getMember('dart:ffi', 'Pointer', 'cast'),
- offsetByMethod = index.getMember('dart:ffi', 'Pointer', '_offsetBy'),
- elementAtMethod = index.getMember('dart:ffi', 'Pointer', 'elementAt'),
- addressGetter = index.getMember('dart:ffi', 'Pointer', 'get:address'),
+ index.getProcedure('dart:ffi', 'Allocator', 'allocate'),
+ castMethod = index.getProcedure('dart:ffi', 'Pointer', 'cast'),
+ offsetByMethod = index.getProcedure('dart:ffi', 'Pointer', '_offsetBy'),
+ elementAtMethod =
+ index.getProcedure('dart:ffi', 'Pointer', 'elementAt'),
+ addressGetter =
+ index.getProcedure('dart:ffi', 'Pointer', 'get:address'),
compoundTypedDataBaseField =
- index.getMember('dart:ffi', '_Compound', '_typedDataBase'),
+ index.getField('dart:ffi', '_Compound', '_typedDataBase'),
arrayTypedDataBaseField =
- index.getMember('dart:ffi', 'Array', '_typedDataBase'),
- arraySizeField = index.getMember('dart:ffi', 'Array', '_size'),
+ index.getField('dart:ffi', 'Array', '_typedDataBase'),
+ arraySizeField = index.getField('dart:ffi', 'Array', '_size'),
arrayNestedDimensionsField =
- index.getMember('dart:ffi', 'Array', '_nestedDimensions'),
- arrayCheckIndex = index.getMember('dart:ffi', 'Array', '_checkIndex'),
+ index.getField('dart:ffi', 'Array', '_nestedDimensions'),
+ arrayCheckIndex =
+ index.getProcedure('dart:ffi', 'Array', '_checkIndex'),
arrayNestedDimensionsFlattened =
- index.getMember('dart:ffi', 'Array', '_nestedDimensionsFlattened'),
+ index.getField('dart:ffi', 'Array', '_nestedDimensionsFlattened'),
arrayNestedDimensionsFirst =
- index.getMember('dart:ffi', 'Array', '_nestedDimensionsFirst'),
+ index.getField('dart:ffi', 'Array', '_nestedDimensionsFirst'),
arrayNestedDimensionsRest =
- index.getMember('dart:ffi', 'Array', '_nestedDimensionsRest'),
+ index.getField('dart:ffi', 'Array', '_nestedDimensionsRest'),
structFromTypedDataBase =
- index.getMember('dart:ffi', 'Struct', '_fromTypedDataBase'),
+ index.getConstructor('dart:ffi', 'Struct', '_fromTypedDataBase'),
unionFromTypedDataBase =
- index.getMember('dart:ffi', 'Union', '_fromTypedDataBase'),
- arrayConstructor = index.getMember('dart:ffi', 'Array', '_'),
+ index.getConstructor('dart:ffi', 'Union', '_fromTypedDataBase'),
+ arrayConstructor = index.getConstructor('dart:ffi', 'Array', '_'),
fromAddressInternal =
- index.getTopLevelMember('dart:ffi', '_fromAddress'),
+ index.getTopLevelProcedure('dart:ffi', '_fromAddress'),
structPointerRef =
- index.getMember('dart:ffi', 'StructPointer', 'get:ref'),
+ index.getProcedure('dart:ffi', 'StructPointer', 'get:ref'),
structPointerElemAt =
- index.getMember('dart:ffi', 'StructPointer', '[]'),
+ index.getProcedure('dart:ffi', 'StructPointer', '[]'),
unionPointerRef =
- index.getMember('dart:ffi', 'UnionPointer', 'get:ref'),
- unionPointerElemAt = index.getMember('dart:ffi', 'UnionPointer', '[]'),
- structArrayElemAt = index.getMember('dart:ffi', 'StructArray', '[]'),
- unionArrayElemAt = index.getMember('dart:ffi', 'UnionArray', '[]'),
- arrayArrayElemAt = index.getMember('dart:ffi', 'ArrayArray', '[]'),
- arrayArrayAssignAt = index.getMember('dart:ffi', 'ArrayArray', '[]='),
- asFunctionMethod =
- index.getMember('dart:ffi', 'NativeFunctionPointer', 'asFunction'),
+ index.getProcedure('dart:ffi', 'UnionPointer', 'get:ref'),
+ unionPointerElemAt =
+ index.getProcedure('dart:ffi', 'UnionPointer', '[]'),
+ structArrayElemAt = index.getProcedure('dart:ffi', 'StructArray', '[]'),
+ unionArrayElemAt = index.getProcedure('dart:ffi', 'UnionArray', '[]'),
+ arrayArrayElemAt = index.getProcedure('dart:ffi', 'ArrayArray', '[]'),
+ arrayArrayAssignAt =
+ index.getProcedure('dart:ffi', 'ArrayArray', '[]='),
+ asFunctionMethod = index.getProcedure(
+ 'dart:ffi', 'NativeFunctionPointer', 'asFunction'),
asFunctionInternal =
- index.getTopLevelMember('dart:ffi', '_asFunctionInternal'),
- sizeOfMethod = index.getTopLevelMember('dart:ffi', 'sizeOf'),
- lookupFunctionMethod = index.getMember(
+ index.getTopLevelProcedure('dart:ffi', '_asFunctionInternal'),
+ sizeOfMethod = index.getTopLevelProcedure('dart:ffi', 'sizeOf'),
+ lookupFunctionMethod = index.getProcedure(
'dart:ffi', 'DynamicLibraryExtension', 'lookupFunction'),
fromFunctionMethod =
- index.getMember('dart:ffi', 'Pointer', 'fromFunction'),
+ index.getProcedure('dart:ffi', 'Pointer', 'fromFunction'),
libraryLookupMethod =
- index.getMember('dart:ffi', 'DynamicLibrary', 'lookup'),
- abiMethod = index.getTopLevelMember('dart:ffi', '_abi'),
+ index.getProcedure('dart:ffi', 'DynamicLibrary', 'lookup'),
+ abiMethod = index.getTopLevelProcedure('dart:ffi', '_abi'),
pointerFromFunctionProcedure =
- index.getTopLevelMember('dart:ffi', '_pointerFromFunction'),
+ index.getTopLevelProcedure('dart:ffi', '_pointerFromFunction'),
nativeCallbackFunctionProcedure =
- index.getTopLevelMember('dart:ffi', '_nativeCallbackFunction'),
+ index.getTopLevelProcedure('dart:ffi', '_nativeCallbackFunction'),
nativeTypesClasses = nativeTypeClassNames
.map((name) => index.getClass('dart:ffi', name))
.toList(),
loadMethods = Map.fromIterable(optimizedTypes, value: (t) {
final name = nativeTypeClassNames[t.index];
- return index.getTopLevelMember('dart:ffi', "_load$name");
+ return index.getTopLevelProcedure('dart:ffi', "_load$name");
}),
loadUnalignedMethods =
Map.fromIterable(unalignedLoadsStores, value: (t) {
final name = nativeTypeClassNames[t.index];
- return index.getTopLevelMember('dart:ffi', "_load${name}Unaligned");
+ return index.getTopLevelProcedure(
+ 'dart:ffi', "_load${name}Unaligned");
}),
storeMethods = Map.fromIterable(optimizedTypes, value: (t) {
final name = nativeTypeClassNames[t.index];
- return index.getTopLevelMember('dart:ffi', "_store$name");
+ return index.getTopLevelProcedure('dart:ffi', "_store$name");
}),
storeUnalignedMethods =
Map.fromIterable(unalignedLoadsStores, value: (t) {
final name = nativeTypeClassNames[t.index];
- return index.getTopLevelMember('dart:ffi', "_store${name}Unaligned");
+ return index.getTopLevelProcedure(
+ 'dart:ffi', "_store${name}Unaligned");
}),
elementAtMethods = Map.fromIterable(optimizedTypes, value: (t) {
final name = nativeTypeClassNames[t.index];
- return index.getTopLevelMember('dart:ffi', "_elementAt$name");
+ return index.getTopLevelProcedure('dart:ffi', "_elementAt$name");
}),
- memCopy = index.getTopLevelMember('dart:ffi', '_memCopy'),
- allocationTearoff = index.getMember(
+ memCopy = index.getTopLevelProcedure('dart:ffi', '_memCopy'),
+ allocationTearoff = index.getProcedure(
'dart:ffi', 'AllocatorAlloc', LibraryIndex.tearoffPrefix + 'call'),
- asFunctionTearoff = index.getMember('dart:ffi', 'NativeFunctionPointer',
- LibraryIndex.tearoffPrefix + 'asFunction'),
- lookupFunctionTearoff = index.getMember(
+ asFunctionTearoff = index.getProcedure('dart:ffi',
+ 'NativeFunctionPointer', LibraryIndex.tearoffPrefix + 'asFunction'),
+ lookupFunctionTearoff = index.getProcedure(
'dart:ffi',
'DynamicLibraryExtension',
LibraryIndex.tearoffPrefix + 'lookupFunction');
@@ -472,7 +484,7 @@
/// [Handle] -> [Object]
/// [NativeFunction]<T1 Function(T2, T3) -> S1 Function(S2, S3)
/// where DartRepresentationOf(Tn) -> Sn
- DartType convertNativeTypeToDartType(DartType nativeType,
+ DartType? convertNativeTypeToDartType(DartType nativeType,
{bool allowCompounds = false,
bool allowHandle = false,
bool allowInlineArray = false}) {
@@ -481,7 +493,7 @@
}
final InterfaceType native = nativeType;
final Class nativeClass = native.classNode;
- final NativeType nativeType_ = getType(nativeClass);
+ final NativeType? nativeType_ = getType(nativeClass);
if (nativeClass == arrayClass) {
if (!allowInlineArray) {
@@ -519,27 +531,29 @@
return null;
}
- final FunctionType fun = native.typeArguments[0];
+ final FunctionType fun = native.typeArguments[0] as FunctionType;
if (fun.namedParameters.isNotEmpty) return null;
if (fun.positionalParameters.length != fun.requiredParameterCount) {
return null;
}
if (fun.typeParameters.length != 0) return null;
- final DartType returnType = convertNativeTypeToDartType(fun.returnType,
+ final DartType? returnType = convertNativeTypeToDartType(fun.returnType,
allowCompounds: true, allowHandle: true);
if (returnType == null) return null;
final List<DartType> argumentTypes = fun.positionalParameters
- .map((t) => convertNativeTypeToDartType(t,
- allowCompounds: true, allowHandle: true))
+ .map((t) =>
+ convertNativeTypeToDartType(t,
+ allowCompounds: true, allowHandle: true) ??
+ dummyDartType)
.toList();
- if (argumentTypes.contains(null)) return null;
+ if (argumentTypes.contains(dummyDartType)) return null;
return FunctionType(argumentTypes, returnType, Nullability.legacy);
}
/// The [NativeType] corresponding to [c]. Returns `null` for user-defined
/// structs.
- NativeType getType(Class c) {
+ NativeType? getType(Class c) {
final int index = nativeTypesClasses.indexOf(c);
if (index == -1) {
return null;
@@ -559,9 +573,9 @@
Expression runtimeBranchOnLayout(Map<Abi, int> values) {
return MethodInvocation(
intListConstantExpression([
- values[Abi.wordSize64],
- values[Abi.wordSize32Align32],
- values[Abi.wordSize32Align64]
+ values[Abi.wordSize64]!,
+ values[Abi.wordSize32Align32]!,
+ values[Abi.wordSize32Align64]!
]),
Name("[]"),
Arguments([StaticInvocation(abiMethod, Arguments([]))]),
diff --git a/pkg/vm/lib/transformations/late_var_init_transformer.dart b/pkg/vm/lib/transformations/late_var_init_transformer.dart
index 4acb7e4..88d8a25 100644
--- a/pkg/vm/lib/transformations/late_var_init_transformer.dart
+++ b/pkg/vm/lib/transformations/late_var_init_transformer.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
import 'package:kernel/ast.dart';
/// Wraps the initializers of late local variables in closures.
@@ -18,7 +20,7 @@
// Variables with no initializer or a trivial initializer are ignored.
if (s.initializer == null) return false;
- final Expression init = s.initializer;
+ final Expression? init = s.initializer;
if (init is StringLiteral) return false;
if (init is BoolLiteral) return false;
if (init is IntLiteral) return false;
@@ -47,12 +49,13 @@
return [fn, node];
}
- List<Statement> _transformStatements(List<Statement> statements) {
+ List<Statement>? _transformStatements(List<Statement> statements) {
if (!statements.any((s) => _shouldApplyTransform(s))) return null;
final List<Statement> newStatements = <Statement>[];
for (Statement s in statements) {
if (_shouldApplyTransform(s)) {
- newStatements.addAll(_transformVariableDeclaration(s));
+ newStatements
+ .addAll(_transformVariableDeclaration(s as VariableDeclaration));
} else {
newStatements.add(s);
}
diff --git a/pkg/vm/lib/transformations/specializer/factory_specializer.dart b/pkg/vm/lib/transformations/specializer/factory_specializer.dart
index 02a3cfe..7475638 100644
--- a/pkg/vm/lib/transformations/specializer/factory_specializer.dart
+++ b/pkg/vm/lib/transformations/specializer/factory_specializer.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
library vm.transformations.specializer.factory_specializer;
import 'package:kernel/kernel.dart';
@@ -33,6 +35,7 @@
TreeNode transformStaticInvocation(StaticInvocation invocation) {
final target = invocation.target;
+ // ignore: unnecessary_null_comparison
if (target == null) {
return invocation;
}
diff --git a/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart b/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
index 672d618..248c192 100644
--- a/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
+++ b/pkg/vm/lib/transformations/specializer/list_factory_specializer.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
library vm.transformations.specializer.list_factory_specializer;
import 'package:kernel/ast.dart';
@@ -39,28 +41,29 @@
ListFactorySpecializer(CoreTypes coreTypes)
: _defaultListFactory =
- coreTypes.index.getMember('dart:core', 'List', ''),
+ coreTypes.index.getProcedure('dart:core', 'List', ''),
_listEmptyFactory =
- coreTypes.index.getMember('dart:core', 'List', 'empty'),
+ coreTypes.index.getProcedure('dart:core', 'List', 'empty'),
_listFilledFactory =
- coreTypes.index.getMember('dart:core', 'List', 'filled'),
+ coreTypes.index.getProcedure('dart:core', 'List', 'filled'),
_listGenerateFactory =
- coreTypes.index.getMember('dart:core', 'List', 'generate'),
+ coreTypes.index.getProcedure('dart:core', 'List', 'generate'),
_growableListFactory =
- coreTypes.index.getMember('dart:core', '_GrowableList', ''),
+ coreTypes.index.getProcedure('dart:core', '_GrowableList', ''),
_growableListEmptyFactory =
- coreTypes.index.getMember('dart:core', '_GrowableList', 'empty'),
- _growableListFilledFactory =
- coreTypes.index.getMember('dart:core', '_GrowableList', 'filled'),
- _growableListGenerateFactory =
- coreTypes.index.getMember('dart:core', '_GrowableList', 'generate'),
- _fixedListFactory = coreTypes.index.getMember('dart:core', '_List', ''),
+ coreTypes.index.getProcedure('dart:core', '_GrowableList', 'empty'),
+ _growableListFilledFactory = coreTypes.index
+ .getProcedure('dart:core', '_GrowableList', 'filled'),
+ _growableListGenerateFactory = coreTypes.index
+ .getProcedure('dart:core', '_GrowableList', 'generate'),
+ _fixedListFactory =
+ coreTypes.index.getProcedure('dart:core', '_List', ''),
_fixedListEmptyFactory =
- coreTypes.index.getMember('dart:core', '_List', 'empty'),
+ coreTypes.index.getProcedure('dart:core', '_List', 'empty'),
_fixedListFilledFactory =
- coreTypes.index.getMember('dart:core', '_List', 'filled'),
+ coreTypes.index.getProcedure('dart:core', '_List', 'filled'),
_fixedListGenerateFactory =
- coreTypes.index.getMember('dart:core', '_List', 'generate') {
+ coreTypes.index.getProcedure('dart:core', '_List', 'generate') {
assert(_defaultListFactory.isFactory);
assert(_listEmptyFactory.isFactory);
assert(_listFilledFactory.isFactory);
@@ -96,7 +99,8 @@
TreeNode transformListEmptyFactory(StaticInvocation node) {
final args = node.arguments;
assert(args.positional.length == 0);
- final bool growable = _getConstantOptionalArgument(args, 'growable', false);
+ final bool? growable =
+ _getConstantOptionalArgument(args, 'growable', false);
if (growable == null) {
return node;
}
@@ -118,7 +122,8 @@
final fill = args.positional[1];
final fillingWithNull = fill is NullLiteral ||
(fill is ConstantExpression && fill.constant is NullConstant);
- final bool growable = _getConstantOptionalArgument(args, 'growable', false);
+ final bool? growable =
+ _getConstantOptionalArgument(args, 'growable', false);
if (growable == null) {
return node;
}
@@ -150,7 +155,7 @@
assert(args.positional.length == 2);
final length = args.positional[0];
final generator = args.positional[1];
- final bool growable = _getConstantOptionalArgument(args, 'growable', true);
+ final bool? growable = _getConstantOptionalArgument(args, 'growable', true);
if (growable == null) {
return node;
}
@@ -168,7 +173,7 @@
/// Returns constant value of the only optional argument in [args],
/// or null if it is not a constant. Returns [defaultValue] if optional
/// argument is not passed. Argument is asserted to have the given [name].
- bool /*?*/ _getConstantOptionalArgument(
+ bool? _getConstantOptionalArgument(
Arguments args, String name, bool defaultValue) {
if (args.named.isEmpty) {
return defaultValue;
diff --git a/pkg/vm/lib/transformations/specializer/map_factory_specializer.dart b/pkg/vm/lib/transformations/specializer/map_factory_specializer.dart
index 5779807..8a01984 100644
--- a/pkg/vm/lib/transformations/specializer/map_factory_specializer.dart
+++ b/pkg/vm/lib/transformations/specializer/map_factory_specializer.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
library vm.transformations.specializer.map_factory_specializer;
import 'package:kernel/ast.dart';
@@ -19,14 +21,14 @@
MapFactorySpecializer(CoreTypes coreTypes)
: _linkedHashMapDefaultFactory = assertNotNull(
- coreTypes.index.getMember(
+ coreTypes.index.getProcedure(
'dart:collection',
'LinkedHashMap',
'',
),
),
_internalLinkedHashMapConstructor = assertNotNull(
- coreTypes.index.getMember(
+ coreTypes.index.getConstructor(
'dart:collection',
'_InternalLinkedHashMap',
'',
diff --git a/pkg/vm/lib/transformations/specializer/set_factory_specializer.dart b/pkg/vm/lib/transformations/specializer/set_factory_specializer.dart
index 0e6a855..a508435 100644
--- a/pkg/vm/lib/transformations/specializer/set_factory_specializer.dart
+++ b/pkg/vm/lib/transformations/specializer/set_factory_specializer.dart
@@ -2,6 +2,8 @@
// 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.
+// @dart=2.12
+
library vm.transformations.specializer.set_factory_specializer;
import 'package:kernel/ast.dart';
@@ -19,14 +21,14 @@
SetFactorySpecializer(CoreTypes coreTypes)
: _linkedHashSetDefaultFactory = assertNotNull(
- coreTypes.index.getMember(
+ coreTypes.index.getProcedure(
'dart:collection',
'LinkedHashSet',
'',
),
),
_compactLinkedHashSetConstructor = assertNotNull(
- coreTypes.index.getMember(
+ coreTypes.index.getConstructor(
'dart:collection',
'_CompactLinkedHashSet',
'',
diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc
index 507ce9d..6b0e86c 100644
--- a/runtime/lib/object.cc
+++ b/runtime/lib/object.cc
@@ -33,21 +33,29 @@
return Object::null();
}
-DEFINE_NATIVE_ENTRY(Object_getHash, 0, 1) {
-// Please note that no handle is created for the argument.
-// This is safe since the argument is only used in a tail call.
-// The performance benefit is more than 5% when using hashCode.
+static intptr_t GetHash(Isolate* isolate, const ObjectPtr obj) {
#if defined(HASH_IN_OBJECT_HEADER)
- return Smi::New(Object::GetCachedHash(arguments->NativeArgAt(0)));
+ return Object::GetCachedHash(obj);
#else
Heap* heap = isolate->group()->heap();
- ASSERT(arguments->NativeArgAt(0)->IsDartInstance());
- return Smi::New(heap->GetHash(arguments->NativeArgAt(0)));
+ ASSERT(obj->IsDartInstance());
+ return heap->GetHash(obj);
#endif
}
-DEFINE_NATIVE_ENTRY(Object_setHash, 0, 2) {
+DEFINE_NATIVE_ENTRY(Object_getHash, 0, 1) {
+ // Please note that no handle is created for the argument.
+ // This is safe since the argument is only used in a tail call.
+ // The performance benefit is more than 5% when using hashCode.
+ return Smi::New(GetHash(isolate, arguments->NativeArgAt(0)));
+}
+
+DEFINE_NATIVE_ENTRY(Object_setHashIfNotSetYet, 0, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(Smi, hash, arguments->NativeArgAt(1));
+ const intptr_t current_hash = GetHash(isolate, arguments->NativeArgAt(0));
+ if (current_hash != 0) {
+ return Smi::New(current_hash);
+ }
#if defined(HASH_IN_OBJECT_HEADER)
Object::SetCachedHash(arguments->NativeArgAt(0), hash.Value());
#else
@@ -56,7 +64,7 @@
Heap* heap = isolate->group()->heap();
heap->SetHash(instance.ptr(), hash.Value());
#endif
- return Object::null();
+ return hash.ptr();
}
DEFINE_NATIVE_ENTRY(Object_toString, 0, 1) {
diff --git a/runtime/vm/bootstrap_natives.h b/runtime/vm/bootstrap_natives.h
index fe0f192..c17daf4 100644
--- a/runtime/vm/bootstrap_natives.h
+++ b/runtime/vm/bootstrap_natives.h
@@ -18,7 +18,7 @@
V(DartAsync_fatal, 1) \
V(Object_equals, 2) \
V(Object_getHash, 1) \
- V(Object_setHash, 2) \
+ V(Object_setHashIfNotSetYet, 2) \
V(Object_toString, 1) \
V(Object_runtimeType, 1) \
V(Object_haveSameRuntimeType, 2) \
diff --git a/runtime/vm/compiler/asm_intrinsifier_arm.cc b/runtime/vm/compiler/asm_intrinsifier_arm.cc
index 101ea94..770d456 100644
--- a/runtime/vm/compiler/asm_intrinsifier_arm.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_arm.cc
@@ -1555,8 +1555,8 @@
UNREACHABLE();
}
-void AsmIntrinsifier::Object_setHash(Assembler* assembler,
- Label* normal_ir_body) {
+void AsmIntrinsifier::Object_setHashIfNotSetYet(Assembler* assembler,
+ Label* normal_ir_body) {
UNREACHABLE();
}
diff --git a/runtime/vm/compiler/asm_intrinsifier_arm64.cc b/runtime/vm/compiler/asm_intrinsifier_arm64.cc
index 91c8e54..167e089 100644
--- a/runtime/vm/compiler/asm_intrinsifier_arm64.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_arm64.cc
@@ -1551,20 +1551,27 @@
__ ret();
}
-void AsmIntrinsifier::Object_setHash(Assembler* assembler,
- Label* normal_ir_body) {
+void AsmIntrinsifier::Object_setHashIfNotSetYet(Assembler* assembler,
+ Label* normal_ir_body) {
+ Label already_set;
__ ldr(R0, Address(SP, 1 * target::kWordSize)); // Object.
+ __ ldr(R1, FieldAddress(R0, target::String::hash_offset(), kFourBytes),
+ kUnsignedFourBytes);
+ __ cbnz(&already_set, R1, kFourBytes);
__ ldr(R1, Address(SP, 0 * target::kWordSize)); // Value.
// R0: Untagged address of header word (ldxr/stxr do not support offsets).
__ sub(R0, R0, Operand(kHeapObjectTag));
__ SmiUntag(R1);
- __ LslImmediate(R1, R1, target::UntaggedObject::kHashTagPos);
+ __ LslImmediate(R3, R1, target::UntaggedObject::kHashTagPos);
Label retry;
__ Bind(&retry);
__ ldxr(R2, R0, kEightBytes);
- __ orr(R2, R2, Operand(R1));
+ __ orr(R2, R2, Operand(R3));
__ stxr(R4, R2, R0, kEightBytes);
__ cbnz(&retry, R4);
+ // Fall-through with R1 containing new hash value (untagged).
+ __ Bind(&already_set);
+ __ SmiTag(R0, R1);
__ ret();
}
diff --git a/runtime/vm/compiler/asm_intrinsifier_ia32.cc b/runtime/vm/compiler/asm_intrinsifier_ia32.cc
index 9cfe941..a52f0ab 100644
--- a/runtime/vm/compiler/asm_intrinsifier_ia32.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_ia32.cc
@@ -1544,8 +1544,8 @@
UNREACHABLE();
}
-void AsmIntrinsifier::Object_setHash(Assembler* assembler,
- Label* normal_ir_body) {
+void AsmIntrinsifier::Object_setHashIfNotSetYet(Assembler* assembler,
+ Label* normal_ir_body) {
UNREACHABLE();
}
diff --git a/runtime/vm/compiler/asm_intrinsifier_x64.cc b/runtime/vm/compiler/asm_intrinsifier_x64.cc
index c47d307..0bcfb90 100644
--- a/runtime/vm/compiler/asm_intrinsifier_x64.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_x64.cc
@@ -1408,15 +1408,24 @@
__ ret();
}
-void AsmIntrinsifier::Object_setHash(Assembler* assembler,
- Label* normal_ir_body) {
+void AsmIntrinsifier::Object_setHashIfNotSetYet(Assembler* assembler,
+ Label* normal_ir_body) {
+ Label already_set;
__ movq(RAX, Address(RSP, +2 * target::kWordSize)); // Object.
+ __ movl(RDX, FieldAddress(RAX, target::String::hash_offset()));
+ __ testl(RDX, RDX);
+ __ j(NOT_ZERO, &already_set, AssemblerBase::kNearJump);
__ movq(RDX, Address(RSP, +1 * target::kWordSize)); // Value.
__ SmiUntag(RDX);
__ shlq(RDX, Immediate(target::UntaggedObject::kHashTagPos));
// lock+orq is an atomic read-modify-write.
__ lock();
__ orq(FieldAddress(RAX, target::Object::tags_offset()), RDX);
+ __ movq(RAX, Address(RSP, +1 * target::kWordSize));
+ __ ret();
+ __ Bind(&already_set);
+ __ movl(RAX, RDX);
+ __ SmiTag(RAX);
__ ret();
}
diff --git a/runtime/vm/compiler/intrinsifier.cc b/runtime/vm/compiler/intrinsifier.cc
index b4161bf..a1a0973 100644
--- a/runtime/vm/compiler/intrinsifier.cc
+++ b/runtime/vm/compiler/intrinsifier.cc
@@ -269,7 +269,8 @@
// therefore don't intrinsify them, falling back on the native C++
// implementations.
if (function.recognized_kind() == MethodRecognizer::kObject_getHash ||
- function.recognized_kind() == MethodRecognizer::kObject_setHash) {
+ function.recognized_kind() ==
+ MethodRecognizer::kObject_setHashIfNotSetYet) {
return false;
}
#endif
diff --git a/runtime/vm/compiler/recognized_methods_list.h b/runtime/vm/compiler/recognized_methods_list.h
index 80308087..7e54439 100644
--- a/runtime/vm/compiler/recognized_methods_list.h
+++ b/runtime/vm/compiler/recognized_methods_list.h
@@ -254,7 +254,7 @@
V(_FunctionType, get:hashCode, FunctionType_getHashCode, 0x75e0d454) \
V(_FunctionType, ==, FunctionType_equality, 0x465868ae) \
V(::, _getHash, Object_getHash, 0xc60ff758) \
- V(::, _setHash, Object_setHash, 0x8f2a5b0b) \
+ V(::, _setHashIfNotSetYet, Object_setHashIfNotSetYet, 0x4e17c2f5) \
#define CORE_INTEGER_LIB_INTRINSIC_LIST(V) \
V(_IntegerImplementation, >, Integer_greaterThan, 0x402b12df) \
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc
index 9df16ee..1ce7b76 100644
--- a/runtime/vm/object_graph.cc
+++ b/runtime/vm/object_graph.cc
@@ -1329,13 +1329,23 @@
return hash;
}
+// Generates a random value which can serve as an identity hash.
+// It must be a non-zero smi value (see also [Object._getObjectHash]).
+static uint32_t GenerateHash(Random* random) {
+ uint32_t hash;
+ do {
+ hash = random->NextUInt32();
+ } while (hash == 0 || (kSmiBits < 32 && !Smi::IsValid(hash)));
+ return hash;
+}
+
uint32_t HeapSnapshotWriter::GetHashHelper(Thread* thread, ObjectPtr obj) {
uint32_t hash;
#if defined(HASH_IN_OBJECT_HEADER)
hash = Object::GetCachedHash(obj);
if (hash == 0) {
ASSERT(!thread->heap()->old_space()->IsObjectFromImagePages(obj));
- hash = thread->random()->NextUInt32();
+ hash = GenerateHash(thread->random());
Object::SetCachedHash(obj, hash);
}
#else
@@ -1343,7 +1353,7 @@
hash = heap->GetHash(obj);
if (hash == 0) {
ASSERT(!heap->old_space()->IsObjectFromImagePages(obj));
- hash = thread->random()->NextUInt32();
+ hash = GenerateHash(thread->random());
heap->SetHash(obj, hash);
}
#endif
diff --git a/sdk/lib/_internal/vm/lib/object_patch.dart b/sdk/lib/_internal/vm/lib/object_patch.dart
index 0c20579..545d274 100644
--- a/sdk/lib/_internal/vm/lib/object_patch.dart
+++ b/sdk/lib/_internal/vm/lib/object_patch.dart
@@ -7,8 +7,13 @@
@pragma("vm:recognized", "asm-intrinsic")
@pragma("vm:exact-result-type", "dart:core#_Smi")
int _getHash(obj) native "Object_getHash";
+
+/// Set hash code associated with the object if it is not set yet
+/// and return the current hash code. See [Object._objectHashCode]
+/// for why this function needs to check for already set hash code.
@pragma("vm:recognized", "asm-intrinsic")
-void _setHash(obj, hash) native "Object_setHash";
+@pragma("vm:exact-result-type", "dart:core#_Smi")
+int _setHashIfNotSetYet(obj, int hash) native "Object_setHashIfNotSetYet";
@patch
@pragma("vm:entry-point")
@@ -29,11 +34,15 @@
var result = _getHash(obj);
if (result == 0) {
// We want the hash to be a Smi value greater than 0.
- result = _hashCodeRnd.nextInt(0x40000000);
do {
result = _hashCodeRnd.nextInt(0x40000000);
} while (result == 0);
- _setHash(obj, result);
+
+ // Caveat: we might be interrupted by vm-service which then
+ // can initialize [this] object's hash code, that is why we need to
+ // return the return value of [_setHashIfNotSetYet] rather than
+ // returning [result] itself.
+ return _setHashIfNotSetYet(obj, result);
}
return result;
}
diff --git a/tools/VERSION b/tools/VERSION
index 5b7eae7..1ffa9e2 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 74
+PRERELEASE 75
PRERELEASE_PATCH 0
\ No newline at end of file