Ver código fonte

Record interpreted/cached steps using timestamp_counter

Fabian 6 anos atrás
pai
commit
e750b64d58
3 arquivos alterados com 19 adições e 1 exclusões
  1. 8 0
      src/native/cpu.c
  2. 7 1
      src/native/profiler/profiler.c
  3. 4 0
      src/native/profiler/profiler.h

+ 8 - 0
src/native/cpu.c

@@ -1623,6 +1623,8 @@ void cycle_internal()
         profiler_start(P_RUN_FROM_CACHE);
         profiler_stat_increment(S_RUN_FROM_CACHE);
 
+        int32_t initial_tsc = *timestamp_counter;
+
         assert(entry->opcode[0] == read8(phys_addr));
 
         uint32_t old_start_address = entry->start_addr;
@@ -1636,6 +1638,8 @@ void cycle_internal()
 
         UNUSED(old_start_address);
 
+        profiler_stat_increment_by(S_RUN_FROM_CACHE_STEPS, *timestamp_counter - initial_tsc);
+
         profiler_end(P_RUN_FROM_CACHE);
     }
     else
@@ -1683,7 +1687,11 @@ void cycle_internal()
                 profiler_stat_increment(S_RUN_INTERPRETED_NOT_HOT);
             }
 
+            int32_t initial_tsc = *timestamp_counter;
+
             jit_run_interpreted(phys_addr);
+
+            profiler_stat_increment_by(S_RUN_INTERPRETED_STEPS, *timestamp_counter - initial_tsc);
         }
     }
 

+ 7 - 1
src/native/profiler/profiler.c

@@ -98,7 +98,12 @@ int32_t profiler_get_total(void)
 
 void profiler_stat_increment(enum stat_name stat)
 {
-    profiler_stat_arr[stat].count++;
+    profiler_stat_increment_by(stat, 1);
+}
+
+void profiler_stat_increment_by(enum stat_name stat, int32_t by)
+{
+    profiler_stat_arr[stat].count += by;
 }
 
 // to be called from JS
@@ -122,6 +127,7 @@ void profiler_print(void) {}
 int32_t profiler_get_time(enum profile_name name) { UNUSED(name); return 0; }
 int32_t profiler_get_total(void) { return 0; }
 void profiler_stat_increment(enum stat_name stat) { UNUSED(stat); }
+void profiler_stat_increment_by(enum stat_name stat, int32_t by) { UNUSED(stat); UNUSED(by); }
 void profiler_stat_increment_do_run() {}
 int32_t profiler_stat_get(enum stat_name stat) { UNUSED(stat); return 0; }
 

+ 4 - 0
src/native/profiler/profiler.h

@@ -35,7 +35,10 @@ enum stat_name {
     S_RUN_INTERPRETED_NO_BLOCK_BOUNDARY,
     S_RUN_INTERPRETED_NOT_HOT,
 
+    S_RUN_INTERPRETED_STEPS,
+
     S_RUN_FROM_CACHE,
+    S_RUN_FROM_CACHE_STEPS,
     S_CACHE_MISMATCH,
 
     S_DO_RUN,
@@ -66,6 +69,7 @@ void profiler_end(enum profile_name name);
 void profiler_print(void);
 
 void profiler_stat_increment(enum stat_name stat);
+void profiler_stat_increment_by(enum stat_name stat, int32_t by);
 int32_t profiler_stat_get(enum stat_name stat);
 
 // JS import