[m-rev.] for review: deep profiling enchancements

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jun 4 15:01:57 AEST 2001


For review by Tom.

Enhance deep profiling by

	(1) optimizing self-tail-recursive calls by using a single service
	function, prepare_for_tail_call, instead of the prepare_for_normal_call
	and call_code pair. Since there is no callcode in the inner procedure,
	the inner procedure doesn't pick up the value of MiddleCSD, and thus
	cannot pass it to other service functions. Those functions therefore
	now pick up MiddleCSD from the global current_call_site_dynamic.

	We also avoid calling set_current_csd in the exit and failure
	continuations after tail calls in the outer procedure, since their
	effects will be overridden by the exitcode or failcode of the outer
	procedure.

	(2) using a prepare_for_method_call that is separate from
	prepare_for_ho_call, since extracting a key from a typeclass_info
	as if it were a closure is not robust

	(3) adding callcode/exitcode/failcode to the unify/compare routines
	for the builtin types. This is necessary to record their identities
	and to count their exits and fails.

	The resulting system should conform to the invariant that
	every prepare_for_special_call is matched either by the callcode
	of a builtin unify/compare routine or by the callcode of a
	compiler-generated __Unify__ or __Compare__ procedure.

The third change records information that we need. It leads to slowdown, but
the speedup from the first change more than compensates for it. (The second
change is performance neutral.)

compiler/deep_profiling:
	Modify the source transformation to achieve the effects described
	above.

library/profiling_builtin.m:
	Add prepare_for_tail_call and prepare_for_method_call.

	Remove MiddleCSD from the argument list of service functions that do
	not need it.

	Delete two unused predicates.

runtime/mercury_deep_profiling_hand.h:
	Do not pass MiddleCSD to the service functions from which that argument
	was removed.

runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
	Fix a situation in which one local variable shadowed another.

runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
	Add callcode/exitcode/failcode to the unify and compare routines
	of builtin types. Since these routines never call any other routine,
	we combine callcode/exitcode and callcode/failcode into one action.

	Write out the proc_static structures of the unify/compare procedures
	for the builtin types.

runtime/mercury_deep_profiling.[ch]:
	Add statistics for the new service functions.

	Add statistics for callbacks, for the sake of completeness.

	Delete an unused argument from the histogram statistics functions.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.2
diff -u -b -r1.2 deep_profiling.m
--- compiler/deep_profiling.m	2001/05/31 05:59:32	1.2
+++ compiler/deep_profiling.m	2001/06/02 03:28:01
@@ -858,19 +858,16 @@
 	proc_info_varset(Proc0, Vars0),
 	proc_info_vartypes(Proc0, VarTypes0),
 	CPointerType = c_pointer_type,
-	varset__new_named_var(Vars0, "TopCSD", TopCSD, Vars1),
-	map__set(VarTypes0, TopCSD, CPointerType, VarTypes1),
-	varset__new_named_var(Vars1, "MiddleCSD", MiddleCSD, Vars2),
-	map__set(VarTypes1, MiddleCSD, CPointerType, VarTypes2),
-	varset__new_named_var(Vars2, "ProcStatic", ProcStaticVar, Vars3),
-	map__set(VarTypes2, ProcStaticVar, CPointerType, VarTypes3),
+	% MiddleCSD should be unused
+	varset__new_named_var(Vars0, "MiddleCSD", MiddleCSD, Vars1),
+	map__set(VarTypes0, MiddleCSD, CPointerType, VarTypes1),
 
 	goal_info_get_context(GoalInfo0, Context),
 	FileName = term__context_file(Context),
 
 	proc_info_get_maybe_deep_profile_info(Proc0, MaybeRecInfo),
 	DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD,
-		counter__init(0), [], Vars3, VarTypes3,
+		counter__init(0), [], Vars1, VarTypes1,
 		FileName, MaybeRecInfo),
 
 	transform_goal([], Goal0, TransformedGoal, DeepInfo0, DeepInfo),
@@ -878,31 +875,9 @@
 	Vars = DeepInfo ^ vars,
 	VarTypes = DeepInfo ^ var_types,
 
-	(
-		MaybeRecInfo = yes(RecInfo),
-		RecInfo ^ role = inner_proc(OuterPredProcId)
-	->
-		OuterPredProcId = proc(PredId, ProcId)
-	;
-		error("transform_inner_proc: no rec_info")
-	),
-
-	RttiProcLabel = rtti__make_proc_label(ModuleInfo, PredId, ProcId),
-	ProcStaticConsId = deep_profiling_proc_static(RttiProcLabel),
-	generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal),
-
-	generate_call(ModuleInfo, "inner_call_port_code", 2,
-		[ProcStaticVar, MiddleCSD], [MiddleCSD], CallPortCode),
-
-	Goal = conj([
-		BindProcStaticVarGoal,
-		CallPortCode,
-		TransformedGoal
-	]) - GoalInfo0,
-
 	proc_info_set_varset(Proc0, Vars, Proc1),
 	proc_info_set_vartypes(Proc1, VarTypes, Proc2),
-	proc_info_set_goal(Proc2, Goal, Proc).
+	proc_info_set_goal(Proc2, TransformedGoal, Proc).
 
 %-----------------------------------------------------------------------------%
 
@@ -1007,23 +982,17 @@
 wrap_call(GoalPath, Goal0, Goal, DeepInfo0, DeepInfo) :-
 	Goal0 = GoalExpr - GoalInfo0,
 	ModuleInfo = DeepInfo0 ^ module_info,
-	MiddleCSD = DeepInfo0 ^ current_csd,
-
-	goal_info_get_nonlocals(GoalInfo0, NonLocals0),
 	goal_info_get_features(GoalInfo0, GoalFeatures),
-	NewNonlocals = set__make_singleton_set(MiddleCSD),
-	NonLocals = union(NonLocals0, NewNonlocals),
-	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo1),
-	goal_info_remove_feature(GoalInfo1, tailcall, GoalInfo),
+	goal_info_remove_feature(GoalInfo0, tailcall, GoalInfo),
 
 	SiteNumCounter0 = DeepInfo0 ^ site_num_counter,
 	counter__allocate(SiteNum, SiteNumCounter0, SiteNumCounter),
-	varset__new_named_var(DeepInfo0 ^ vars, "SiteNum", SiteNumVar, Vars),
+	varset__new_named_var(DeepInfo0 ^ vars, "SiteNum", SiteNumVar, Vars1),
 	IntType = int_type,
-	map__set(DeepInfo0 ^ var_types, SiteNumVar, IntType, VarTypes),
+	map__set(DeepInfo0 ^ var_types, SiteNumVar, IntType, VarTypes1),
 	generate_unify(int_const(SiteNum), SiteNumVar, SiteNumVarGoal),
