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

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

Issue 10392104: Diagnose compiler crashes. (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 int hashCode() => element.hashCode(); 15 int hashCode() => element.hashCode();
16 16
17 String run(Compiler compiler) { 17 String run(Compiler compiler) {
18 String code = compiler.universe.generatedCode[element]; 18 String code = compiler.universe.generatedCode[element];
19 if (code !== null) return code; 19 if (code !== null) return code;
20 if (!isAnalyzed()) compiler.analyze(this); 20 try {
21 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 }
22 } 29 }
23 } 30 }
24 31
25 class Compiler implements DiagnosticListener { 32 class Compiler implements DiagnosticListener {
26 Queue<WorkItem> codegenQueue; 33 Queue<WorkItem> codegenQueue;
27 Universe universe; 34 Universe universe;
28 World world; 35 World world;
29 String assembledCode; 36 String assembledCode;
30 Namer namer; 37 Namer namer;
31 Types types; 38 Types types;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 cancel("${red('internal error:')} $message", 138 cancel("${red('internal error:')} $message",
132 node, token, instruction, element); 139 node, token, instruction, element);
133 } 140 }
134 141
135 void internalErrorOnElement(Element element, String message) { 142 void internalErrorOnElement(Element element, String message) {
136 withCurrentElement(element, () { 143 withCurrentElement(element, () {
137 internalError(message, element: element); 144 internalError(message, element: element);
138 }); 145 });
139 } 146 }
140 147
148 void unhandledExceptionOnElement(Element element) {
149 internalErrorOnElement(element, '''
150 An unhandled exception was thrown.
151 Please report this problem at http://dartbug.com/new.''');
152 }
153
141 void cancel([String reason, Node node, Token token, 154 void cancel([String reason, Node node, Token token,
142 HInstruction instruction, Element element]) { 155 HInstruction instruction, Element element]) {
143 SourceSpan span = const SourceSpan(null, null, null); 156 SourceSpan span = const SourceSpan(null, null, null);
144 if (node !== null) { 157 if (node !== null) {
145 span = spanFromNode(node); 158 span = spanFromNode(node);
146 } else if (token !== null) { 159 } else if (token !== null) {
147 span = spanFromTokens(token, token); 160 span = spanFromTokens(token, token);
148 } else if (instruction !== null) { 161 } else if (instruction !== null) {
149 span = spanFromElement(currentElement); 162 span = spanFromElement(currentElement);
150 } else if (element !== null) { 163 } else if (element !== null) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 563 }
551 } 564 }
552 565
553 class SourceSpan { 566 class SourceSpan {
554 final Uri uri; 567 final Uri uri;
555 final int begin; 568 final int begin;
556 final int end; 569 final int end;
557 570
558 const SourceSpan(this.uri, this.begin, this.end); 571 const SourceSpan(this.uri, this.begin, this.end);
559 } 572 }
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