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

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

Issue 80793002: Check compiler exitCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years 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
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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * If true, print a warning for each method that was resolved, but not 8 * If true, print a warning for each method that was resolved, but not
9 * compiled. 9 * compiled.
10 */ 10 */
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 /** 497 /**
498 * Perform an operation, [f], returning the return value from [f]. If an 498 * Perform an operation, [f], returning the return value from [f]. If an
499 * error occurs then report it as having occurred during compilation of 499 * error occurs then report it as having occurred during compilation of
500 * [element]. Can be nested. 500 * [element]. Can be nested.
501 */ 501 */
502 withCurrentElement(Element element, f()) { 502 withCurrentElement(Element element, f()) {
503 Element old = currentElement; 503 Element old = currentElement;
504 _currentElement = element; 504 _currentElement = element;
505 try { 505 try {
506 return f(); 506 return f();
507 } on SpannableAssertionFailure catch (ex, s) { 507 } on SpannableAssertionFailure catch (ex) {
508 if (!hasCrashed) { 508 if (!hasCrashed) {
509 String message = (ex.message != null) ? tryToString(ex.message) 509 String message = (ex.message != null) ? tryToString(ex.message)
510 : tryToString(ex); 510 : tryToString(ex);
511 SourceSpan span = spanFromSpannable(ex.node); 511 SourceSpan span = spanFromSpannable(ex.node);
512 reportError(ex.node, MessageKind.GENERIC, {'text': message}); 512 reportError(ex.node, MessageKind.GENERIC, {'text': message});
513 pleaseReportCrash(s, 'The compiler crashed: $message.'); 513 pleaseReportCrash('The compiler crashed: $message.');
514 } 514 }
515 hasCrashed = true; 515 hasCrashed = true;
516 throw new CompilerCancelledException('The compiler crashed.'); 516 rethrow;
517 } on CompilerCancelledException catch (ex) { 517 } on CompilerCancelledException catch (ex) {
518 rethrow; 518 rethrow;
519 } on StackOverflowError catch (ex) { 519 } on StackOverflowError catch (ex) {
520 // We cannot report anything useful in this case, because we 520 // We cannot report anything useful in this case, because we
521 // do not have enough stack space. 521 // do not have enough stack space.
522 rethrow; 522 rethrow;
523 } catch (ex, s) { 523 } catch (ex) {
524 if (hasCrashed) rethrow; 524 if (hasCrashed) rethrow;
525 String message = 'The compiler crashed: ${tryToString(ex)}.'; 525 String message = 'The compiler crashed: ${tryToString(ex)}.';
526 try { 526 try {
527 unhandledExceptionOnElement(element, s, message); 527 unhandledExceptionOnElement(element, message);
528 } catch (doubleFault) { 528 } catch (doubleFault) {
529 // Ignoring exceptions in exception handling. 529 // Ignoring exceptions in exception handling.
530 } 530 }
531 throw new CompilerCancelledException(message); 531 rethrow;
532 } finally { 532 } finally {
533 _currentElement = old; 533 _currentElement = old;
534 } 534 }
535 } 535 }
536 536
537 List<CompilerTask> tasks; 537 List<CompilerTask> tasks;
538 ScannerTask scanner; 538 ScannerTask scanner;
539 DietParserTask dietParser; 539 DietParserTask dietParser;
540 ParserTask parser; 540 ParserTask parser;
541 PatchParserTask patchParser; 541 PatchParserTask patchParser;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 Element element}) { 695 Element element}) {
696 cancel('Internal Error: $message', 696 cancel('Internal Error: $message',
697 node: node, token: token, 697 node: node, token: token,
698 instruction: instruction, element: element); 698 instruction: instruction, element: element);
699 } 699 }
700 700
701 void internalErrorOnElement(Element element, String message) { 701 void internalErrorOnElement(Element element, String message) {
702 internalError(message, element: element); 702 internalError(message, element: element);
703 } 703 }
704 704
705 void unhandledExceptionOnElement(Element element, 705 void unhandledExceptionOnElement(Element element, String message) {
706 StackTrace stackTrace,
707 String message) {
708 if (hasCrashed) return; 706 if (hasCrashed) return;
709 hasCrashed = true; 707 hasCrashed = true;
710 reportDiagnostic(spanFromElement(element), 708 reportDiagnostic(spanFromElement(element),
711 MessageKind.COMPILER_CRASHED.error().toString(), 709 MessageKind.COMPILER_CRASHED.error().toString(),
712 api.Diagnostic.CRASH); 710 api.Diagnostic.CRASH);
713 pleaseReportCrash(stackTrace, message); 711 pleaseReportCrash(message);
714 } 712 }
715 713
716 void pleaseReportCrash(StackTrace stackTrace, String message) { 714 void pleaseReportCrash(String message) {
ahe 2013/11/26 11:18:25 I think you can eliminate this argument as well (o
Johnni Winther 2013/11/27 07:58:04 Done.
717 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId})); 715 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId}));
718 if (message != null) { 716 if (message != null) {
719 print(message); 717 print(message);
720 } 718 }
721 if (stackTrace != null) {
722 print(stackTrace);
723 }
724 } 719 }
725 720
726 void cancel(String reason, {Node node, Token token, 721 void cancel(String reason, {Node node, Token token,
727 HInstruction instruction, Element element}) { 722 HInstruction instruction, Element element}) {
728 assembledCode = null; // Compilation failed. Make sure that we 723 assembledCode = null; // Compilation failed. Make sure that we
729 // don't return a bogus result. 724 // don't return a bogus result.
730 Spannable spannable = null; 725 Spannable spannable = null;
731 if (node != null) { 726 if (node != null) {
732 spannable = node; 727 spannable = node;
733 } else if (token != null) { 728 } else if (token != null) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 762 }
768 } 763 }
769 764
770 void log(message) { 765 void log(message) {
771 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); 766 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO);
772 } 767 }
773 768
774 Future<bool> run(Uri uri) { 769 Future<bool> run(Uri uri) {
775 totalCompileTime.start(); 770 totalCompileTime.start();
776 771
777 return new Future.sync(() => runCompiler(uri)).catchError((error, trace) { 772 return new Future.sync(() => runCompiler(uri)).catchError((error) {
778 if (error is CompilerCancelledException) { 773 if (error is CompilerCancelledException) {
779 log('Error: $error'); 774 log('Error: $error');
780 return false; 775 return false;
781 } 776 }
782 777
783 try { 778 try {
784 if (!hasCrashed) { 779 if (!hasCrashed) {
785 hasCrashed = true; 780 hasCrashed = true;
786 reportDiagnostic(new SourceSpan(uri, 0, 0), 781 reportDiagnostic(new SourceSpan(uri, 0, 0),
787 MessageKind.COMPILER_CRASHED.error().toString(), 782 MessageKind.COMPILER_CRASHED.error().toString(),
788 api.Diagnostic.CRASH); 783 api.Diagnostic.CRASH);
789 String message = 'The compiler crashed.'; 784 String message = 'The compiler crashed.';
790 pleaseReportCrash(trace, message); 785 pleaseReportCrash(message);
791 } 786 }
792 } catch (doubleFault) { 787 } catch (doubleFault) {
793 // Ignoring exceptions in exception handling. 788 // Ignoring exceptions in exception handling.
794 } 789 }
795 throw error; 790 throw error;
796 }).whenComplete(() { 791 }).whenComplete(() {
797 tracer.close(); 792 tracer.close();
798 totalCompileTime.stop(); 793 totalCompileTime.stop();
799 }).then((_) { 794 }).then((_) {
800 return !compilationFailed; 795 return !compilationFailed;
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 1651
1657 void close() {} 1652 void close() {}
1658 1653
1659 toString() => name; 1654 toString() => name;
1660 1655
1661 /// Convenience method for getting an [api.CompilerOutputProvider]. 1656 /// Convenience method for getting an [api.CompilerOutputProvider].
1662 static NullSink outputProvider(String name, String extension) { 1657 static NullSink outputProvider(String name, String extension) {
1663 return new NullSink('$name.$extension'); 1658 return new NullSink('$name.$extension');
1664 } 1659 }
1665 } 1660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698