Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/types/types.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/types/types.dart b/sdk/lib/_internal/compiler/implementation/types/types.dart |
| index 201a69774d5d1c20e9c9ffabc2147f352b69eae8..459ff1a510861a318ea9f85e231cf3c5acc6630e 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/types/types.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/types/types.dart |
| @@ -52,21 +52,146 @@ class TypesTask extends CompilerTask { |
| } |
| } |
| - TypeMask dynamicType; |
| + TypeMask dynamicTypeCache; |
| TypeMask nullType; |
| - TypeMask intType; |
| - TypeMask doubleType; |
| - TypeMask numType; |
| - TypeMask boolType; |
| - TypeMask functionType; |
| - TypeMask listType; |
| - TypeMask constListType; |
| - TypeMask fixedListType; |
| - TypeMask growableListType; |
| - TypeMask mapType; |
| - TypeMask constMapType; |
| - TypeMask stringType; |
| - TypeMask typeType; |
| + TypeMask intTypeCache; |
| + TypeMask doubleTypeCache; |
| + TypeMask numTypeCache; |
| + TypeMask boolTypeCache; |
| + TypeMask functionTypeCache; |
| + TypeMask listTypeCache; |
| + TypeMask constListTypeCache; |
| + TypeMask fixedListTypeCache; |
| + TypeMask growableListTypeCache; |
| + TypeMask mapTypeCache; |
| + TypeMask constMapTypeCache; |
| + TypeMask stringTypeCache; |
| + TypeMask typeTypeCache; |
| + |
| + TypeMask get dynamicType { |
| + if (dynamicTypeCache == null) { |
| + dynamicTypeCache = new TypeMask.subclass(compiler.objectClass.rawType); |
|
ngeoffray
2013/09/09 12:37:46
Didn't you want to check if it's resolved? Maybe a
Johnni Winther
2013/09/10 13:19:35
Resolution is checked implicitly by the access to
|
| + } |
| + return dynamicTypeCache; |
| + } |
| + |
| + TypeMask get intType { |
| + if (intTypeCache == null) { |
| + Backend backend = compiler.backend; |
|
ngeoffray
2013/09/09 12:37:46
Why this local? Same comment for all methods below
Johnni Winther
2013/09/10 13:19:35
All uses inlined.
|
| + intTypeCache = new TypeMask.nonNullExact( |
| + backend.intImplementation.rawType); |
| + } |
| + return intTypeCache; |
| + } |
| + |
| + TypeMask get doubleType { |
| + if (doubleTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + doubleTypeCache = new TypeMask.nonNullExact( |
| + backend.doubleImplementation.rawType); |
| + } |
| + return doubleTypeCache; |
| + } |
| + |
| + TypeMask get numType { |
| + if (numTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + numTypeCache = new TypeMask.nonNullSubclass( |
| + backend.numImplementation.rawType); |
| + } |
| + return numTypeCache; |
| + } |
| + |
| + TypeMask get boolType { |
| + if (boolTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + boolTypeCache = new TypeMask.nonNullExact( |
| + backend.boolImplementation.rawType); |
| + } |
| + return boolTypeCache; |
| + } |
| + |
| + TypeMask get functionType { |
| + if (functionTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + functionTypeCache = new TypeMask.nonNullSubtype( |
| + backend.functionImplementation.rawType); |
| + } |
| + return functionTypeCache; |
| + } |
| + |
| + TypeMask get listType { |
| + if (listTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + listTypeCache = new TypeMask.nonNullExact( |
| + backend.listImplementation.rawType); |
| + } |
| + return listTypeCache; |
| + } |
| + |
| + TypeMask get constListType { |
| + if (constListTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + constListTypeCache = new TypeMask.nonNullExact( |
| + backend.constListImplementation.rawType); |
| + } |
| + return constListTypeCache; |
| + } |
| + |
| + TypeMask get fixedListType { |
| + if (fixedListTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + fixedListTypeCache = new TypeMask.nonNullExact( |
| + backend.fixedListImplementation.rawType); |
| + } |
| + return fixedListTypeCache; |
| + } |
| + |
| + TypeMask get growableListType { |
| + if (growableListTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + growableListTypeCache = new TypeMask.nonNullExact( |
| + backend.growableListImplementation.rawType); |
| + } |
| + return growableListTypeCache; |
| + } |
| + |
| + TypeMask get mapType { |
| + if (mapTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + mapTypeCache = new TypeMask.nonNullSubtype( |
| + backend.mapImplementation.rawType); |
| + } |
| + return mapTypeCache; |
| + } |
| + |
| + TypeMask get constMapType { |
| + if (constMapTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + constMapTypeCache = new TypeMask.nonNullSubtype( |
| + backend.constMapImplementation.rawType); |
| + } |
| + return constMapTypeCache; |
| + } |
| + |
| + TypeMask get stringType { |
| + if (stringTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + stringTypeCache = new TypeMask.nonNullExact( |
| + backend.stringImplementation.rawType); |
| + } |
| + return stringTypeCache; |
| + } |
| + |
| + TypeMask get typeType { |
| + if (typeTypeCache == null) { |
| + Backend backend = compiler.backend; |
| + typeTypeCache = new TypeMask.nonNullExact( |
| + backend.typeImplementation.rawType); |
| + } |
| + return typeTypeCache; |
| + } |
| + |
| /// Replaces native types by their backend implementation. |
| Element normalize(Element cls) { |
| @@ -181,48 +306,8 @@ class TypesTask extends CompilerTask { |
| } |
| } |
| - // TODO(ngeoffray): Get rid of this method. Unit tests don't always |
|
ngeoffray
2013/09/09 12:37:46
Thank you :-)
|
| - // ensure these classes are resolved. |
| - rawTypeOf(ClassElement cls) { |
| - cls.ensureResolved(compiler); |
| - assert(cls.rawType != null); |
| - return cls.rawType; |
| - } |
| - |
| void initializeTypes() { |
| nullType = new TypeMask.empty(); |
|
ngeoffray
2013/09/09 12:37:46
The null class may also not be there, so maybe you
Johnni Winther
2013/09/10 13:19:35
Done.
|
| - |
| - Backend backend = compiler.backend; |
| - intType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.intImplementation)); |
| - doubleType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.doubleImplementation)); |
| - numType = new TypeMask.nonNullSubclass( |
| - rawTypeOf(backend.numImplementation)); |
| - stringType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.stringImplementation)); |
| - boolType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.boolImplementation)); |
| - |
| - listType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.listImplementation)); |
| - constListType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.constListImplementation)); |
| - fixedListType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.fixedListImplementation)); |
| - growableListType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.growableListImplementation)); |
| - |
| - mapType = new TypeMask.nonNullSubtype( |
| - rawTypeOf(backend.mapImplementation)); |
| - constMapType = new TypeMask.nonNullSubtype( |
| - rawTypeOf(backend.constMapImplementation)); |
| - functionType = new TypeMask.nonNullSubtype( |
| - rawTypeOf(backend.functionImplementation)); |
| - typeType = new TypeMask.nonNullExact( |
| - rawTypeOf(backend.typeImplementation)); |
| - |
| - dynamicType = new TypeMask.subclass(rawTypeOf(compiler.objectClass)); |
| } |
| /** |