Fix tracking of native classes needed for rti.

Closes #32286
Closes #33690

Change-Id: Ic62c145ca7bb5257d71c0d062b111b183258b7d0
Reviewed-on: https://dart-review.googlesource.com/64343
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Johnni Winther 2018-07-16 10:09:06 +00:00 committed by commit-bot@chromium.org
parent 117f651f7b
commit 6acee7cdb7
7 changed files with 25 additions and 21 deletions

View file

@ -511,13 +511,10 @@ abstract class RuntimeTypesSubstitutionsMixin
ArgumentCollector collector = new ArgumentCollector();
for (ClassEntity target in checks.classes) {
ClassChecks classChecks = checks[target];
if (classChecks.isNotEmpty) {
instantiated.add(target);
for (TypeCheck check in classChecks.checks) {
Substitution substitution = check.substitution;
if (substitution != null) {
collector.collectAll(substitution.arguments);
}
for (TypeCheck check in classChecks.checks) {
Substitution substitution = check.substitution;
if (substitution != null) {
collector.collectAll(substitution.arguments);
}
}
}
@ -1862,12 +1859,20 @@ class RuntimeTypesNeedBuilderImpl extends _RuntimeTypesBase
class _RuntimeTypesChecks implements RuntimeTypesChecks {
final RuntimeTypesSubstitutions _substitutions;
final TypeChecks requiredChecks;
final Iterable<ClassEntity> _typeLiterals;
final Iterable<ClassEntity> _typeArguments;
_RuntimeTypesChecks(this._substitutions, this.requiredChecks);
_RuntimeTypesChecks(this._substitutions, this.requiredChecks,
this._typeLiterals, this._typeArguments);
@override
Iterable<ClassEntity> get requiredClasses {
return _substitutions.getClassesUsedInSubstitutions(requiredChecks);
Set<ClassEntity> required = new Set<ClassEntity>();
required.addAll(_typeArguments);
required.addAll(_typeLiterals);
required
.addAll(_substitutions.getClassesUsedInSubstitutions(requiredChecks));
return required;
}
@override
@ -1936,6 +1941,8 @@ class RuntimeTypesImpl extends _RuntimeTypesBase
}
Set<FunctionType> checkedFunctionTypes = new Set<FunctionType>();
Set<ClassEntity> typeLiterals = new Set<ClassEntity>();
Set<ClassEntity> typeArguments = new Set<ClassEntity>();
TypeVisitor liveTypeVisitor =
new TypeVisitor(onClass: (ClassEntity cls, {TypeVisitorState state}) {
@ -1943,9 +1950,11 @@ class RuntimeTypesImpl extends _RuntimeTypesBase
switch (state) {
case TypeVisitorState.typeArgument:
classUse.typeArgument = true;
typeArguments.add(cls);
break;
case TypeVisitorState.typeLiteral:
classUse.typeLiteral = true;
typeLiterals.add(cls);
break;
case TypeVisitorState.direct:
break;
@ -1959,6 +1968,7 @@ class RuntimeTypesImpl extends _RuntimeTypesBase
case TypeVisitorState.typeArgument:
classUse.typeArgument = true;
classUse.checkedTypeArgument = true;
typeArguments.add(cls);
break;
case TypeVisitorState.typeLiteral:
break;
@ -2086,7 +2096,8 @@ class RuntimeTypesImpl extends _RuntimeTypesBase
cachedRequiredChecks = _computeChecks(classUseMap);
rtiChecksBuilderClosed = true;
return new _RuntimeTypesChecks(this, cachedRequiredChecks);
return new _RuntimeTypesChecks(
this, cachedRequiredChecks, typeArguments, typeLiterals);
}
}
@ -2883,8 +2894,6 @@ class ClassChecks {
Iterable<TypeCheck> get checks => _map.values;
bool get isNotEmpty => _map.isNotEmpty;
String toString() {
return 'ClassChecks($checks)';
}

View file

@ -9,11 +9,11 @@ import 'dart:html';
/*kernel.class: global#MouseEvent:checks=[$isMouseEvent],instance,typeArgument*/
/*strong.class: global#MouseEvent:checks=[$isMouseEvent],instance,typeArgument*/
/*omit.class: global#MouseEvent:checks=[],instance*/
/*omit.class: global#MouseEvent:instance*/
/*kernel.class: global#KeyboardEvent:checks=[$isKeyboardEvent],instance,typeArgument*/
/*strong.class: global#KeyboardEvent:checks=[$isKeyboardEvent],instance,typeArgument*/
/*omit.class: global#KeyboardEvent:checks=[],instance*/
/*omit.class: global#KeyboardEvent:instance*/
void main() {
print('InputElement');

View file

@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
/*kernel.class: global#Map:instance*/
/*strong.class: global#Map:checkedInstance,checks=[],instance*/
/*strong.class: global#Map:checkedInstance,instance*/
/*class: global#LinkedHashMap:*/
/*class: global#JsLinkedHashMap:checks=[],instance*/

View file

@ -2,7 +2,7 @@
// 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.
/*class: global#Map:checkedInstance,checks=[],instance*/
/*class: global#Map:checkedInstance,instance*/
/*class: global#LinkedHashMap:checkedInstance*/
/*class: global#JsLinkedHashMap:checkedInstance,checks=[$isLinkedHashMap],instance*/
/*class: global#double:checkedInstance,checks=[],instance,typeArgument*/

View file

@ -38,8 +38,6 @@ main(List<String> args) {
'map_literal_checked.dart',
// TODO(johnniwinther): Optimize local function type signature need.
'subtype_named_args.dart',
// TODO(33690):
'native.dart',
],
);
});

View file

@ -10,7 +10,6 @@ fake_thing_test: RuntimeError # Issue 13010
*: Skip
[ $compiler == dart2js && $checked && !$strong ]
error_safeToString_test: RuntimeError # Fix for Issue 33627 disabled native class sharing
native_method_inlining_test: RuntimeError
[ $compiler == dart2js && $fasta ]
@ -24,5 +23,4 @@ subclassing_super_field_2_test: RuntimeError
optimization_hints_test: RuntimeError, OK # Test relies on unminified names.
[ $compiler == dart2js && $strong ]
error_safeToString_test: RuntimeError # Fix for Issue 33627 disabled native class sharing
native_checked_fields_frog_test: RuntimeError

View file

@ -515,7 +515,6 @@ html/custom/js_custom_test: Fail # Issue 14643
[ $compiler == dart2js && $browser && $strong ]
html/element_classes_svg_test: RuntimeError
html/js_array_test: RuntimeError
html/js_mock_test: RuntimeError
html/typed_arrays_range_checks_test: RuntimeError
[ $compiler == dart2js && $checked ]