Chromium Code Reviews| Index: pkg/compiler/lib/src/dump_info.dart |
| diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart |
| index 2a775a16522c4b3022c3ed335f969933b620ea75..e3ff91e3005823b50d8ce6cc83df675ed41c04bd 100644 |
| --- a/pkg/compiler/lib/src/dump_info.dart |
| +++ b/pkg/compiler/lib/src/dump_info.dart |
| @@ -9,6 +9,7 @@ import 'dart:convert' |
| import 'package:dart2js_info/info.dart'; |
| +import 'closure.dart'; |
| import 'common/tasks.dart' show CompilerTask; |
| import 'common.dart'; |
| import 'compiler.dart' show Compiler; |
| @@ -143,16 +144,15 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| } |
| } |
| - List<FunctionInfo> nestedClosures = <FunctionInfo>[]; |
| - for (Element closure in element.nestedClosures) { |
| - Info child = this.process(closure); |
| - if (child != null) { |
| - ClassInfo parent = this.process(closure.enclosingElement); |
| - if (parent != null) { |
| - child.name = "${parent.name}.${child.name}"; |
| - } |
| - nestedClosures.add(child); |
| - size += child.size; |
| + List<ClosureInfo> nestedClosures = <ClosureInfo>[]; |
|
Siggi Cherem (dart-lang)
2016/10/06 17:58:09
the code here and in line 313 seem almost the same
Harry Terkelsen
2016/10/06 18:22:43
Done.
|
| + for (FunctionElement function in element.nestedClosures) { |
| + assert(function is SynthesizedCallMethodElementX); |
| + SynthesizedCallMethodElementX callMethod = function; |
| + ClosureInfo closure = this.process(callMethod.enclosingClass); |
| + if (closure != null) { |
| + closure.parent = info; |
| + nestedClosures.add(closure); |
| + size += closure.size; |
| } |
| } |
| info.closures = nestedClosures; |
| @@ -184,20 +184,13 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| // them to a function, and by extension, this class. Process and add the |
| // sizes here. |
| if (member is MemberElement) { |
| - for (Element closure in member.nestedClosures) { |
| - FunctionInfo closureInfo = this.process(closure); |
| - if (closureInfo == null) continue; |
| - |
| - // TODO(sigmund): remove this legacy update on the name, represent the |
| - // information explicitly in the info format. |
| - // Look for the parent element of this closure might be the enclosing |
| - // class or an enclosing function. |
| - Element parent = closure.enclosingElement; |
| - ClassInfo parentInfo = this.process(parent); |
| - if (parentInfo != null) { |
| - closureInfo.name = "${parentInfo.name}.${closureInfo.name}"; |
| + for (Element function in member.nestedClosures) { |
|
Siggi Cherem (dart-lang)
2016/10/06 17:58:09
we might be able to use the same function here I t
Harry Terkelsen
2016/10/06 18:22:43
I think we can just iterate over all closures in t
|
| + assert(function is SynthesizedCallMethodElementX); |
| + SynthesizedCallMethodElementX callMethod = function; |
| + ClosureInfo closure = this.process(callMethod.enclosingClass); |
| + if (closure != null) { |
| + size += closure.size; |
| } |
| - size += closureInfo.size; |
| } |
| } |
| }); |
| @@ -215,6 +208,26 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| return classInfo; |
| } |
| + ClosureInfo visitClosureClassElement(ClosureClassElement element, _) { |
| + ClosureInfo closureInfo = new ClosureInfo( |
| + name: element.name, |
| + outputUnit: _unitInfoForElement(element), |
| + size: compiler.dumpInfoTask.sizeOf(element)); |
| + _elementToInfo[element] = closureInfo; |
| + |
| + ClosureClassMap closureMap = |
| + compiler.closureToClassMapper.closureMappingCache[element.node]; |
| + assert(closureMap != null && closureMap.closureClassElement == element); |
| + |
| + FunctionInfo functionInfo = this.process(closureMap.callElement); |
| + if (functionInfo == null) return null; |
|
Siggi Cherem (dart-lang)
2016/10/06 17:58:08
when can this be null?
Harry Terkelsen
2016/10/06 18:22:43
If the closure is not actually output in the code
|
| + closureInfo.function = functionInfo; |
| + functionInfo.parent = closureInfo; |
| + |
| + result.closures.add(closureInfo); |
| + return closureInfo; |
| + } |
| + |
| FunctionInfo visitFunctionElement(FunctionElement element, _) { |
| int size = compiler.dumpInfoTask.sizeOf(element); |
| // TODO(sigmund): consider adding a small info to represent unreachable |
| @@ -294,23 +307,22 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> { |
| outputUnit: _unitInfoForElement(element)); |
| _elementToInfo[element] = info; |
| - List<FunctionInfo> nestedClosures = <FunctionInfo>[]; |
| + List<ClosureInfo> nestedClosures = <ClosureInfo>[]; |
| if (element is MemberElement) { |
| MemberElement member = element as MemberElement; |
| - for (Element closure in member.nestedClosures) { |
| - Info child = this.process(closure); |
| - if (child != null) { |
| - BasicInfo parent = this.process(closure.enclosingElement); |
| - if (parent != null) { |
| - child.name = "${parent.name}.${child.name}"; |
| - } |
| - nestedClosures.add(child); |
| - child.parent = parent; |
| - size += child.size; |
| + for (Element function in member.nestedClosures) { |
| + assert(function is SynthesizedCallMethodElementX); |
| + SynthesizedCallMethodElementX callMethod = function; |
| + ClosureInfo closure = this.process(callMethod.enclosingClass); |
|
Siggi Cherem (dart-lang)
2016/10/06 17:58:09
is .enclosingClass the same as .enclosingElement (
Harry Terkelsen
2016/10/06 18:22:42
Done.
|
| + if (closure != null) { |
| + closure.parent = info; |
| + nestedClosures.add(closure); |
| + size += closure.size; |
| } |
| } |
| } |
| info.closures = nestedClosures; |
| + |
| result.functions.add(info); |
| return info; |
| } |