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

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

Issue 10417054: Revert "Parameterize WorkItem.run." (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/scanner/scanner_task.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
11 WorkItem(this.element, this.resolutionTree); 11 WorkItem(this.element, this.resolutionTree);
12 12
13 bool isAnalyzed() => resolutionTree !== null; 13 bool isAnalyzed() => resolutionTree !== null;
14 14
15 String run(Compiler compiler, Enqueuer world) { 15 int hashCode() => element.hashCode();
16 String code = world.universe.generatedCode[element]; 16
17 String run(Compiler compiler) {
18 String code = compiler.codegenWorld.generatedCode[element];
17 if (code !== null) return code; 19 if (code !== null) return code;
18 if (!isAnalyzed()) compiler.analyze(this); 20 try {
19 return compiler.codegen(this); 21 if (!isAnalyzed()) compiler.analyze(this);
22 return compiler.codegen(this);
23 } catch (CompilerCancelledException ex) {
24 throw;
25 } catch (var ex) {
26 compiler.unhandledExceptionOnElement(element);
27 throw;
28 }
20 } 29 }
21 } 30 }
22 31
23 class Backend { 32 class Backend {
24 final Compiler compiler; 33 final Compiler compiler;
25 34
26 Backend(this.compiler); 35 Backend(this.compiler);
27 36
28 abstract String codegen(WorkItem work); 37 abstract String codegen(WorkItem work);
29 abstract void processNativeClasses(world, libraries); 38 abstract void processNativeClasses(world, libraries);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ClassElement functionClass; 108 ClassElement functionClass;
100 ClassElement nullClass; 109 ClassElement nullClass;
101 ClassElement listClass; 110 ClassElement listClass;
102 111
103 Element get currentElement() => _currentElement; 112 Element get currentElement() => _currentElement;
104 withCurrentElement(Element element, f()) { 113 withCurrentElement(Element element, f()) {
105 Element old = currentElement; 114 Element old = currentElement;
106 _currentElement = element; 115 _currentElement = element;
107 try { 116 try {
108 return f(); 117 return f();
109 } catch (CompilerCancelledException ex) {
110 throw;
111 } catch (var ex) {
112 unhandledExceptionOnElement(element);
113 throw;
114 } finally { 118 } finally {
115 _currentElement = old; 119 _currentElement = old;
116 } 120 }
117 } 121 }
118 122
119 List<CompilerTask> tasks; 123 List<CompilerTask> tasks;
120 ScannerTask scanner; 124 ScannerTask scanner;
121 DietParserTask dietParser; 125 DietParserTask dietParser;
122 ParserTask parser; 126 ParserTask parser;
123 TreeValidatorTask validator; 127 TreeValidatorTask validator;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 "work list is not empty"); 371 "work list is not empty");
368 } 372 }
369 } 373 }
370 374
371 processQueue(Enqueuer world, Element main) { 375 processQueue(Enqueuer world, Element main) {
372 backend.processNativeClasses(world, libraries.getValues()); 376 backend.processNativeClasses(world, libraries.getValues());
373 world.addToWorkList(main); 377 world.addToWorkList(main);
374 codegenProgress.reset(); 378 codegenProgress.reset();
375 while (!world.queue.isEmpty()) { 379 while (!world.queue.isEmpty()) {
376 WorkItem work = world.queue.removeLast(); 380 WorkItem work = world.queue.removeLast();
377 withCurrentElement(work.element, () => work.run(this, world)); 381 withCurrentElement(work.element, () => work.run(this));
378 } 382 }
379 world.queueIsClosed = true; 383 world.queueIsClosed = true;
380 assert(world.checkNoEnqueuedInvokedInstanceMethods()); 384 assert(world.checkNoEnqueuedInvokedInstanceMethods());
381 world.registerFieldClosureInvocations(); 385 world.registerFieldClosureInvocations();
382 } 386 }
383 387
384 TreeElements analyzeElement(Element element) { 388 TreeElements analyzeElement(Element element) {
385 assert(parser !== null); 389 assert(parser !== null);
386 Node tree = parser.parse(element); 390 Node tree = parser.parse(element);
387 validator.validate(tree); 391 validator.validate(tree);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // invariant that endOffset > beginOffset, but for EOF the 578 // invariant that endOffset > beginOffset, but for EOF the
575 // charoffset of the next token may be [beginOffset]. This can 579 // charoffset of the next token may be [beginOffset]. This can
576 // also happen for synthetized tokens that are produced during 580 // also happen for synthetized tokens that are produced during
577 // error handling. 581 // error handling.
578 final endOffset = 582 final endOffset =
579 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); 583 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1);
580 assert(endOffset > beginOffset); 584 assert(endOffset > beginOffset);
581 return f(beginOffset, endOffset); 585 return f(beginOffset, endOffset);
582 } 586 }
583 } 587 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698