Chromium Code Reviews| 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 ab36275286da195ec31e8e5a5ba009c5dc01cc14..de5a37d24d31611d1da2648ec2eaf94b8a7af313 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart |
| @@ -9,12 +9,9 @@ import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
| JS, |
| JS_CALL_IN_ISOLATE, |
| JS_CURRENT_ISOLATE, |
| - JS_CURRENT_ISOLATE_CONTEXT, |
| JS_DART_OBJECT_CONSTRUCTOR, |
| - JS_IS_INDEXABLE_FIELD_NAME, |
| - JS_OBJECT_CLASS_NAME, |
| - JS_OPERATOR_AS_PREFIX, |
| JS_OPERATOR_IS_PREFIX, |
| + JS_OPERATOR_AS_PREFIX, |
| RAW_DART_FUNCTION_REF; |
| import 'dart:_interceptors'; |
| import "dart:_collection-dev" as _symbol_dev; |
| @@ -34,7 +31,32 @@ bool isJsIndexable(var object, var record) { |
| var result = dispatchRecordIndexability(record); |
| if (result != null) return result; |
| } |
| - return object is JavaScriptIndexingBehavior; |
| + return isJsIndexableSlow(object); |
| +} |
| + |
| +// We keep the slow path of the indexability check in a separate method |
| +// to get better code generated for the fast path and to increase the |
| +// chance of having it inlined. |
| +bool isJsIndexableSlow(var object) { |
| + bool result = object is JavaScriptIndexingBehavior; |
| + var record = getDispatchProperty(object); |
| + if (record == null) return result; |
| + // This is intentionally written to have two return points, so we |
| + // will not inline the slow path function into the fast one. |
| + setDispatchRecordIndexability(record, result); |
| + return result; |
| +} |
| + |
| +checkMutable(list, reason) { |
| + if (JS('bool', r'!!(#.immutable$list)', list)) { |
| + throw new UnsupportedError(reason); |
| + } |
| +} |
| + |
| +checkGrowable(list, reason) { |
| + if (JS('bool', r'!!(#.fixed$length)', list)) { |
| + throw new UnsupportedError(reason); |
| + } |
| } |
| String S(value) { |
| @@ -145,12 +167,12 @@ class JSInvocationMirror implements Invocation { |
| class Primitives { |
| static int objectHashCode(object) { |
| - int hash = JS('int|Null', r'#.$identityHash', object); |
| + int hash = JS('var', r'#.$identityHash', object); |
| if (hash == null) { |
| hash = JS('int', '(Math.random() * 0x3fffffff) | 0'); |
| JS('void', r'#.$identityHash = #', object, hash); |
| } |
| - return JS('int', '#', hash); |
| + return hash; |
| } |
| /** |
| @@ -296,7 +318,7 @@ class Primitives { |
| /// Returns the type of [object] as a string (including type arguments). |
| static String objectTypeName(Object object) { |
| - String name = constructorNameFallback(getInterceptor(object)); |
| + String name = constructorNameFallback(object); |
| if (name == 'Object') { |
| // Try to decompile the constructor by turning it into a string |
| // and get the name out of that. If the decompiled name is a |
| @@ -575,7 +597,8 @@ class Primitives { |
| if (JS('bool', '# == "num"', int)) return const JSNumber(); |
| if (JS('bool', '# == "bool"', int)) return const JSBool(); |
| if (JS('bool', '# == "List"', int)) return const JSArray(); |
| - return JS('var', '#[#]', JS_CURRENT_ISOLATE(), className); |
| + // TODO(ahe): How to safely access $? |
| + return JS('var', r'$[#]', className); |
| } |
| static bool identicalImplementation(a, b) { |
| @@ -930,7 +953,7 @@ convertDartClosureToJS(closure, int arity) { |
| // Capture the current isolate now. Remember that "#" |
| // in JS is simply textual substitution of compiled |
| // expressions. |
| - JS_CURRENT_ISOLATE_CONTEXT(), |
| + JS_CURRENT_ISOLATE(), |
| DART_CLOSURE_TO_JS(invokeClosure)); |
| JS('void', r'#.$identity = #', closure, function); |
| @@ -1444,5 +1467,15 @@ void throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) { |
| * field that is currently being initialized. |
| */ |
|
Johnni Winther
2013/06/04 09:58:52
What is the reason for all the changes above?
Lasse Reichstein Nielsen
2013/06/04 10:21:08
Looks like a really bad merge.
|
| void throwCyclicInit(String staticName) { |
| - throw new RuntimeError("Cyclic initialization for static $staticName"); |
| + throw new CyclicInitializationError( |
| + "Cyclic initialization for static $staticName"); |
| +} |
| + |
| +/** |
| + * Error thrown when a runtime error occurs. |
| + */ |
| +class RuntimeError implements Error { |
| + final message; |
| + RuntimeError(this.message); |
| + String toString() => "RuntimeError: $message"; |
| } |