vm: fix build on windows
parent
1351e30e52
commit
abaa051768
|
@ -347,7 +347,7 @@ void factor_vm::end_sampling_profiler_timer()
|
||||||
DWORD wait_result = WaitForSingleObject(sampler_thread,
|
DWORD wait_result = WaitForSingleObject(sampler_thread,
|
||||||
3000/FACTOR_PROFILE_SAMPLES_PER_SECOND);
|
3000/FACTOR_PROFILE_SAMPLES_PER_SECOND);
|
||||||
if (wait_result != WAIT_OBJECT_0)
|
if (wait_result != WAIT_OBJECT_0)
|
||||||
TerminateThread(sampler_thread);
|
TerminateThread(sampler_thread, 0);
|
||||||
sampler_thread = NULL;
|
sampler_thread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@ namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
profiling_sample::profiling_sample(factor_vm *vm,
|
profiling_sample::profiling_sample(factor_vm *vm,
|
||||||
cell sample_count,
|
fixnum sample_count,
|
||||||
cell gc_sample_count,
|
fixnum gc_sample_count,
|
||||||
cell foreign_sample_count,
|
fixnum foreign_sample_count,
|
||||||
cell foreign_thread_sample_count,
|
fixnum foreign_thread_sample_count,
|
||||||
context *ctx)
|
context *ctx)
|
||||||
:
|
:
|
||||||
sample_count(sample_count),
|
sample_count(sample_count),
|
||||||
|
@ -21,10 +21,10 @@ profiling_sample::profiling_sample(factor_vm *vm,
|
||||||
|
|
||||||
void factor_vm::record_sample()
|
void factor_vm::record_sample()
|
||||||
{
|
{
|
||||||
cell recorded_sample_count;
|
fixnum recorded_sample_count;
|
||||||
cell recorded_gc_sample_count;
|
fixnum recorded_gc_sample_count;
|
||||||
cell recorded_foreign_sample_count;
|
fixnum recorded_foreign_sample_count;
|
||||||
cell recorded_foreign_thread_sample_count;
|
fixnum recorded_foreign_thread_sample_count;
|
||||||
|
|
||||||
FACTOR_MEMORY_BARRIER();
|
FACTOR_MEMORY_BARRIER();
|
||||||
recorded_sample_count = safepoint_sample_count;
|
recorded_sample_count = safepoint_sample_count;
|
||||||
|
|
|
@ -6,13 +6,13 @@ namespace factor
|
||||||
struct profiling_sample
|
struct profiling_sample
|
||||||
{
|
{
|
||||||
// Number of samples taken before the safepoint that recorded the sample
|
// Number of samples taken before the safepoint that recorded the sample
|
||||||
cell sample_count;
|
fixnum sample_count;
|
||||||
// Number of samples taken during GC
|
// Number of samples taken during GC
|
||||||
cell gc_sample_count;
|
fixnum gc_sample_count;
|
||||||
// Number of samples taken during foreign code execution
|
// Number of samples taken during foreign code execution
|
||||||
cell foreign_sample_count;
|
fixnum foreign_sample_count;
|
||||||
// Number of samples taken during code execution in non-Factor threads
|
// Number of samples taken during code execution in non-Factor threads
|
||||||
cell foreign_thread_sample_count;
|
fixnum foreign_thread_sample_count;
|
||||||
// Active context during sample
|
// Active context during sample
|
||||||
context *ctx;
|
context *ctx;
|
||||||
/* The callstack at safepoint time. Indexes to the beginning and ending
|
/* The callstack at safepoint time. Indexes to the beginning and ending
|
||||||
|
@ -20,10 +20,10 @@ struct profiling_sample
|
||||||
cell callstack_begin, callstack_end;
|
cell callstack_begin, callstack_end;
|
||||||
|
|
||||||
profiling_sample(factor_vm *vm,
|
profiling_sample(factor_vm *vm,
|
||||||
cell sample_count,
|
fixnum sample_count,
|
||||||
cell gc_sample_count,
|
fixnum gc_sample_count,
|
||||||
cell foreign_sample_count,
|
fixnum foreign_sample_count,
|
||||||
cell foreign_thread_sample_count,
|
fixnum foreign_thread_sample_count,
|
||||||
context *ctx);
|
context *ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,24 +58,26 @@ VM_C_API void *factor_memcpy(void *dst, void *src, size_t len);
|
||||||
#if defined(FACTOR_64)
|
#if defined(FACTOR_64)
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_CAS(ptr, old_val, new_val) \
|
#define FACTOR_ATOMIC_CAS(ptr, old_val, new_val) \
|
||||||
(InterlockedCompareExchange64(ptr, new_val, old_val) == old_val)
|
(InterlockedCompareExchange64( \
|
||||||
|
reinterpret_cast<volatile LONG64 *>(ptr), new_val, old_val) == old_val)
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_ADD(ptr, val) \
|
#define FACTOR_ATOMIC_ADD(ptr, val) \
|
||||||
InterlockedAdd64(ptr, val)
|
InterlockedAdd64(reinterpret_cast<volatile LONG64 *>(ptr), val)
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_SUB(ptr, val) \
|
#define FACTOR_ATOMIC_SUB(ptr, val) \
|
||||||
InterlockedSub64(ptr, val)
|
InterlockedAdd64(reinterpret_cast<volatile LONG64 *>(ptr), -val)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_CAS(ptr, old_val, new_val) \
|
#define FACTOR_ATOMIC_CAS(ptr, old_val, new_val) \
|
||||||
(InterlockedCompareExchange(ptr, new_val, old_val) == old_val)
|
(InterlockedCompareExchange( \
|
||||||
|
reinterpret_cast<volatile LONG *>(ptr), new_val, old_val) == old_val)
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_ADD(ptr, val) \
|
#define FACTOR_ATOMIC_ADD(ptr, val) \
|
||||||
InterlockedAdd(ptr, val)
|
InterlockedAdd(reinterpret_cast<volatile LONG *>(ptr), val)
|
||||||
|
|
||||||
#define FACTOR_ATOMIC_SUB(ptr, val) \
|
#define FACTOR_ATOMIC_SUB(ptr, val) \
|
||||||
InterlockedSub(ptr, val)
|
InterlockedAdd(reinterpret_cast<volatile LONG *>(ptr), -val)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,10 @@ struct factor_vm
|
||||||
/* State kept by the sampling profiler */
|
/* State kept by the sampling profiler */
|
||||||
std::vector<profiling_sample> samples;
|
std::vector<profiling_sample> samples;
|
||||||
std::vector<code_block*> sample_callstacks;
|
std::vector<code_block*> sample_callstacks;
|
||||||
volatile cell safepoint_sample_count;
|
volatile fixnum safepoint_sample_count;
|
||||||
volatile cell safepoint_gc_sample_count;
|
volatile fixnum safepoint_gc_sample_count;
|
||||||
volatile cell safepoint_foreign_sample_count;
|
volatile fixnum safepoint_foreign_sample_count;
|
||||||
volatile cell safepoint_foreign_thread_sample_count;
|
volatile fixnum safepoint_foreign_thread_sample_count;
|
||||||
|
|
||||||
/* GC is off during heap walking */
|
/* GC is off during heap walking */
|
||||||
bool gc_off;
|
bool gc_off;
|
||||||
|
|
Loading…
Reference in New Issue