VM: Refactor safepoints.cpp/hpp to Factor style
parent
debdb11538
commit
2af4b6a7e6
|
@ -1,61 +1,53 @@
|
||||||
#include "master.hpp"
|
#include "master.hpp"
|
||||||
|
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
void safepoint_state::enqueue_safepoint(factor_vm *parent) volatile
|
void safepoint_state::enqueue_safepoint(factor_vm* parent) volatile {
|
||||||
{
|
parent->code->guard_safepoint();
|
||||||
parent->code->guard_safepoint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void safepoint_state::enqueue_fep(factor_vm *parent) volatile
|
void safepoint_state::enqueue_fep(factor_vm* parent) volatile {
|
||||||
{
|
if (parent->fep_p)
|
||||||
if (parent->fep_p)
|
fatal_error("Low-level debugger interrupted", 0);
|
||||||
fatal_error("Low-level debugger interrupted", 0);
|
atomic::store(&fep_p, true);
|
||||||
atomic::store(&fep_p, true);
|
enqueue_safepoint(parent);
|
||||||
enqueue_safepoint(parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void safepoint_state::enqueue_samples(factor_vm *parent, cell samples, cell pc, bool foreign_thread_p) volatile
|
void safepoint_state::enqueue_samples(factor_vm* parent, cell samples, cell pc,
|
||||||
{
|
bool foreign_thread_p) volatile {
|
||||||
if (atomic::load(&parent->sampling_profiler_p))
|
if (atomic::load(&parent->sampling_profiler_p)) {
|
||||||
{
|
atomic::fetch_add(&sample_counts.sample_count, samples);
|
||||||
atomic::fetch_add(&sample_counts.sample_count, samples);
|
if (foreign_thread_p)
|
||||||
if (foreign_thread_p)
|
atomic::fetch_add(&sample_counts.foreign_thread_sample_count, samples);
|
||||||
atomic::fetch_add(&sample_counts.foreign_thread_sample_count, samples);
|
else {
|
||||||
else {
|
if (atomic::load(&parent->current_gc_p))
|
||||||
if (atomic::load(&parent->current_gc_p))
|
atomic::fetch_add(&sample_counts.gc_sample_count, samples);
|
||||||
atomic::fetch_add(&sample_counts.gc_sample_count, samples);
|
if (atomic::load(&parent->current_jit_count) > 0)
|
||||||
if (atomic::load(&parent->current_jit_count) > 0)
|
atomic::fetch_add(&sample_counts.jit_sample_count, samples);
|
||||||
atomic::fetch_add(&sample_counts.jit_sample_count, samples);
|
if (!parent->code->seg->in_segment_p(pc))
|
||||||
if (!parent->code->seg->in_segment_p(pc))
|
atomic::fetch_add(&sample_counts.foreign_sample_count, samples);
|
||||||
atomic::fetch_add(&sample_counts.foreign_sample_count, samples);
|
}
|
||||||
}
|
enqueue_safepoint(parent);
|
||||||
enqueue_safepoint(parent);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void safepoint_state::handle_safepoint(factor_vm *parent, cell pc) volatile
|
void safepoint_state::handle_safepoint(factor_vm* parent, cell pc) volatile {
|
||||||
{
|
parent->code->unguard_safepoint();
|
||||||
parent->code->unguard_safepoint();
|
parent->faulting_p = false;
|
||||||
parent->faulting_p = false;
|
|
||||||
|
|
||||||
if (atomic::load(&fep_p))
|
if (atomic::load(&fep_p)) {
|
||||||
{
|
if (atomic::load(&parent->sampling_profiler_p))
|
||||||
if (atomic::load(&parent->sampling_profiler_p))
|
parent->end_sampling_profiler();
|
||||||
parent->end_sampling_profiler();
|
std::cout << "Interrupted\n";
|
||||||
std::cout << "Interrupted\n";
|
parent->factorbug();
|
||||||
parent->factorbug();
|
atomic::store(&fep_p, false);
|
||||||
atomic::store(&fep_p, false);
|
} else if (atomic::load(&parent->sampling_profiler_p)) {
|
||||||
}
|
FACTOR_ASSERT(parent->code->seg->in_segment_p(pc));
|
||||||
else if (atomic::load(&parent->sampling_profiler_p))
|
code_block* block = parent->code->code_block_for_address(pc);
|
||||||
{
|
bool prolog_p = (cell) block->entry_point() == pc;
|
||||||
FACTOR_ASSERT(parent->code->seg->in_segment_p(pc));
|
|
||||||
code_block *block = parent->code->code_block_for_address(pc);
|
|
||||||
bool prolog_p = (cell)block->entry_point() == pc;
|
|
||||||
|
|
||||||
parent->record_sample(prolog_p);
|
parent->record_sample(prolog_p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
struct safepoint_state
|
struct safepoint_state {
|
||||||
{
|
cell fep_p;
|
||||||
cell fep_p;
|
profiling_sample_count sample_counts;
|
||||||
profiling_sample_count sample_counts;
|
|
||||||
|
|
||||||
safepoint_state() :
|
safepoint_state() : fep_p(false), sample_counts() {}
|
||||||
fep_p(false),
|
|
||||||
sample_counts()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void handle_safepoint(factor_vm *parent, cell pc) volatile;
|
void handle_safepoint(factor_vm* parent, cell pc) volatile;
|
||||||
|
|
||||||
void enqueue_safepoint(factor_vm *parent) volatile;
|
void enqueue_safepoint(factor_vm* parent) volatile;
|
||||||
void enqueue_samples(factor_vm *parent, cell samples, cell pc, bool foreign_thread_p) volatile;
|
void enqueue_samples(factor_vm* parent, cell samples, cell pc,
|
||||||
void enqueue_fep(factor_vm *parent) volatile;
|
bool foreign_thread_p) volatile;
|
||||||
|
void enqueue_fep(factor_vm* parent) volatile;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue