summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2020-07-09 19:21:20 +0200
committerAraq <rumpf_a@web.de>2020-07-09 19:21:20 +0200
commitf92d2eaa3516b4c11e4d499ef2ec0d6047862f80 (patch)
tree2c5e1c5c600076b034948b573e9eaede318eb52e /compiler
parentd7ccd82eacd7a03c7cf31ea56315c3a35218e122 (diff)
downloadNim-f92d2eaa3516b4c11e4d499ef2ec0d6047862f80.tar.gz
cleanup of PR #14833 (VM profiler)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/vmprofiler.nim29
1 files changed, 16 insertions, 13 deletions
diff --git a/compiler/vmprofiler.nim b/compiler/vmprofiler.nim
index 57a0430b4..f586c8ffe 100644
--- a/compiler/vmprofiler.nim
+++ b/compiler/vmprofiler.nim
@@ -2,26 +2,29 @@
 import
   options, vmdef, times, lineinfos, strutils, tables,
   msgs
-  
+
 proc enter*(prof: var Profiler, c: PCtx, tos: PStackFrame) {.inline.} =
   if optProfileVM in c.config.globalOptions:
     prof.tEnter = cpuTime()
     prof.tos = tos
 
+proc leaveImpl(prof: var Profiler, c: PCtx) {.noinline.} =
+  let tLeave = cpuTime()
+  var tos = prof.tos
+  var data = c.config.vmProfileData.data
+  while tos != nil:
+    if tos.prc != nil:
+      let li = tos.prc.info
+      if li notin data:
+        data[li] = ProfileInfo()
+      data[li].time += tLeave - prof.tEnter
+      if tos == prof.tos:
+        inc data[li].count
+    tos = tos.next
+
 proc leave*(prof: var Profiler, c: PCtx) {.inline.} =
   if optProfileVM in c.config.globalOptions:
-    let tLeave = cpuTime()
-    var tos = prof.tos
-    var data = c.config.vmProfileData.data
-    while tos != nil:
-      if tos.prc != nil:
-        let li = tos.prc.info
-        if li notin data:
-          data[li] = ProfileInfo()
-        data[li].time += tLeave - prof.tEnter
-        if tos == prof.tos:
-          inc data[li].count
-      tos = tos.next
+    leaveImpl(prof, c)
 
 proc dump*(conf: ConfigRef, pd: ProfileData): string =
   var data = pd.data