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

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

Issue 1187553005: Revert "Better messages for optimized index errors." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_array.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index 7c881729b7e11d0c7e1cc41cb6b937d12c4e0f0e..1c6183d4f32f67fa48e559fe73df982f09ffb73f 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -1388,41 +1388,23 @@ class JsCache {
* for example, if a non-integer index is given to an optimized
* indexed access.
*/
-@NoInline()
iae(argument) {
throw _argumentError(argument);
}
/**
- * Called by generated code to throw an index-out-of-range exception, for
- * example, if a bounds check fails in an optimized indexed access. This may
- * also be called when the index is not an integer, in which case it throws an
- * illegal-argument exception instead, like [iae], or when the receiver is null.
+ * Called by generated code to throw an index-out-of-range exception,
+ * for example, if a bounds check fails in an optimized indexed
+ * access. This may also be called when the index is not an integer, in
+ * which case it throws an illegal-argument exception instead, like
+ * [iae], or when the receiver is null.
*/
-@NoInline()
ioore(receiver, index) {
if (receiver == null) receiver.length; // Force a NoSuchMethodError.
- throw diagnoseIndexError(receiver, index);
-}
-
-/**
- * Diagnoses an indexing error. Returns the ArgumentError or RangeError that
- * describes the problem.
- */
-@NoInline()
-Error diagnoseIndexError(indexable, index) {
- if (index is !int) return new ArgumentError.value(index, 'index');
- int length = indexable.length;
- // The following returns the same error that would be thrown by calling
- // [RangeError.checkValidIndex] with no optional parameters provided.
- if (index < 0 || index >= length) {
- return new RangeError.index(index, indexable, 'index', null, length);
- }
- // The above should always match, but if it does not, use the following.
- return new RangeError.value(index, 'index');
+ if (index is !int) iae(index);
+ throw new RangeError.value(index);
}
-
stringLastIndexOfUnchecked(receiver, element, start)
=> JS('int', r'#.lastIndexOf(#, #)', receiver, element, start);
@@ -2033,14 +2015,10 @@ unwrapException(ex) {
return new StackOverflowError();
}
- // In general, a RangeError is thrown when trying to pass a number as an
- // argument to a function that does not allow a range that includes that
- // number. Translate to a Dart RangeError with the same message.
- String message = tryStringifyException(ex);
- if (message is String) {
- message = JS('String', r'#.replace(/^RangeError:\s*/, "")', message);
- }
- return saveStackTrace(new RangeError(message));
+ // In general, a RangeError is thrown when trying to pass a number
+ // as an argument to a function that does not allow a range that
+ // includes that number.
+ return saveStackTrace(new ArgumentError());
}
// Check for the Firefox specific stack overflow signal.
@@ -2058,20 +2036,6 @@ unwrapException(ex) {
return ex;
}
-String tryStringifyException(ex) {
- // Since this function is called from [unwrapException] which is called from
- // code injected into a catch-clause, use JavaScript try-catch to avoid a
- // potential loop if stringifying crashes.
- return JS('String', r'''
- (function(ex) {
- try {
- return String(ex);
- } catch (e) {}
- return null;
- })(#)
- ''', ex);
-}
-
/**
* Called by generated code to fetch the stack trace from an
* exception. Should never return null.
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_array.dart ('k') | sdk/lib/_internal/compiler/js_lib/js_string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698