Skip to content

Commit 2e7d273

Browse files
committed
More counters for instrumentation
1 parent 9362914 commit 2e7d273

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ object Contexts {
433433
}
434434

435435
/** A fresh clone of this context. */
436-
def fresh: FreshContext = clone.asInstanceOf[FreshContext].init(this)
436+
def fresh: FreshContext = {
437+
util.Stats.record("Context.fresh")
438+
clone.asInstanceOf[FreshContext].init(this)
439+
}
437440

438441
final def withOwner(owner: Symbol): Context =
439442
if (owner ne this.owner) fresh.setOwner(owner) else this

compiler/src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import reporting._
99
import config.Config
1010
import collection.mutable
1111
import java.lang.ref.WeakReference
12+
import util.Stats
1213

1314
import scala.annotation.internal.sharable
1415

@@ -18,6 +19,8 @@ object TyperState {
1819

1920
class TyperState(previous: TyperState /* | Null */) {
2021

22+
Stats.record("typerState")
23+
2124
val id: Int = TyperState.nextId
2225
TyperState.nextId += 1
2326

@@ -138,6 +141,7 @@ class TyperState(previous: TyperState /* | Null */) {
138141
* many parts of dotty itself.
139142
*/
140143
def commit()(implicit ctx: Context): Unit = {
144+
Stats.record("typerState.commit")
141145
val targetState = ctx.typerState
142146
assert(isCommittable)
143147
targetState.constraint =

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package typer
55
import core._
66
import ast.{Trees, tpd, untpd}
77
import util.Spans._
8-
import util.Stats.track
8+
import util.Stats.{track, record}
99
import util.{SourcePosition, NoSourcePosition, SourceFile}
1010
import Trees.Untyped
1111
import Contexts._
@@ -758,6 +758,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
758758

759759
def realApply(implicit ctx: Context): Tree = track("realApply") {
760760
val originalProto = new FunProto(tree.args, IgnoredProto(pt))(this, tree.isContextual)(argCtx(tree))
761+
record("typedApply")
761762
val fun1 = typedExpr(tree.fun, originalProto)
762763

763764
// Warning: The following lines are dirty and fragile. We record that auto-tupling was demanded as
@@ -892,6 +893,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
892893
def typedTypeApply(tree: untpd.TypeApply, pt: Type)(implicit ctx: Context): Tree = track("typedTypeApply") {
893894
val isNamed = hasNamedArg(tree.args)
894895
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
896+
record("typedTypeApply")
895897
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
896898
case ExtMethodApply(app) =>
897899
app

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2153,9 +2153,12 @@ class Typer extends Namer
21532153
def tryEither[T](op: Context => T)(fallBack: (T, TyperState) => T)(implicit ctx: Context): T = {
21542154
val nestedCtx = ctx.fresh.setNewTyperState()
21552155
val result = op(nestedCtx)
2156-
if (nestedCtx.reporter.hasErrors)
2156+
if (nestedCtx.reporter.hasErrors) {
2157+
record("tryEither.fallBack")
21572158
fallBack(result, nestedCtx.typerState)
2159+
}
21582160
else {
2161+
record("tryEither.commit")
21592162
nestedCtx.typerState.commit()
21602163
result
21612164
}

0 commit comments

Comments
 (0)