6 void factor_vm::record_sample()
8 cell recorded_sample_count;
9 cell recorded_gc_sample_count;
11 recorded_sample_count = safepoint_sample_count;
12 recorded_gc_sample_count = safepoint_gc_sample_count;
13 if (recorded_sample_count == 0 && recorded_gc_sample_count == 0)
16 /* Another sample signal could be raised while we record these counts */
17 FACTOR_ATOMIC_SUB(&safepoint_sample_count, recorded_sample_count);
18 FACTOR_ATOMIC_SUB(&safepoint_gc_sample_count, recorded_gc_sample_count);
20 samples.push_back(profiling_sample(
21 recorded_sample_count,
22 recorded_gc_sample_count,
24 capture_callstack(ctx)
28 void factor_vm::set_sampling_profiler(bool sampling_p)
30 if (sampling_p == sampling_profiler_p)
34 start_sampling_profiler();
36 end_sampling_profiler();
39 void factor_vm::start_sampling_profiler()
41 safepoint_sample_count = 0;
42 safepoint_gc_sample_count = 0;
44 samples.reserve(10*FACTOR_PROFILE_SAMPLES_PER_SECOND);
45 sampling_profiler_p = true;
46 start_sampling_profiler_timer();
49 void factor_vm::end_sampling_profiler()
51 end_sampling_profiler_timer();
53 sampling_profiler_p = false;
56 void factor_vm::primitive_sampling_profiler()
58 set_sampling_profiler(to_boolean(ctx->pop()));