Chromium Code Reviews| 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); |
| } |