Chromium Code Reviews| 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 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 7 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 8 final Set<HInstruction> boundsChecked; | 8 final Set<HInstruction> boundsChecked; |
| 9 | 9 |
| 10 JavaScriptItemCompilationContext() | 10 JavaScriptItemCompilationContext() |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 metadataStaticUse.clear(); | 1388 metadataStaticUse.clear(); |
| 1389 for (Element e in metadataGetOfStaticFunction) { | 1389 for (Element e in metadataGetOfStaticFunction) { |
| 1390 registerMetadataGetOfStaticFunction(e); | 1390 registerMetadataGetOfStaticFunction(e); |
| 1391 } | 1391 } |
| 1392 metadataGetOfStaticFunction.clear(); | 1392 metadataGetOfStaticFunction.clear(); |
| 1393 } | 1393 } |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 /// Called when [:const Symbol(name):] is seen. | 1396 /// Called when [:const Symbol(name):] is seen. |
| 1397 void registerConstSymbol(String name, TreeElements elements) { | 1397 void registerConstSymbol(String name, TreeElements elements) { |
| 1398 symbolsUsed.add(name); | |
| 1398 } | 1399 } |
| 1399 | 1400 |
| 1400 /// Called when [:new Symbol(...):] is seen. | 1401 /// Called when [:new Symbol(...):] is seen. |
| 1401 void registerNewSymbol(TreeElements elements) { | 1402 void registerNewSymbol(TreeElements elements) { |
| 1402 } | 1403 } |
| 1403 | 1404 |
| 1404 bool retainGetter(Element element) => isTreeShakingDisabled; | 1405 bool retainGetter(Element element) => isNeededForReflection(element); |
|
Johnni Winther
2013/08/07 10:47:34
Rename these three to shouldRetainX, isXRetained o
ahe
2013/08/07 14:03:17
Done.
| |
| 1405 | 1406 |
| 1406 bool retainSetter(Element element) => isTreeShakingDisabled; | 1407 bool retainSetter(Element element) => isNeededForReflection(element); |
| 1407 | 1408 |
| 1408 bool retainName(SourceString name) => mustPreserveNames; | 1409 bool retainName(SourceString name) { |
| 1410 if (name == const SourceString('')) return false; | |
| 1411 return symbolsUsed.contains(name.slowToString()); | |
| 1412 } | |
| 1409 | 1413 |
| 1410 bool get rememberLazies => isTreeShakingDisabled; | 1414 bool get rememberLazies => isTreeShakingDisabled; |
| 1411 | 1415 |
| 1412 bool retainMetadataOf(Element element) { | 1416 bool retainMetadataOf(Element element) { |
| 1413 if (mustRetainMetadata) { | 1417 if (mustRetainMetadata) { |
| 1414 // TODO(ahe): This is a little hacky, but I'll have to rewrite this when | 1418 // TODO(ahe): This is a little hacky, but I'll have to rewrite this when |
| 1415 // implementing @MirrorsUsed anyways. | 1419 // implementing @MirrorsUsed anyways. |
| 1416 compiler.constantHandler.compiledConstants.addAll( | 1420 compiler.constantHandler.compiledConstants.addAll( |
| 1417 compiler.metadataHandler.compiledConstants); | 1421 compiler.metadataHandler.compiledConstants); |
| 1418 compiler.metadataHandler.compiledConstants.clear(); | 1422 compiler.metadataHandler.compiledConstants.clear(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1468 targetsUsed.add(field.getter); | 1472 targetsUsed.add(field.getter); |
| 1469 targetsUsed.add(field.setter); | 1473 targetsUsed.add(field.setter); |
| 1470 } else { | 1474 } else { |
| 1471 targetsUsed.add(target); | 1475 targetsUsed.add(target); |
| 1472 } | 1476 } |
| 1473 } | 1477 } |
| 1474 } | 1478 } |
| 1475 if (metaTargets != null) metaTargetsUsed.addAll(metaTargets); | 1479 if (metaTargets != null) metaTargetsUsed.addAll(metaTargets); |
| 1476 } | 1480 } |
| 1477 | 1481 |
| 1482 bool rememberNameOf(Element element) { | |
|
Johnni Winther
2013/08/07 10:47:34
Ditto.
ahe
2013/08/07 14:03:17
Done.
| |
| 1483 symbolsUsed.add(element.name.slowToString()); | |
| 1484 if (element.isConstructor()) { | |
| 1485 symbolsUsed.add(element.getEnclosingClass().name.slowToString()); | |
| 1486 } | |
| 1487 return true; | |
| 1488 } | |
| 1489 | |
| 1478 bool isNeededForReflection(Element element) { | 1490 bool isNeededForReflection(Element element) { |
| 1479 // TODO(ahe): Implement this. | 1491 // TODO(ahe): Implement this. |
| 1480 if (!metaTargetsUsed.isEmpty) return true; | 1492 if (!metaTargetsUsed.isEmpty) return rememberNameOf(element); |
| 1481 if (!targetsUsed.isEmpty) { | 1493 if (!targetsUsed.isEmpty) { |
| 1482 for (Element e = element; e != null; e = e.enclosingElement) { | 1494 for (Element e = element; e != null; e = e.enclosingElement) { |
| 1483 if (targetsUsed.contains(e)) return true; | 1495 if (targetsUsed.contains(e)) return rememberNameOf(element); |
| 1484 } | 1496 } |
| 1485 } | 1497 } |
| 1486 return false; | 1498 return false; |
| 1487 } | 1499 } |
| 1488 } | 1500 } |
| 1489 | 1501 |
| 1490 /// Records that [type] is used by [user.element]. | 1502 /// Records that [type] is used by [user.element]. |
| 1491 class Dependency { | 1503 class Dependency { |
| 1492 final DartType type; | 1504 final DartType type; |
| 1493 final TreeElements user; | 1505 final TreeElements user; |
| 1494 | 1506 |
| 1495 const Dependency(this.type, this.user); | 1507 const Dependency(this.type, this.user); |
| 1496 } | 1508 } |
| OLD | NEW |