void iterate_active_callstacks(Iterator &iter, Fixup &fixup) { std::set<context *>::const_iterator begin = active_contexts.begin(); std::set<context *>::const_iterator end = active_contexts.end(); while(begin != end) { iterate_callstack(*begin++,iter,fixup); } }
template<typename Iterator> void iterate_active_frames(Iterator &iter) { context *ctx = this->ctx; while(ctx) { iterate_callstack(ctx,iter); if(ctx->magic_frame) iter(ctx->magic_frame); ctx = ctx->next; } }
void factor_vm::record_sample(bool prolog_p) { profiling_sample_count counts = sample_counts.record_counts(); if (counts.empty()) { return; } // Appends the callstack, which is just a sequence of quotation or // word references, to sample_callstacks. cell begin = sample_callstacks.size(); bool skip_p = prolog_p; auto recorder = [&](cell frame_top, cell size, code_block* owner, cell addr) { if (skip_p) skip_p = false; else sample_callstacks.push_back(owner->owner); }; iterate_callstack(ctx, recorder); cell end = sample_callstacks.size(); // Add the sample. cell thread = special_objects[OBJ_CURRENT_THREAD]; samples.push_back(profiling_sample(counts, thread, begin, end)); }
template<typename Iterator> void iterate_active_callstacks(Iterator &iter) { std::set<context *>::const_iterator begin = active_contexts.begin(); std::set<context *>::const_iterator end = active_contexts.end(); while(begin != end) iterate_callstack(*begin++,iter); }
inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) { no_fixup none; iterate_callstack(ctx, iterator, none); }
template<typename T> void iterate_callstack_object(callstack *stack, T &iterator) { iterate_callstack((cell)stack->top(),(cell)stack->bottom(),iterator); }
void factor_vm::scrub_context(context *ctx) { call_frame_scrubber scrubber(this,ctx); iterate_callstack(ctx,scrubber); }