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 dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class World { | 7 class World { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final FullFunctionSet allFunctions; | 9 final FullFunctionSet allFunctions; |
| 10 final Set<Element> functionsCalledInLoop = new Set<Element>(); | 10 final Set<Element> functionsCalledInLoop = new Set<Element>(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 | 199 |
| 200 void addFunctionCalledInLoop(Element element) { | 200 void addFunctionCalledInLoop(Element element) { |
| 201 functionsCalledInLoop.add(element.declaration); | 201 functionsCalledInLoop.add(element.declaration); |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool isCalledInLoop(Element element) { | 204 bool isCalledInLoop(Element element) { |
| 205 return functionsCalledInLoop.contains(element.declaration); | 205 return functionsCalledInLoop.contains(element.declaration); |
| 206 } | 206 } |
| 207 | 207 |
| 208 SideEffects getSideEffectsOfElement(Element element) { | 208 SideEffects getSideEffectsOfElement(Element element) { |
| 209 assert(!element.isGenerativeConstructorBody()); | |
|
kasperl
2013/05/22 12:49:15
Add a comment that explains why this doesn't make
ngeoffray
2013/05/22 12:51:55
Done.
| |
| 209 return sideEffects.putIfAbsent(element.declaration, () { | 210 return sideEffects.putIfAbsent(element.declaration, () { |
| 210 return new SideEffects(); | 211 return new SideEffects(); |
| 211 }); | 212 }); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void registerSideEffects(Element element, SideEffects effects) { | 215 void registerSideEffects(Element element, SideEffects effects) { |
| 215 sideEffects[element.declaration] = effects; | 216 sideEffects[element.declaration] = effects; |
| 216 } | 217 } |
| 217 | 218 |
| 218 SideEffects getSideEffectsOfSelector(Selector selector) { | 219 SideEffects getSideEffectsOfSelector(Selector selector) { |
| 219 // We're not tracking side effects of closures. | 220 // We're not tracking side effects of closures. |
| 220 if (selector.isClosureCall()) { | 221 if (selector.isClosureCall()) { |
| 221 return new SideEffects(); | 222 return new SideEffects(); |
| 222 } | 223 } |
| 223 SideEffects sideEffects = new SideEffects.empty(); | 224 SideEffects sideEffects = new SideEffects.empty(); |
| 224 for (Element e in allFunctions.filter(selector)) { | 225 for (Element e in allFunctions.filter(selector)) { |
| 225 if (e.isField()) { | 226 if (e.isField()) { |
| 226 if (selector.isGetter()) { | 227 if (selector.isGetter()) { |
| 227 sideEffects.setDependsOnInstancePropertyStore(); | 228 sideEffects.setDependsOnInstancePropertyStore(); |
| 228 } else if (selector.isSetter()) { | 229 } else if (selector.isSetter()) { |
| 229 sideEffects.setChangesInstanceProperty(); | 230 sideEffects.setChangesInstanceProperty(); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 sideEffects.add(getSideEffectsOfElement(e)); | 233 sideEffects.add(getSideEffectsOfElement(e)); |
| 233 } | 234 } |
| 234 return sideEffects; | 235 return sideEffects; |
| 235 } | 236 } |
| 236 } | 237 } |
| OLD | NEW |