Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10386086: RFC: Start refactoring to provide more than a single backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Next iteration Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 669f95d7f7d23c9a1927833a079ebf2a925af884..c0c896b5ae49f84fca3c36597e8b43a756d24409 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -3,8 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
class SsaCodeGeneratorTask extends CompilerTask {
- SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
+ final JavaScriptBackend backend;
+ SsaCodeGeneratorTask(JavaScriptBackend backend)
+ : this.backend = backend,
+ super(backend.compiler);
String get name() => 'SSA code generator';
+ NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter;
String buildJavaScriptFunction(FunctionElement element,
@@ -37,7 +41,7 @@ class SsaCodeGeneratorTask extends CompilerTask {
Map<Element, String> parameterNames = getParameterNames(work);
String parameters = Strings.join(parameterNames.getValues(), ', ');
SsaOptimizedCodeGenerator codegen = new SsaOptimizedCodeGenerator(
- compiler, work, parameters, parameterNames);
+ backend, work, parameters, parameterNames);
codegen.visitGraph(graph);
FunctionElement element = work.element;
@@ -45,13 +49,12 @@ class SsaCodeGeneratorTask extends CompilerTask {
if (element.isInstanceMember()
&& element.enclosingElement.isClass()
&& element.enclosingElement.isNative()
- && native.isOverriddenMethod(element,
- element.enclosingElement,
- compiler.emitter.nativeEmitter)) {
+ && native.isOverriddenMethod(
+ element, element.enclosingElement, nativeEmitter)) {
// Record that this method is overridden. In case of optional
// arguments, the emitter will generate stubs to handle them,
// and needs to know if the method is overridden.
- compiler.emitter.nativeEmitter.overriddenMethods.add(element);
+ nativeEmitter.overriddenMethods.add(element);
StringBuffer buffer = new StringBuffer();
native.generateMethodWithPrototypeCheckForElement(
compiler, buffer, element, '${codegen.buffer}', parameters);
@@ -71,7 +74,7 @@ class SsaCodeGeneratorTask extends CompilerTask {
Map<Element, String> parameterNames = getParameterNames(work);
String parameters = Strings.join(parameterNames.getValues(), ', ');
SsaUnoptimizedCodeGenerator codegen = new SsaUnoptimizedCodeGenerator(
- compiler, work, parameters, parameterNames);
+ backend, work, parameters, parameterNames);
codegen.visitGraph(graph);
StringBuffer newParameters = new StringBuffer();
@@ -137,7 +140,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
static final String TEMPORARY_PREFIX = 't';
- final Compiler compiler;
+ final JavaScriptBackend backend;
final WorkItem work;
final StringBuffer buffer;
final String parameters;
@@ -179,12 +182,13 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
SubGraph subGraph;
LibraryElement get currentLibrary() => work.element.getLibrary();
+ Compiler get compiler() => backend.compiler;
bool isGenerateAtUseSite(HInstruction instruction) {
return generateAtUseSite.contains(instruction);
}
- SsaCodeGenerator(this.compiler,
+ SsaCodeGenerator(this.backend,
this.work,
this.parameters,
this.parameterNames)
@@ -207,7 +211,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
// Create a namespace for temporaries.
prefixes[TEMPORARY_PREFIX] = 0;
- Interceptors interceptors = compiler.builder.interceptors;
+ Interceptors interceptors = backend.builder.interceptors;
equalsNullElement = interceptors.getEqualsNullInterceptor();
boolifiedEqualsNullElement =
interceptors.getBoolifiedVersionOf(equalsNullElement);
@@ -2043,7 +2047,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
void checkType(HInstruction input, Element element) {
bool requiresNativeIsCheck =
- compiler.emitter.nativeEmitter.requiresNativeIsCheck(element);
+ compiler.backend.emitter.nativeEmitter.requiresNativeIsCheck(element);
if (!requiresNativeIsCheck) buffer.add('!!');
use(input, JSPrecedence.MEMBER_PRECEDENCE);
buffer.add('.');
@@ -2162,8 +2166,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
compiler.registerIsCheck(element);
SourceString helper;
String additionalArgument;
- bool nativeCheck =
- compiler.emitter.nativeEmitter.requiresNativeIsCheck(element);
+ bool nativeCheck = nativeEmitter.requiresNativeIsCheck(element);
beginExpression(JSPrecedence.CALL_PRECEDENCE);
if (element == compiler.stringClass) {
@@ -2215,8 +2218,8 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
- SsaOptimizedCodeGenerator(compiler, work, parameters, parameterNames)
- : super(compiler, work, parameters, parameterNames);
+ SsaOptimizedCodeGenerator(backend, work, parameters, parameterNames)
+ : super(backend, work, parameters, parameterNames);
void beginGraph(HGraph graph) {}
void endGraph(HGraph graph) {}
@@ -2384,8 +2387,8 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator {
int labelId = 0;
int maxBailoutParameters = 0;
- SsaUnoptimizedCodeGenerator(compiler, work, parameters, parameterNames)
- : super(compiler, work, parameters, parameterNames),
+ SsaUnoptimizedCodeGenerator(backend, work, parameters, parameterNames)
+ : super(backend, work, parameters, parameterNames),
setup = new StringBuffer(),
labels = <String>[];

Powered by Google App Engine
This is Rietveld 408576698