Verified Commit 730fe1db authored by Camil Staps's avatar Camil Staps
Browse files

Add support for callgraph profiling; thunks receive an extra B-stack field to...

Add support for callgraph profiling; thunks receive an extra B-stack field to keep track of the cost centre where they have been created
parent be206b84
Loading
Loading
Loading
Loading
+6
Changes for cgaas.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5647,6 +5647,12 @@ static void write_code (void)
				store_l (0);
			*/

			if (callgraph_profiling && block->block_n_node_arguments>=0){
				if (block->block_descriptor && block->block_descriptor->label_name!=NULL && !strcmp (block->block_descriptor->label_name,"EMPTY"))
					store_l (0);
				else
					store_l (block->block_n_node_arguments+257);
			} else
				store_l (block->block_n_node_arguments);
		}
#ifdef NEW_APPLY
+6
Changes for cgawas.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4455,6 +4455,12 @@ void write_assembly (VOID)
#ifdef GENERATIONAL_GC
			}
#endif
			if (callgraph_profiling && block->block_n_node_arguments>=0){
				if (block->block_descriptor && block->block_descriptor->label_name!=NULL && !strcmp (block->block_descriptor->label_name,"EMPTY"))
					w_as_number_of_arguments (0);
				else
					w_as_number_of_arguments (block->block_n_node_arguments+257);
			} else
				w_as_number_of_arguments (block->block_n_node_arguments);
		}
#ifdef NEW_APPLY
+77
Changes for cgcode.c: 77 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -230,6 +230,8 @@ int no_memory_profiling;

#ifdef PROFILE
int no_time_profiling;
int callgraph_profiling;
static LABEL *profile_current_cost_centre_label;
#endif

#define g_add(g1,g2) g_instruction_2(GADD,(g1),(g2))
@@ -833,6 +835,10 @@ void code_build (char descriptor_name[],int arity,char *code_name)

	if (strcmp (code_name,"__hnf")==0){
		code_buildh (descriptor_name,arity);
#ifdef PROFILE
	} else if (callgraph_profiling){
		code_build_u (descriptor_name,arity<0 ? 1 : arity,0,code_name);
#endif
	} else {
		int n_arguments;
		union instruction_parameter *parameter;
@@ -1146,6 +1152,11 @@ void code_build_u (char descriptor_name[],int a_size,int b_size,char *code_name)
	int n_arguments;
	union instruction_parameter *parameter;

#ifdef PROFILE
	if (callgraph_profiling)
		++b_size;
#endif

	code_label=enter_label (code_name,NODE_ENTRY_LABEL);
	code_label->label_arity=a_size+b_size+(b_size<<8);

@@ -1174,6 +1185,24 @@ void code_build_u (char descriptor_name[],int a_size,int b_size,char *code_name)
		++parameter;
	}

#ifdef PROFILE
	if (callgraph_profiling){
		INSTRUCTION_GRAPH graph_5;

		--b_size;

		if (profile_current_cost_centre_label==NULL)
# ifdef MACH_O64
			profile_current_cost_centre_label=enter_label ("_profile_current_cost_centre",IMPORT_LABEL | DATA_LABEL);
# else
			profile_current_cost_centre_label=enter_label ("profile_current_cost_centre",IMPORT_LABEL | DATA_LABEL);
# endif
		graph_4=g_lea (profile_current_cost_centre_label);
		graph_5=g_load_id (0,graph_4);
		parameter[b_size].p=graph_5;
	}
