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

Side by Side Diff: pkg/compiler/lib/src/dump_info.dart

Issue 2468303003: dart2js: move type-mask intermediate data from tree-elements into the global (Closed)
Patch Set: bug fix: handle closures and constructor bodies Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library dump_info; 5 library dump_info;
6 6
7 import 'dart:convert' 7 import 'dart:convert'
8 show ChunkedConversionSink, JsonEncoder, StringConversionSink; 8 show ChunkedConversionSink, JsonEncoder, StringConversionSink;
9 9
10 import 'package:dart2js_info/info.dart'; 10 import 'package:dart2js_info/info.dart';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 TypedefInfo visitTypedefElement(TypedefElement element, _) { 109 TypedefInfo visitTypedefElement(TypedefElement element, _) {
110 if (!element.isResolved) return null; 110 if (!element.isResolved) return null;
111 TypedefInfo info = new TypedefInfo( 111 TypedefInfo info = new TypedefInfo(
112 element.name, '${element.alias}', _unitInfoForElement(element)); 112 element.name, '${element.alias}', _unitInfoForElement(element));
113 _elementToInfo[element] = info; 113 _elementToInfo[element] = info;
114 result.typedefs.add(info); 114 result.typedefs.add(info);
115 return info; 115 return info;
116 } 116 }
117 117
118 _resultOf(e) => compiler.globalInference.results.resultOf(e);
119
118 FieldInfo visitFieldElement(FieldElement element, _) { 120 FieldInfo visitFieldElement(FieldElement element, _) {
119 TypeMask inferredType = compiler.globalInference.results.typeOf(element); 121 TypeMask inferredType = _resultOf(element).type;
120 // If a field has an empty inferred type it is never used. 122 // If a field has an empty inferred type it is never used.
121 if (inferredType == null || inferredType.isEmpty) return null; 123 if (inferredType == null || inferredType.isEmpty) return null;
122 124
123 int size = compiler.dumpInfoTask.sizeOf(element); 125 int size = compiler.dumpInfoTask.sizeOf(element);
124 String code = compiler.dumpInfoTask.codeOf(element); 126 String code = compiler.dumpInfoTask.codeOf(element);
125 if (code != null) size += code.length; 127 if (code != null) size += code.length;
126 128
127 FieldInfo info = new FieldInfo( 129 FieldInfo info = new FieldInfo(
128 name: element.name, 130 name: element.name,
129 // We use element.hashCode because it is globally unique and it is 131 // We use element.hashCode because it is globally unique and it is
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 isStatic: element.isStatic, 244 isStatic: element.isStatic,
243 isConst: element.isConst, 245 isConst: element.isConst,
244 isFactory: element.isFactoryConstructor, 246 isFactory: element.isFactoryConstructor,
245 isExternal: element.isPatched); 247 isExternal: element.isPatched);
246 String code = compiler.dumpInfoTask.codeOf(element); 248 String code = compiler.dumpInfoTask.codeOf(element);
247 249
248 List<ParameterInfo> parameters = <ParameterInfo>[]; 250 List<ParameterInfo> parameters = <ParameterInfo>[];
249 if (element.hasFunctionSignature) { 251 if (element.hasFunctionSignature) {
250 FunctionSignature signature = element.functionSignature; 252 FunctionSignature signature = element.functionSignature;
251 signature.forEachParameter((parameter) { 253 signature.forEachParameter((parameter) {
252 parameters.add(new ParameterInfo( 254 parameters.add(new ParameterInfo(parameter.name,
253 parameter.name, 255 '${_resultOf(parameter).type}', '${parameter.node.type}'));
254 '${compiler.globalInference.results.typeOf(parameter)}',
255 '${parameter.node.type}'));
256 }); 256 });
257 } 257 }
258 258
259 String returnType = null; 259 String returnType = null;
260 // TODO(sigmund): why all these checks? 260 // TODO(sigmund): why all these checks?
261 if (element.isInstanceMember && 261 if (element.isInstanceMember &&
262 !element.isAbstract && 262 !element.isAbstract &&
263 compiler.closedWorld.allFunctions.contains(element)) { 263 compiler.closedWorld.allFunctions.contains(element)) {
264 returnType = '${element.type.returnType}'; 264 returnType = '${element.type.returnType}';
265 } 265 }
266 String inferredReturnType = 266 String inferredReturnType = '${_resultOf(element).returnType}';
267 '${compiler.globalInference.results.returnTypeOf(element)}';
268 String sideEffects = 267 String sideEffects =
269 '${compiler.closedWorld.getSideEffectsOfElement(element)}'; 268 '${compiler.closedWorld.getSideEffectsOfElement(element)}';
270 269
271 int inlinedCount = compiler.dumpInfoTask.inlineCount[element]; 270 int inlinedCount = compiler.dumpInfoTask.inlineCount[element];
272 if (inlinedCount == null) inlinedCount = 0; 271 if (inlinedCount == null) inlinedCount = 0;
273 272
274 FunctionInfo info = new FunctionInfo( 273 FunctionInfo info = new FunctionInfo(
275 name: name, 274 name: name,
276 functionKind: kind, 275 functionKind: kind,
277 // We use element.hashCode because it is globally unique and it is 276 // We use element.hashCode because it is globally unique and it is
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 596
598 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion( 597 ChunkedConversionSink<Object> sink = encoder.startChunkedConversion(
599 new StringConversionSink.fromStringSink(buffer)); 598 new StringConversionSink.fromStringSink(buffer));
600 sink.add(new AllInfoJsonCodec().encode(result)); 599 sink.add(new AllInfoJsonCodec().encode(result));
601 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, { 600 compiler.reporter.reportInfo(NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {
602 'text': "View the dumped .info.json file at " 601 'text': "View the dumped .info.json file at "
603 "https://dart-lang.github.io/dump-info-visualizer" 602 "https://dart-lang.github.io/dump-info-visualizer"
604 }); 603 });
605 } 604 }
606 } 605 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698