-	DeepInfo1 = (((DeepInfo0 ^ vars := Vars)
-		^ var_types := VarTypes)
+	DeepInfo1 = (((DeepInfo0 ^ vars := Vars1)
+		^ var_types := VarTypes1)
 		^ site_num_counter := SiteNumCounter),
 
 	goal_info_get_context(GoalInfo0, Context),
@@ -1033,8 +1002,13 @@
 	classify_call(ModuleInfo, GoalExpr, CallKind),
 	(
 		CallKind = normal(PredProcId),
-		generate_call(ModuleInfo, "prepare_for_normal_call", 2,
-			[MiddleCSD, SiteNumVar], [], PrepareGoal),
+		( member(tailcall, GoalFeatures) ->
+			generate_call(ModuleInfo, "prepare_for_tail_call", 1,
+				[SiteNumVar], [], PrepareGoal)
+		;
+			generate_call(ModuleInfo, "prepare_for_normal_call", 1,
+				[SiteNumVar], [], PrepareGoal)
+		),
 		PredProcId = proc(PredId, ProcId),
 		TypeSubst = compute_type_subst(GoalExpr, DeepInfo1),
 		MaybeRecInfo = DeepInfo1 ^ maybe_rec_info,
@@ -1062,24 +1036,42 @@
 		CallSite = normal_call(RttiProcLabel, TypeSubst,
 			FileName, LineNumber, GoalPath),
 		Goal1 = Goal0,
-		DeepInfo2 = DeepInfo1
+		DeepInfo3 = DeepInfo1
 	;
 		CallKind = special(_PredProcId, TypeInfoVar),
-		generate_call(ModuleInfo, "prepare_for_special_call", 3,
-			[MiddleCSD, SiteNumVar, TypeInfoVar], [], PrepareGoal),
+		generate_call(ModuleInfo, "prepare_for_special_call", 2,
+			[SiteNumVar, TypeInfoVar], [], PrepareGoal),
 		CallSite = special_call(FileName, LineNumber, GoalPath),
 		Goal1 = Goal0,
-		DeepInfo2 = DeepInfo1
+		DeepInfo3 = DeepInfo1
 	;
 		CallKind = generic(Generic),
-		generate_call(ModuleInfo, "prepare_for_ho_call", 3,
-			[MiddleCSD, SiteNumVar, ClosureVar], [], PrepareGoal),
 		(
 			Generic = higher_order(ClosureVar, _, _),
+			generate_call(ModuleInfo, "prepare_for_ho_call", 2,
+				[SiteNumVar, ClosureVar], [], PrepareGoal),
 			CallSite = higher_order_call(FileName, LineNumber,
-				GoalPath)
+				GoalPath),
+			DeepInfo2 = DeepInfo1
 		;
-			Generic = class_method(ClosureVar, _, _, _),
+			Generic = class_method(TypeClassInfoVar, MethodNum,
+				_, _),
+			varset__new_named_var(DeepInfo1 ^ vars, "MethodNum",
+				MethodNumVar, Vars2),
+			map__set(DeepInfo1 ^ var_types, MethodNumVar, IntType,
+				VarTypes2),
+			generate_unify(int_const(MethodNum), MethodNumVar,
+				MethodNumVarGoal),
+			DeepInfo2 = ((DeepInfo1 ^ vars := Vars2)
+				^ var_types := VarTypes2),
+			generate_call(ModuleInfo, "prepare_for_method_call", 3,
+				[SiteNumVar, TypeClassInfoVar, MethodNumVar],
+				[], PrepareCallGoal),
+			PrepareCallGoal = _ - PrepareCallGoalInfo,
+			PrepareGoal = conj([
+				MethodNumVarGoal,
+				PrepareCallGoal
+			]) - PrepareCallGoalInfo,
 			CallSite = method_call(FileName, LineNumber, GoalPath)
 		;
 			Generic = aditi_builtin(_, _),
@@ -1091,80 +1083,75 @@
 			use_zeroing_for_ho_cycles, UseZeroing),
 		( UseZeroing = yes ->
 			transform_higher_order_call(Globals, GoalCodeModel,
-				Goal0, Goal1, DeepInfo1, DeepInfo2)
+				Goal0, Goal1, DeepInfo2, DeepInfo3)
 		;
 			Goal1 = Goal0,
-			DeepInfo2 = DeepInfo1
+			DeepInfo3 = DeepInfo2
 		)
 	),
-	DeepInfo3 = DeepInfo2 ^ call_sites :=
-		(DeepInfo2 ^ call_sites ++ [CallSite]),
+	DeepInfo4 = DeepInfo3 ^ call_sites :=
+		(DeepInfo3 ^ call_sites ++ [CallSite]),
 	(
 		member(tailcall, GoalFeatures),
-		DeepInfo3 ^ maybe_rec_info = yes(RecInfo),
+		DeepInfo4 ^ maybe_rec_info = yes(RecInfo),
 		RecInfo ^ role = outer_proc(_)
 	->
 		VisSCC = RecInfo ^ visible_scc,
+		MiddleCSD = DeepInfo4 ^ current_csd,
 		(
 			VisSCC = [],
 			CallGoals = [],
 			ExitGoals = [],
 			FailGoals = [],
-			ExtraVarList = [],
-			DeepInfo = DeepInfo3
+			SaveRestoreVars = [],
+			DeepInfo = DeepInfo4
 		;
 			VisSCC = [SCCmember],
 			generate_recursion_counter_saves_and_restores(
 				SCCmember ^ rec_call_sites, MiddleCSD,
-				CallGoals, ExitGoals, FailGoals, ExtraVarList,
-				DeepInfo3, DeepInfo)
+				CallGoals, ExitGoals, FailGoals,
+				SaveRestoreVars, DeepInfo4, DeepInfo)
 		;
 			VisSCC = [_, _ | _],
 			error("wrap_call: multi-procedure SCCs not yet implemented")
 		),
-
-		generate_call(ModuleInfo, "set_current_csd", 1,
-			[MiddleCSD], [], ReturnGoal),
 
-		goal_info_get_code_model(GoalInfo, CodeModel),
+		goal_info_get_code_model(GoalInfo0, CodeModel),
 		( CodeModel = model_det ->
-			condense([
+			list__condense([
 				CallGoals,
-				[SiteNumVarGoal, PrepareGoal, Goal1,
-					ReturnGoal],
+				[SiteNumVarGoal, PrepareGoal, Goal1],
 				ExitGoals
 			], Goals),
 			Goal = conj(Goals) - GoalInfo
 		;
-			ExtraVars = list_to_set(ExtraVarList),
+			
+			ExtraVars = list_to_set([MiddleCSD | SaveRestoreVars]),
 			WrappedGoalGoalInfo =
 				goal_info_add_nonlocals_make_impure(GoalInfo,
 					ExtraVars),
 
-			insert(ExtraVars, MiddleCSD, ReturnFailsNonLocals),
 			ReturnFailsGoalInfo =
 				impure_unreachable_init_goal_info(
-					ReturnFailsNonLocals, failure),
+					ExtraVars, failure),
 
 			FailGoalInfo = fail_goal_info,
 			FailGoal = disj([], init) - FailGoalInfo,
 
-			append(FailGoals, [FailGoal], FailGoalsAndFail),
+			list__append(FailGoals, [FailGoal], FailGoalsAndFail),
 
-			condense([
+			list__condense([
 				CallGoals,
 				[disj([
 					conj([
 						SiteNumVarGoal,
 						PrepareGoal,
-						Goal1,
-						ReturnGoal |
+						Goal1 |
 						ExitGoals
 					]) - WrappedGoalGoalInfo,
-					conj([
-						ReturnGoal |
+					conj(
 						FailGoalsAndFail
-					]) - ReturnFailsGoalInfo
+					) - ReturnFailsGoalInfo
 				], init) - WrappedGoalGoalInfo]
 			], Goals),
 			Goal = conj(Goals) - GoalInfo
@@ -1175,7 +1162,7 @@
 			PrepareGoal,
 			Goal1
 		]) - GoalInfo,
-		DeepInfo = DeepInfo3
+		DeepInfo = DeepInfo4
 	).
 
 :- pred transform_higher_order_call(globals::in, code_model::in,
@@ -1202,40 +1189,35 @@
 
 		DeepInfo1 = DeepInfo0 ^ vars := Vars,
 		DeepInfo = DeepInfo1 ^ var_types := VarTypes,
-		MiddleCSD = DeepInfo ^ current_csd,
 		ExtraNonLocals = set__list_to_set(
-			[MiddleCSD, SavedCountVar, SavedPtrVar]),
+			[SavedCountVar, SavedPtrVar]),
 
 		generate_call(DeepInfo ^ module_info,
-			"save_and_zero_activation_info_ac", 3,
-			[MiddleCSD, SavedCountVar, SavedPtrVar],
+			"save_and_zero_activation_info_ac", 2,
+			[SavedCountVar, SavedPtrVar],
 			[SavedCountVar, SavedPtrVar], SaveStuff),
 		generate_call(DeepInfo ^ module_info,
-			"reset_activation_info_ac", 3,
-			[MiddleCSD, SavedCountVar, SavedPtrVar], [],
-			RestoreStuff),
+			"reset_activation_info_ac", 2,
+			[SavedCountVar, SavedPtrVar], [], RestoreStuff),
 		generate_call(DeepInfo ^ module_info,
-			"rezero_activation_info_ac", 1,
-			[MiddleCSD], [], ReZeroStuff)
+			"rezero_activation_info_ac", 0,
+			[], [], ReZeroStuff)
 	;
 		UseActivationCounts = no,
 
 		DeepInfo1 = DeepInfo0 ^ vars := Vars1,
 		DeepInfo = DeepInfo1 ^ var_types := VarTypes1,
