vm: sample thread object rather than raw context
parent
fb837b91dc
commit
be8db5aed3
|
@ -29,10 +29,10 @@ void profiling_sample_count::clear() volatile
|
||||||
|
|
||||||
profiling_sample::profiling_sample(factor_vm *vm,
|
profiling_sample::profiling_sample(factor_vm *vm,
|
||||||
profiling_sample_count const &counts,
|
profiling_sample_count const &counts,
|
||||||
context *ctx)
|
cell thread)
|
||||||
:
|
:
|
||||||
counts(counts),
|
counts(counts),
|
||||||
ctx(ctx)
|
thread(thread)
|
||||||
{
|
{
|
||||||
vm->record_callstack_sample(&callstack_begin, &callstack_end);
|
vm->record_callstack_sample(&callstack_begin, &callstack_end);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ void factor_vm::record_sample()
|
||||||
{
|
{
|
||||||
profiling_sample_count counts = safepoint_sample_counts.record_counts();
|
profiling_sample_count counts = safepoint_sample_counts.record_counts();
|
||||||
if (!counts.empty())
|
if (!counts.empty())
|
||||||
samples.push_back(profiling_sample(this, counts, ctx));
|
samples.push_back(profiling_sample(this,
|
||||||
|
counts, special_objects[OBJ_CURRENT_THREAD]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::record_callstack_sample(cell *begin, cell *end)
|
void factor_vm::record_callstack_sample(cell *begin, cell *end)
|
||||||
|
@ -121,8 +122,7 @@ void factor_vm::primitive_get_samples()
|
||||||
set_array_nth(sample.untagged(),2,tag_fixnum(from_iter->counts.foreign_sample_count));
|
set_array_nth(sample.untagged(),2,tag_fixnum(from_iter->counts.foreign_sample_count));
|
||||||
set_array_nth(sample.untagged(),3,tag_fixnum(from_iter->counts.foreign_thread_sample_count));
|
set_array_nth(sample.untagged(),3,tag_fixnum(from_iter->counts.foreign_thread_sample_count));
|
||||||
|
|
||||||
cell ctx = allot_alien((void*)from_iter->ctx);
|
set_array_nth(sample.untagged(),4,from_iter->thread);
|
||||||
set_array_nth(sample.untagged(),4,ctx);
|
|
||||||
|
|
||||||
cell callstack_size = from_iter->callstack_end - from_iter->callstack_begin;
|
cell callstack_size = from_iter->callstack_end - from_iter->callstack_begin;
|
||||||
data_root<array> callstack(allot_array(callstack_size,false_object),this);
|
data_root<array> callstack(allot_array(callstack_size,false_object),this);
|
||||||
|
|
|
@ -43,15 +43,15 @@ struct profiling_sample
|
||||||
{
|
{
|
||||||
// Sample counts
|
// Sample counts
|
||||||
profiling_sample_count counts;
|
profiling_sample_count counts;
|
||||||
// Active context during sample
|
// Active thread during sample
|
||||||
context *ctx;
|
cell thread;
|
||||||
/* The callstack at safepoint time. Indexes to the beginning and ending
|
/* The callstack at safepoint time. Indexes to the beginning and ending
|
||||||
code_block entries in the vm sample_callstacks array. */
|
code_block entries in the vm sample_callstacks array. */
|
||||||
cell callstack_begin, callstack_end;
|
cell callstack_begin, callstack_end;
|
||||||
|
|
||||||
profiling_sample(factor_vm *vm,
|
profiling_sample(factor_vm *vm,
|
||||||
profiling_sample_count const &counts,
|
profiling_sample_count const &counts,
|
||||||
context *ctx);
|
cell thread);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ template<typename Fixup> struct slot_visitor {
|
||||||
void visit_code_block_objects(code_block *compiled);
|
void visit_code_block_objects(code_block *compiled);
|
||||||
void visit_embedded_literals(code_block *compiled);
|
void visit_embedded_literals(code_block *compiled);
|
||||||
void visit_sample_callstacks();
|
void visit_sample_callstacks();
|
||||||
|
void visit_sample_threads();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Fixup>
|
template<typename Fixup>
|
||||||
|
@ -261,6 +262,17 @@ void slot_visitor<Fixup>::visit_sample_callstacks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Fixup>
|
||||||
|
void slot_visitor<Fixup>::visit_sample_threads()
|
||||||
|
{
|
||||||
|
for (std::vector<profiling_sample>::iterator iter = parent->samples.begin();
|
||||||
|
iter != parent->samples.end();
|
||||||
|
++iter)
|
||||||
|
{
|
||||||
|
visit_handle(&iter->thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Fixup>
|
template<typename Fixup>
|
||||||
void slot_visitor<Fixup>::visit_roots()
|
void slot_visitor<Fixup>::visit_roots()
|
||||||
{
|
{
|
||||||
|
@ -274,6 +286,7 @@ void slot_visitor<Fixup>::visit_roots()
|
||||||
visit_callback_roots();
|
visit_callback_roots();
|
||||||
visit_literal_table_roots();
|
visit_literal_table_roots();
|
||||||
visit_sample_callstacks();
|
visit_sample_callstacks();
|
||||||
|
visit_sample_threads();
|
||||||
|
|
||||||
visit_object_array(parent->special_objects,parent->special_objects + special_object_count);
|
visit_object_array(parent->special_objects,parent->special_objects + special_object_count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue