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

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

Issue 10696194: Introduce CodeBuffer as StringBuffer replacement in compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 5 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/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 6b130e442bb074e78040abd5a662f3bb11e6d8d2..79e936668248c2a67fd6ecb0cc9d506efd0254fd 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -25,8 +25,8 @@ class WorkItem {
bool isAnalyzed() => resolutionTree !== null;
String run(Compiler compiler, Enqueuer world) {
- CodeBlock codeBlock = world.universe.generatedCode[element];
- if (codeBlock !== null) return codeBlock.code;
+ CodeBuffer codeBuffer = world.universe.generatedCode[element];
+ if (codeBuffer !== null) return codeBuffer.toString();
resolutionTree = compiler.analyze(this, world);
return compiler.codegen(this, world);
}
@@ -44,7 +44,7 @@ class Backend {
}
abstract void enqueueHelpers(Enqueuer world);
- abstract CodeBlock codegen(WorkItem work);
+ abstract CodeBuffer codegen(WorkItem work);
abstract void processNativeClasses(Enqueuer world,
Collection<LibraryElement> libraries);
abstract void assembleProgram();
@@ -86,13 +86,13 @@ class JavaScriptBackend extends Backend {
}
}
- CodeBlock codegen(WorkItem work) {
+ CodeBuffer codegen(WorkItem work) {
HGraph graph = builder.build(work);
optimizer.optimize(work, graph);
if (work.allowSpeculativeOptimization
&& optimizer.trySpeculativeOptimizations(work, graph)) {
- CodeBlock codeBlock = generator.generateBailoutMethod(work, graph);
- compiler.codegenWorld.addBailoutCode(work, codeBlock);
+ CodeBuffer codeBuffer = generator.generateBailoutMethod(work, graph);
+ compiler.codegenWorld.addBailoutCode(work, codeBuffer);
optimizer.prepareForSpeculativeOptimizations(work, graph);
optimizer.optimize(work, graph);
}
@@ -773,11 +773,11 @@ class Compiler implements DiagnosticListener {
assert(phase == PHASE_RECOMPILING);
while (!world.recompilationCandidates.isEmpty()) {
WorkItem work = world.recompilationCandidates.next();
- String oldCode = world.universe.generatedCode[work.element].code;
+ CodeBuffer oldCode = world.universe.generatedCode[work.element];
world.universe.generatedCode.remove(work.element);
world.universe.generatedBailoutCode.remove(work.element);
withCurrentElement(work.element, () => work.run(this, world));
- String newCode = world.universe.generatedCode[work.element].code;
+ CodeBuffer newCode = world.universe.generatedCode[work.element];
if (REPORT_PASS2_OPTIMIZATIONS && newCode != oldCode) {
log("Pass 2 optimization:");
log("Before:\n$oldCode");
@@ -897,9 +897,9 @@ class Compiler implements DiagnosticListener {
constantHandler.compileWorkItem(work);
return null;
} else {
- CodeBlock codeBlock = backend.codegen(work);
- codegenWorld.addGeneratedCode(work, codeBlock);
- return codeBlock.code;
+ CodeBuffer codeBuffer = backend.codegen(work);
+ codegenWorld.addGeneratedCode(work, codeBuffer);
+ return codeBuffer.toString();
}
}

Powered by Google App Engine
This is Rietveld 408576698