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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1288593002: dart2js: add function coverage tracking in dart2js output, dumpinfo, and (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months 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
OLDNEW
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 ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 }); 1755 });
1756 } 1756 }
1757 assert(argumentIndex == compiledArguments.length); 1757 assert(argumentIndex == compiledArguments.length);
1758 1758
1759 elements = function.resolvedAst.elements; 1759 elements = function.resolvedAst.elements;
1760 assert(elements != null); 1760 assert(elements != null);
1761 returnType = signature.type.returnType; 1761 returnType = signature.type.returnType;
1762 stack = <HInstruction>[]; 1762 stack = <HInstruction>[];
1763 1763
1764 insertTraceCall(function); 1764 insertTraceCall(function);
1765 insertCoverageCall(function);
1765 } 1766 }
1766 1767
1767 void restoreState(AstInliningState state) { 1768 void restoreState(AstInliningState state) {
1768 localsHandler = state.oldLocalsHandler; 1769 localsHandler = state.oldLocalsHandler;
1769 returnLocal = state.oldReturnLocal; 1770 returnLocal = state.oldReturnLocal;
1770 inTryStatement = state.inTryStatement; 1771 inTryStatement = state.inTryStatement;
1771 elements = state.oldElements; 1772 elements = state.oldElements;
1772 returnType = state.oldReturnType; 1773 returnType = state.oldReturnType;
1773 assert(stack.isEmpty); 1774 assert(stack.isEmpty);
1774 stack = state.oldStack; 1775 stack = state.oldStack;
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 localsHandler.directLocals[parameterElement] = newParameter; 2394 localsHandler.directLocals[parameterElement] = newParameter;
2394 }); 2395 });
2395 2396
2396 returnType = signature.type.returnType; 2397 returnType = signature.type.returnType;
2397 } else { 2398 } else {
2398 // Otherwise it is a lazy initializer which does not have parameters. 2399 // Otherwise it is a lazy initializer which does not have parameters.
2399 assert(element is VariableElement); 2400 assert(element is VariableElement);
2400 } 2401 }
2401 2402
2402 insertTraceCall(element); 2403 insertTraceCall(element);
2404 insertCoverageCall(element);
2403 } 2405 }
2404 2406
2405 insertTraceCall(Element element) { 2407 insertTraceCall(Element element) {
2406 if (JavaScriptBackend.TRACE_CALLS) { 2408 if (JavaScriptBackend.TRACE_METHOD == 'console') {
2407 if (element == backend.traceHelper) return; 2409 if (element == backend.traceHelper) return;
2408 n(e) => e == null ? '' : e.name; 2410 n(e) => e == null ? '' : e.name;
2409 String name = "${n(element.library)}:${n(element.enclosingClass)}." 2411 String name = "${n(element.library)}:${n(element.enclosingClass)}."
2410 "${n(element)}"; 2412 "${n(element)}";
2411 HConstant nameConstant = addConstantString(name); 2413 HConstant nameConstant = addConstantString(name);
2412 add(new HInvokeStatic(backend.traceHelper, 2414 add(new HInvokeStatic(backend.traceHelper,
2413 <HInstruction>[nameConstant], 2415 <HInstruction>[nameConstant],
2414 backend.dynamicType)); 2416 backend.dynamicType));
2415 } 2417 }
2416 } 2418 }
2417 2419
2420 insertCoverageCall(Element element) {
2421 if (JavaScriptBackend.TRACE_METHOD == 'post') {
2422 if (element == backend.traceHelper) return;
2423 // TODO(sigmund): create a better uuid for elements.
2424 HConstant idConstant = graph.addConstantInt(element.hashCode, compiler);
2425 HConstant nameConstant = addConstantString(element.name);
2426 add(new HInvokeStatic(backend.traceHelper,
2427 <HInstruction>[idConstant, nameConstant],
2428 backend.dynamicType));
2429 }
2430 }
2431
2418 /// Check that [type] is valid in the context of `localsHandler.contextClass`. 2432 /// Check that [type] is valid in the context of `localsHandler.contextClass`.
2419 /// This should only be called in assertions. 2433 /// This should only be called in assertions.
2420 bool assertTypeInContext(DartType type, [Spannable spannable]) { 2434 bool assertTypeInContext(DartType type, [Spannable spannable]) {
2421 return invariant(spannable == null ? CURRENT_ELEMENT_SPANNABLE : spannable, 2435 return invariant(spannable == null ? CURRENT_ELEMENT_SPANNABLE : spannable,
2422 () { 2436 () {
2423 ClassElement contextClass = Types.getClassContext(type); 2437 ClassElement contextClass = Types.getClassContext(type);
2424 return contextClass == null || 2438 return contextClass == null ||
2425 contextClass == localsHandler.contextClass; 2439 contextClass == localsHandler.contextClass;
2426 }, 2440 },
2427 message: "Type '$type' is not valid context of " 2441 message: "Type '$type' is not valid context of "
(...skipping 6411 matching lines...) Expand 10 before | Expand all | Expand 10 after
8839 if (unaliased is TypedefType) throw 'unable to unalias $type'; 8853 if (unaliased is TypedefType) throw 'unable to unalias $type';
8840 unaliased.accept(this, builder); 8854 unaliased.accept(this, builder);
8841 } 8855 }
8842 8856
8843 void visitDynamicType(DynamicType type, SsaBuilder builder) { 8857 void visitDynamicType(DynamicType type, SsaBuilder builder) {
8844 JavaScriptBackend backend = builder.compiler.backend; 8858 JavaScriptBackend backend = builder.compiler.backend;
8845 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 8859 ClassElement cls = backend.findHelper('DynamicRuntimeType');
8846 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 8860 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
8847 } 8861 }
8848 } 8862 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698