[dart2js] Clean up js_backend/rti_new migration files.

Change-Id: I3d065099f7a71e6a80f9e8f2abc667a019f019a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268403
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Nate Biggs 2022-11-08 00:59:20 +00:00 committed by Commit Queue
parent 7e0eb08525
commit 25371c516c
12 changed files with 68 additions and 97 deletions

View file

@ -6,7 +6,7 @@ import '../tracer.dart' show Tracer;
import 'checked_mode_helpers.dart';
import 'namer_migrated.dart';
import 'runtime_types_codegen.dart';
import 'runtime_types_new_interfaces.dart';
import 'runtime_types_new.dart';
/// Holds resources only used during code generation.
class CodegenInputs {

View file

@ -19,7 +19,7 @@ import '../js_model/elements.dart';
import '../js_model/type_recipe.dart' show TypeExpressionRecipe;
import '../options.dart';
import 'namer_interfaces.dart';
import 'runtime_types_new_interfaces.dart' show RecipeEncoder;
import 'runtime_types_new.dart' show RecipeEncoder;
import 'runtime_types_resolution.dart';
typedef _ConstantReferenceGenerator = jsAst.Expression Function(

View file

@ -14,22 +14,17 @@ import '../js/js.dart' show js;
import '../js_model/js_world.dart';
import '../js_model/type_recipe.dart';
import '../js_emitter/interfaces.dart' show ModularEmitter;
import '../universe/class_hierarchy.dart';
import 'namer.dart' show StringBackedName;
import 'native_data.dart';
import 'runtime_types_codegen.dart' show RuntimeTypesSubstitutions;
import 'runtime_types_new_interfaces.dart' as interfaces;
import 'runtime_types_new_migrated.dart';
export 'runtime_types_new_migrated.dart';
abstract class RecipeEncoder implements interfaces.RecipeEncoder {
abstract class RecipeEncoder {
/// Returns a [RecipeEncoding] representing the given [recipe] to be
/// evaluated against a type environment with shape [structure].
@override
RecipeEncoding encodeRecipe(covariant ModularEmitter emitter,
TypeEnvironmentStructure environmentStructure, TypeRecipe recipe);
@override
// TODO(48820): Remove covariant when ModularEmitter is migrated.
jsAst.Literal encodeGroundRecipe(
covariant ModularEmitter emitter, TypeRecipe recipe);
@ -591,3 +586,58 @@ class RulesetEncoder {
_rightBracket
]);
}
class RecipeEncoding {
final jsAst.Literal recipe;
final Set<TypeVariableType> typeVariables;
const RecipeEncoding(this.recipe, this.typeVariables);
}
int? indexTypeVariable(
JClosedWorld world,
RuntimeTypesSubstitutions rtiSubstitutions,
FullTypeEnvironmentStructure environment,
TypeVariableType type,
{bool metadata = false}) {
int i = environment.bindings.indexOf(type);
if (i >= 0) {
// Indices are 1-based since '0' encodes using the entire type for the
// singleton structure.
return i + 1;
}
TypeVariableEntity element = type.element;
// TODO(48820): remove `!`. Added to increase coverage of null assertions
// while the compiler runs in unsound null safety.
ClassEntity cls = element.typeDeclaration! as ClassEntity;
if (metadata) {
if (identical(environment.classType!.element, cls)) {
// Indexed class type variables come after the bound function type
// variables.
return 1 + environment.bindings.length + element.index;
}
}
// TODO(sra): We might be in a context where the class type variable has an
// index, even though in the general case it is not at a specific index.
ClassHierarchy classHierarchy = world.classHierarchy;
var test = mustCheckAllSubtypes(world, cls)
? classHierarchy.anyStrictSubtypeOf
: classHierarchy.anyStrictSubclassOf;
if (test(cls, (ClassEntity subclass) {
return !rtiSubstitutions.isTrivialSubstitution(subclass, cls);
})) {
return null;
}
// Indexed class type variables come after the bound function type
// variables.
return 1 + environment.bindings.length + element.index;
}
bool mustCheckAllSubtypes(JClosedWorld world, ClassEntity cls) =>
world.isUsedAsMixin(cls) ||
world.extractTypeArgumentsInterfacesNewRti.contains(cls);

View file

@ -1,10 +0,0 @@
import '../js_emitter/interfaces.dart' show ModularEmitter;
import '../js_model/type_recipe.dart';
import '../js/js.dart' as jsAst;
import 'runtime_types_new_migrated.dart';
abstract class RecipeEncoder {
jsAst.Literal encodeGroundRecipe(ModularEmitter emitter, TypeRecipe recipe);
RecipeEncoding encodeRecipe(ModularEmitter emitter,
TypeEnvironmentStructure environmentStructure, TypeRecipe recipe);
}

View file

@ -1,68 +0,0 @@
// Copyright (c) 2019, 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.
library js_backend.runtime_types_new_migrated;
import '../elements/entities.dart';
import '../elements/types.dart';
import '../js/js.dart' as jsAst;
import '../js_model/js_world.dart';
import '../js_model/type_recipe.dart';
import '../universe/class_hierarchy.dart';
import 'runtime_types_codegen.dart' show RuntimeTypesSubstitutions;
class RecipeEncoding {
final jsAst.Literal recipe;
final Set<TypeVariableType> typeVariables;
const RecipeEncoding(this.recipe, this.typeVariables);
}
int? indexTypeVariable(
JClosedWorld world,
RuntimeTypesSubstitutions rtiSubstitutions,
FullTypeEnvironmentStructure environment,
TypeVariableType type,
{bool metadata = false}) {
int i = environment.bindings.indexOf(type);
if (i >= 0) {
// Indices are 1-based since '0' encodes using the entire type for the
// singleton structure.
return i + 1;
}
TypeVariableEntity element = type.element;
// TODO(48820): remove `!`. Added to increase coverage of null assertions
// while the compiler runs in unsound null safety.
ClassEntity cls = element.typeDeclaration! as ClassEntity;
if (metadata) {
if (identical(environment.classType!.element, cls)) {
// Indexed class type variables come after the bound function type
// variables.
return 1 + environment.bindings.length + element.index;
}
}
// TODO(sra): We might be in a context where the class type variable has an
// index, even though in the general case it is not at a specific index.
ClassHierarchy classHierarchy = world.classHierarchy;
var test = mustCheckAllSubtypes(world, cls)
? classHierarchy.anyStrictSubtypeOf
: classHierarchy.anyStrictSubclassOf;
if (test(cls, (ClassEntity subclass) {
return !rtiSubstitutions.isTrivialSubstitution(subclass, cls);
})) {
return null;
}
// Indexed class type variables come after the bound function type
// variables.
return 1 + environment.bindings.length + element.index;
}
bool mustCheckAllSubtypes(JClosedWorld world, ClassEntity cls) =>
world.isUsedAsMixin(cls) ||
world.extractTypeArgumentsInterfacesNewRti.contains(cls);

View file

@ -78,7 +78,7 @@ import '../serialization/serialization.dart';
import '../util/util.dart' show Hashing;
import 'frequency_assignment.dart';
import 'namer_migrated.dart' as namer;
import 'runtime_types_new_interfaces.dart' show RecipeEncoder;
import 'runtime_types_new.dart' show RecipeEncoder;
/// Run the minifier for 'type$' property names even in non-minified mode,
/// making a name from minified name and the readable name. Usage:

View file

@ -11,7 +11,7 @@ import '../deferred_load/output_unit.dart' show OutputUnit;
import '../elements/types.dart';
import '../js/js.dart' as jsAst;
import '../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../js_backend/runtime_types_new.dart' show RecipeEncoder;
import '../js_model/type_recipe.dart' show TypeExpressionRecipe;
import 'interfaces.dart' show ModularEmitter;

View file

@ -27,8 +27,8 @@ import '../../js_backend/namer.dart' show StringBackedName, compareNames;
import '../../js_backend/native_data.dart';
import '../../js_backend/runtime_types.dart' show RuntimeTypesChecks;
import '../../js_backend/runtime_types_codegen.dart' show TypeCheck;
import '../../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../../js_backend/runtime_types_new_migrated.dart' show RecipeEncoding;
import '../../js_backend/runtime_types_new.dart'
show RecipeEncoder, RecipeEncoding;
import '../../js_backend/runtime_types_new.dart' as newRti;
import '../../js_backend/runtime_types_resolution.dart' show RuntimeTypesNeed;
import '../../js_model/elements.dart' show JGeneratorBody, JSignatureMethod;

View file

@ -17,7 +17,7 @@ import '../../io/source_information.dart';
import '../../js/js.dart' as js;
import '../../js_backend/constant_emitter.dart';
import '../../js_backend/namer_interfaces.dart';
import '../../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../../js_backend/runtime_types_new.dart' show RecipeEncoder;
import '../../js_model/js_world.dart' show JClosedWorld;
import '../../options.dart';
import '../../universe/codegen_world_builder.dart' show CodegenWorld;

View file

@ -59,7 +59,7 @@ import '../../js_backend/js_backend.dart'
import '../../js_backend/js_interop_analysis.dart' as jsInteropAnalysis;
import '../../js_backend/runtime_types.dart';
import '../../js_backend/runtime_types_codegen.dart';
import '../../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../../js_backend/runtime_types_new.dart' show RecipeEncoder;
import '../../js_backend/runtime_types_new.dart'
show RecipeEncoderImpl, Ruleset, RulesetEncoder;
import '../../js_backend/runtime_types_resolution.dart' show RuntimeTypesNeed;

View file

@ -43,7 +43,7 @@ import '../js_backend/namer_interfaces.dart' hide Namer;
import '../js_backend/namer_migrated.dart';
import '../js_backend/runtime_types.dart';
import '../js_backend/runtime_types_codegen.dart';
import '../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../js_backend/runtime_types_new.dart' show RecipeEncoder;
import '../js_backend/runtime_types_new.dart' show RecipeEncoderImpl;
import '../js_emitter/code_emitter_task.dart' show ModularEmitter;
import '../js_emitter/js_emitter.dart' show CodeEmitterTask;

View file

@ -29,9 +29,8 @@ import '../js_backend/checked_mode_helpers.dart';
import '../js_backend/native_data.dart';
import '../js_backend/namer_interfaces.dart' show ModularNamer;
import '../js_backend/runtime_types_codegen.dart';
import '../js_backend/runtime_types_new_interfaces.dart' show RecipeEncoder;
import '../js_backend/runtime_types_new_migrated.dart'
show RecipeEncoding, indexTypeVariable;
import '../js_backend/runtime_types_new.dart'
show RecipeEncoder, RecipeEncoding, indexTypeVariable;
import '../js_backend/specialized_checks.dart' show IsTestSpecialization;
import '../js_backend/type_reference.dart' show TypeReference;
import '../js_emitter/interfaces.dart' show ModularEmitter;