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

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

Issue 10827180: Move types out of the HInstructions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 4 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 | lib/compiler/implementation/enqueue.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 5
6 /** 6 /**
7 * If true, print a warning for each method that was resolved, but not 7 * If true, print a warning for each method that was resolved, but not
8 * compiled. 8 * compiled.
9 */ 9 */
10 final bool REPORT_EXCESS_RESOLUTION = false; 10 final bool REPORT_EXCESS_RESOLUTION = false;
11 11
12 /** 12 /**
13 * If true, trace information on pass2 optimizations. 13 * If true, trace information on pass2 optimizations.
14 */ 14 */
15 final bool REPORT_PASS2_OPTIMIZATIONS = false; 15 final bool REPORT_PASS2_OPTIMIZATIONS = false;
16 16
17 /**
18 * Contains backend-specific data that is used throughout the compilation of
19 * one work item.
20 */
21 class ItemCompilationContext {
22 }
23
17 class WorkItem { 24 class WorkItem {
25 final ItemCompilationContext compilationContext;
18 final Element element; 26 final Element element;
19 TreeElements resolutionTree; 27 TreeElements resolutionTree;
20 bool allowSpeculativeOptimization = true; 28 bool allowSpeculativeOptimization = true;
21 List<HTypeGuard> guards = const <HTypeGuard>[]; 29 List<HTypeGuard> guards = const <HTypeGuard>[];
22 30
23 WorkItem(this.element, this.resolutionTree); 31 WorkItem(this.element, this.resolutionTree, this.compilationContext);
24 32
25 bool isAnalyzed() => resolutionTree !== null; 33 bool isAnalyzed() => resolutionTree !== null;
26 34
27 void run(Compiler compiler, Enqueuer world) { 35 void run(Compiler compiler, Enqueuer world) {
28 CodeBuffer codeBuffer = world.universe.generatedCode[element]; 36 CodeBuffer codeBuffer = world.universe.generatedCode[element];
29 if (codeBuffer !== null) return; 37 if (codeBuffer !== null) return;
30 resolutionTree = compiler.analyze(this, world); 38 resolutionTree = compiler.analyze(this, world);
31 compiler.codegen(this, world); 39 compiler.codegen(this, world);
32 } 40 }
33 } 41 }
34 42
35 class Backend { 43 class Backend {
36 final Compiler compiler; 44 final Compiler compiler;
37 45
38 Backend(this.compiler); 46 Backend(this.compiler);
39 47
40 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { 48 void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) {
41 lib.forEachExport((Element e) { 49 lib.forEachExport((Element e) {
42 if (e.isFunction()) world.addToWorkList(e); 50 if (e.isFunction()) world.addToWorkList(e);
43 }); 51 });
44 } 52 }
45 53
46 abstract void enqueueHelpers(Enqueuer world); 54 abstract void enqueueHelpers(Enqueuer world);
47 abstract void codegen(WorkItem work); 55 abstract void codegen(WorkItem work);
48 abstract void processNativeClasses(Enqueuer world, 56 abstract void processNativeClasses(Enqueuer world,
49 Collection<LibraryElement> libraries); 57 Collection<LibraryElement> libraries);
50 abstract void assembleProgram(); 58 abstract void assembleProgram();
51 abstract List<CompilerTask> get tasks(); 59 abstract List<CompilerTask> get tasks();
60
61 ItemCompilationContext createItemCompilationContext() {
62 return new ItemCompilationContext();
63 }
52 } 64 }
53 65
54 class Compiler implements DiagnosticListener { 66 class Compiler implements DiagnosticListener {
55 final Map<String, LibraryElement> libraries; 67 final Map<String, LibraryElement> libraries;
56 int nextFreeClassId = 0; 68 int nextFreeClassId = 0;
57 World world; 69 World world;
58 String assembledCode; 70 String assembledCode;
59 Namer namer; 71 Namer namer;
60 Types types; 72 Types types;
61 final bool enableTypeAssertions; 73 final bool enableTypeAssertions;
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 String banner = 'compiler cancelled'; 925 String banner = 'compiler cancelled';
914 return (reason !== null) ? '$banner: $reason' : '$banner'; 926 return (reason !== null) ? '$banner: $reason' : '$banner';
915 } 927 }
916 } 928 }
917 929
918 class Tracer { 930 class Tracer {
919 final bool enabled = false; 931 final bool enabled = false;
920 932
921 const Tracer(); 933 const Tracer();
922 934
923 void traceCompilation(String methodName) { 935 void traceCompilation(String methodName, ItemCompilationContext context) {
924 } 936 }
925 937
926 void traceGraph(String name, var graph) { 938 void traceGraph(String name, var graph) {
927 } 939 }
928 940
929 void close() { 941 void close() {
930 } 942 }
931 } 943 }
932 944
933 class SourceSpan { 945 class SourceSpan {
934 final Uri uri; 946 final Uri uri;
935 final int begin; 947 final int begin;
936 final int end; 948 final int end;
937 949
938 const SourceSpan(this.uri, this.begin, this.end); 950 const SourceSpan(this.uri, this.begin, this.end);
939 951
940 static withCharacterOffsets(Token begin, Token end, 952 static withCharacterOffsets(Token begin, Token end,
941 f(int beginOffset, int endOffset)) { 953 f(int beginOffset, int endOffset)) {
942 final beginOffset = begin.charOffset; 954 final beginOffset = begin.charOffset;
943 final endOffset = end.charOffset + end.slowCharCount; 955 final endOffset = end.charOffset + end.slowCharCount;
944 956
945 // [begin] and [end] might be the same for the same empty token. This 957 // [begin] and [end] might be the same for the same empty token. This
946 // happens for instance when scanning '$$'. 958 // happens for instance when scanning '$$'.
947 assert(endOffset >= beginOffset); 959 assert(endOffset >= beginOffset);
948 return f(beginOffset, endOffset); 960 return f(beginOffset, endOffset);
949 } 961 }
950 962
951 String toString() => 'SourceSpan($uri, $begin, $end)'; 963 String toString() => 'SourceSpan($uri, $begin, $end)';
952 } 964 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698