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 typedef void Recompile(Element element); | 5 typedef void Recompile(Element element); |
6 | 6 |
7 class ReturnInfo { | 7 class ReturnInfo { |
8 HType returnType; | 8 HType returnType; |
9 List<Element> compiledFunctions; | 9 List<Element> compiledFunctions; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 compiledFunctions.clear(); | 24 compiledFunctions.clear(); |
25 } | 25 } |
26 returnType = newType; | 26 returnType = newType; |
27 if (recompile != null) { | 27 if (recompile != null) { |
28 compiledFunctions.forEach(recompile); | 28 compiledFunctions.forEach(recompile); |
29 } | 29 } |
30 compiledFunctions.clear(); | 30 compiledFunctions.clear(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 addCompiledFunction(FunctionElement function) => | 34 // Note that lazy initializers are treated like functions (but are not |
35 compiledFunctions.add(function); | 35 // of type [FunctionElement]. |
| 36 addCompiledFunction(Element function) => compiledFunctions.add(function); |
36 } | 37 } |
37 | 38 |
38 class HTypeList { | 39 class HTypeList { |
39 final List<HType> types; | 40 final List<HType> types; |
40 | 41 |
41 HTypeList(int length) : types = new List<HType>(length); | 42 HTypeList(int length) : types = new List<HType>(length); |
42 const HTypeList.withAllUnknown() : types = null; | 43 const HTypeList.withAllUnknown() : types = null; |
43 | 44 |
44 factory HTypeList.fromInvocation(HInvoke node, HTypeMap types) { | 45 factory HTypeList.fromInvocation(HInvoke node, HTypeMap types) { |
45 bool allUnknown = true; | 46 bool allUnknown = true; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 546 } |
546 | 547 |
547 /** | 548 /** |
548 * Retrieve the return type of the function [callee]. The type is optimistic | 549 * Retrieve the return type of the function [callee]. The type is optimistic |
549 * in the sense that is is based on the compilation of [callee]. If [callee] | 550 * in the sense that is is based on the compilation of [callee]. If [callee] |
550 * is recompiled the return type might change to someting broader. For that | 551 * is recompiled the return type might change to someting broader. For that |
551 * reason [caller] is registered for recompilation if this happens. If the | 552 * reason [caller] is registered for recompilation if this happens. If the |
552 * function [callee] has not yet been compiled the returned type is [null]. | 553 * function [callee] has not yet been compiled the returned type is [null]. |
553 */ | 554 */ |
554 HType optimisticReturnTypesWithRecompilationOnTypeChange( | 555 HType optimisticReturnTypesWithRecompilationOnTypeChange( |
555 FunctionElement caller, FunctionElement callee) { | 556 Element caller, FunctionElement callee) { |
556 returnInfo.putIfAbsent(callee, () => new ReturnInfo.unknownType()); | 557 returnInfo.putIfAbsent(callee, () => new ReturnInfo.unknownType()); |
557 ReturnInfo info = returnInfo[callee]; | 558 ReturnInfo info = returnInfo[callee]; |
558 if (info.returnType != HType.UNKNOWN && caller != null) { | 559 if (info.returnType != HType.UNKNOWN && caller != null) { |
559 info.addCompiledFunction(caller); | 560 info.addCompiledFunction(caller); |
560 } | 561 } |
561 return info.returnType; | 562 return info.returnType; |
562 } | 563 } |
563 | 564 |
564 SourceString getCheckedModeHelper(DartType type) { | 565 SourceString getCheckedModeHelper(DartType type) { |
565 Element element = type.element; | 566 Element element = type.element; |
(...skipping 27 matching lines...) Expand all Loading... |
593 return const SourceString('listSuperTypeCheck'); | 594 return const SourceString('listSuperTypeCheck'); |
594 } | 595 } |
595 } else if (nativeCheck) { | 596 } else if (nativeCheck) { |
596 return const SourceString('callTypeCheck'); | 597 return const SourceString('callTypeCheck'); |
597 } else { | 598 } else { |
598 return const SourceString('propertyTypeCheck'); | 599 return const SourceString('propertyTypeCheck'); |
599 } | 600 } |
600 } | 601 } |
601 } | 602 } |
602 } | 603 } |
OLD | NEW |