vm: fix build on windows

db4
Joe Groff 2011-10-31 15:06:34 -07:00
parent 1351e30e52
commit abaa051768
5 changed files with 29 additions and 27 deletions

View File

@ -347,7 +347,7 @@ void factor_vm::end_sampling_profiler_timer()
DWORD wait_result = WaitForSingleObject(sampler_thread,
3000/FACTOR_PROFILE_SAMPLES_PER_SECOND);
if (wait_result != WAIT_OBJECT_0)
TerminateThread(sampler_thread);
TerminateThread(sampler_thread, 0);
sampler_thread = NULL;
}

View File

@ -4,10 +4,10 @@ namespace factor
{
profiling_sample::profiling_sample(factor_vm *vm,
cell sample_count,
cell gc_sample_count,
cell foreign_sample_count,
cell foreign_thread_sample_count,
fixnum sample_count,
fixnum gc_sample_count,
fixnum foreign_sample_count,
fixnum foreign_thread_sample_count,
context *ctx)
:
sample_count(sample_count),
@ -21,10 +21,10 @@ profiling_sample::profiling_sample(factor_vm *vm,
void factor_vm::record_sample()
{
cell recorded_sample_count;
cell recorded_gc_sample_count;
cell recorded_foreign_sample_count;
cell recorded_foreign_thread_sample_count;
fixnum recorded_sample_count;
fixnum recorded_gc_sample_count;
fixnum recorded_foreign_sample_count;
fixnum recorded_foreign_thread_sample_count;
FACTOR_MEMORY_BARRIER();
recorded_sample_count = safepoint_sample_count;

View File

@ -6,13 +6,13 @@ namespace factor
struct profiling_sample
{
// Number of samples taken before the safepoint that recorded the sample
cell sample_count;
fixnum sample_count;
// Number of samples taken during GC
cell gc_sample_count;
fixnum gc_sample_count;
// 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
cell foreign_thread_sample_count;
fixnum foreign_thread_sample_count;
// Active context during sample
context *ctx;
/* The callstack at safepoint time. Indexes to the beginning and ending
@ -20,10 +20,10 @@ struct profiling_sample
cell callstack_begin, callstack_end;
profiling_sample(factor_vm *vm,
cell sample_count,
cell gc_sample_count,
cell foreign_sample_count,
cell foreign_thread_sample_count,
fixnum sample_count,
fixnum gc_sample_count,
fixnum foreign_sample_count,
fixnum foreign_thread_sample_count,
context *ctx);
};

View File

@ -58,24 +58,26 @@ VM_C_API void *factor_memcpy(void *dst, void *src, size_t len);
#if defined(FACTOR_64)
#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) \
InterlockedAdd64(ptr, val)
InterlockedAdd64(reinterpret_cast<volatile LONG64 *>(ptr), val)
#define FACTOR_ATOMIC_SUB(ptr, val) \
InterlockedSub64(ptr, val)
InterlockedAdd64(reinterpret_cast<volatile LONG64 *>(ptr), -val)
#else
#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) \
InterlockedAdd(ptr, val)
InterlockedAdd(reinterpret_cast<volatile LONG *>(ptr), val)
#define FACTOR_ATOMIC_SUB(ptr, val) \
InterlockedSub(ptr, val)
InterlockedAdd(reinterpret_cast<volatile LONG *>(ptr), -val)
#endif

View File

@ -75,10 +75,10 @@ struct factor_vm
/* State kept by the sampling profiler */
std::vector<profiling_sample> samples;
std::vector<code_block*> sample_callstacks;
volatile cell safepoint_sample_count;
volatile cell safepoint_gc_sample_count;
volatile cell safepoint_foreign_sample_count;
volatile cell safepoint_foreign_thread_sample_count;
volatile fixnum safepoint_sample_count;
volatile fixnum safepoint_gc_sample_count;
volatile fixnum safepoint_foreign_sample_count;
volatile fixnum safepoint_foreign_thread_sample_count;
/* GC is off during heap walking */
bool gc_off;