| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (node.inputs[i].instructionType != HType.UNKNOWN) { | 83 if (node.inputs[i].instructionType != HType.UNKNOWN) { |
| 84 allUnknown = false; | 84 allUnknown = false; |
| 85 break; | 85 break; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 if (allUnknown) return HTypeList.ALL_UNKNOWN; | 88 if (allUnknown) return HTypeList.ALL_UNKNOWN; |
| 89 | 89 |
| 90 HTypeList result = new HTypeList(node.inputs.length - 1); | 90 HTypeList result = new HTypeList(node.inputs.length - 1); |
| 91 for (int i = 0; i < result.types.length; i++) { | 91 for (int i = 0; i < result.types.length; i++) { |
| 92 result.types[i] = node.inputs[i + 1].instructionType; | 92 result.types[i] = node.inputs[i + 1].instructionType; |
| 93 assert(!result.types[i].isConflicting()); |
| 93 } | 94 } |
| 94 return result; | 95 return result; |
| 95 } | 96 } |
| 96 | 97 |
| 97 factory HTypeList.fromDynamicInvocation(HInvokeDynamic node, | 98 factory HTypeList.fromDynamicInvocation(HInvokeDynamic node, |
| 98 Selector selector) { | 99 Selector selector) { |
| 99 HTypeList result; | 100 HTypeList result; |
| 100 int argumentsCount = node.inputs.length - 1; | 101 int argumentsCount = node.inputs.length - 1; |
| 101 int startInvokeIndex = HInvoke.ARGUMENTS_OFFSET; | 102 int startInvokeIndex = HInvoke.ARGUMENTS_OFFSET; |
| 102 | 103 |
| 103 if (node.isInterceptorCall) { | 104 if (node.isInterceptorCall) { |
| 104 argumentsCount--; | 105 argumentsCount--; |
| 105 startInvokeIndex++; | 106 startInvokeIndex++; |
| 106 } | 107 } |
| 107 | 108 |
| 108 if (selector.namedArgumentCount > 0) { | 109 if (selector.namedArgumentCount > 0) { |
| 109 result = | 110 result = |
| 110 new HTypeList.withNamedArguments( | 111 new HTypeList.withNamedArguments( |
| 111 argumentsCount, selector.namedArguments); | 112 argumentsCount, selector.namedArguments); |
| 112 } else { | 113 } else { |
| 113 result = new HTypeList(argumentsCount); | 114 result = new HTypeList(argumentsCount); |
| 114 } | 115 } |
| 115 | 116 |
| 116 for (int i = 0; i < result.types.length; i++) { | 117 for (int i = 0; i < result.types.length; i++) { |
| 117 result.types[i] = node.inputs[i + startInvokeIndex].instructionType; | 118 result.types[i] = node.inputs[i + startInvokeIndex].instructionType; |
| 119 assert(!result.types[i].isConflicting()); |
| 118 } | 120 } |
| 119 return result; | 121 return result; |
| 120 } | 122 } |
| 121 | 123 |
| 122 static const HTypeList ALL_UNKNOWN = const HTypeList.withAllUnknown(); | 124 static const HTypeList ALL_UNKNOWN = const HTypeList.withAllUnknown(); |
| 123 | 125 |
| 124 bool get allUnknown => types == null; | 126 bool get allUnknown => types == null; |
| 125 bool get hasNamedArguments => namedArguments != null; | 127 bool get hasNamedArguments => namedArguments != null; |
| 126 int get length => types.length; | 128 int get length => types.length; |
| 127 HType operator[](int index) => types[index]; | 129 HType operator[](int index) => types[index]; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 int constructorCount(Element element) { | 271 int constructorCount(Element element) { |
| 270 assert(element.isClass()); | 272 assert(element.isClass()); |
| 271 Set<Element> ctors = constructors[element]; | 273 Set<Element> ctors = constructors[element]; |
| 272 return ctors == null ? 0 : ctors.length; | 274 return ctors == null ? 0 : ctors.length; |
| 273 } | 275 } |
| 274 | 276 |
| 275 void registerFieldType(Map<Element, HType> typeMap, | 277 void registerFieldType(Map<Element, HType> typeMap, |
| 276 Element field, | 278 Element field, |
| 277 HType type) { | 279 HType type) { |
| 278 assert(field.isField()); | 280 assert(field.isField()); |
| 281 assert(!type.isConflicting()); |
| 279 HType before = optimisticFieldType(field); | 282 HType before = optimisticFieldType(field); |
| 280 | 283 |
| 281 HType oldType = typeMap[field]; | 284 HType oldType = typeMap[field]; |
| 282 HType newType; | 285 HType newType; |
| 283 | 286 |
| 284 if (oldType != null) { | 287 if (oldType != null) { |
| 285 newType = oldType.union(type, compiler); | 288 newType = oldType.union(type, compiler); |
| 286 } else { | 289 } else { |
| 287 newType = type; | 290 newType = type; |
| 288 } | 291 } |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 * | 1499 * |
| 1497 * Invariant: [element] must be a declaration element. | 1500 * Invariant: [element] must be a declaration element. |
| 1498 */ | 1501 */ |
| 1499 void eagerRecompile(Element element) { | 1502 void eagerRecompile(Element element) { |
| 1500 assert(invariant(element, element.isDeclaration)); | 1503 assert(invariant(element, element.isDeclaration)); |
| 1501 generatedCode.remove(element); | 1504 generatedCode.remove(element); |
| 1502 generatedBailoutCode.remove(element); | 1505 generatedBailoutCode.remove(element); |
| 1503 compiler.enqueuer.codegen.addToWorkList(element); | 1506 compiler.enqueuer.codegen.addToWorkList(element); |
| 1504 } | 1507 } |
| 1505 } | 1508 } |
| OLD | NEW |