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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1126063002: Recognize unmodifiable lists (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | « no previous file | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index aeb4fb83d503180aa0b7cc191ed501e59e7bbde9..986a313245899d01686855f88ce713922e7f7726 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -290,6 +290,7 @@ class JavaScriptBackend extends Backend {
ClassElement jsMutableArrayClass;
ClassElement jsFixedArrayClass;
ClassElement jsExtendableArrayClass;
+ ClassElement jsUnmodifiableArrayClass;
ClassElement jsPositiveIntClass;
ClassElement jsUInt32Class;
ClassElement jsUInt31Class;
@@ -386,6 +387,15 @@ class JavaScriptBackend extends Backend {
return _extendableArrayTypeCache;
}
+ TypeMask _unmodifiableArrayTypeCache;
+ TypeMask get unmodifiableArrayType {
+ if (_unmodifiableArrayTypeCache == null) {
+ _unmodifiableArrayTypeCache =
+ new TypeMask.nonNullExact(jsUnmodifiableArrayClass, compiler.world);
+ }
+ return _fixedArrayTypeCache;
+ }
+
TypeMask _nonNullTypeCache;
TypeMask get nonNullType {
if (_nonNullTypeCache == null) {
@@ -1055,11 +1065,13 @@ class JavaScriptBackend extends Backend {
} else if (cls == compiler.listClass ||
cls == jsArrayClass ||
cls == jsFixedArrayClass ||
- cls == jsExtendableArrayClass) {
+ cls == jsExtendableArrayClass ||
+ cls == jsUnmodifiableArrayClass) {
addInterceptors(jsArrayClass, enqueuer, registry);
addInterceptors(jsMutableArrayClass, enqueuer, registry);
addInterceptors(jsFixedArrayClass, enqueuer, registry);
addInterceptors(jsExtendableArrayClass, enqueuer, registry);
+ addInterceptors(jsUnmodifiableArrayClass, enqueuer, registry);
} else if (cls == compiler.intClass || cls == jsIntClass) {
addInterceptors(jsIntClass, enqueuer, registry);
addInterceptors(jsPositiveIntClass, enqueuer, registry);
@@ -1639,7 +1651,8 @@ class JavaScriptBackend extends Backend {
element == jsArrayClass ||
element == jsMutableArrayClass ||
element == jsExtendableArrayClass ||
- element == jsFixedArrayClass;
+ element == jsFixedArrayClass ||
+ element == jsUnmodifiableArrayClass;
}
/// Return [true] if the class is represented by a native JavaSCript type in
@@ -1871,7 +1884,7 @@ class JavaScriptBackend extends Backend {
ClassElement get numImplementation => jsNumberClass;
ClassElement get stringImplementation => jsStringClass;
ClassElement get listImplementation => jsArrayClass;
- ClassElement get constListImplementation => jsArrayClass;
+ ClassElement get constListImplementation => jsUnmodifiableArrayClass;
ClassElement get fixedListImplementation => jsFixedArrayClass;
ClassElement get growableListImplementation => jsExtendableArrayClass;
ClassElement get mapImplementation => mapLiteralClass;
@@ -2032,6 +2045,7 @@ class JavaScriptBackend extends Backend {
jsMutableArrayClass = findClass('JSMutableArray'),
jsFixedArrayClass = findClass('JSFixedArray'),
jsExtendableArrayClass = findClass('JSExtendableArray'),
+ jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'),
jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'),
jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'),
];
@@ -2115,6 +2129,9 @@ class JavaScriptBackend extends Backend {
if (jsExtendableArrayClass != null) {
jsExtendableArrayClass.ensureResolved(compiler);
}
+ if (jsUnmodifiableArrayClass != null) {
+ jsUnmodifiableArrayClass.ensureResolved(compiler);
+ }
jsIndexableClass.ensureResolved(compiler);
jsIndexableLength = compiler.lookupElementIn(
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698