OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
8 | 8 |
9 class ReturnInfo { | 9 class ReturnInfo { |
10 HType returnType; | 10 HType returnType; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 constructors.putIfAbsent(cls, () => new Set<Element>()); | 299 constructors.putIfAbsent(cls, () => new Set<Element>()); |
300 Set<Element> ctors = constructors[cls]; | 300 Set<Element> ctors = constructors[cls]; |
301 if (ctors.contains(element)) return; | 301 if (ctors.contains(element)) return; |
302 ctors.add(element); | 302 ctors.add(element); |
303 // We cannot infer field types for classes with more than one constructor. | 303 // We cannot infer field types for classes with more than one constructor. |
304 // When the second constructor is seen, recompile all functions relying on | 304 // When the second constructor is seen, recompile all functions relying on |
305 // optimistic field types for that class. | 305 // optimistic field types for that class. |
306 // TODO(sgjesse): Handle field types for classes with more than one | 306 // TODO(sgjesse): Handle field types for classes with more than one |
307 // constructor. | 307 // constructor. |
308 if (ctors.length == 2) { | 308 if (ctors.length == 2) { |
309 optimizedFunctions.forEach((Element field, _) { | 309 new Map.from(optimizedFunctions).forEach((Element field, _) { |
310 if (identical(field.enclosingElement, cls)) { | 310 if (identical(field.enclosingElement, cls)) { |
311 scheduleRecompilation(field); | 311 scheduleRecompilation(field); |
312 } | 312 } |
313 }); | 313 }); |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void registerFieldInitializer(Element field, HType type) { | 317 void registerFieldInitializer(Element field, HType type) { |
318 registerFieldType(fieldInitializerTypeMap, field, type); | 318 registerFieldType(fieldInitializerTypeMap, field, type); |
319 } | 319 } |
(...skipping 20 matching lines...) Expand all Loading... |
340 registerFieldType(fieldTypeMap, field, type); | 340 registerFieldType(fieldTypeMap, field, type); |
341 } | 341 } |
342 | 342 |
343 void addedDynamicSetter(Selector setter, HType type) { | 343 void addedDynamicSetter(Selector setter, HType type) { |
344 // Field type optimizations are disabled for all fields matching a | 344 // Field type optimizations are disabled for all fields matching a |
345 // setter selector. | 345 // setter selector. |
346 assert(setter.isSetter()); | 346 assert(setter.isSetter()); |
347 // TODO(sgjesse): Take the type of the setter into account. | 347 // TODO(sgjesse): Take the type of the setter into account. |
348 if (setterSelectorsUsed.contains(setter.name)) return; | 348 if (setterSelectorsUsed.contains(setter.name)) return; |
349 setterSelectorsUsed.add(setter.name); | 349 setterSelectorsUsed.add(setter.name); |
350 optimizedStaticFunctions.forEach((Element field, _) { | 350 new Map.from(optimizedStaticFunctions).forEach((Element field, _) { |
351 if (field.name == setter.name) { | 351 if (field.name == setter.name) { |
352 scheduleRecompilation(field); | 352 scheduleRecompilation(field); |
353 } | 353 } |
354 }); | 354 }); |
355 optimizedFunctions.forEach((Element field, _) { | 355 new Map.from(optimizedFunctions).forEach((Element field, _) { |
356 if (field.name == setter.name) { | 356 if (field.name == setter.name) { |
357 scheduleRecompilation(field); | 357 scheduleRecompilation(field); |
358 } | 358 } |
359 }); | 359 }); |
360 } | 360 } |
361 | 361 |
362 HType optimisticFieldType(Element field) { | 362 HType optimisticFieldType(Element field) { |
363 assert(field.isField()); | 363 assert(field.isField()); |
364 if (constructorCount(field.getEnclosingClass()) > 1) { | 364 if (constructorCount(field.getEnclosingClass()) > 1) { |
365 return HType.UNKNOWN; | 365 return HType.UNKNOWN; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } else if (cls == compiler.nullClass) { | 890 } else if (cls == compiler.nullClass) { |
891 addInterceptors(jsNullClass, enqueuer); | 891 addInterceptors(jsNullClass, enqueuer); |
892 } else if (cls == compiler.numClass) { | 892 } else if (cls == compiler.numClass) { |
893 addInterceptors(jsIntClass, enqueuer); | 893 addInterceptors(jsIntClass, enqueuer); |
894 addInterceptors(jsDoubleClass, enqueuer); | 894 addInterceptors(jsDoubleClass, enqueuer); |
895 addInterceptors(jsNumberClass, enqueuer); | 895 addInterceptors(jsNumberClass, enqueuer); |
896 } else if (cls == compiler.mapClass) { | 896 } else if (cls == compiler.mapClass) { |
897 // The backend will use a literal list to initialize the entries | 897 // The backend will use a literal list to initialize the entries |
898 // of the map. | 898 // of the map. |
899 if (enqueuer.isResolutionQueue) { | 899 if (enqueuer.isResolutionQueue) { |
900 enqueuer.registerInstantiatedClass(compiler.listClass); | 900 enqueuer.registerInstantiatedClass(compiler.listClass); |
901 } | 901 } |
902 } | 902 } |
903 } | 903 } |
904 | 904 |
905 Element get cyclicThrowHelper { | 905 Element get cyclicThrowHelper { |
906 return compiler.findHelper(const SourceString("throwCyclicInit")); | 906 return compiler.findHelper(const SourceString("throwCyclicInit")); |
907 } | 907 } |
908 | 908 |
909 JavaScriptItemCompilationContext createItemCompilationContext() { | 909 JavaScriptItemCompilationContext createItemCompilationContext() { |
910 return new JavaScriptItemCompilationContext(); | 910 return new JavaScriptItemCompilationContext(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 } | 1216 } |
1217 | 1217 |
1218 Element getSetRuntimeTypeInfo() { | 1218 Element getSetRuntimeTypeInfo() { |
1219 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); | 1219 return compiler.findHelper(const SourceString('setRuntimeTypeInfo')); |
1220 } | 1220 } |
1221 | 1221 |
1222 Element getGetRuntimeTypeInfo() { | 1222 Element getGetRuntimeTypeInfo() { |
1223 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); | 1223 return compiler.findHelper(const SourceString('getRuntimeTypeInfo')); |
1224 } | 1224 } |
1225 } | 1225 } |
OLD | NEW |