dart2js: reuse stack trace on rethrow

BUG= dartbug.com/15171
R=sigurdm@google.com

Review URL: https://codereview.chromium.org//1152023004
This commit is contained in:
Sigmund Cherem 2015-06-08 12:27:49 -07:00
parent 2c533ac971
commit 1763aa3467
2 changed files with 28 additions and 1 deletions

View file

@ -2052,7 +2052,11 @@ StackTrace getTraceFromException(exception) {
if (exception is ExceptionAndStackTrace) {
return exception.stackTrace;
}
return new _StackTrace(exception);
if (exception == null) return new _StackTrace(exception);
_StackTrace trace = JS('_StackTrace|Null', r'#.$cachedTrace', exception);
if (trace != null) return trace;
trace = new _StackTrace(exception);
return JS('_StackTrace', r'#.$cachedTrace = #', exception, trace);
}
class _StackTrace implements StackTrace {

View file

@ -0,0 +1,23 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:expect/expect.dart';
main() {
var st1;
try {
try {
throw 'bad';
} catch (e, st) {
st1 = st;
rethrow;
}
Expect.fail('Exception expected');
} catch (e, st2) {
Expect.equals(st1, st2);
Expect.identical(st1, st2);
return;
}
Expect.fail('Exception expected');
}