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

Unified Diff: frog/leg/ssa/builder.dart

Issue 9601014: Support for stack traces in catch blocks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/ssa/builder.dart
===================================================================
--- frog/leg/ssa/builder.dart (revision 4945)
+++ frog/leg/ssa/builder.dart (working copy)
@@ -93,6 +93,10 @@
Element getExceptionUnwrapper() {
return compiler.findHelper(const SourceString('unwrapException'));
}
+
+ Element getTraceFromException() {
+ return compiler.findHelper(const SourceString('getTraceFromException'));
+ }
}
class SsaBuilderTask extends CompilerTask {
@@ -2314,10 +2318,27 @@
push(new HStatic(interceptors.getExceptionUnwrapper()));
List<HInstruction> inputs = <HInstruction>[pop(), exception];
HInvokeStatic unwrappedException =
- new HInvokeStatic(Selector.INVOCATION_1, inputs);
+ new HInvokeStatic(Selector.INVOCATION_1, inputs);
add(unwrappedException);
tryInstruction.exception = exception;
+
+ bool requiresTrace = false;
+ for (CatchBlock block in node.catchBlocks) {
+ if (block.trace != null) {
+ requiresTrace = true;
+ break;
+ }
+ }
+
+ HInstruction traceInstruction = null;
floitsch 2012/03/06 10:22:32 Did you consider to fetch the trace lazily (in the
ngeoffray 2012/03/06 12:12:50 Yes. But the last implementation I ended up with d
+ if (requiresTrace) {
+ push(new HStatic(interceptors.getTraceFromException()));
+ traceInstruction = new HInvokeStatic(Selector.INVOCATION_1,
+ <HInstruction>[pop(), exception]);
+ add(traceInstruction);
+ }
+
Link<Node> link = node.catchBlocks.nodes;
void pushCondition(CatchBlock catchBlock) {
@@ -2339,9 +2360,12 @@
void visitThen() {
CatchBlock catchBlock = link.head;
link = link.tail;
- VariableDefinitions declaration = catchBlock.formals.nodes.head;
- localsHandler.updateLocal(elements[declaration.definitions.nodes.head],
+ localsHandler.updateLocal(elements[catchBlock.exception],
unwrappedException);
+ Node trace = catchBlock.trace;
+ if (trace != null) {
+ localsHandler.updateLocal(elements[trace], traceInstruction);
+ }
visit(catchBlock);
}

Powered by Google App Engine
This is Rietveld 408576698