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

Side by Side Diff: dart/lib/compiler/implementation/compiler.dart

Issue 10408087: Parameterize the native_handler with the world/enqueuer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class WorkItem { 5 class WorkItem {
6 final Element element; 6 final Element element;
7 TreeElements resolutionTree; 7 TreeElements resolutionTree;
8 bool allowSpeculativeOptimization = true; 8 bool allowSpeculativeOptimization = true;
9 List<HTypeGuard> guards = const <HTypeGuard>[]; 9 List<HTypeGuard> guards = const <HTypeGuard>[];
10 10
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 } 29 }
30 } 30 }
31 31
32 class Backend { 32 class Backend {
33 final Compiler compiler; 33 final Compiler compiler;
34 34
35 Backend(this.compiler); 35 Backend(this.compiler);
36 36
37 abstract String codegen(WorkItem work); 37 abstract String codegen(WorkItem work);
38 abstract void processNativeClasses(libraries); 38 abstract void processNativeClasses(world, libraries);
39 abstract void assembleProgram(); 39 abstract void assembleProgram();
40 } 40 }
41 41
42 class JavaScriptBackend extends Backend { 42 class JavaScriptBackend extends Backend {
43 SsaBuilderTask builder; 43 SsaBuilderTask builder;
44 SsaOptimizerTask optimizer; 44 SsaOptimizerTask optimizer;
45 SsaCodeGeneratorTask generator; 45 SsaCodeGeneratorTask generator;
46 CodeEmitterTask emitter; 46 CodeEmitterTask emitter;
47 47
48 JavaScriptBackend(Compiler compiler) 48 JavaScriptBackend(Compiler compiler)
(...skipping 10 matching lines...) Expand all
59 if (work.allowSpeculativeOptimization 59 if (work.allowSpeculativeOptimization
60 && optimizer.trySpeculativeOptimizations(work, graph)) { 60 && optimizer.trySpeculativeOptimizations(work, graph)) {
61 String code = generator.generateBailoutMethod(work, graph); 61 String code = generator.generateBailoutMethod(work, graph);
62 compiler.codegenWorld.addBailoutCode(work, code); 62 compiler.codegenWorld.addBailoutCode(work, code);
63 optimizer.prepareForSpeculativeOptimizations(work, graph); 63 optimizer.prepareForSpeculativeOptimizations(work, graph);
64 optimizer.optimize(work, graph); 64 optimizer.optimize(work, graph);
65 } 65 }
66 return generator.generateMethod(work, graph); 66 return generator.generateMethod(work, graph);
67 } 67 }
68 68
69 void processNativeClasses(libraries) { 69 void processNativeClasses(world, libraries) {
70 native.processNativeClasses(emitter, libraries); 70 native.processNativeClasses(world, emitter, libraries);
71 } 71 }
72 72
73 void assembleProgram() => emitter.assembleProgram(); 73 void assembleProgram() => emitter.assembleProgram();
74 } 74 }
75 75
76 class DartBackend extends Backend { 76 class DartBackend extends Backend {
77 DartBackend(Compiler compiler) : super(compiler); 77 DartBackend(Compiler compiler) : super(compiler);
78 } 78 }
79 79
80 class Compiler implements DiagnosticListener { 80 class Compiler implements DiagnosticListener {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 cancel("${red('internal error:')} $message", 186 cancel("${red('internal error:')} $message",
187 node, token, instruction, element); 187 node, token, instruction, element);
188 } 188 }
189 189
190 void internalErrorOnElement(Element element, String message) { 190 void internalErrorOnElement(Element element, String message) {
191 internalError(message, element: element); 191 internalError(message, element: element);
192 } 192 }
193 193
194 void unhandledExceptionOnElement(Element element) { 194 void unhandledExceptionOnElement(Element element) {
195 reportDiagnostic(spanFromElement(element), 195 reportDiagnostic(spanFromElement(element),
196 MessageKind.COMPILER_CRASHED.error(), 196 MessageKind.COMPILER_CRASHED.error().toString(),
karlklose 2012/05/23 14:03:36 Why is this necessary?
ahe 2012/05/23 14:24:33 Because reportDiagnostic takes a String.
197 false); 197 false);
198 // TODO(ahe): Obtain the build ID. 198 // TODO(ahe): Obtain the build ID.
199 var buildId = 'build number could not be determined'; 199 var buildId = 'build number could not be determined';
200 print(MessageKind.PLEASE_REPORT_THE_CRASH.message([buildId])); 200 print(MessageKind.PLEASE_REPORT_THE_CRASH.message([buildId]).toString());
ahe 2012/05/23 14:24:33 Not necessary, though.
201 } 201 }
202 202
203 void cancel([String reason, Node node, Token token, 203 void cancel([String reason, Node node, Token token,
204 HInstruction instruction, Element element]) { 204 HInstruction instruction, Element element]) {
205 SourceSpan span = const SourceSpan(null, null, null); 205 SourceSpan span = const SourceSpan(null, null, null);
206 if (node !== null) { 206 if (node !== null) {
207 span = spanFromNode(node); 207 span = spanFromNode(node);
208 } else if (token !== null) { 208 } else if (token !== null) {
209 span = spanFromTokens(token, token); 209 span = spanFromTokens(token, token);
210 } else if (instruction !== null) { 210 } else if (instruction !== null) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 reportFatalError('Could not find $MAIN', mainApp); 350 reportFatalError('Could not find $MAIN', mainApp);
351 } else { 351 } else {
352 if (!main.isFunction()) reportFatalError('main is not a function', main); 352 if (!main.isFunction()) reportFatalError('main is not a function', main);
353 FunctionElement mainMethod = main; 353 FunctionElement mainMethod = main;
354 FunctionSignature parameters = mainMethod.computeSignature(this); 354 FunctionSignature parameters = mainMethod.computeSignature(this);
355 parameters.forEachParameter((Element parameter) { 355 parameters.forEachParameter((Element parameter) {
356 reportFatalError('main cannot have parameters', parameter); 356 reportFatalError('main cannot have parameters', parameter);
357 }); 357 });
358 } 358 }
359 Collection<LibraryElement> libraries = libraries.getValues(); 359 Collection<LibraryElement> libraries = libraries.getValues();
360 backend.processNativeClasses(libraries); 360 backend.processNativeClasses(enqueuer.codegen, libraries);
361 world.populate(this, libraries); 361 world.populate(this, libraries);
362 enqueuer.codegen.addToWorkList(main); 362 enqueuer.codegen.addToWorkList(main);
363 codegenProgress.reset(); 363 codegenProgress.reset();
364 while (!enqueuer.codegen.queue.isEmpty()) { 364 while (!enqueuer.codegen.queue.isEmpty()) {
365 WorkItem work = enqueuer.codegen.queue.removeLast(); 365 WorkItem work = enqueuer.codegen.queue.removeLast();
366 withCurrentElement(work.element, () => work.run(this)); 366 withCurrentElement(work.element, () => work.run(this));
367 } 367 }
368 enqueuer.codegen.queueIsClosed = true; 368 enqueuer.codegen.queueIsClosed = true;
369 assert(enqueuer.codegen.checkNoEnqueuedInvokedInstanceMethods()); 369 assert(enqueuer.codegen.checkNoEnqueuedInvokedInstanceMethods());
370 enqueuer.codegen.registerFieldClosureInvocations(); 370 enqueuer.codegen.registerFieldClosureInvocations();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // invariant that endOffset > beginOffset, but for EOF the 568 // invariant that endOffset > beginOffset, but for EOF the
569 // charoffset of the next token may be [beginOffset]. This can 569 // charoffset of the next token may be [beginOffset]. This can
570 // also happen for synthetized tokens that are produced during 570 // also happen for synthetized tokens that are produced during
571 // error handling. 571 // error handling.
572 final endOffset = 572 final endOffset =
573 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); 573 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1);
574 assert(endOffset > beginOffset); 574 assert(endOffset > beginOffset);
575 return f(beginOffset, endOffset); 575 return f(beginOffset, endOffset);
576 } 576 }
577 } 577 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/native_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698