| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 type_graph_inferrer; | 5 part of type_graph_inferrer; |
| 6 | 6 |
| 7 // A set of selectors we know do not escape the elements inside the | 7 // A set of selectors we know do not escape the elements inside the |
| 8 // list. | 8 // list. |
| 9 Set<String> doesNotEscapeListSet = new Set<String>.from( | 9 Set<String> doesNotEscapeListSet = new Set<String>.from( |
| 10 const <String>[ | 10 const <String>[ |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 'isNotEmpty', | 59 'isNotEmpty', |
| 60 'length', | 60 'length', |
| 61 'clear', | 61 'clear', |
| 62 'containsKey', | 62 'containsKey', |
| 63 'containsValue', | 63 'containsValue', |
| 64 '[]=', | 64 '[]=', |
| 65 // [keys] only allows key values to escape, which we do not track. | 65 // [keys] only allows key values to escape, which we do not track. |
| 66 'keys' | 66 'keys' |
| 67 ]); | 67 ]); |
| 68 | 68 |
| 69 abstract class TracerVisitor implements TypeInformationVisitor { | 69 abstract class TracerVisitor<T extends TypeInformation> |
| 70 final TypeInformation tracedType; | 70 implements TypeInformationVisitor { |
| 71 final T tracedType; |
| 71 final TypeGraphInferrerEngine inferrer; | 72 final TypeGraphInferrerEngine inferrer; |
| 72 final Compiler compiler; | 73 final Compiler compiler; |
| 73 | 74 |
| 74 static const int MAX_ANALYSIS_COUNT = 16; | 75 static const int MAX_ANALYSIS_COUNT = 16; |
| 75 final Setlet<Element> analyzedElements = new Setlet<Element>(); | 76 final Setlet<Element> analyzedElements = new Setlet<Element>(); |
| 76 | 77 |
| 77 TracerVisitor(this.tracedType, inferrer) | 78 TracerVisitor(this.tracedType, inferrer) |
| 78 : this.inferrer = inferrer, this.compiler = inferrer.compiler; | 79 : this.inferrer = inferrer, this.compiler = inferrer.compiler; |
| 79 | 80 |
| 80 // Work list that gets populated with [TypeInformation] that could | 81 // Work list that gets populated with [TypeInformation] that could |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 Element outermost = element.getOutermostEnclosingMemberOrTopLevel(); | 337 Element outermost = element.getOutermostEnclosingMemberOrTopLevel(); |
| 337 return outermost.declaration != element.declaration; | 338 return outermost.declaration != element.declaration; |
| 338 } | 339 } |
| 339 | 340 |
| 340 void visitElementTypeInformation(ElementTypeInformation info) { | 341 void visitElementTypeInformation(ElementTypeInformation info) { |
| 341 Element element = info.element; | 342 Element element = info.element; |
| 342 if (element.isParameter() | 343 if (element.isParameter() |
| 343 && inferrer.isNativeElement(element.enclosingElement)) { | 344 && inferrer.isNativeElement(element.enclosingElement)) { |
| 344 bailout('Passed to a native method'); | 345 bailout('Passed to a native method'); |
| 345 } | 346 } |
| 346 if (info.isClosurized()) { | 347 if (info.isClosurized) { |
| 347 bailout('Returned from a closurized method'); | 348 bailout('Returned from a closurized method'); |
| 348 } | 349 } |
| 349 if (isClosure(info.element)) { | 350 if (isClosure(info.element)) { |
| 350 bailout('Returned from a closure'); | 351 bailout('Returned from a closure'); |
| 351 } | 352 } |
| 352 if (compiler.backend.isNeededForReflection(info.element)) { | 353 if (compiler.backend.isNeededForReflection(info.element)) { |
| 353 bailout('Escape in reflection'); | 354 bailout('Escape in reflection'); |
| 354 } | 355 } |
| 356 if (!inferrer.compiler.backend |
| 357 .canBeUsedForGlobalOptimizations(info.element)) { |
| 358 bailout('Escape to code that has special backend treatment'); |
| 359 } |
| 355 if (isParameterOfListAddingMethod(info.element) || | 360 if (isParameterOfListAddingMethod(info.element) || |
| 356 isParameterOfMapAddingMethod(info.element)) { | 361 isParameterOfMapAddingMethod(info.element)) { |
| 357 // These elements are being handled in | 362 // These elements are being handled in |
| 358 // [visitDynamicCallSiteTypeInformation]. | 363 // [visitDynamicCallSiteTypeInformation]. |
| 359 return; | 364 return; |
| 360 } | 365 } |
| 361 addNewEscapeInformation(info); | 366 addNewEscapeInformation(info); |
| 362 } | 367 } |
| 363 } | 368 } |
| OLD | NEW |