-		MiddleCSD = DeepInfo ^ current_csd,
-		ExtraNonLocals = set__list_to_set([MiddleCSD, SavedPtrVar]),
+		ExtraNonLocals = set__list_to_set([SavedPtrVar]),
 
 		generate_call(DeepInfo ^ module_info,
-			"save_and_zero_activation_info_sr", 2,
-			[MiddleCSD, SavedPtrVar],
-			[SavedPtrVar], SaveStuff),
+			"save_and_zero_activation_info_sr", 1,
+			[SavedPtrVar], [SavedPtrVar], SaveStuff),
 		generate_call(DeepInfo ^ module_info,
-			"reset_activation_info_sr", 2,
-			[MiddleCSD, SavedPtrVar], [],
-			RestoreStuff),
+			"reset_activation_info_sr", 1,
+			[SavedPtrVar], [], RestoreStuff),
 		generate_call(DeepInfo ^ module_info,
-			"rezero_activation_info_sr", 1,
-			[MiddleCSD], [], ReZeroStuff)
+			"rezero_activation_info_sr", 0,
+			[], [], ReZeroStuff)
 	),
 
 	Goal0 = _ - GoalInfo0,
@@ -1253,8 +1235,8 @@
 	RestoreFailGoalInfo = impure_unreachable_init_goal_info(ExtraNonLocals,
 		failure),
 
