Add KernelCodegenWorkItem stub

With this change we can run the compilation of hello_world from .dill
(with --read-dill --disable-type-inference) to where we need to run
the KernelSsaBuilder.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2888413004 .
This commit is contained in:
Johnni Winther 2017-05-22 10:18:46 +02:00
parent 789fce309f
commit 915383a17a
7 changed files with 47 additions and 20 deletions

View file

@ -5,7 +5,7 @@
library dart2js.common.codegen;
import '../elements/elements.dart'
show AsyncMarker, ClassElement, LocalFunctionElement, MemberElement;
show AsyncMarker, ClassElement, LocalFunctionElement;
import '../elements/entities.dart';
import '../elements/types.dart' show DartType, InterfaceType;
import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse;
@ -110,12 +110,11 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
// TODO(johnniwinther): Split this class into interface and implementation.
// TODO(johnniwinther): Move this implementation to the JS backend.
class CodegenRegistry {
final MemberElement currentElement;
final MemberEntity currentElement;
final _CodegenImpact worldImpact;
CodegenRegistry(MemberElement currentElement)
: this.currentElement = currentElement,
this.worldImpact = new _CodegenImpact();
CodegenRegistry(this.currentElement)
: this.worldImpact = new _CodegenImpact();
bool get isForResolution => false;

View file

@ -46,7 +46,7 @@ class InferrerEngine {
final Map<Element, TypeInformation> defaultTypeOfParameter =
new Map<Element, TypeInformation>();
final WorkQueue workQueue = new WorkQueue();
final Element mainElement;
final FunctionEntity mainElement;
final Set<Element> analyzedElements = new Set<Element>();
/// The maximum number of times we allow a node in the graph to

View file

@ -63,7 +63,7 @@ class TypeGraphInferrer implements TypesInferrer {
TypeMask get _dynamicType => commonMasks.dynamicType;
void analyzeMain(Element main) {
void analyzeMain(FunctionEntity main) {
inferrer =
new InferrerEngine(compiler, closedWorld, closedWorldRefiner, main);
inferrer.runOverAllElements();

View file

@ -239,16 +239,15 @@ class CodegenEnqueuerListener extends EnqueuerListener {
}
@override
WorldImpact registerUsedElement(MemberElement member) {
WorldImpact registerUsedElement(MemberEntity member) {
WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl();
_customElementsAnalysis.registerStaticUse(member);
if (member.isFunction && member.isInstanceMember) {
MethodElement method = member;
ClassElement cls = method.enclosingClass;
if (method.name == Identifiers.call &&
!cls.typeVariables.isEmpty &&
_rtiNeed.methodNeedsRti(method)) {
ClassEntity cls = member.enclosingClass;
if (member.name == Identifiers.call &&
_elementEnvironment.isGenericClass(cls) &&
_rtiNeed.methodNeedsRti(member)) {
worldImpact.addImpact(_registerComputeSignature());
}
}

View file

@ -9,7 +9,7 @@ import '../backend_strategy.dart';
import '../common.dart';
import '../common_elements.dart';
import '../common/backend_api.dart';
import '../common/codegen.dart' show CodegenWorkItem;
import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
import '../common/resolution.dart';
import '../common/tasks.dart';
import '../common/work.dart';
@ -231,7 +231,8 @@ class MirrorsResolutionAnalysisImpl implements MirrorsResolutionAnalysis {
@override
MirrorsCodegenAnalysis close() {
throw new UnimplementedError('MirrorsResolutionAnalysisImpl.close');
// TODO(johnniwinther): Implement this.
return new MirrorsCodegenAnalysisImpl();
}
@override
@ -255,7 +256,6 @@ class KernelBackendStrategy implements BackendStrategy {
void convertClosures(ClosedWorldRefiner closedWorldRefiner) {
// TODO(johnniwinther,efortuna): Compute closure classes for kernel based
// elements.
throw new UnimplementedError('KernelBackendStrategy.createClosureClasses');
}
@override
@ -273,9 +273,35 @@ class KernelBackendStrategy implements BackendStrategy {
}
}
class MirrorsCodegenAnalysisImpl implements MirrorsCodegenAnalysis {
@override
int get preMirrorsMethodCount {
throw new UnimplementedError(
'MirrorsCodegenAnalysisImpl.preMirrorsMethodCount');
}
@override
void onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses) {
throw new UnimplementedError('MirrorsCodegenAnalysisImpl.onQueueEmpty');
}
}
class KernelCodegenWorkItemBuilder implements WorkItemBuilder {
@override
CodegenWorkItem createWorkItem(MemberEntity entity) {
throw new UnimplementedError('KernelCodegenWorkItemBuilder.createWorkItem');
return new KernelCodegenWorkItem(entity);
}
}
class KernelCodegenWorkItem extends CodegenWorkItem {
final MemberEntity element;
final CodegenRegistry registry;
KernelCodegenWorkItem(this.element) : registry = new CodegenRegistry(element);
@override
WorldImpact run() {
// TODO(johnniwinther): Build SSA graph from kernel and run codegen on it.
return const WorldImpact();
}
}

View file

@ -206,7 +206,9 @@ class FormattingDiagnosticHandler implements CompilerDiagnostics {
print('${color(message)}');
} else {
SourceFile file = provider.sourceFiles[uri];
if (file != null) {
// TODO(johnniwinther): Remove the '.dill' hack; add support for binary
// files to avoid crashes on trying to decode .dill binaries as utf8.
if (file != null && !file.filename.endsWith('.dill')) {
print(file.getLocationMessage(color(message), begin, end,
colorize: color));
} else {

View file

@ -9,6 +9,7 @@ import '../common.dart' show invariant;
import '../common/tasks.dart' show CompilerTask;
import '../compiler.dart' show Compiler;
import '../elements/elements.dart';
import '../elements/entities.dart';
import '../inferrer/type_graph_inferrer.dart' show TypeGraphInferrer;
import '../inferrer/type_system.dart';
import '../tree/tree.dart';
@ -171,7 +172,7 @@ class GlobalTypeInferenceElementData {
/// API to interact with the global type-inference engine.
abstract class TypesInferrer {
void analyzeMain(Element element);
void analyzeMain(FunctionEntity element);
TypeMask getReturnTypeOfElement(Element element);
TypeMask getTypeOfElement(Element element);
TypeMask getTypeForNewList(Element owner, Node node);
@ -271,7 +272,7 @@ class GlobalTypeInferenceTask extends CompilerTask {
super(compiler.measurer);
/// Runs the global type-inference algorithm once.
void runGlobalTypeInference(MethodElement mainElement,
void runGlobalTypeInference(FunctionEntity mainElement,
ClosedWorld closedWorld, ClosedWorldRefiner closedWorldRefiner) {
measure(() {
typesInferrerInternal ??=