Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: pkg/compiler/lib/src/dump_info.dart

Issue 1431693003: dart2js: add OutputUnit info for constants (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0d305d15e150981f220a143669387dd2fca19b51..7209ab0ffb55f1bb85e0bad2b39ad610223ddf50 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -10,24 +10,17 @@ import 'dart:convert'
import 'package:dart2js_info/info.dart';
import 'common.dart';
-import 'common/tasks.dart' show
- CompilerTask;
-import 'constants/values.dart' show ConstantValue;
-import 'compiler.dart' show
- Compiler;
+import 'common/tasks.dart' show CompilerTask;
+import 'constants/values.dart' show ConstantValue, InterceptorConstantValue;
+import 'compiler.dart' show Compiler;
import 'elements/elements.dart';
import 'elements/visitor.dart';
-import 'types/types.dart' show
- TypeMask;
-import 'deferred_load.dart' show
- OutputUnit;
-import 'js_backend/js_backend.dart' show
- JavaScriptBackend;
-import 'js_emitter/full_emitter/emitter.dart' as full show
- Emitter;
+import 'types/types.dart' show TypeMask;
+import 'deferred_load.dart' show OutputUnit;
+import 'js_backend/js_backend.dart' show JavaScriptBackend;
+import 'js_emitter/full_emitter/emitter.dart' as full show Emitter;
import 'js/js.dart' as jsAst;
-import 'universe/universe.dart' show
- UniverseSelector;
+import 'universe/universe.dart' show UniverseSelector;
import 'info/send_info.dart' show collectSendMeasurements;
class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
@@ -45,10 +38,10 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
// TODO(sigmund): add dependencies on other constants
var size = compiler.dumpInfoTask._nodeToSize[node];
var code = jsAst.prettyPrint(node, compiler).getText();
- var info = new ConstantInfo(size: size, code: code);
+ var info = new ConstantInfo(
+ size: size, code: code, outputUnit: _unitInfoForConstant(constant));
_constantToInfo[constant] = info;
result.constants.add(info);
-
});
compiler.libraryLoader.libraries.forEach(visit);
}
@@ -82,7 +75,7 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
String libname = element.hasLibraryName ? element.libraryName : "<unnamed>";
int size = compiler.dumpInfoTask.sizeOf(element);
LibraryInfo info =
- new LibraryInfo(libname, element.canonicalUri, null, size);
+ new LibraryInfo(libname, element.canonicalUri, null, size);
_elementToInfo[element] = info;
LibraryElement realElement = element.isPatched ? element.patch : element;
@@ -113,8 +106,8 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
TypedefInfo visitTypedefElement(TypedefElement element, _) {
if (!element.isResolved) return null;
- TypedefInfo info = new TypedefInfo(element.name, '${element.alias}',
- _unitInfoForElement(element));
+ TypedefInfo info = new TypedefInfo(
+ element.name, '${element.alias}', _unitInfoForElement(element));
_elementToInfo[element] = info;
result.typedefs.add(info);
return info;
@@ -284,6 +277,7 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
FunctionInfo info = new FunctionInfo(
name: name,
+ functionKind: kind,
// We use element.hashCode because it is globally unique and it is
// available while we are doing codegen.
coverageId: '${element.hashCode}',
@@ -323,9 +317,7 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
return info;
}
- OutputUnitInfo _unitInfoForElement(Element element) {
- OutputUnit outputUnit =
- compiler.deferredLoadTask.outputUnitForElement(element);
+ OutputUnitInfo _infoFromOutputUnit(OutputUnit outputUnit) {
return _outputToInfo.putIfAbsent(outputUnit, () {
// Dump-info currently only works with the full emitter. If another
// emitter is used it will fail here.
@@ -337,6 +329,21 @@ class ElementInfoCollector extends BaseElementVisitor<Info, dynamic> {
return info;
});
}
+
+ OutputUnitInfo _unitInfoForElement(Element element) {
+ return _infoFromOutputUnit(
+ compiler.deferredLoadTask.outputUnitForElement(element));
+ }
+
+ OutputUnitInfo _unitInfoForConstant(ConstantValue constant) {
+ OutputUnit outputUnit =
+ compiler.deferredLoadTask.outputUnitForConstant(constant);
+ if (outputUnit == null) {
+ assert(constant is InterceptorConstantValue);
+ return null;
+ }
+ return _infoFromOutputUnit(outputUnit);
+ }
}
class Selection {
@@ -547,9 +554,9 @@ class DumpInfoTask extends CompilerTask implements InfoReporter {
var a = infoCollector._elementToInfo[element];
if (a == null) continue;
result.dependencies[a] = _dependencies[element]
- .map((o) => infoCollector._elementToInfo[o])
- .where((o) => o != null)
- .toList();
+ .map((o) => infoCollector._elementToInfo[o])
+ .where((o) => o != null)
+ .toList();
}
result.deferredFiles = compiler.deferredLoadTask.computeDeferredMap();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698