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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 13947004: dart2js: Allow 'throw' when inlining (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Nicolas' Code review feedback Created 7 years, 8 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: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index badbb4dd1186584f34d1bf51708783def14f5ac9..781d1c101c0093b8a2d9efd378ff87093b76d80e 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -614,7 +614,7 @@ checkString(value) {
* The code in [unwrapException] deals with getting the original Dart
* object out of the wrapper again.
*/
-$throw(ex) {
+wrapException(ex) {
if (ex == null) ex = const NullThrownError();
var wrapper = new DartError(ex);
@@ -622,7 +622,7 @@ $throw(ex) {
// Use V8 API for recording a "fast" stack trace (this installs a
// "stack" property getter on [wrapper]).
JS('void', r'Error.captureStackTrace(#, #)',
- wrapper, RAW_DART_FUNCTION_REF($throw));
+ wrapper, RAW_DART_FUNCTION_REF(wrapException));
} else {
// Otherwise, produce a stack trace and record it in the wrapper.
// This is a slower way to create a stack trace which works on
@@ -634,6 +634,16 @@ $throw(ex) {
}
/**
+ * This wraos the exception and actually does the throw too. It is
ngeoffray 2013/04/11 09:31:08 wraos -> wraps
ngeoffray 2013/04/11 09:31:08 actually does the throw too -> does the throw
+ * possible to call this in a JS expression context, where the throw statement
+ * is not allowed. Helpers are never inlined, so we don't risk inlining the
+ * throw statement into an expression context.
+ */
+throwExpression(ex) {
+ JS('void', 'throw #', wrapException(ex));
+}
+
+/**
* Wrapper class for throwing exceptions.
*/
class DartError {
@@ -652,8 +662,8 @@ class DartError {
/**
* V8/Chrome installs a property getter, "stack", when calling
- * Error.captureStackTrace (see [$throw]). In [$throw], we make sure
- * that this property is always set.
+ * Error.captureStackTrace (see [wrapException]). In [wrapException], we make
+ * sure that this property is always set.
*/
String get stack => JS('', '#.stack', this);
@@ -663,7 +673,7 @@ class DartError {
*
* We only expect this method to be called (indirectly) by the
* browser when an uncaught exception occurs. Instance of this class
- * should never escape into Dart code (except for [$throw] above).
+ * should never escape into Dart code (except for [wrapException] above).
*/
String toString() {
// If Error.captureStackTrace is available, accessing stack from
@@ -715,7 +725,7 @@ throwAbstractClassInstantiationError(className) {
/**
* Called from catch blocks in generated code to extract the Dart
* exception from the thrown value. The thrown value may have been
- * created by [$throw] or it may be a 'native' JS exception.
+ * created by [wrapException] or it may be a 'native' JS exception.
*
* Some native exceptions are mapped to new Dart instances, others are
* returned unmodified.

Powered by Google App Engine
This is Rietveld 408576698