-	RezeroFailGoalInfo = impure_unreachable_init_goal_info(
-		list_to_set([MiddleCSD]), failure),
+	RezeroFailGoalInfo = impure_unreachable_init_goal_info(set__init,
+		failure),
 
 	goal_info_add_feature(GoalInfo0, impure, GoalInfo),
 	(
@@ -1308,22 +1290,15 @@
 wrap_foreign_code(GoalPath, Goal0, Goal, DeepInfo0, DeepInfo) :-
 	Goal0 = _ - GoalInfo0,
 	ModuleInfo = DeepInfo0 ^ module_info,
-	MiddleCSD = DeepInfo0 ^ current_csd,
-
-	goal_info_get_nonlocals(GoalInfo0, NonLocals0),
-	NewNonlocals = set__make_singleton_set(MiddleCSD),
-	NonLocals = union(NonLocals0, NewNonlocals),
-	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
 
 	SiteNumCounter0 = DeepInfo0 ^ site_num_counter,
 	counter__allocate(SiteNum, SiteNumCounter0, SiteNumCounter),
 	varset__new_named_var(DeepInfo0 ^ vars, "SiteNum", SiteNumVar, Vars),
-	IntType = int_type,
-	map__set(DeepInfo0 ^ var_types, SiteNumVar, IntType, VarTypes),
+	map__set(DeepInfo0 ^ var_types, SiteNumVar, int_type, VarTypes),
 	generate_unify(int_const(SiteNum), SiteNumVar, SiteNumVarGoal),
 
-	generate_call(ModuleInfo, "prepare_for_callback", 2,
-		[MiddleCSD, SiteNumVar], [], PrepareGoal),
+	generate_call(ModuleInfo, "prepare_for_callback", 1,
+		[SiteNumVar], [], PrepareGoal),
 
 	goal_info_get_context(GoalInfo0, Context),
 	LineNumber = term__context_line(Context),
@@ -1335,7 +1310,7 @@
 		SiteNumVarGoal,
 		PrepareGoal,
 		Goal0
-	]) - GoalInfo,
+	]) - GoalInfo0,
 	DeepInfo = ((((DeepInfo0 ^ site_num_counter := SiteNumCounter)
 		^ vars := Vars)
 		^ var_types := VarTypes)
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing library
Index: library/profiling_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/profiling_builtin.m,v
retrieving revision 1.2
diff -u -b -r1.2 profiling_builtin.m
--- library/profiling_builtin.m	2001/05/31 06:00:05	1.2
+++ library/profiling_builtin.m	2001/06/02 16:15:40
@@ -24,16 +24,18 @@
 :- type proc_dynamic.
 :- type call_site_dynamic.
 
-:- impure pred prepare_for_normal_call(call_site_dynamic::in, int::in) is det.
+:- impure pred prepare_for_normal_call(int::in) is det.
 
-:- impure pred prepare_for_special_call(call_site_dynamic::in, int::in,
-	c_pointer::in) is det.
+:- impure pred prepare_for_special_call(int::in, c_pointer::in) is det.
 
-:- impure pred prepare_for_ho_call(call_site_dynamic::in, int::in,
-	c_pointer::in) is det.
+:- impure pred prepare_for_ho_call(int::in, c_pointer::in) is det.
 
-:- impure pred prepare_for_callback(call_site_dynamic::in, int::in) is det.
+:- impure pred prepare_for_method_call(int::in, c_pointer::in, int::in) is det.
 
+:- impure pred prepare_for_callback(int::in) is det.
+
+:- impure pred prepare_for_tail_call(int::in) is det.
+
 :- impure pred det_call_port_code_ac(proc_static::in,
 	call_site_dynamic::out, call_site_dynamic::out) is det.
 
@@ -88,30 +90,19 @@
 :- impure pred non_fail_port_code_sr(call_site_dynamic::in,
 	call_site_dynamic::in, proc_dynamic::in) is failure.
 
-:- impure pred inner_call_port_code(proc_static::in, call_site_dynamic::out)
+:- impure pred save_and_zero_activation_info_ac(int::out, proc_dynamic::out)
 	is det.
-
-:- impure pred set_outermost_activation_ptr(call_site_dynamic::in,
-	proc_dynamic::in) is det.
-
-:- impure pred save_and_zero_activation_info_ac(call_site_dynamic::in,
-	int::out, proc_dynamic::out) is det.
 
-:- impure pred save_and_zero_activation_info_sr(call_site_dynamic::in,
-	proc_dynamic::out) is det.
+:- impure pred save_and_zero_activation_info_sr(proc_dynamic::out) is det.
 
-:- impure pred rezero_activation_info_ac(call_site_dynamic::in) is det.
+:- impure pred rezero_activation_info_ac is det.
 
-:- impure pred rezero_activation_info_sr(call_site_dynamic::in) is det.
+:- impure pred rezero_activation_info_sr is det.
 
-:- impure pred reset_activation_info_ac(call_site_dynamic::in,
-	int::in, proc_dynamic::in) is det.
+:- impure pred reset_activation_info_ac(int::in, proc_dynamic::in) is det.
 
-:- impure pred reset_activation_info_sr(call_site_dynamic::in,
-	proc_dynamic::in) is det.
+:- impure pred reset_activation_info_sr(proc_dynamic::in) is det.
 
-:- impure pred set_current_csd(call_site_dynamic::in) is det.
-
 :- type call_site_nums_2
 	--->	call_site_nums_2(int, int).
 
@@ -520,7 +511,7 @@
 % Procedures that prepare for calls
 %---------------------------------------------------------------------------%
 
-:- pragma foreign_proc("C", prepare_for_normal_call(CSD::in, N::in),
+:- pragma foreign_proc("C", prepare_for_normal_call(N::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
@@ -528,8 +519,8 @@
 	MR_CallSiteDynamic	*child_csd;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 
@@ -555,8 +546,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C",
-		prepare_for_special_call(CSD::in, CSN::in, TypeInfo::in),
+:- pragma foreign_proc("C", prepare_for_special_call(CSN::in, TypeInfo::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
@@ -570,8 +560,8 @@
 	void			*void_key;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 
@@ -580,7 +570,7 @@
 
 	void_key = (void *) type_ctor_info;
 	MR_search_csdlist(csdlist, prev, pd, CSN, void_key);
-	MR_maybe_deep_profile_update_special_history(type_ctor_info);
+	MR_maybe_deep_profile_update_special_history();
 
   #ifdef MR_DEEP_PROFILING_STATISTICS
 	if (csdlist != NULL) {
@@ -606,7 +596,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", prepare_for_ho_call(CSD::in, CSN::in, Closure::in),
+:- pragma foreign_proc("C", prepare_for_ho_call(CSN::in, Closure::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
@@ -619,9 +609,9 @@
   #endif
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
 	closure = (MR_Closure *) Closure;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 
@@ -632,7 +622,7 @@
   #endif
 
 	MR_search_csdlist(csdlist, prev, pd, CSN, void_key);
-	MR_maybe_deep_profile_update_closure_history(closure);
+	MR_maybe_deep_profile_update_closure_history();
 
   #ifdef MR_DEEP_PROFILING_STATISTICS
 	if (csdlist != NULL) {
@@ -658,124 +648,121 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", prepare_for_callback(CSD::in, N::in),
-		[thread_safe, will_not_call_mercury], "{
-#ifdef MR_DEEP_PROFILING
-	MR_CallSiteDynamic	*csd;
-
-	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
-	MR_deep_assert(csd->MR_csd_callee_ptr != NULL);
-
-	MR_current_callback_site = (MR_CallSiteDynList **)
-		&(csd->MR_csd_callee_ptr->MR_pd_call_site_ptr_ptrs[N]);
-	MR_leave_instrumentation();
-#else
-	MR_fatal_error(""prepare_for_callback: deep profiling not enabled"");
-#endif
-}").
-
-%---------------------------------------------------------------------------%
-% Procedures needed for handling directly recursive procedures
-%---------------------------------------------------------------------------%
-
 :- pragma foreign_proc("C",
-		inner_call_port_code(ProcStatic::in, MiddleCSD::out),
+	prepare_for_method_call(CSN::in, TypeClassInfo::in, MethodNum::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
 	MR_CallSiteDynamic	*csd;
-	MR_ProcStatic		*ps;
-
-	MR_enter_instrumentation();
-
-  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
-	MR_print_deep_prof_vars(stdout);
+	MR_ProcDynamic		*pd;
+	MR_CallSiteDynList	*csdlist;
+	void			*void_key;
+  #ifdef MR_DEEP_PROFILING_MOVE_TO_FRONT_LISTS
+	MR_CallSiteDynList	*prev = NULL;
   #endif
 
-	MiddleCSD = (MR_Word) MR_next_call_site_dynamic;
-	MR_current_call_site_dynamic = MR_next_call_site_dynamic;
+	MR_enter_instrumentation();
 	csd = MR_current_call_site_dynamic;
-	csd->MR_csd_depth_count++;
-	ps = (MR_ProcStatic *) ProcStatic;
+	MR_deep_assert(csd != NULL);
+	pd = csd->MR_csd_callee_ptr;
+	MR_deep_assert(pd != NULL);
+
+	void_key = (void *)
+		MR_typeclass_info_class_method(TypeClassInfo, MethodNum);
+	MR_search_csdlist(csdlist, prev, pd, CSN, void_key);
+	MR_maybe_deep_profile_update_method_history();
 
   #ifdef MR_DEEP_PROFILING_STATISTICS
-	MR_deep_prof_call_inner++;
+	if (csdlist != NULL) {
+		MR_deep_prof_prep_method_old++;
+	} else {
+		MR_deep_prof_prep_method_new++;
+	}
   #endif
 
-	MR_deep_assert(ps->MR_ps_outermost_activation_ptr != NULL);
+	if (csdlist != NULL) {
+		MR_next_call_site_dynamic = csdlist->MR_csdlist_call_site;
+	} else {
+		MR_CallSiteDynamic	*newcsd;
 
-	if (csd->MR_csd_callee_ptr == NULL) {
-		csd->MR_csd_callee_ptr = ps->MR_ps_outermost_activation_ptr;
+		MR_new_call_site_dynamic(newcsd);
+		MR_make_and_link_csdlist(csdlist, newcsd, pd, CSN, void_key);
+		MR_next_call_site_dynamic = newcsd;
 	}
 
 	MR_leave_instrumentation();
 #else
-	MR_fatal_error(""inner_call_port_code: deep profiling not enabled"");
+	MR_fatal_error(""prepare_for_method_call: deep profiling not enabled"");
 #endif
 }").
 
-:- pragma foreign_proc("C", set_current_csd(CSD::in),
+:- pragma foreign_proc("C", prepare_for_callback(CSN::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
-	MR_current_call_site_dynamic = (MR_CallSiteDynamic *) CSD;
-#else
-	MR_fatal_error(""set_current_csd: deep profiling not enabled"");
-#endif
-}").
-
-:- impure pred increment_activation_count(call_site_dynamic::in,
-	proc_dynamic::in) is det.
-
-:- pragma foreign_proc("C", increment_activation_count(CSD::in, PD::in),
-		[thread_safe, will_not_call_mercury], "{
-#ifdef MR_DEEP_PROFILING
-  #ifdef MR_USE_ACTIVATION_COUNTS
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
-	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
-	ps = pd->MR_pd_proc_static;
-	MR_deep_assert(ps != NULL);
 
-	ps->MR_ps_activation_count++;
-	ps->MR_ps_outermost_activation_ptr = (MR_ProcDynamic *) PD;
+	MR_current_callback_site = (MR_CallSiteDynList **)
+		&(pd->MR_pd_call_site_ptr_ptrs[CSN]);
 	MR_leave_instrumentation();
-  #else
-	MR_fatal_error(""increment_activation_count: no activation_count"");
-  #endif
 #else
-	MR_fatal_error(""increment_activation_count: deep profiling not enabled"");
+	MR_fatal_error(""prepare_for_callback: deep profiling not enabled"");
 #endif
 }").
+
+%---------------------------------------------------------------------------%
+% Procedures needed for handling tail recursive procedures
+%---------------------------------------------------------------------------%
 
-:- pragma foreign_proc("C", set_outermost_activation_ptr(CSD::in, Ptr::in),
+:- pragma foreign_proc("C", prepare_for_tail_call(CSN::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
+	MR_CallSiteDynamic	*child_csd;
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
-	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
+
+  #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
+	MR_print_deep_prof_vars(stdout);
+  #endif
+
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
-	ps = pd->MR_pd_proc_static;
 
-	ps->MR_ps_outermost_activation_ptr = (MR_ProcDynamic *) Ptr;
+	child_csd = pd->MR_pd_call_site_ptr_ptrs[CSN];
+
+  #ifdef MR_DEEP_PROFILING_STATISTICS
+	if (child_csd == NULL) {
+		MR_deep_prof_prep_tail_new++;
+	} else {
+		MR_deep_prof_prep_tail_old++;
+	}
+  #endif
+	if (child_csd == NULL) {
+		MR_new_call_site_dynamic(child_csd);
+		child_csd->MR_csd_callee_ptr = pd;
+		pd->MR_pd_call_site_ptr_ptrs[CSN] = child_csd;
+	}
+
+	child_csd->MR_csd_depth_count++;
+	MR_current_call_site_dynamic = child_csd;
+
 	MR_leave_instrumentation();
 #else
-	MR_fatal_error(""set_outermost_activation_ptr: deep profiling not enabled"");
+	MR_fatal_error(""prepare_for_tail_call: deep profiling not enabled"");
 #endif
 }").
 
 :- pragma foreign_proc("C",
-	save_and_zero_activation_info_ac(CSD::in, Count::out, Ptr::out),
+	save_and_zero_activation_info_ac(Count::out, Ptr::out),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
@@ -784,8 +771,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
@@ -803,8 +790,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C",
-	save_and_zero_activation_info_sr(CSD::in, Ptr::out),
+:- pragma foreign_proc("C", save_and_zero_activation_info_sr(Ptr::out),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
@@ -813,8 +799,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
@@ -830,7 +816,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", rezero_activation_info_ac(CSD::in),
+:- pragma foreign_proc("C", rezero_activation_info_ac,
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
@@ -839,8 +825,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
@@ -856,7 +842,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", rezero_activation_info_sr(CSD::in),
+:- pragma foreign_proc("C", rezero_activation_info_sr,
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
@@ -865,8 +851,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
@@ -881,8 +867,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C",
-	reset_activation_info_ac(CSD::in, Count::in, Ptr::in),
+:- pragma foreign_proc("C", reset_activation_info_ac(Count::in, Ptr::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifdef MR_USE_ACTIVATION_COUNTS
@@ -891,8 +876,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
@@ -908,7 +893,7 @@
 #endif
 }").
 
-:- pragma foreign_proc("C", reset_activation_info_sr(CSD::in, Ptr::in),
+:- pragma foreign_proc("C", reset_activation_info_sr(Ptr::in),
 		[thread_safe, will_not_call_mercury], "{
 #ifdef MR_DEEP_PROFILING
   #ifndef MR_USE_ACTIVATION_COUNTS
@@ -917,8 +902,8 @@
 	MR_ProcStatic		*ps;
 
 	MR_enter_instrumentation();
-	csd = (MR_CallSiteDynamic *) CSD;
-	MR_deep_assert(csd == MR_current_call_site_dynamic);
+	csd = MR_current_call_site_dynamic;
+	MR_deep_assert(csd != NULL);
 	pd = csd->MR_csd_callee_ptr;
 	MR_deep_assert(pd != NULL);
 	ps = pd->MR_pd_proc_static;
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_deep_profiling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.c,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_deep_profiling.c
--- runtime/mercury_deep_profiling.c	2001/05/31 06:00:12	1.2
+++ runtime/mercury_deep_profiling.c	2001/06/03 17:22:04
@@ -92,6 +92,7 @@
 
 int	MR_dictionary_search_lengths[MR_MAX_CLOSURE_LIST_LENGTH];
 int	MR_closure_search_lengths[MR_MAX_CLOSURE_LIST_LENGTH];
+int	MR_method_search_lengths[MR_MAX_CLOSURE_LIST_LENGTH];
 
 int	MR_deep_prof_prep_normal_new = 0;
 int	MR_deep_prof_prep_normal_old = 0;
@@ -99,11 +100,18 @@
 int	MR_deep_prof_prep_special_old = 0;
 int	MR_deep_prof_prep_ho_new = 0;
 int	MR_deep_prof_prep_ho_old = 0;
+int	MR_deep_prof_prep_method_new = 0;
+int	MR_deep_prof_prep_method_old = 0;
+int	MR_deep_prof_prep_callback_new = 0;
+int	MR_deep_prof_prep_callback_old = 0;
+int	MR_deep_prof_prep_tail_old = 0;
+int	MR_deep_prof_prep_tail_new = 0;
 
-int	MR_deep_prof_call_old = 0;
-int	MR_deep_prof_call_rec = 0;
 int	MR_deep_prof_call_new = 0;
-int	MR_deep_prof_call_inner = 0;
+int	MR_deep_prof_call_rec = 0;
+int	MR_deep_prof_call_old = 0;
+int	MR_deep_prof_call_builtin_new = 0;
+int	MR_deep_prof_call_builtin_old = 0;
 
 #endif	/* MR_DEEP_PROFILING_STATISTICS */
 
@@ -130,6 +138,9 @@
 		if (csd_list->MR_csdlist_key == entry) {
 			MR_next_call_site_dynamic =
 				csd_list->MR_csdlist_call_site;
+#ifdef	MR_DEEP_PROFILING_STATISTICS
+			MR_deep_prof_prep_callback_old++;
+#endif
 			MR_leave_instrumentation();
 			return;
 		}
@@ -137,6 +148,10 @@
 		csd_list = csd_list->MR_csdlist_next;
 	}
 
+#ifdef	MR_DEEP_PROFILING_STATISTICS
+	MR_deep_prof_prep_callback_new++;
+#endif
+
 	MR_new_call_site_dynamic(csd);
 
 	csd_list = MR_PROFILING_MALLOC(MR_CallSiteDynList);
@@ -154,7 +169,7 @@
 int	MR_deep_prof_search_len;
 
 void
-MR_deep_profile_update_special_history(MR_TypeCtorInfo type_ctor_info)
+MR_deep_profile_update_special_history(void)
 {
 	if (MR_deep_prof_search_len < MR_MAX_CLOSURE_LIST_LENGTH) {
 		MR_dictionary_search_lengths[MR_deep_prof_search_len]++;
@@ -162,13 +177,21 @@
 }
 
 void
-MR_deep_profile_update_closure_history(MR_Closure *closure)
+MR_deep_profile_update_closure_history()
 {
 	if (MR_deep_prof_search_len < MR_MAX_CLOSURE_LIST_LENGTH) {
 		MR_closure_search_lengths[MR_deep_prof_search_len]++;
 	}
 }
 
+void
+MR_deep_profile_update_method_history()
+{
+	if (MR_deep_prof_search_len < MR_MAX_CLOSURE_LIST_LENGTH) {
+		MR_method_search_lengths[MR_deep_prof_search_len]++;
+	}
+}
+
 #endif	/* MR_DEEP_PROFILING_STATISTICS */
 
 /*----------------------------------------------------------------------------*/
@@ -356,17 +379,59 @@
 		"MR_deep_prof_prep_normal_old:",
 		MR_deep_prof_prep_normal_old);
 	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_normal all:",
+		MR_deep_prof_prep_normal_new +
+		MR_deep_prof_prep_normal_old);
+	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_prep_special_new:",
 		MR_deep_prof_prep_special_new);
 	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_prep_special_old:",
 		MR_deep_prof_prep_special_old);
 	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_special all:",
+		MR_deep_prof_prep_special_new +
+		MR_deep_prof_prep_special_old);
+	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_prep_ho_new:",
 		MR_deep_prof_prep_ho_new);
 	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_prep_ho_old:",
 		MR_deep_prof_prep_ho_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_ho all:",
+		MR_deep_prof_prep_ho_new +
+		MR_deep_prof_prep_ho_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_method_new:",
+		MR_deep_prof_prep_method_new);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_method_old:",
+		MR_deep_prof_prep_method_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_method all:",
+		MR_deep_prof_prep_method_new +
+		MR_deep_prof_prep_method_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_callback_new:",
+		MR_deep_prof_prep_callback_new);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_callback_old:",
+		MR_deep_prof_prep_callback_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_callback all:",
+		MR_deep_prof_prep_callback_new +
+		MR_deep_prof_prep_callback_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_tail_new:",
+		MR_deep_prof_prep_tail_new);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_tail_old:",
+		MR_deep_prof_prep_tail_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_prep_tail all:",
+		MR_deep_prof_prep_tail_new +
+		MR_deep_prof_prep_tail_old);
 
 	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_call_new:",
@@ -377,9 +442,45 @@
 	fprintf(stderr, "%-40s %10d\n",
 		"MR_deep_prof_call_old:",
 		MR_deep_prof_call_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_call all:",
+		MR_deep_prof_call_new +
+		MR_deep_prof_call_rec +
+		MR_deep_prof_call_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_call_builtin_new:",
+		MR_deep_prof_call_builtin_new);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_call_builtin_old:",
+		MR_deep_prof_call_builtin_old);
+	fprintf(stderr, "%-40s %10d\n",
+		"MR_deep_prof_call_builtin all:",
+		MR_deep_prof_call_builtin_new +
+		MR_deep_prof_call_builtin_old);
+
 	fprintf(stderr, "%-40s %10d\n",
-		"MR_deep_prof_call_inner:",
-		MR_deep_prof_call_inner);
+		"call prepare:",
+		MR_deep_prof_prep_normal_new +
+		MR_deep_prof_prep_normal_old +
+		MR_deep_prof_prep_special_new +
+		MR_deep_prof_prep_special_old +
+		MR_deep_prof_prep_ho_new +
+		MR_deep_prof_prep_ho_old +
+		MR_deep_prof_prep_method_new +
+		MR_deep_prof_prep_method_old +
+		MR_deep_prof_prep_callback_new +
+		MR_deep_prof_prep_callback_old +
+		MR_deep_prof_prep_tail_old +
+		MR_deep_prof_prep_tail_new);
+	fprintf(stderr, "%-40s %10d\n",
+		"call arrival:",
+		MR_deep_prof_prep_tail_old +
+		MR_deep_prof_prep_tail_new +
+		MR_deep_prof_call_new +
+		MR_deep_prof_call_rec +
+		MR_deep_prof_call_old +
+		MR_deep_prof_call_builtin_new +
+		MR_deep_prof_call_builtin_old);
 
 	fprintf(stderr, "\ntotal size of profiling tree: %10d bytes\n",
 		MR_deep_num_csd_nodes * sizeof(MR_CallSiteDynamic) +
@@ -403,6 +504,14 @@
 		sizeof(MR_CallSiteDynList),
 		MR_deep_num_dynlist_nodes * sizeof(MR_CallSiteDynList));
 
+	fprintf(stderr, "\nTypeInfo search length histogram:\n");
+	for (i = 0; i < MR_MAX_CLOSURE_LIST_LENGTH; i++) {
+		if (MR_dictionary_search_lengths[i] > 0) {
+			fprintf(stderr, "\t%3d: %12d\n", i,
+				MR_dictionary_search_lengths[i]);
+		}
+	}
+
 	fprintf(stderr, "\nClosure search length histogram:\n");
 	for (i = 0; i < MR_MAX_CLOSURE_LIST_LENGTH; i++) {
 		if (MR_closure_search_lengths[i] > 0) {
@@ -411,11 +520,11 @@
 		}
 	}
 
-	fprintf(stderr, "\nTypeInfo search length histogram:\n");
+	fprintf(stderr, "\nMethod search length histogram:\n");
 	for (i = 0; i < MR_MAX_CLOSURE_LIST_LENGTH; i++) {
-		if (MR_dictionary_search_lengths[i] > 0) {
+		if (MR_method_search_lengths[i] > 0) {
 			fprintf(stderr, "\t%3d: %12d\n", i,
-				MR_dictionary_search_lengths[i]);
+				MR_method_search_lengths[i]);
 		}
 	}
 #endif
Index: runtime/mercury_deep_profiling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.h,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_deep_profiling.h
--- runtime/mercury_deep_profiling.h	2001/05/31 06:00:12	1.2
+++ runtime/mercury_deep_profiling.h	2001/06/03 17:03:44
@@ -216,26 +216,31 @@
 
 #ifdef	MR_DEEP_PROFILING_STATISTICS
   extern int	MR_deep_prof_search_len;
-  extern void	MR_deep_profile_update_special_history(MR_TypeCtorInfo);
-  extern void	MR_deep_profile_update_closure_history(MR_Closure *);
+  extern void	MR_deep_profile_update_special_history(void);
+  extern void	MR_deep_profile_update_closure_history(void);
+  extern void	MR_deep_profile_update_method_history(void);
 
   #define MR_maybe_init_search_len()					\
   	do { MR_deep_prof_search_len = 0; } while(0)
   #define MR_maybe_increment_search_len()				\
   	do { MR_deep_prof_search_len++; } while (0)
-  #define MR_maybe_deep_profile_update_special_history(typectorinfo) 	\
-	MR_deep_profile_update_special_history(typectorinfo)
-  #define MR_maybe_deep_profile_update_closure_history(closure) 	\
-	MR_deep_profile_update_closure_history(closure)
+  #define MR_maybe_deep_profile_update_special_history()	 	\
+	MR_deep_profile_update_special_history()
+  #define MR_maybe_deep_profile_update_closure_history() 		\
+	MR_deep_profile_update_closure_history()
+  #define MR_maybe_deep_profile_update_method_history() 		\
+	MR_deep_profile_update_method_history()
 #else
   #define MR_maybe_init_search_len()					\
 	((void) 0)
   #define MR_maybe_increment_search_len()				\
 	((void) 0)
-  #define MR_maybe_deep_profile_update_special_history(typeinfo)	\
+  #define MR_maybe_deep_profile_update_special_history()		\
 	((void) 0)
-  #define MR_maybe_deep_profile_update_closure_history(closure)		\
+  #define MR_maybe_deep_profile_update_closure_history()		\
 	((void) 0)
+  #define MR_maybe_deep_profile_update_method_history()			\
+	((void) 0)
 #endif
 
 #ifdef MR_DEEP_PROFILING_MOVE_TO_FRONT_LISTS
@@ -321,20 +326,24 @@
 
 #define MR_MAX_CLOSURE_LIST_LENGTH 256
 
-extern	int	MR_dictionary_search_lengths[MR_MAX_CLOSURE_LIST_LENGTH];
-extern	int	MR_closure_search_lengths[MR_MAX_CLOSURE_LIST_LENGTH];
-
 extern	int	MR_deep_prof_prep_normal_new;
 extern	int	MR_deep_prof_prep_normal_old;
 extern	int	MR_deep_prof_prep_special_new;
 extern	int	MR_deep_prof_prep_special_old;
 extern	int	MR_deep_prof_prep_ho_new;
 extern	int	MR_deep_prof_prep_ho_old;
+extern	int	MR_deep_prof_prep_method_new;
+extern	int	MR_deep_prof_prep_method_old;
+extern	int	MR_deep_prof_prep_callback_new;
+extern	int	MR_deep_prof_prep_callback_old;
+extern	int	MR_deep_prof_prep_tail_new;
+extern	int	MR_deep_prof_prep_tail_old;
 
-extern	int	MR_deep_prof_call_old;
-extern	int	MR_deep_prof_call_rec;
 extern	int	MR_deep_prof_call_new;
-extern	int	MR_deep_prof_call_inner;
+extern	int	MR_deep_prof_call_rec;
+extern	int	MR_deep_prof_call_old;
+extern	int	MR_deep_prof_call_builtin_new;
+extern	int	MR_deep_prof_call_builtin_old;
 
 #endif	/* MR_DEEP_PROFILING_STATISTICS */
 
Index: runtime/mercury_deep_profiling_hand.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling_hand.h,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_deep_profiling_hand.h
--- runtime/mercury_deep_profiling_hand.h	2001/05/31 06:00:12	1.2
+++ runtime/mercury_deep_profiling_hand.h	2001/06/01 10:13:43
@@ -422,20 +422,18 @@
 */
 
 #define	MR_deep_prepare_normal_call(proclabel, first_slot, label, site)	\
-	MR_r1 = MR_stackvar(first_slot+1);				\
-	MR_r2 = site;							\
+	MR_r1 = site;							\
 	MR_call_localret(MR_ENTRY(					\
-		mercury__profiling_builtin__prepare_for_normal_call_2_0),\
+		mercury__profiling_builtin__prepare_for_normal_call_1_0),\
 		label, MR_ENTRY(proclabel));				\
     MR_define_label(label);						\
 	MR_update_prof_current_proc(MR_LABEL(proclabel))
 
 #define	MR_deep_prepare_ho_call(proclabel, first_slot, label, site, closure) \
-	MR_r1 = MR_stackvar(first_slot+1);				\
-	MR_r2 = site;							\
-	MR_r3 = closure;						\
+	MR_r1 = site;							\
+	MR_r2 = closure;						\
 	MR_call_localret(MR_ENTRY(					\
-		mercury__profiling_builtin__prepare_for_ho_call_3_0),	\
+		mercury__profiling_builtin__prepare_for_ho_call_2_0),	\
 		label, MR_ENTRY(proclabel));				\
     MR_define_label(label);						\
 	MR_update_prof_current_proc(MR_LABEL(proclabel))
Index: runtime/mercury_deep_rec_depth_actions.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_rec_depth_actions.h,v
retrieving revision 1.1
diff -u -b -r1.1 mercury_deep_rec_depth_actions.h
--- runtime/mercury_deep_rec_depth_actions.h	2001/05/31 06:00:12	1.1
+++ runtime/mercury_deep_rec_depth_actions.h	2001/06/01 10:13:43
@@ -41,6 +41,8 @@
 		inner_csd = pd->MR_pd_call_site_ptr_ptrs[csn];		\
 									\
 		if (inner_csd != NULL) {				\
+			int	inner_count;				\
+									\
 			inner_count = inner_csd->MR_csd_depth_count;	\
 			/* calls are computed from the other counts */	\
 			inner_csd->MR_csd_own.inc_field += inner_count;	\
Index: runtime/mercury_deep_rec_depth_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_rec_depth_body.h,v
retrieving revision 1.1
diff -u -b -r1.1 mercury_deep_rec_depth_body.h
--- runtime/mercury_deep_rec_depth_body.h	2001/05/31 06:00:12	1.1
+++ runtime/mercury_deep_rec_depth_body.h	2001/06/01 10:13:43
@@ -30,8 +30,6 @@
 	MR_CallSiteDynamic	*csd;
 	MR_ProcDynamic		*pd;
 	MR_ProcStatic		*ps;
-	MR_CallSiteDynamic	*inner_csd;
-	int			inner_count;
 
 	MR_enter_instrumentation();
 	csd = (MR_CallSiteDynamic *) CSD;
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.44
diff -u -b -r1.44 mercury_ho_call.c
--- runtime/mercury_ho_call.c	2001/05/31 06:00:14	1.44
+++ runtime/mercury_ho_call.c	2001/06/03 17:17:31
@@ -21,7 +21,76 @@
 
 #include "mercury_imp.h"
 #include "mercury_ho_call.h"
+#include "mercury_deep_profiling.h"
+#include "mercury_deep_profiling_hand.h"
 
+#ifdef	MR_DEEP_PROFILING
+  #ifdef MR_DEEP_PROFILING_STATISTICS
+    #define	maybe_incr_prof_call_builtin_new()			\
+			do { MR_deep_prof_call_builtin_new++; } while (0)
+    #define	maybe_incr_prof_call_builtin_old()			\
+			do { MR_deep_prof_call_builtin_old++; } while (0)
+  #else
+    #define	maybe_incr_prof_call_builtin_new()			\
+			((void) 0)
+    #define	maybe_incr_prof_call_builtin_old()			\
+			((void) 0)
+  #endif
+
+  #ifdef MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS
+    #define	maybe_incr_call_count(csd)				\
+			do { csd->MR_csd_own.MR_own_calls++; } while (0)
+  #else
+    #define	maybe_incr_call_count(csd)				\
+			((void) 0)
+  #endif
+
+  #define	special_pred_call_leave_code(ps, field)			\
+	do {								\
+		MR_CallSiteDynamic	*csd;				\
+		MR_ProcDynamic		*pd;				\
+									\
+		csd = MR_next_call_site_dynamic;			\
+		pd = csd->MR_csd_callee_ptr;				\
+		if (pd == NULL) {					\
+			MR_new_proc_dynamic(pd, (MR_ProcStatic *) &ps);	\
+			csd->MR_csd_callee_ptr = pd;			\
+			maybe_incr_prof_call_builtin_new();		\
+		} else {						\
+			maybe_incr_prof_call_builtin_old();		\
+		}							\
+		maybe_incr_call_count(csd);				\
+		csd->MR_csd_own.field++;				\
+	} while (0)
+
+  #define	unify_call_exit_code(predname)				\
+	special_pred_call_leave_code(					\
+		MR_proc_static_user_builtin_name(predname, 2, 0),	\
+		MR_own_exits)
+
+  #define	unify_call_fail_code(predname)				\
+	special_pred_call_leave_code(					\
+		MR_proc_static_user_builtin_name(predname, 2, 0),	\
+		MR_own_fails)
+
+  #define	compare_call_exit_code(predname)			\
+	special_pred_call_leave_code(					\
+		MR_proc_static_user_builtin_name(predname, 3, 0),	\
+		MR_own_exits)
+
+MR_proc_static_user_builtin_empty(integer_unify, 2, 0,    "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(integer_compare, 3, 0,  "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(float_unify, 2, 0,      "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(float_compare, 3, 0,    "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(string_unify, 2, 0,     "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(string_compare, 3, 0,   "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(c_pointer_unify, 2, 0 , "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(c_pointer_compare, 3, 0,"mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(typeinfo_unify, 2, 0,   "mercury_ho_call.c");
+MR_proc_static_user_builtin_empty(typeinfo_compare, 3, 0, "mercury_ho_call.c");
+
+#endif
+
 #ifndef MR_HIGHLEVEL_CODE
 static	MR_Word	MR_generic_compare(MR_TypeInfo type_info, MR_Word x, MR_Word y);
 static	MR_Word	MR_generic_unify(MR_TypeInfo type_info, MR_Word x, MR_Word y);
@@ -232,6 +301,7 @@
 #define	call_user_code_label	call_unify_in_proc
 #define	type_stat_struct	MR_type_stat_mer_unify
 #define	attempt_msg		"attempt to unify "
+#define	entry_point_is_mercury
 
 #include "mercury_unify_compare_body.h"
 
@@ -243,6 +313,7 @@
 #undef	call_user_code_label
 #undef  type_stat_struct
 #undef  attempt_msg
+#undef  entry_point_is_mercury
 
 }
 
@@ -304,6 +375,7 @@
 #define	type_stat_struct	MR_type_stat_mer_compare
 #define	attempt_msg		"attempt to compare "
 #define	select_compare_code
+#define	entry_point_is_mercury
 
 #include "mercury_unify_compare_body.h"
 
@@ -316,6 +388,7 @@
 #undef  type_stat_struct
 #undef  attempt_msg
 #undef	select_compare_code
+#undef	entry_point_is_mercury
 
 }
 MR_END_MODULE
@@ -433,6 +506,25 @@
 #ifdef	MR_DEEP_PROFILING
 void mercury_sys_init_call_write_out_proc_statics(FILE *fp)
 {
-	/* no proc_statics to write out */
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(integer_unify, 2, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(integer_compare, 3, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(float_unify, 2, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(float_compare, 3, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(string_unify, 2, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(string_compare, 3, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(c_pointer_unify, 2, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(c_pointer_compare, 3, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(typeinfo_unify, 2, 0));
+	MR_write_out_proc_static(fp, (MR_ProcStatic *)
+		&MR_proc_static_user_builtin_name(typeinfo_compare, 3, 0));
 }
 #endif
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.9
diff -u -b -r1.9 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h	2001/03/18 23:10:13	1.9
+++ runtime/mercury_unify_compare_body.h	2001/06/01 14:51:59
@@ -84,18 +84,18 @@
         case MR_TYPECTOR_REP_DU:
             {
                 const MR_DuFunctorDesc  *functor_desc;
-#ifdef  select_compare_code
+  #ifdef  select_compare_code
                 const MR_DuFunctorDesc  *x_functor_desc;
                 const MR_DuFunctorDesc  *y_functor_desc;
                 MR_DuPtagLayout         *x_ptaglayout;
                 MR_DuPtagLayout         *y_ptaglayout;
-#else
+  #else
                 MR_Word                    x_ptag;
                 MR_Word                    y_ptag;
                 MR_Word                    x_sectag;
                 MR_Word                    y_sectag;
                 MR_DuPtagLayout         *ptaglayout;
-#endif
+  #endif
                 MR_Word                    *x_data_value;
                 MR_Word                    *y_data_value;
                 const MR_DuExistInfo    *exist_info;
@@ -104,9 +104,9 @@
                 int                     arity;
                 int                     i;
 
-#ifdef  select_compare_code
+  #ifdef  select_compare_code
 
-#define MR_find_du_functor_desc(data, data_value, functor_desc)               \
+  #define MR_find_du_functor_desc(data, data_value, functor_desc)             \
                 do {                                                          \
                     MR_DuPtagLayout         *ptaglayout;                      \
                     int                     ptag;                             \
@@ -127,7 +127,8 @@
                             sectag = 0;                                       \
                             break;                                            \
                         case MR_SECTAG_VARIABLE:                              \
-                            MR_fatal_error("find_du_functor_desc(): attempt get functor desc of variable");                                                   \
+                            MR_fatal_error("find_du_functor_desc(): "         \
+                                "attempt get functor desc of variable");      \
                     }                                                         \
                                                                               \
                     functor_desc = ptaglayout->MR_sectag_alternatives[sectag];\
@@ -136,7 +137,7 @@
                 MR_find_du_functor_desc(x, x_data_value, x_functor_desc);
                 MR_find_du_functor_desc(y, y_data_value, y_functor_desc);
 
-#undef MR_find_du_functor_desc
+  #undef MR_find_du_functor_desc
 
                 if (x_functor_desc->MR_du_functor_ordinal !=
                     y_functor_desc->MR_du_functor_ordinal)
@@ -151,7 +152,7 @@
                 }
 
                 functor_desc = x_functor_desc;
-#else
+  #else /* ! select_compare_code */
                 x_ptag = MR_tag(x);
                 y_ptag = MR_tag(y);
 
@@ -193,7 +194,7 @@
                 }
 
                 functor_desc = ptaglayout->MR_sectag_alternatives[x_sectag];
-#endif
+  #endif /* select_compare_code */
 
                 if (functor_desc->MR_du_functor_sectag_locn ==
                     MR_SECTAG_REMOTE)
@@ -235,11 +236,11 @@
                         }
                         result = MR_compare_type_info(x_ti, y_ti);
                         if (result != MR_COMPARE_EQUAL) {
-#ifdef  select_compare_code
+  #ifdef  select_compare_code
                             return_answer(result);
-#else
+  #else
                             return_answer(FALSE);
-#endif
+  #endif
                         }
                     }
 
@@ -258,32 +259,32 @@
                         arg_type_info = (MR_TypeInfo)
                             functor_desc->MR_du_functor_arg_types[i];
                     }
-#ifdef  select_compare_code
+  #ifdef  select_compare_code
                     result = MR_generic_compare(arg_type_info,
                         x_data_value[cur_slot], y_data_value[cur_slot]);
                     if (result != MR_COMPARE_EQUAL) {
                         return_answer(result);
                     }
-#else
+  #else
                     result = MR_generic_unify(arg_type_info,
                         x_data_value[cur_slot], y_data_value[cur_slot]);
                     if (! result) {
                         return_answer(FALSE);
                     }
-#endif
+  #endif
                     cur_slot++;
                 }
 
-#ifdef  select_compare_code
+  #ifdef  select_compare_code
                 return_answer(MR_COMPARE_EQUAL);
-#else
+  #else
                 return_answer(TRUE);
-#endif
+  #endif
             }
 
             break;
 
-#else
+#else /* ! MR_COMPARE_BY_RTTI */
 
         case MR_TYPECTOR_REP_EQUIV:
         case MR_TYPECTOR_REP_EQUIV_GROUND:
@@ -403,7 +404,11 @@
         case MR_TYPECTOR_REP_ENUM:
         case MR_TYPECTOR_REP_INT:
         case MR_TYPECTOR_REP_CHAR:
+
 #ifdef  select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+            compare_call_exit_code(integer_compare);
+  #endif
             if ((MR_Integer) x == (MR_Integer) y) {
                 return_answer(MR_COMPARE_EQUAL);
             } else if ((MR_Integer) x < (MR_Integer) y) {
@@ -412,7 +417,17 @@
                 return_answer(MR_COMPARE_GREATER);
             }
 #else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+            if ((MR_Integer) x == (MR_Integer) y) {
+                unify_call_exit_code(integer_unify);
+                return_answer(TRUE);
+            } else {
+                unify_call_fail_code(integer_unify);
+                return_answer(FALSE);
+            }
+  #else
             return_answer((MR_Integer) x == (MR_Integer) y);
+  #endif
 #endif
 
         case MR_TYPECTOR_REP_FLOAT:
@@ -422,6 +437,9 @@
                 fx = MR_word_to_float(x);
                 fy = MR_word_to_float(y);
 #ifdef  select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                compare_call_exit_code(float_compare);
+  #endif
                 if (fx == fy) {
                     return_answer(MR_COMPARE_EQUAL);
                 } else if (fx < fy) {
@@ -430,7 +448,17 @@
                     return_answer(MR_COMPARE_GREATER);
                 }
 #else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                if (fx == fy) {
+                    unify_call_exit_code(float_unify);
+                    return_answer(TRUE);
+                } else {
+                    unify_call_fail_code(float_unify);
+                    return_answer(FALSE);
+                }
+  #else
                 return_answer(fx == fy);
+  #endif
 #endif
             }
 
@@ -441,6 +469,9 @@
                 result = strcmp((char *) x, (char *) y);
 
 #ifdef  select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                compare_call_exit_code(string_compare);
+  #endif
                 if (result == 0) {
                     return_answer(MR_COMPARE_EQUAL);
                 } else if (result < 0) {
@@ -449,12 +480,25 @@
                     return_answer(MR_COMPARE_GREATER);
                 }
 #else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                if (result == 0) {
+                    unify_call_exit_code(string_unify);
+                    return_answer(TRUE);
+                } else {
+                    unify_call_fail_code(string_unify);
+                    return_answer(FALSE);
+                }
+  #else
                 return_answer(result == 0);
+  #endif
 #endif
             }
 
         case MR_TYPECTOR_REP_C_POINTER:
 #ifdef	select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+            compare_call_exit_code(c_pointer_compare);
+  #endif
             if ((void *) x == (void *) y) {
                 return_answer(MR_COMPARE_EQUAL);
             } else if ((void *) x < (void *) y) {
@@ -463,7 +507,17 @@
                 return_answer(MR_COMPARE_GREATER);
             }
 #else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+            if ((void *) x == (void *) y) {
+                unify_call_exit_code(c_pointer_unify);
+                return_answer(TRUE);
+            } else {
+                unify_call_fail_code(c_pointer_unify);
+                return_answer(FALSE);
+            }
+  #else
 	        return_answer((void *) x == (void *) y);
+  #endif
 #endif
 
         case MR_TYPECTOR_REP_TYPEINFO:
@@ -475,9 +529,22 @@
                     (MR_TypeInfo) x, (MR_TypeInfo) y);
                 MR_restore_transient_registers();
 #ifdef	select_compare_code
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                compare_call_exit_code(typeinfo_compare);
+  #endif
                 return_answer(result);
 #else
+  #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
+                if (result == MR_COMPARE_EQUAL) {
+                    unify_call_exit_code(typeinfo_unify);
+                    return_answer(TRUE);
+                } else {
+                    unify_call_fail_code(typeinfo_unify);
+                    return_answer(FALSE);
+                }
+  #else
                 return_answer(result == MR_COMPARE_EQUAL);
+  #endif
 #endif
             }
 
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list