get sampler working under windows

db4
Joe Groff 2011-10-31 16:50:21 -07:00
parent 252915a37c
commit d9afe92c97
4 changed files with 12 additions and 2 deletions

View File

@ -390,6 +390,9 @@ void factor_vm::factorbug()
exit(1);
}
if (sampling_profiler_p)
end_sampling_profiler();
fep_p = true;
std::cout << "Starting low level debugger..." << std::endl;

View File

@ -312,7 +312,7 @@ void factor_vm::sampler_thread_loop()
assert(QueryPerformanceCounter(&counter));
while (FACTOR_MEMORY_BARRIER(), sampling_profiler_p)
{
Sleep(0);
SwitchToThread();
assert(QueryPerformanceCounter(&new_counter));
cell samples = 0;
while (new_counter.QuadPart - counter.QuadPart > units_per_sample) {
@ -320,6 +320,7 @@ void factor_vm::sampler_thread_loop()
++samples;
counter.QuadPart += units_per_sample;
}
if (samples > 0)
enqueue_safepoint_sample(samples, 0, false);
}
}
@ -344,6 +345,8 @@ void factor_vm::start_sampling_profiler_timer()
void factor_vm::end_sampling_profiler_timer()
{
sampling_profiler_p = false;
FACTOR_MEMORY_BARRIER();
DWORD wait_result = WaitForSingleObject(sampler_thread,
3000/FACTOR_PROFILE_SAMPLES_PER_SECOND);
if (wait_result != WAIT_OBJECT_0)

View File

@ -92,6 +92,8 @@ void factor_vm::start_sampling_profiler()
{
safepoint_sample_count = 0;
safepoint_gc_sample_count = 0;
safepoint_foreign_sample_count = 0;
safepoint_foreign_thread_sample_count = 0;
clear_samples();
samples.reserve(10*FACTOR_PROFILE_SAMPLES_PER_SECOND);
sample_callstacks.reserve(100*FACTOR_PROFILE_SAMPLES_PER_SECOND);

View File

@ -12,6 +12,8 @@ factor_vm::factor_vm() :
safepoint_fep(false),
safepoint_sample_count(0),
safepoint_gc_sample_count(0),
safepoint_foreign_sample_count(0),
safepoint_foreign_thread_sample_count(0),
gc_off(false),
current_gc(NULL),
gc_events(NULL),