#endif

	for (n_arguments=b_size; n_arguments>0; --n_arguments){
		graph_4=s_pop_b();
		parameter->p=graph_4;
@@ -2307,6 +2336,11 @@ void code_create (int n_arguments)
	if (EMPTY_label==NULL)
		EMPTY_label=enter_label ("EMPTY",IMPORT_LABEL | DATA_LABEL);

#ifdef PROFILE
	if (callgraph_profiling)
		n_arguments++;
#endif

	if (n_arguments<=2){
#ifndef RESERVE_CODE_REGISTER
		if (!parallel_flag){
@@ -3036,6 +3070,10 @@ void code_fill (char descriptor_name[],int arity,char *code_name,int a_offset)

	if (strcmp (code_name,"__hnf")==0){
		code_fillh (descriptor_name,arity,a_offset);
#ifdef PROFILE
	} else if (callgraph_profiling){
		code_fill_u (descriptor_name,arity<0 ? 1 : arity,0,code_name,a_offset);
#endif
	} else {
		int n_arguments;
		union instruction_parameter *parameter;
@@ -3219,6 +3257,11 @@ void code_fill_u (char descriptor_name[],int a_size,int b_size,char *code_name,i

	graph_1=s_get_a (a_offset);

#ifdef PROFILE
	if (callgraph_profiling)
		++b_size;
#endif

	code_label=enter_label (code_name,NODE_ENTRY_LABEL);
	code_label->label_arity=a_size+b_size+(b_size<<8);

@@ -3250,6 +3293,24 @@ void code_fill_u (char descriptor_name[],int a_size,int b_size,char *code_name,i
		++parameter;
	}

#ifdef PROFILE
	if (callgraph_profiling){
		INSTRUCTION_GRAPH graph_5;

		--b_size;

		if (profile_current_cost_centre_label==NULL)
# ifdef MACH_O64
			profile_current_cost_centre_label=enter_label ("_profile_current_cost_centre",IMPORT_LABEL | DATA_LABEL);
# else
			profile_current_cost_centre_label=enter_label ("profile_current_cost_centre",IMPORT_LABEL | DATA_LABEL);
# endif
		graph_4=g_lea (profile_current_cost_centre_label);
		graph_5=g_load_id (0,graph_4);
		parameter[b_size].p=graph_5;
	}
#endif

	for (; argument_n<a_size+b_size; ++argument_n){
		graph_4=s_pop_b();
		parameter->p=graph_4;
@@ -9331,6 +9392,7 @@ void code_comp (int version,char *options)
	no_memory_profiling = system_file && l>3 && options[3]=='1';
# ifdef PROFILE
	no_time_profiling   = system_file && l>5 && options[5]=='1';
	callgraph_profiling = l>13 && options[13]=='1';
# endif
#endif
}
@@ -10277,6 +10339,12 @@ void code_pb (char string[],int string_length)
		w_as_new_data_module();
# endif

	if (callgraph_profiling){
		store_long_word_in_data_section (0);
		if (assembly_flag)
			w_as_long_in_data_section (0);
	}

#if TIME_PROFILE_WITH_MODULE_NAMES
	if (module_label!=NULL){
# ifdef GEN_OBJ
@@ -10296,6 +10364,7 @@ void code_pb (char string[],int string_length)

# ifdef GEN_OBJ
	define_data_label (profile_function_label);
	if (!callgraph_profiling)
#  ifdef G_A64
		store_word64_in_data_section (0);
#  else
@@ -10323,6 +10392,7 @@ void code_pb (char string[],int string_length)
#  endif
		w_as_define_data_label (profile_function_label->label_number);
# endif
		if (!callgraph_profiling)
# ifdef G_A64
			w_as_word64_in_data_section ((int_64)0);
# else
@@ -10518,6 +10588,13 @@ void code_module (char label_name[],char string[],int string_length)
#else
	module_label=code_string_or_module (label_name,string,string_length);
#endif
#ifdef PROFILE
	if (callgraph_profiling){
		store_long_word_in_data_section (0);
		if (assembly_flag)
			w_as_long_in_data_section (0);
	}
#endif
}

void code_label (char *label_name)
+1
Changes for cgcode.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ extern LABEL *profile_ti_label;
extern INSTRUCTION_GRAPH load_indexed_list;

extern int no_memory_profiling;
extern int callgraph_profiling;

#define PROFILE_NOT 0
#define PROFILE_NORMAL 1