mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:31:50 +00:00
[dart2js] prepare additional files in inferrer folder (part 2)
This now breaks the cycle in this folder, so all libraries can be migrated in a specific order. Change-Id: Ib76d813804e2d0eac485bbeb84a1e0aac0027e7a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264360 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
parent
ab0da67708
commit
fa4851cd4e
|
@ -24,6 +24,7 @@ import 'compiler_interfaces.dart'
|
||||||
show
|
show
|
||||||
CompilerDeferredLoadingFacade,
|
CompilerDeferredLoadingFacade,
|
||||||
CompilerDiagnosticsFacade,
|
CompilerDiagnosticsFacade,
|
||||||
|
CompilerInferrerFacade,
|
||||||
CompilerKernelStrategyFacade,
|
CompilerKernelStrategyFacade,
|
||||||
CompilerTypeInferenceFacade;
|
CompilerTypeInferenceFacade;
|
||||||
import 'deferred_load/deferred_load.dart' show DeferredLoadTask;
|
import 'deferred_load/deferred_load.dart' show DeferredLoadTask;
|
||||||
|
@ -80,6 +81,7 @@ class Compiler
|
||||||
implements
|
implements
|
||||||
CompilerDiagnosticsFacade,
|
CompilerDiagnosticsFacade,
|
||||||
CompilerDeferredLoadingFacade,
|
CompilerDeferredLoadingFacade,
|
||||||
|
CompilerInferrerFacade,
|
||||||
CompilerKernelStrategyFacade,
|
CompilerKernelStrategyFacade,
|
||||||
CompilerTypeInferenceFacade {
|
CompilerTypeInferenceFacade {
|
||||||
@override
|
@override
|
||||||
|
@ -145,6 +147,7 @@ class Compiler
|
||||||
DumpInfoTask dumpInfoTask;
|
DumpInfoTask dumpInfoTask;
|
||||||
SerializationTask serializationTask;
|
SerializationTask serializationTask;
|
||||||
|
|
||||||
|
@override
|
||||||
Progress progress = const Progress();
|
Progress progress = const Progress();
|
||||||
|
|
||||||
static const int PHASE_SCANNING = 0;
|
static const int PHASE_SCANNING = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import 'kernel/kernel_strategy_migrated.dart'
|
||||||
show KernelFrontendStrategyForDeferredLoading;
|
show KernelFrontendStrategyForDeferredLoading;
|
||||||
import 'options.dart' show CompilerOptions;
|
import 'options.dart' show CompilerOptions;
|
||||||
import 'universe/world_impact.dart' show WorldImpact;
|
import 'universe/world_impact.dart' show WorldImpact;
|
||||||
|
import 'compiler_migrated.dart';
|
||||||
|
|
||||||
/// Subset of [Compiler] needed by deferred loading.
|
/// Subset of [Compiler] needed by deferred loading.
|
||||||
///
|
///
|
||||||
|
@ -80,3 +81,13 @@ abstract class CompilerKernelStrategyFacade {
|
||||||
ConstraintData? get programSplitConstraintsData;
|
ConstraintData? get programSplitConstraintsData;
|
||||||
DeferredLoadTask get deferredLoadTask;
|
DeferredLoadTask get deferredLoadTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Subset of [Compiler] needed by type_graph_inferrer
|
||||||
|
///
|
||||||
|
/// See definitions on [Compiler] for documentation.
|
||||||
|
abstract class CompilerInferrerFacade {
|
||||||
|
CompilerOptions get options;
|
||||||
|
Progress get progress;
|
||||||
|
DiagnosticReporter get reporter;
|
||||||
|
CompilerOutput get outputProvider;
|
||||||
|
}
|
||||||
|
|
|
@ -39,10 +39,10 @@ import 'list_tracer.dart';
|
||||||
import 'map_tracer.dart';
|
import 'map_tracer.dart';
|
||||||
import 'set_tracer.dart';
|
import 'set_tracer.dart';
|
||||||
import 'type_graph_dump.dart';
|
import 'type_graph_dump.dart';
|
||||||
import 'type_graph_inferrer.dart';
|
|
||||||
import 'type_graph_nodes.dart';
|
import 'type_graph_nodes.dart';
|
||||||
import 'type_system.dart';
|
import 'type_system.dart';
|
||||||
import 'types.dart';
|
import 'types.dart';
|
||||||
|
import 'work_queue.dart';
|
||||||
|
|
||||||
/// An inferencing engine that computes a call graph of [TypeInformation] nodes
|
/// An inferencing engine that computes a call graph of [TypeInformation] nodes
|
||||||
/// by visiting the AST of the application, and then does the inferencing on the
|
/// by visiting the AST of the application, and then does the inferencing on the
|
||||||
|
@ -81,6 +81,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
|
|
||||||
final WorkQueue _workQueue = WorkQueue();
|
final WorkQueue _workQueue = WorkQueue();
|
||||||
|
|
||||||
|
@override
|
||||||
final _InferrerEngineMetrics metrics = _InferrerEngineMetrics();
|
final _InferrerEngineMetrics metrics = _InferrerEngineMetrics();
|
||||||
|
|
||||||
final Set<MemberEntity> _analyzedElements = {};
|
final Set<MemberEntity> _analyzedElements = {};
|
||||||
|
@ -328,6 +329,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
_workQueue.add(info);
|
_workQueue.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void runOverAllElements() {
|
void runOverAllElements() {
|
||||||
metrics.time.measure(_runOverAllElements);
|
metrics.time.measure(_runOverAllElements);
|
||||||
}
|
}
|
||||||
|
@ -1071,6 +1073,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void close() {
|
void close() {
|
||||||
for (MemberTypeInformation typeInformation
|
for (MemberTypeInformation typeInformation
|
||||||
in types.memberTypeInformations.values) {
|
in types.memberTypeInformations.values) {
|
||||||
|
@ -1078,6 +1081,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void clear() {
|
void clear() {
|
||||||
if (retainDataForTesting) return;
|
if (retainDataForTesting) return;
|
||||||
|
|
||||||
|
@ -1111,6 +1115,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
_memberData.clear();
|
_memberData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element) {
|
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element) {
|
||||||
MemberTypeInformation info = types.getInferredTypeOfMember(element);
|
MemberTypeInformation info = types.getInferredTypeOfMember(element);
|
||||||
return info.callersForTesting;
|
return info.callersForTesting;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import 'package:kernel/ast.dart' as ir;
|
import 'package:kernel/ast.dart' as ir;
|
||||||
|
|
||||||
import '../common/elements.dart';
|
import '../common/elements.dart';
|
||||||
|
import '../common/metrics.dart' show Metrics;
|
||||||
import '../elements/entities.dart';
|
import '../elements/entities.dart';
|
||||||
import '../js_backend/inferred_data.dart';
|
import '../js_backend/inferred_data.dart';
|
||||||
import '../js_backend/no_such_method_registry_interfaces.dart';
|
import '../js_backend/no_such_method_registry_interfaces.dart';
|
||||||
|
@ -28,6 +29,7 @@ abstract class InferrerEngine {
|
||||||
NoSuchMethodData get noSuchMethodData;
|
NoSuchMethodData get noSuchMethodData;
|
||||||
Set<Selector> get returnsListElementTypeSet;
|
Set<Selector> get returnsListElementTypeSet;
|
||||||
Map<ir.TreeNode, TypeInformation> get concreteTypes;
|
Map<ir.TreeNode, TypeInformation> get concreteTypes;
|
||||||
|
Metrics get metrics;
|
||||||
|
|
||||||
TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior);
|
TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior);
|
||||||
bool canFieldBeUsedForGlobalOptimizations(FieldEntity element);
|
bool canFieldBeUsedForGlobalOptimizations(FieldEntity element);
|
||||||
|
@ -91,6 +93,10 @@ abstract class InferrerEngine {
|
||||||
void recordReturnType(FunctionEntity element, TypeInformation type);
|
void recordReturnType(FunctionEntity element, TypeInformation type);
|
||||||
void recordTypeOfField(FieldEntity element, TypeInformation type);
|
void recordTypeOfField(FieldEntity element, TypeInformation type);
|
||||||
void setDefaultTypeOfParameter(Local parameter, TypeInformation type);
|
void setDefaultTypeOfParameter(Local parameter, TypeInformation type);
|
||||||
|
void runOverAllElements();
|
||||||
|
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element);
|
||||||
|
void close();
|
||||||
|
void clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KernelGlobalTypeInferenceElementData
|
abstract class KernelGlobalTypeInferenceElementData
|
||||||
|
|
|
@ -6,56 +6,26 @@
|
||||||
|
|
||||||
library type_graph_inferrer;
|
library type_graph_inferrer;
|
||||||
|
|
||||||
import 'dart:collection' show Queue;
|
|
||||||
|
|
||||||
import 'package:kernel/ast.dart' as ir;
|
import 'package:kernel/ast.dart' as ir;
|
||||||
import '../closure.dart';
|
import '../closure.dart';
|
||||||
import '../common/metrics.dart' show Metrics;
|
import '../common/metrics.dart' show Metrics;
|
||||||
import '../compiler.dart';
|
import '../compiler_interfaces.dart';
|
||||||
import '../elements/entities.dart';
|
import '../elements/entities.dart';
|
||||||
import '../js_backend/inferred_data.dart';
|
import '../js_backend/inferred_data.dart';
|
||||||
import '../js_model/elements.dart' show JClosureCallMethod;
|
import '../js_model/elements.dart' show JClosureCallMethod;
|
||||||
import '../js_model/locals.dart';
|
import '../js_model/locals.dart';
|
||||||
import '../world.dart';
|
import '../world.dart';
|
||||||
import 'abstract_value_domain.dart';
|
import 'abstract_value_domain.dart';
|
||||||
import 'engine.dart';
|
import 'engine_interfaces.dart';
|
||||||
|
import 'engine.dart' as engine;
|
||||||
import 'type_graph_nodes.dart';
|
import 'type_graph_nodes.dart';
|
||||||
import 'types.dart';
|
import 'types.dart';
|
||||||
|
|
||||||
/// A work queue for the inferrer. It filters out nodes that are tagged as
|
|
||||||
/// [TypeInformation.doNotEnqueue], as well as ensures through
|
|
||||||
/// [TypeInformation.inQueue] that a node is in the queue only once at
|
|
||||||
/// a time.
|
|
||||||
class WorkQueue {
|
|
||||||
final Queue<TypeInformation> queue = Queue<TypeInformation>();
|
|
||||||
|
|
||||||
void add(TypeInformation element) {
|
|
||||||
if (element.doNotEnqueue) return;
|
|
||||||
if (element.inQueue) return;
|
|
||||||
queue.addLast(element);
|
|
||||||
element.inQueue = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addAll(Iterable<TypeInformation> all) {
|
|
||||||
all.forEach(add);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeInformation remove() {
|
|
||||||
TypeInformation element = queue.removeFirst();
|
|
||||||
element.inQueue = false;
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isEmpty => queue.isEmpty;
|
|
||||||
|
|
||||||
int get length => queue.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TypeGraphInferrer implements TypesInferrer {
|
class TypeGraphInferrer implements TypesInferrer {
|
||||||
InferrerEngine inferrer;
|
InferrerEngine inferrer;
|
||||||
final JClosedWorld closedWorld;
|
final JClosedWorld closedWorld;
|
||||||
|
|
||||||
final Compiler _compiler;
|
final CompilerInferrerFacade _compiler;
|
||||||
final GlobalLocalsMap _globalLocalsMap;
|
final GlobalLocalsMap _globalLocalsMap;
|
||||||
final InferredDataBuilder _inferredDataBuilder;
|
final InferredDataBuilder _inferredDataBuilder;
|
||||||
Metrics _metrics = Metrics.none();
|
Metrics _metrics = Metrics.none();
|
||||||
|
@ -80,7 +50,7 @@ class TypeGraphInferrer implements TypesInferrer {
|
||||||
}
|
}
|
||||||
|
|
||||||
InferrerEngine createInferrerEngineFor(FunctionEntity main) {
|
InferrerEngine createInferrerEngineFor(FunctionEntity main) {
|
||||||
return InferrerEngine(
|
return engine.InferrerEngine(
|
||||||
_compiler.options,
|
_compiler.options,
|
||||||
_compiler.progress,
|
_compiler.progress,
|
||||||
_compiler.reporter,
|
_compiler.reporter,
|
||||||
|
|
37
pkg/compiler/lib/src/inferrer/work_queue.dart
Normal file
37
pkg/compiler/lib/src/inferrer/work_queue.dart
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (c) 2022, 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.
|
||||||
|
|
||||||
|
// @dart = 2.10
|
||||||
|
|
||||||
|
import 'dart:collection' show Queue;
|
||||||
|
import 'type_graph_nodes.dart';
|
||||||
|
|
||||||
|
/// A work queue for the inferrer. It filters out nodes that are tagged as
|
||||||
|
/// [TypeInformation.doNotEnqueue], as well as ensures through
|
||||||
|
/// [TypeInformation.inQueue] that a node is in the queue only once at
|
||||||
|
/// a time.
|
||||||
|
class WorkQueue {
|
||||||
|
final Queue<TypeInformation> queue = Queue<TypeInformation>();
|
||||||
|
|
||||||
|
void add(TypeInformation element) {
|
||||||
|
if (element.doNotEnqueue) return;
|
||||||
|
if (element.inQueue) return;
|
||||||
|
queue.addLast(element);
|
||||||
|
element.inQueue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAll(Iterable<TypeInformation> all) {
|
||||||
|
all.forEach(add);
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeInformation remove() {
|
||||||
|
TypeInformation element = queue.removeFirst();
|
||||||
|
element.inQueue = false;
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get isEmpty => queue.isEmpty;
|
||||||
|
|
||||||
|
int get length => queue.length;
|
||||||
|
}
|
|
@ -39,10 +39,10 @@ import 'list_tracer.dart';
|
||||||
import 'map_tracer.dart';
|
import 'map_tracer.dart';
|
||||||
import 'set_tracer.dart';
|
import 'set_tracer.dart';
|
||||||
import 'type_graph_dump.dart';
|
import 'type_graph_dump.dart';
|
||||||
import 'type_graph_inferrer.dart';
|
|
||||||
import 'type_graph_nodes.dart';
|
import 'type_graph_nodes.dart';
|
||||||
import 'type_system.dart';
|
import 'type_system.dart';
|
||||||
import 'types.dart';
|
import 'types.dart';
|
||||||
|
import 'work_queue.dart';
|
||||||
|
|
||||||
/// An inferencing engine that computes a call graph of [TypeInformation] nodes
|
/// An inferencing engine that computes a call graph of [TypeInformation] nodes
|
||||||
/// by visiting the AST of the application, and then does the inferencing on the
|
/// by visiting the AST of the application, and then does the inferencing on the
|
||||||
|
@ -81,6 +81,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
|
|
||||||
final WorkQueue _workQueue = WorkQueue();
|
final WorkQueue _workQueue = WorkQueue();
|
||||||
|
|
||||||
|
@override
|
||||||
final _InferrerEngineMetrics metrics = _InferrerEngineMetrics();
|
final _InferrerEngineMetrics metrics = _InferrerEngineMetrics();
|
||||||
|
|
||||||
final Set<MemberEntity> _analyzedElements = {};
|
final Set<MemberEntity> _analyzedElements = {};
|
||||||
|
@ -328,6 +329,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
_workQueue.add(info);
|
_workQueue.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void runOverAllElements() {
|
void runOverAllElements() {
|
||||||
metrics.time.measure(_runOverAllElements);
|
metrics.time.measure(_runOverAllElements);
|
||||||
}
|
}
|
||||||
|
@ -1071,6 +1073,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void close() {
|
void close() {
|
||||||
for (MemberTypeInformation typeInformation
|
for (MemberTypeInformation typeInformation
|
||||||
in types.memberTypeInformations.values) {
|
in types.memberTypeInformations.values) {
|
||||||
|
@ -1078,6 +1081,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void clear() {
|
void clear() {
|
||||||
if (retainDataForTesting) return;
|
if (retainDataForTesting) return;
|
||||||
|
|
||||||
|
@ -1111,6 +1115,7 @@ class InferrerEngine implements interfaces.InferrerEngine {
|
||||||
_memberData.clear();
|
_memberData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element) {
|
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element) {
|
||||||
MemberTypeInformation info = types.getInferredTypeOfMember(element);
|
MemberTypeInformation info = types.getInferredTypeOfMember(element);
|
||||||
return info.callersForTesting;
|
return info.callersForTesting;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import 'package:kernel/ast.dart' as ir;
|
import 'package:kernel/ast.dart' as ir;
|
||||||
|
|
||||||
import '../common/elements.dart';
|
import '../common/elements.dart';
|
||||||
|
import '../common/metrics.dart' show Metrics;
|
||||||
import '../elements/entities.dart';
|
import '../elements/entities.dart';
|
||||||
import '../js_backend/inferred_data.dart';
|
import '../js_backend/inferred_data.dart';
|
||||||
import '../js_backend/no_such_method_registry_interfaces.dart';
|
import '../js_backend/no_such_method_registry_interfaces.dart';
|
||||||
|
@ -13,10 +14,10 @@ import '../universe/selector.dart';
|
||||||
import '../universe/side_effects.dart';
|
import '../universe/side_effects.dart';
|
||||||
import '../world_interfaces.dart';
|
import '../world_interfaces.dart';
|
||||||
import '../inferrer/abstract_value_domain.dart';
|
import '../inferrer/abstract_value_domain.dart';
|
||||||
import '../inferrer_experimental/types.dart';
|
|
||||||
import 'locals_handler.dart';
|
import 'locals_handler.dart';
|
||||||
import 'type_graph_nodes.dart';
|
import 'type_graph_nodes.dart';
|
||||||
import 'type_system.dart';
|
import 'type_system.dart';
|
||||||
|
import 'types.dart';
|
||||||
|
|
||||||
abstract class InferrerEngine {
|
abstract class InferrerEngine {
|
||||||
AbstractValueDomain get abstractValueDomain;
|
AbstractValueDomain get abstractValueDomain;
|
||||||
|
@ -28,6 +29,7 @@ abstract class InferrerEngine {
|
||||||
NoSuchMethodData get noSuchMethodData;
|
NoSuchMethodData get noSuchMethodData;
|
||||||
Set<Selector> get returnsListElementTypeSet;
|
Set<Selector> get returnsListElementTypeSet;
|
||||||
Map<ir.TreeNode, TypeInformation> get concreteTypes;
|
Map<ir.TreeNode, TypeInformation> get concreteTypes;
|
||||||
|
Metrics get metrics;
|
||||||
|
|
||||||
TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior);
|
TypeInformation typeOfNativeBehavior(NativeBehavior nativeBehavior);
|
||||||
bool canFieldBeUsedForGlobalOptimizations(FieldEntity element);
|
bool canFieldBeUsedForGlobalOptimizations(FieldEntity element);
|
||||||
|
@ -91,6 +93,10 @@ abstract class InferrerEngine {
|
||||||
void recordReturnType(FunctionEntity element, TypeInformation type);
|
void recordReturnType(FunctionEntity element, TypeInformation type);
|
||||||
void recordTypeOfField(FieldEntity element, TypeInformation type);
|
void recordTypeOfField(FieldEntity element, TypeInformation type);
|
||||||
void setDefaultTypeOfParameter(Local parameter, TypeInformation type);
|
void setDefaultTypeOfParameter(Local parameter, TypeInformation type);
|
||||||
|
void runOverAllElements();
|
||||||
|
Iterable<MemberEntity> getCallersOfForTesting(MemberEntity element);
|
||||||
|
void close();
|
||||||
|
void clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KernelGlobalTypeInferenceElementData
|
abstract class KernelGlobalTypeInferenceElementData
|
||||||
|
|
|
@ -6,56 +6,26 @@
|
||||||
|
|
||||||
library type_graph_inferrer;
|
library type_graph_inferrer;
|
||||||
|
|
||||||
import 'dart:collection' show Queue;
|
|
||||||
|
|
||||||
import 'package:kernel/ast.dart' as ir;
|
import 'package:kernel/ast.dart' as ir;
|
||||||
import '../closure.dart';
|
import '../closure.dart';
|
||||||
import '../common/metrics.dart' show Metrics;
|
import '../common/metrics.dart' show Metrics;
|
||||||
import '../compiler.dart';
|
import '../compiler_interfaces.dart';
|
||||||
import '../elements/entities.dart';
|
import '../elements/entities.dart';
|
||||||
import '../js_backend/inferred_data.dart';
|
import '../js_backend/inferred_data.dart';
|
||||||
import '../js_model/elements.dart' show JClosureCallMethod;
|
import '../js_model/elements.dart' show JClosureCallMethod;
|
||||||
import '../js_model/locals.dart';
|
import '../js_model/locals.dart';
|
||||||
import '../world.dart';
|
import '../world.dart';
|
||||||
import '../inferrer/abstract_value_domain.dart';
|
import '../inferrer/abstract_value_domain.dart';
|
||||||
import 'engine.dart';
|
import 'engine_interfaces.dart';
|
||||||
|
import 'engine.dart' as engine;
|
||||||
import 'type_graph_nodes.dart';
|
import 'type_graph_nodes.dart';
|
||||||
import 'types.dart';
|
import 'types.dart';
|
||||||
|
|
||||||
/// A work queue for the inferrer. It filters out nodes that are tagged as
|
|
||||||
/// [TypeInformation.doNotEnqueue], as well as ensures through
|
|
||||||
/// [TypeInformation.inQueue] that a node is in the queue only once at
|
|
||||||
/// a time.
|
|
||||||
class WorkQueue {
|
|
||||||
final Queue<TypeInformation> queue = Queue<TypeInformation>();
|
|
||||||
|
|
||||||
void add(TypeInformation element) {
|
|
||||||
if (element.doNotEnqueue) return;
|
|
||||||
if (element.inQueue) return;
|
|
||||||
queue.addLast(element);
|
|
||||||
element.inQueue = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addAll(Iterable<TypeInformation> all) {
|
|
||||||
all.forEach(add);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeInformation remove() {
|
|
||||||
TypeInformation element = queue.removeFirst();
|
|
||||||
element.inQueue = false;
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isEmpty => queue.isEmpty;
|
|
||||||
|
|
||||||
int get length => queue.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TypeGraphInferrer implements TypesInferrer {
|
class TypeGraphInferrer implements TypesInferrer {
|
||||||
InferrerEngine inferrer;
|
InferrerEngine inferrer;
|
||||||
final JClosedWorld closedWorld;
|
final JClosedWorld closedWorld;
|
||||||
|
|
||||||
final Compiler _compiler;
|
final CompilerInferrerFacade _compiler;
|
||||||
final GlobalLocalsMap _globalLocalsMap;
|
final GlobalLocalsMap _globalLocalsMap;
|
||||||
final InferredDataBuilder _inferredDataBuilder;
|
final InferredDataBuilder _inferredDataBuilder;
|
||||||
Metrics _metrics = Metrics.none();
|
Metrics _metrics = Metrics.none();
|
||||||
|
@ -80,7 +50,7 @@ class TypeGraphInferrer implements TypesInferrer {
|
||||||
}
|
}
|
||||||
|
|
||||||
InferrerEngine createInferrerEngineFor(FunctionEntity main) {
|
InferrerEngine createInferrerEngineFor(FunctionEntity main) {
|
||||||
return InferrerEngine(
|
return engine.InferrerEngine(
|
||||||
_compiler.options,
|
_compiler.options,
|
||||||
_compiler.progress,
|
_compiler.progress,
|
||||||
_compiler.reporter,
|
_compiler.reporter,
|
||||||
|
|
37
pkg/compiler/lib/src/inferrer_experimental/work_queue.dart
Normal file
37
pkg/compiler/lib/src/inferrer_experimental/work_queue.dart
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (c) 2022, 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.
|
||||||
|
|
||||||
|
// @dart = 2.10
|
||||||
|
|
||||||
|
import 'dart:collection' show Queue;
|
||||||
|
import 'type_graph_nodes.dart';
|
||||||
|
|
||||||
|
/// A work queue for the inferrer. It filters out nodes that are tagged as
|
||||||
|
/// [TypeInformation.doNotEnqueue], as well as ensures through
|
||||||
|
/// [TypeInformation.inQueue] that a node is in the queue only once at
|
||||||
|
/// a time.
|
||||||
|
class WorkQueue {
|
||||||
|
final Queue<TypeInformation> queue = Queue<TypeInformation>();
|
||||||
|
|
||||||
|
void add(TypeInformation element) {
|
||||||
|
if (element.doNotEnqueue) return;
|
||||||
|
if (element.inQueue) return;
|
||||||
|
queue.addLast(element);
|
||||||
|
element.inQueue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAll(Iterable<TypeInformation> all) {
|
||||||
|
all.forEach(add);
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeInformation remove() {
|
||||||
|
TypeInformation element = queue.removeFirst();
|
||||||
|
element.inQueue = false;
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get isEmpty => queue.isEmpty;
|
||||||
|
|
||||||
|
int get length => queue.length;
|
||||||
|
}
|
Loading…
Reference in a new issue