vm: sample code block owners instead of blocks
							parent
							
								
									e880095da3
								
							
						
					
					
						commit
						7da8a9776f
					
				| 
						 | 
				
			
			@ -24,7 +24,6 @@ template<typename Fixup> struct code_block_visitor {
 | 
			
		|||
	void visit_embedded_code_pointers(code_block *compiled);
 | 
			
		||||
	void visit_context_code_blocks();
 | 
			
		||||
	void visit_uninitialized_code_blocks();
 | 
			
		||||
	void visit_sample_callstacks();
 | 
			
		||||
 | 
			
		||||
	void visit_code_roots();
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -136,22 +135,10 @@ void code_block_visitor<Fixup>::visit_uninitialized_code_blocks()
 | 
			
		|||
	parent->code->uninitialized_blocks = new_uninitialized_blocks;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Fixup>
 | 
			
		||||
void code_block_visitor<Fixup>::visit_sample_callstacks()
 | 
			
		||||
{
 | 
			
		||||
	for (std::vector<code_block *>::iterator iter = parent->sample_callstacks.begin();
 | 
			
		||||
		iter != parent->sample_callstacks.end();
 | 
			
		||||
		++iter)
 | 
			
		||||
	{
 | 
			
		||||
		*iter = fixup.fixup_code(*iter);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Fixup>
 | 
			
		||||
void code_block_visitor<Fixup>::visit_code_roots()
 | 
			
		||||
{
 | 
			
		||||
	visit_uninitialized_code_blocks();
 | 
			
		||||
	visit_sample_callstacks();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ void factor_vm::record_callstack_sample(cell *begin, cell *end)
 | 
			
		|||
	stack_frame *frame = ctx->bottom_frame();
 | 
			
		||||
 | 
			
		||||
	while (frame >= ctx->callstack_top) {
 | 
			
		||||
		sample_callstacks.push_back(frame_code(frame));
 | 
			
		||||
		sample_callstacks.push_back(frame_code(frame)->owner);
 | 
			
		||||
		frame = frame_successor(frame);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ void factor_vm::clear_samples()
 | 
			
		|||
	// Swapping into temporaries releases the vector's allocated storage,
 | 
			
		||||
	// whereas clear() would leave the allocation as-is
 | 
			
		||||
	std::vector<profiling_sample> sample_graveyard;
 | 
			
		||||
	std::vector<code_block*> sample_callstack_graveyard;
 | 
			
		||||
	std::vector<cell> sample_callstack_graveyard;
 | 
			
		||||
	samples.swap(sample_graveyard);
 | 
			
		||||
	sample_callstacks.swap(sample_callstack_graveyard);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -127,14 +127,14 @@ void factor_vm::primitive_get_samples()
 | 
			
		|||
			cell callstack_size = from_iter->callstack_end - from_iter->callstack_begin;
 | 
			
		||||
			data_root<array> callstack(allot_array(callstack_size,false_object),this);
 | 
			
		||||
 | 
			
		||||
			std::vector<code_block*>::const_iterator
 | 
			
		||||
			std::vector<cell>::const_iterator
 | 
			
		||||
				callstacks_begin = sample_callstacks.begin(),
 | 
			
		||||
				c_from_iter = callstacks_begin + from_iter->callstack_begin,
 | 
			
		||||
				c_from_iter_end = callstacks_begin + from_iter->callstack_end;
 | 
			
		||||
			cell c_to_i = 0;
 | 
			
		||||
 | 
			
		||||
			for (; c_from_iter != c_from_iter_end; ++c_from_iter, ++c_to_i)
 | 
			
		||||
				set_array_nth(callstack.untagged(),c_to_i,(*c_from_iter)->owner);
 | 
			
		||||
				set_array_nth(callstack.untagged(),c_to_i,*c_from_iter);
 | 
			
		||||
 | 
			
		||||
			set_array_nth(sample.untagged(),5,callstack.value());
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -134,6 +134,7 @@ template<typename Fixup> struct slot_visitor {
 | 
			
		|||
	void visit_contexts();
 | 
			
		||||
	void visit_code_block_objects(code_block *compiled);
 | 
			
		||||
	void visit_embedded_literals(code_block *compiled);
 | 
			
		||||
	void visit_sample_callstacks();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template<typename Fixup>
 | 
			
		||||
| 
						 | 
				
			
			@ -249,6 +250,17 @@ void slot_visitor<Fixup>::visit_literal_table_roots()
 | 
			
		|||
	parent->code->uninitialized_blocks = new_uninitialized_blocks;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Fixup>
 | 
			
		||||
void slot_visitor<Fixup>::visit_sample_callstacks()
 | 
			
		||||
{
 | 
			
		||||
	for (std::vector<cell>::iterator iter = parent->sample_callstacks.begin();
 | 
			
		||||
		iter != parent->sample_callstacks.end();
 | 
			
		||||
		++iter)
 | 
			
		||||
	{
 | 
			
		||||
		visit_handle(&*iter);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<typename Fixup>
 | 
			
		||||
void slot_visitor<Fixup>::visit_roots()
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -261,6 +273,7 @@ void slot_visitor<Fixup>::visit_roots()
 | 
			
		|||
	visit_bignum_roots();
 | 
			
		||||
	visit_callback_roots();
 | 
			
		||||
	visit_literal_table_roots();
 | 
			
		||||
	visit_sample_callstacks();
 | 
			
		||||
 | 
			
		||||
	visit_object_array(parent->special_objects,parent->special_objects + special_object_count);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,7 +75,7 @@ struct factor_vm
 | 
			
		|||
 | 
			
		||||
	/* State kept by the sampling profiler */
 | 
			
		||||
	std::vector<profiling_sample> samples;
 | 
			
		||||
	std::vector<code_block*> sample_callstacks;
 | 
			
		||||
	std::vector<cell> sample_callstacks;
 | 
			
		||||
	volatile profiling_sample_count safepoint_sample_counts;
 | 
			
		||||
 | 
			
		||||
	/* GC is off during heap walking */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue