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 ssa; | 5 part of ssa; |
6 | 6 |
7 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
8 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 && returnType.isEmpty | 1355 && returnType.isEmpty |
1356 && !returnType.isNullable) { | 1356 && !returnType.isNullable) { |
1357 isReachable = false; | 1357 isReachable = false; |
1358 return false; | 1358 return false; |
1359 } | 1359 } |
1360 } | 1360 } |
1361 | 1361 |
1362 return true; | 1362 return true; |
1363 } | 1363 } |
1364 | 1364 |
| 1365 bool doesNotContainCode() { |
| 1366 // A function with size 1 does not contain any code. |
| 1367 return InlineWeeder.canBeInlined(function, 1, true); |
| 1368 } |
| 1369 |
1365 bool reductiveHeuristic() { | 1370 bool reductiveHeuristic() { |
1366 // The call is on a path which is executed rarely, so inline only if it | 1371 // The call is on a path which is executed rarely, so inline only if it |
1367 // does not make the program larger. | 1372 // does not make the program larger. |
1368 if (isCalledOnce(element)) { | 1373 if (isCalledOnce(element)) { |
1369 return InlineWeeder.canBeInlined(function, -1, false); | 1374 return InlineWeeder.canBeInlined(function, -1, false); |
1370 } | 1375 } |
1371 // TODO(sra): Measure if inlining would 'reduce' the size. One desirable | 1376 // TODO(sra): Measure if inlining would 'reduce' the size. One desirable |
1372 // case we miss by doing nothing is inlining very simple constructors | 1377 // case we miss by doing nothing is inlining very simple constructors |
1373 // where all fields are initialized with values from the arguments at this | 1378 // where all fields are initialized with values from the arguments at this |
1374 // call site. The code is slightly larger (`new Foo(1)` vs `Foo$(1)`) but | 1379 // call site. The code is slightly larger (`new Foo(1)` vs `Foo$(1)`) but |
1375 // that usually means the factory constructor is left unused and not | 1380 // that usually means the factory constructor is left unused and not |
1376 // emitted. | 1381 // emitted. |
1377 // We at least inline bodies that are empty (and thus have a size of 1). | 1382 // We at least inline bodies that are empty (and thus have a size of 1). |
1378 return InlineWeeder.canBeInlined(function, 1, true); | 1383 return doesNotContainCode(); |
1379 } | |
1380 | |
1381 bool doesNotContainCode() { | |
1382 // A function with size 1 does not contain any code. | |
1383 return InlineWeeder.canBeInlined(function, 1, true); | |
1384 } | 1384 } |
1385 | 1385 |
1386 bool heuristicSayGoodToGo() { | 1386 bool heuristicSayGoodToGo() { |
1387 // Don't inline recursively | 1387 // Don't inline recursively |
1388 if (inliningStack.any((entry) => entry.function == function)) { | 1388 if (inliningStack.any((entry) => entry.function == function)) { |
1389 return false; | 1389 return false; |
1390 } | 1390 } |
1391 | 1391 |
1392 if (element.isSynthesized) return true; | 1392 if (element.isSynthesized) return true; |
1393 | 1393 |
(...skipping 6270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7664 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 7664 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
7665 unaliased.accept(this, builder); | 7665 unaliased.accept(this, builder); |
7666 } | 7666 } |
7667 | 7667 |
7668 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 7668 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
7669 JavaScriptBackend backend = builder.compiler.backend; | 7669 JavaScriptBackend backend = builder.compiler.backend; |
7670 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 7670 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
7671 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 7671 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
7672 } | 7672 } |
7673 } | 7673 } |
OLD | NEW |