[m-rev.] For review: Several improvements to RBMM
Quan Phan
quan.phan at cs.kuleuven.be
Fri Jan 18 11:46:58 AEDT 2008
Hi,
Zoltan, can you take a look at the diff soon? After committing, it would
be easier for me to have the changes in all my workspaces.
I sent part of this for you to review on 10/01, so please ignore that
outdate one.
Regards,
Quan.
-------------- next part --------------
Estimated hours taken: 8
Branch: main
1) Implement the saving of protected regions at disj frames ONLY for semidet
disjunctions. We need this information so as to be able to commit the regions'
removals when a nonlast disjunct of a semidet disjunction succeeds.
Now the fixed part of a disj frame will have 4 slots instead of 3. The extra
slot is to store the number of protected regions. It will be zero for nondet
disjunctions.
For semidet disjunctions we can use the information in their rbmm_goal_info
for protected regions and allocated-into regions.
Also implement the profiling and debugging messages for the saving.
2) Fix a bug relates to the saving of region size records at ite frame.
3) Do not protect regions that are explicitly removed at the end of the
condition of an if-then-else. It is because when the program reaches that
point, we know for sure that the condition will succeed.
4) Improving the profiling of RBMM
compiler/disj_gen.m:
Implement 1).
Remove the old code that do the saving for nondet disjunctions.
compiler/llds.m
compiler/llds_out.m
compiler/opt_debug.m
Make them conform to the changes for 1).
compiler/options.m
Make sure the size of the fixed part of disj frames is 4 (slots).
Change to conform to the changes for 1).
runtime/mercury_region.h
runtime/mercury_region.c
Implement the saving and its profiling and debugging messages.
Implement the improvement of the profiling of RBMM:
more information,
more structured when displaying the profiling information,
correct some bugs.
runtime/mercury_types.h:
To conform to the changes at 1).
-------------- next part --------------
? benchmarks
? diff_071219
? diff_080117
? tmp
? compiler/diff.disj
? compiler/ite_gen.backup
? runtime/diff
? runtime/diff2
? scripts/mtags
Index: INSTALL_CVS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/INSTALL_CVS,v
retrieving revision 1.8
diff -u -r1.8 INSTALL_CVS
--- INSTALL_CVS 26 Jul 2003 15:22:31 -0000 1.8
+++ INSTALL_CVS 17 Jan 2008 20:26:22 -0000
@@ -38,15 +38,15 @@
# If you don't want to do a parallel make, comment out the
# `parallel=-j3' line below.
-parallel=-j3
+#parallel=-j2
-autoconf &&
-./configure &&
+#autoconf &&
+#./configure &&
touch Mmake.params &&
touch Mercury.options &&
-mmake depend $parallel &&
+#mmake depend $parallel &&
mmake MMAKEFLAGS=$parallel &&
-tools/bootcheck $parallel &&
-cd stage2 &&
-mmake install MMAKEFLAGS=$parallel &&
+#tools/bootcheck $parallel &&
+#cd stage2 &&
+#mmake install MMAKEFLAGS=$parallel &&
true
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.108
diff -u -r1.108 disj_gen.m
--- compiler/disj_gen.m 30 Dec 2007 04:09:20 -0000 1.108
+++ compiler/disj_gen.m 17 Jan 2008 20:26:24 -0000
@@ -361,14 +361,13 @@
ReclaimHeap),
maybe_save_hp(ReclaimHeap, SaveHpCode, MaybeHpSlot, !CI),
- maybe_create_disj_region_frame(AddRegionOps, DisjGoalInfo,
- do_not_commit_at_end_of_disjunct,
- BeforeEnterRegionCode, LaterRegionCode, LastRegionCode,
- _RegionStackVars, RegionCommitDisjCleanup, !CI),
+ maybe_create_disj_region_frame_nondet(AddRegionOps, DisjGoalInfo,
+ BeforeEnterRegionCode, LaterRegionCode, LastRegionCode, !CI),
% We can't release any of the stack slots holding the embedded stack
% frame, since we can't let code to the right of the disjunction reuse
% any of those slots.
- RegionStackVarsToRelease = []
+ RegionStackVarsToRelease = [],
+ RegionCommitDisjCleanup = no_commit_disj_region_cleanup
;
( CodeModel = model_det
; CodeModel = model_semi
@@ -409,8 +408,8 @@
;
% We only need region support for backtracking if some disjunct
% performs some region operations (allocation or removal).
- maybe_create_disj_region_frame(AddRegionOps, DisjGoalInfo,
- commit_at_end_of_disjunct,
+ maybe_create_disj_region_frame_semi(AddRegionOps,
+ DisjRemovedRegionVars, DisjAllocRegionVars,
BeforeEnterRegionCode, LaterRegionCode, LastRegionCode,
RegionStackVars, RegionCommitDisjCleanup, !CI),
RegionStackVarsToRelease = RegionStackVars
@@ -678,10 +677,6 @@
%-----------------------------------------------------------------------------%
-:- type commit_at_end_of_disjunct
- ---> commit_at_end_of_disjunct
- ; do_not_commit_at_end_of_disjunct.
-
:- type commit_disj_region_cleanup
---> no_commit_disj_region_cleanup
; commit_disj_region_cleanup(
@@ -689,38 +684,125 @@
cleanup_code :: code_tree
).
-:- pred maybe_create_disj_region_frame(add_region_ops::in, hlds_goal_info::in,
- commit_at_end_of_disjunct::in,
- code_tree::out, code_tree::out, code_tree::out, list(lval)::out,
- commit_disj_region_cleanup::out, code_info::in, code_info::out) is det.
-
-maybe_create_disj_region_frame(DisjRegionOps, _DisjGoalInfo,
- CommitAtEndOfDisjunct, BeforeEnterCode, LaterCode, LastCode,
- StackVars, RegionCommitDisjCleanup, !CI) :-
+:- pred maybe_create_disj_region_frame_nondet(add_region_ops::in,
+ hlds_goal_info::in, code_tree::out, code_tree::out, code_tree::out,
+ code_info::in, code_info::out) is det.
+
+maybe_create_disj_region_frame_nondet(DisjRegionOps, _DisjGoalInfo,
+ BeforeEnterCode, LaterCode, LastCode, !CI) :-
(
DisjRegionOps = do_not_add_region_ops,
BeforeEnterCode = empty,
LaterCode = empty,
- LastCode = empty,
- StackVars = [],
- RegionCommitDisjCleanup = no_commit_disj_region_cleanup
+ LastCode = empty
;
DisjRegionOps = add_region_ops,
get_forward_live_vars(!.CI, ForwardLiveVars),
LiveRegionVars = filter_region_vars(!.CI, ForwardLiveVars),
- % XXX In computing both ProtectRegionVars and SnapshotRegionVars,
+ % Protection of backward live regions for nondet disjunction is by
+ % saving the sequence number to the disj frame, therefore we do not
+ % need to save any protected regions.
+
+ % XXX In computing SnapshotRegionVars,
% we should intersect LiveRegionVars with the set of region variables
% whose regions (the regions themselves, not their variables) are live
% at the starts of some later disjuncts (i.e. aren't used only in the
% first disjunct). We don't yet gather this information.
- %
- % XXX In computing ProtectRegionVars, we should also delete any
- % variables that are statically known to be already protected by
- % an outer disjunction, but we don't yet have the program analysis
- % required to gather such information.
- ProtectRegionVars = LiveRegionVars,
SnapshotRegionVars = LiveRegionVars,
+ SnapshotRegionVarList = set.to_sorted_list(SnapshotRegionVars),
+ list.length(SnapshotRegionVarList, NumSnapshotRegionVars),
+
+ get_globals(!.CI, Globals),
+ globals.lookup_int_option(Globals, size_region_disj_fixed,
+ FixedSize),
+ globals.lookup_int_option(Globals, size_region_disj_snapshot,
+ SnapshotSize),
+ FrameSize = FixedSize + SnapshotSize * NumSnapshotRegionVars,
+
+ Items = list.duplicate(FrameSize, slot_region_disj),
+ acquire_several_temp_slots(Items, non_persistent_temp_slot,
+ _StackVars, MainStackId, FirstSlotNum, LastSlotNum, !CI),
+ EmbeddedStackFrame = embedded_stack_frame_id(MainStackId,
+ FirstSlotNum, LastSlotNum),
+ FirstNonFixedAddr =
+ first_nonfixed_embedded_slot_addr(EmbeddedStackFrame, FixedSize),
+ acquire_reg(reg_r, SnapshotNumRegLval, !CI),
+ acquire_reg(reg_r, AddrRegLval, !CI),
+ PushInitCode = node([
+ llds_instr(
+ push_region_frame(region_stack_disj, EmbeddedStackFrame),
+ "Save stack pointer of embedded region nondet stack"),
+ llds_instr(
+ assign(SnapshotNumRegLval, const(llconst_int(0))),
+ "Initialize number of snapshot_infos"),
+ llds_instr(
+ assign(AddrRegLval, FirstNonFixedAddr),
+ "Initialize pointer to nonfixed part of embedded frame")
+ ]),
+ disj_alloc_snapshot_regions(SnapshotNumRegLval, AddrRegLval,
+ EmbeddedStackFrame, SnapshotRegionVarList, SnapshotRegionCode,
+ !CI),
+ SetCode = node([
+ llds_instr(
+ region_set_fixed_slot(region_set_disj_num_snapshots,
+ EmbeddedStackFrame, lval(SnapshotNumRegLval)),
+ "Store the number of snapshot_infos")
+ ]),
+ release_reg(SnapshotNumRegLval, !CI),
+ release_reg(AddrRegLval, !CI),
+
+ BeforeEnterCode = tree_list([
+ PushInitCode,
+ SnapshotRegionCode,
+ SetCode
+ ]),
+ LaterCode = node([
+ llds_instr(
+ use_and_maybe_pop_region_frame(region_disj_later,
+ EmbeddedStackFrame),
+ "region enter later disjunct")
+ ]),
+ LastCode = node([
+ llds_instr(
+ use_and_maybe_pop_region_frame(region_disj_last,
+ EmbeddedStackFrame),
+ "region enter last disjunct")
+ ])
+ ).
+
+:- pred maybe_create_disj_region_frame_semi(add_region_ops::in,
+ set(prog_var)::in, set(prog_var)::in, code_tree::out, code_tree::out,
+ code_tree::out, list(lval)::out, commit_disj_region_cleanup::out,
+ code_info::in, code_info::out) is det.
+
+maybe_create_disj_region_frame_semi(DisjRegionOps, DisjRemovedRegionVars,
+ DisjAllocRegionVars, BeforeEnterCode, LaterCode, LastCode, StackVars,
+ RegionCommitDisjCleanup, !CI) :-
+ (
+ DisjRegionOps = do_not_add_region_ops,
+ BeforeEnterCode = empty,
+ LaterCode = empty,
+ LastCode = empty,
+ StackVars = [],
+ RegionCommitDisjCleanup = no_commit_disj_region_cleanup
+ ;
+ DisjRegionOps = add_region_ops,
+
+ % For a semidet disjunction, we need to save the protected regions,
+ % i.e., those removed in the scope of the semidet disjunction,
+ % into the disj frame so that if a non-last disjunct succeeds,
+ % we can reclaim such regions. We will only save ones which
+ % are currently not protected (this is checked at runtime).
+ ProtectRegionVars = DisjRemovedRegionVars,
+
+ % XXX In computing SnapshotRegionVars,
+ % we should intersect DisjAllocRegionVars with the set of region
+ % variables whose regions (the regions themselves, not their variables)
+ % are live at the starts of some later disjuncts (i.e. aren't used only
+ % in the first disjunct). We don't yet gather this information.
+ %
+ SnapshotRegionVars = DisjAllocRegionVars,
ProtectRegionVarList = set.to_sorted_list(ProtectRegionVars),
SnapshotRegionVarList = set.to_sorted_list(SnapshotRegionVars),
@@ -731,7 +813,7 @@
get_globals(!.CI, Globals),
globals.lookup_int_option(Globals, size_region_disj_fixed,
FixedSize),
- globals.lookup_int_option(Globals, size_region_disj_protect,
+ globals.lookup_int_option(Globals, size_region_semi_disj_protect,
ProtectSize),
globals.lookup_int_option(Globals, size_region_disj_snapshot,
SnapshotSize),
@@ -802,21 +884,15 @@
"region enter last disjunct")
]),
- (
- CommitAtEndOfDisjunct = do_not_commit_at_end_of_disjunct,
- RegionCommitDisjCleanup = no_commit_disj_region_cleanup
- ;
- CommitAtEndOfDisjunct = commit_at_end_of_disjunct,
- get_next_label(CleanupLabel, !CI),
- CleanupCode = node([
- llds_instr(
- use_and_maybe_pop_region_frame(
- region_disj_nonlast_semi_commit, EmbeddedStackFrame),
- "region cleanup commit for nonlast disjunct")
- ]),
- RegionCommitDisjCleanup = commit_disj_region_cleanup(CleanupLabel,
- CleanupCode)
- )
+ get_next_label(CleanupLabel, !CI),
+ CleanupCode = node([
+ llds_instr(
+ use_and_maybe_pop_region_frame(
+ region_disj_nonlast_semi_commit, EmbeddedStackFrame),
+ "region cleanup commit for nonlast disjunct")
+ ]),
+ RegionCommitDisjCleanup = commit_disj_region_cleanup(CleanupLabel,
+ CleanupCode)
).
:- pred disj_protect_regions(lval::in, lval::in, embedded_stack_frame_id::in,
@@ -828,7 +904,7 @@
produce_variable(RegionVar, ProduceVarCode, RegionVarRval, !CI),
SaveCode = node([
llds_instr(
- region_fill_frame(region_fill_disj_protect,
+ region_fill_frame(region_fill_semi_disj_protect,
EmbeddedStackFrame, RegionVarRval, NumLval, AddrLval),
"disj protect the region if needed")
]),
Index: compiler/ite_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.104
diff -u -r1.104 ite_gen.m
--- compiler/ite_gen.m 22 Nov 2007 17:12:07 -0000 1.104
+++ compiler/ite_gen.m 17 Jan 2008 20:26:24 -0000
@@ -144,7 +144,8 @@
AddRegionOps = should_add_region_ops(!.CI, IteGoalInfo),
IteRegionOps = AddRegionOps,
goal_to_conj_list(ElseGoal, ElseGoals),
- maybe_create_ite_region_frame(IteRegionOps, CondInfo, ElseGoals,
+ goal_to_conj_list(CondGoal, CondGoals),
+ maybe_create_ite_region_frame(IteRegionOps, CondInfo, CondGoals, ElseGoals,
RegionCondCode, RegionThenCode, RegionElseCode, RegionStackVars,
MaybeEmbeddedStackFrameId, !CI),
@@ -365,7 +366,8 @@
AddRegionOps = should_add_region_ops(!.CI, NotGoalInfo),
IteRegionOps = AddRegionOps,
Goal = hlds_goal(_, GoalInfo),
- maybe_create_ite_region_frame(IteRegionOps, GoalInfo, [],
+ goal_to_conj_list(Goal, CondGoals),
+ maybe_create_ite_region_frame(IteRegionOps, GoalInfo, CondGoals, [],
RegionCondCode, RegionThenCode, RegionElseCode, RegionStackVars,
MaybeRegionSuccRecordSlot, !CI),
% MaybeRegionSuccRecordSlot should be yes only for nondet conditions,
@@ -540,11 +542,11 @@
%-----------------------------------------------------------------------------%
:- pred maybe_create_ite_region_frame(add_region_ops::in,
- hlds_goal_info::in, list(hlds_goal)::in,
+ hlds_goal_info::in, list(hlds_goal)::in, list(hlds_goal)::in,
code_tree::out, code_tree::out, code_tree::out, list(lval)::out,
maybe(embedded_stack_frame_id)::out, code_info::in, code_info::out) is det.
-maybe_create_ite_region_frame(IteRegionOps, CondGoalInfo, ElseGoals,
+maybe_create_ite_region_frame(IteRegionOps, CondGoalInfo, CondGoals, ElseGoals,
CondCode, ThenCode, ElseCode, StackVars, MaybeEmbeddedStackFrameId,
!CI) :-
(
@@ -572,9 +574,15 @@
RbmmInfo = rbmm_goal_info(CondCreatedRegionVars,
CondRemovedRegionVars, CondCarriedRegionVars,
CondAllocRegionVars, _CondUsedRegionVars),
+ list.reverse(CondGoals, ReversedCondGoals),
+ code_info.get_module_info(!.CI, ModuleInfo),
+ find_regions_removed_at_start_of_goals(ReversedCondGoals,
+ ModuleInfo, set.init, RemovedAtEndOfThen),
+ set.difference(CondRemovedRegionVars, RemovedAtEndOfThen,
+ NeedToBeProtectedRegionVars),
(
set.empty(CondCreatedRegionVars),
- set.empty(CondRemovedRegionVars),
+ set.empty(NeedToBeProtectedRegionVars),
set.empty(CondAllocRegionVars)
->
% When no region-related operations occur in the
@@ -585,8 +593,7 @@
StackVars = [],
MaybeEmbeddedStackFrameId = no
;
- code_info.get_module_info(!.CI, ModuleInfo),
- find_regions_removed_at_start_of_else(ElseGoals, ModuleInfo,
+ find_regions_removed_at_start_of_goals(ElseGoals, ModuleInfo,
set.init, RemovedAtStartOfElse),
% The UnprotectedRemovedAtStartOfElse is the
@@ -599,7 +606,7 @@
RemovedAtStartOfElse, CondCarriedRegionVars),
ProtectRegionVars = set.intersect(LiveRegionVars,
- CondRemovedRegionVars),
+ NeedToBeProtectedRegionVars),
SnapshotRegionVars0 = set.intersect(LiveRegionVars,
CondAllocRegionVars),
SnapshotRegionVars = set.difference(SnapshotRegionVars0,
@@ -718,11 +725,11 @@
% Given the list of goals in the else branch, accumulate the region
% variables whose regions are removed at the start of that list.
%
-:- pred find_regions_removed_at_start_of_else(list(hlds_goal)::in,
+:- pred find_regions_removed_at_start_of_goals(list(hlds_goal)::in,
module_info::in, set(prog_var)::in, set(prog_var)::out) is det.
-find_regions_removed_at_start_of_else([], _, !Removed).
-find_regions_removed_at_start_of_else([Goal | Goals], ModuleInfo, !Removed) :-
+find_regions_removed_at_start_of_goals([], _, !Removed).
+find_regions_removed_at_start_of_goals([Goal | Goals], ModuleInfo, !Removed) :-
Goal = hlds_goal(GoalExpr, _),
(
GoalExpr = plain_call(PredId, _ProcId, Args, _Builtin, _UC, _SymName),
@@ -732,7 +739,7 @@
Args = [RegionVar]
->
set.insert(!.Removed, RegionVar, !:Removed),
- find_regions_removed_at_start_of_else(Goals, ModuleInfo, !Removed)
+ find_regions_removed_at_start_of_goals(Goals, ModuleInfo, !Removed)
;
true
).
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.356
diff -u -r1.356 llds.m
--- compiler/llds.m 30 Dec 2007 08:23:46 -0000 1.356
+++ compiler/llds.m 17 Jan 2008 20:26:25 -0000
@@ -768,7 +768,7 @@
:- type region_fill_frame_op
---> region_fill_ite_protect
; region_fill_ite_snapshot(removed_at_start_of_else)
- ; region_fill_disj_protect
+ ; region_fill_semi_disj_protect
; region_fill_disj_snapshot
; region_fill_commit.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.321
diff -u -r1.321 llds_out.m
--- compiler/llds_out.m 30 Dec 2007 08:23:47 -0000 1.321
+++ compiler/llds_out.m 17 Jan 2008 20:26:27 -0000
@@ -2601,8 +2601,8 @@
FillOp = region_fill_ite_snapshot(not_removed_at_start_of_else),
io.write_string("\tMR_region_fill_ite_snapshot_not_removed", !IO)
;
- FillOp = region_fill_disj_protect,
- io.write_string("\tMR_region_fill_disj_protect", !IO)
+ FillOp = region_fill_semi_disj_protect,
+ io.write_string("\tMR_region_fill_semi_disj_protect", !IO)
;
FillOp = region_fill_disj_snapshot,
io.write_string("\tMR_region_fill_disj_snapshot", !IO)
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.203
diff -u -r1.203 opt_debug.m
--- compiler/opt_debug.m 30 Dec 2007 08:23:51 -0000 1.203
+++ compiler/opt_debug.m 17 Jan 2008 20:26:28 -0000
@@ -846,8 +846,8 @@
FillOp = region_fill_ite_snapshot(not_removed_at_start_of_else),
FillOpStr = "ite_snapshot(not_removed_at_start_of_else)"
;
- FillOp = region_fill_disj_protect,
- FillOpStr = "disj_protect"
+ FillOp = region_fill_semi_disj_protect,
+ FillOpStr = "semi_disj_protect"
;
FillOp = region_fill_disj_snapshot,
FillOpStr = "disj_snapshot"
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.608
diff -u -r1.608 options.m
--- compiler/options.m 30 Dec 2007 08:23:52 -0000 1.608
+++ compiler/options.m 17 Jan 2008 20:26:30 -0000
@@ -471,11 +471,12 @@
; size_region_ite_fixed
; size_region_disj_fixed
+ ; size_region_semi_disj_fixed
; size_region_commit_fixed
; size_region_ite_protect
; size_region_ite_snapshot
- ; size_region_disj_protect
+ ; size_region_semi_disj_protect
; size_region_disj_snapshot
; size_region_commit_entry
@@ -1221,15 +1222,11 @@
% The size_* values below *must* be consistent with the corresponding
% values or data structures in mercury_region.h.
size_region_ite_fixed - int(4),
- size_region_disj_fixed - int(3),
+ size_region_disj_fixed - int(4),
size_region_commit_fixed - int(4),
size_region_ite_protect - int(1),
size_region_ite_snapshot - int(3),
- size_region_disj_protect - int(0),
- % size_region_disj_protect is no longer
- % used. It should be removed when the
- % runtime support for RBMM is more
- % stable.
+ size_region_semi_disj_protect - int(1),
size_region_disj_snapshot - int(3),
size_region_commit_entry - int(1),
solver_type_auto_init - bool(no),
@@ -2017,14 +2014,14 @@
long_option("disable-mm-pneg", disable_minimal_model_stack_copy_pneg).
long_option("disable-mm-cut", disable_minimal_model_stack_copy_cut).
long_option("disable-trail-ops", disable_trail_ops).
-long_option("size-region-ite-fixed", size_region_ite_fixed).
-long_option("size-region-disj-fixed", size_region_disj_fixed).
-long_option("size-region-commit-fixed", size_region_commit_fixed).
-long_option("size-region-ite-protect", size_region_ite_protect).
-long_option("size-region-ite-snapshot", size_region_ite_snapshot).
-long_option("size-region-disj-protect", size_region_disj_protect).
-long_option("size-region-disj-snapshot", size_region_disj_snapshot).
-long_option("size-region-commit-entry", size_region_commit_entry).
+long_option("size-region-ite-fixed", size_region_ite_fixed).
+long_option("size-region-disj-fixed", size_region_disj_fixed).
+long_option("size-region-commit-fixed", size_region_commit_fixed).
+long_option("size-region-ite-protect", size_region_ite_protect).
+long_option("size-region-ite-snapshot", size_region_ite_snapshot).
+long_option("size-region-semi-disj-protect", size_region_semi_disj_protect).
+long_option("size-region-disj-snapshot", size_region_disj_snapshot).
+long_option("size-region-commit-entry", size_region_commit_entry).
long_option("solver-type-auto-init", solver_type_auto_init).
long_option("allow-multi-arm-switches", allow_multi_arm_switches).
Index: runtime/mercury_region.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.c,v
retrieving revision 1.8
diff -u -r1.8 mercury_region.c
--- runtime/mercury_region.c 21 Dec 2007 14:18:59 -0000 1.8
+++ runtime/mercury_region.c 17 Jan 2008 20:26:31 -0000
@@ -30,25 +30,44 @@
#if defined(MR_RBMM_PROFILING)
-MR_RegionProfUnit MR_rbmmp_words_used = {0, 0, 0};
MR_RegionProfUnit MR_rbmmp_regions_used = {0, 0, 0};
+unsigned int MR_rbmmp_biggest_region_size = 0;
+int MR_rbmmp_biggest_region = 0;
+unsigned int MR_rbmmp_regions_instant_reclaimed_at_disj = 0;
+unsigned int MR_rbmmp_regions_instant_reclaimed_at_ite = 0;
+unsigned int MR_rbmmp_regions_reclaimed_by_remove_instr = 0;
+unsigned int MR_rbmmp_regions_reclaimed_at_then_part = 0;
+unsigned int MR_rbmmp_regions_reclaimed_at_commit = 0;
+
+MR_RegionProfUnit MR_rbmmp_words_used = {0, 0, 0};
+unsigned int MR_rbmmp_words_instant_reclaimed_new_alloc = 0;
+unsigned int MR_rbmmp_words_instant_reclaimed_new_regions = 0;
+unsigned int MR_rbmmp_words_reclaimed_by_remove_instr = 0;
+unsigned int MR_rbmmp_words_reclaimed_at_then_part = 0;
+unsigned int MR_rbmmp_words_reclaimed_at_commit = 0;
+
MR_RegionProfUnit MR_rbmmp_pages_used = {0, 0, 0};
unsigned int MR_rbmmp_pages_requested = 0;
-unsigned int MR_rbmmp_biggest_region_size = 0;
-unsigned int MR_rbmmp_regions_saved_at_commit = 0;
-unsigned int MR_rbmmp_regions_protected_at_ite = 0;
-unsigned int MR_rbmmp_snapshots_saved_at_ite = 0;
-unsigned int MR_rbmmp_regions_protected_at_disj;
-unsigned int MR_rbmmp_snapshots_saved_at_disj = 0;
double MR_rbmmp_page_utilized;
-unsigned int MR_rbmmp_words_snapshot_instant_reclaimed = 0;
-unsigned int MR_rbmmp_pages_snapshot_instant_reclaimed = 0;
-MR_RegionProfUnit MR_rbmmp_num_ite_frames = {0, 0, 0};
+unsigned int MR_rbmmp_pages_instant_reclaimed_new_alloc = 0;
+unsigned int MR_rbmmp_pages_instant_reclaimed_new_regions = 0;
+unsigned int MR_rbmmp_pages_reclaimed_by_remove_instr = 0;
+unsigned int MR_rbmmp_pages_reclaimed_at_then_part = 0;
+unsigned int MR_rbmmp_pages_reclaimed_at_commit = 0;
+
MR_RegionProfUnit MR_rbmmp_num_disj_frames = {0, 0, 0};
-MR_RegionProfUnit MR_rbmmp_num_commit_frames = {0, 0, 0};
-MR_RegionProfUnit MR_rbmmp_words_used_by_ite_frames = {0, 0, 0};
MR_RegionProfUnit MR_rbmmp_words_used_by_disj_frames = {0, 0, 0};
+unsigned int MR_rbmmp_regions_protected_at_semi_disj = 0;
+unsigned int MR_rbmmp_snapshots_saved_at_disj = 0;
+
+MR_RegionProfUnit MR_rbmmp_num_ite_frames = {0, 0, 0};
+MR_RegionProfUnit MR_rbmmp_words_used_by_ite_frames = {0, 0, 0};
+unsigned int MR_rbmmp_regions_protected_at_ite = 0;
+unsigned int MR_rbmmp_snapshots_saved_at_ite = 0;
+
+MR_RegionProfUnit MR_rbmmp_num_commit_frames = {0, 0, 0};
MR_RegionProfUnit MR_rbmmp_words_used_by_commit_frames = {0, 0, 0};
+unsigned int MR_rbmmp_regions_saved_at_commit = 0;
#endif
@@ -296,6 +315,12 @@
MR_remove_undisjprotected_region_ite_then_semidet(MR_RegionHeader *region)
{
MR_region_destroy_region(region);
+#if defined(MR_RBMM_PROFILING)
+ MR_region_profile_reclaim_region(region,
+ &MR_rbmmp_regions_reclaimed_at_then_part,
+ &MR_rbmmp_pages_reclaimed_at_then_part,
+ &MR_rbmmp_words_reclaimed_at_then_part);
+#endif
MR_region_debug_destroy_region(region);
}
@@ -314,6 +339,12 @@
if ( !MR_region_is_disj_protected(region) ) {
MR_region_nullify_in_ite_frame(region);
MR_region_destroy_region(region);
+#if defined(MR_RBMM_PROFILING)
+ MR_region_profile_reclaim_region(region,
+ &MR_rbmmp_regions_reclaimed_at_then_part,
+ &MR_rbmmp_pages_reclaimed_at_then_part,
+ &MR_rbmmp_words_reclaimed_at_then_part);
+#endif
MR_region_debug_destroy_region(region);
} else {
region->MR_region_logical_removed = 1;
@@ -330,6 +361,12 @@
!(MR_region_is_disj_protected(region)) )
{
MR_region_destroy_region(region);
+#if defined(MR_RBMM_PROFILING)
+ MR_region_profile_reclaim_region(region,
+ &MR_rbmmp_regions_reclaimed_by_remove_instr,
+ &MR_rbmmp_pages_reclaimed_by_remove_instr,
+ &MR_rbmmp_words_reclaimed_by_remove_instr);
+#endif
} else {
region->MR_region_logical_removed = 1;
@@ -369,6 +406,10 @@
#if defined(MR_RBMM_PROFILING)
MR_region_update_profiling_unit(&MR_rbmmp_words_used, words);
region->MR_region_allocated_size += words;
+ if (region->MR_region_allocated_size > MR_rbmmp_biggest_region_size) {
+ MR_rbmmp_biggest_region_size = region->MR_region_allocated_size;
+ MR_rbmmp_biggest_region = region->MR_region_sequence_number;
+ }
#endif
return allocated_cell;
@@ -406,6 +447,12 @@
** region, So just need to destroy it at commit.
*/
MR_region_destroy_region(region);
+#if defined(MR_RBMM_PROFILING)
+ MR_region_profile_reclaim_region(region,
+ &MR_rbmmp_regions_reclaimed_at_commit,
+ &MR_rbmmp_pages_reclaimed_at_commit,
+ &MR_rbmmp_words_reclaimed_at_commit);
+#endif
}
}
}
@@ -425,6 +472,12 @@
{
if (region->MR_region_destroy_at_commit) {
MR_region_destroy_region(region);
+#if defined(MR_RBMM_PROFILING)
+ MR_region_profile_reclaim_region(region,
+ &MR_rbmmp_regions_reclaimed_at_commit,
+ &MR_rbmmp_pages_reclaimed_at_commit,
+ &MR_rbmmp_words_reclaimed_at_commit);
+#endif
}
/*
** XXX It is fine to destroy the region and then still use it to find
@@ -761,6 +814,19 @@
}
void
+MR_region_fill_semi_disj_protect_msg(MR_RegionSemiDisjProtect *semi_disj_prot,
+ MR_RegionHeader *region)
+{
+ if (semi_disj_prot == NULL) {
+ printf("\tNot protect region #%d.\n",
+ region->MR_region_sequence_number);
+ } else {
+ printf("\tAt slot: %d, protect region #%d.\n", semi_disj_prot,
+ region->MR_region_sequence_number);
+ }
+}
+
+void
MR_region_fill_disj_snapshot_msg(MR_RegionSnapshot *snapshot,
MR_RegionHeader *region)
{
@@ -840,9 +906,6 @@
allocated_size_of_region = region->MR_region_allocated_size;
MR_region_update_profiling_unit(&MR_rbmmp_words_used,
-allocated_size_of_region);
- if (allocated_size_of_region > MR_rbmmp_biggest_region_size) {
- MR_rbmmp_biggest_region_size = allocated_size_of_region;
- }
}
void
@@ -858,8 +921,28 @@
restoring_region->MR_region_allocated_size
-= new_words;
MR_region_update_profiling_unit(&MR_rbmmp_words_used, -new_words);
- MR_rbmmp_pages_snapshot_instant_reclaimed += new_pages;
- MR_rbmmp_words_snapshot_instant_reclaimed += new_words;
+ MR_rbmmp_pages_instant_reclaimed_new_alloc += new_pages;
+ MR_rbmmp_words_instant_reclaimed_new_alloc += new_words;
+}
+
+void
+MR_region_profile_reclaim_region(MR_RegionHeader *region,
+ unsigned int *regions_reclaimed, unsigned int *pages_reclaimed,
+ unsigned int *words_reclaimed)
+{
+ MR_region_profile_increase_counter(regions_reclaimed);
+ MR_region_profile_reclaim_pages_and_words(region, pages_reclaimed,
+ words_reclaimed);
+}
+
+void
+MR_region_profile_reclaim_pages_and_words(MR_RegionHeader *region,
+ unsigned int *pages_reclaimed, unsigned int *words_reclaimed)
+{
+ *pages_reclaimed += MR_region_get_number_of_pages(
+ MR_region_to_first_regionpage(region),
+ region->MR_region_last_page);
+ *words_reclaimed += region->MR_region_allocated_size;
}
void
@@ -935,36 +1018,75 @@
MR_region_print_profiling_info(void)
{
printf("\n---------- Profiling information ----------\n");
+ /* Info about regions */
MR_region_print_profiling_unit("Regions:", &MR_rbmmp_regions_used);
printf("Biggest region size: %d.\n", MR_rbmmp_biggest_region_size);
+ printf("Biggest region's sequence number: %d.\n", MR_rbmmp_biggest_region);
+ printf("Reclaimed as follows:\n");
+ printf("\tThanks to reclaiming new regions at ite: %d.\n",
+ MR_rbmmp_regions_instant_reclaimed_at_ite);
+ printf("\tThanks to reclaiming new regions at disj: %d.\n",
+ MR_rbmmp_regions_instant_reclaimed_at_disj);
+ printf("\tAt the start of then part: %d.\n",
+ MR_rbmmp_regions_reclaimed_at_then_part);
+ printf("\tAt commit point: %d.\n",
+ MR_rbmmp_regions_reclaimed_at_commit);
+ printf("\tBy remove instruction: %d.\n",
+ MR_rbmmp_regions_reclaimed_by_remove_instr);
+
+ /* Info about words used*/
MR_region_print_profiling_unit("Words:", &MR_rbmmp_words_used);
- MR_region_print_profiling_unit("Pages used:", &MR_rbmmp_pages_used);
+ printf("Reclaimed as follows:\n");
+ printf("\tInstant reclaiming of new allocations: %d.\n",
+ MR_rbmmp_words_instant_reclaimed_new_alloc);
+ printf("\tInstant reclaiming of new regions: %d.\n",
+ MR_rbmmp_words_instant_reclaimed_new_regions);
+ printf("\tAt the start of then part: %d.\n",
+ MR_rbmmp_words_reclaimed_at_then_part);
+ printf("\tAt commit point: %d.\n",
+ MR_rbmmp_words_reclaimed_at_commit);
+ printf("\tBy remove instruction: %d.\n",
+ MR_rbmmp_words_reclaimed_by_remove_instr);
+
+ /* Info about pages used*/
+ MR_region_print_profiling_unit("Pages:", &MR_rbmmp_pages_used);
printf("Pages requested: %d.\n", MR_rbmmp_pages_requested);
printf("Pages utilized: %lf.\n",
MR_rbmmp_pages_used.MR_rbmmpu_total / (double)MR_rbmmp_pages_requested);
- printf("Regions protected at ite frames: %d.\n",
- MR_rbmmp_regions_protected_at_ite);
- printf("Regions saved at commit frames: %d.\n",
- MR_rbmmp_regions_saved_at_commit);
- printf("Snapshots at ite frames: %d.\n", MR_rbmmp_snapshots_saved_at_ite);
- printf("Snapshots at disj frames: %d.\n",
+ printf("\tInstant reclaiming of new allocations: %d.\n",
+ MR_rbmmp_pages_instant_reclaimed_new_alloc);
+ printf("\tInstant reclaiming of new regions: %d.\n",
+ MR_rbmmp_pages_instant_reclaimed_new_regions);
+ printf("\tAt the start of then part: %d.\n",
+ MR_rbmmp_pages_reclaimed_at_then_part);
+ printf("\tAt commit point: %d.\n",
+ MR_rbmmp_pages_reclaimed_at_commit);
+ printf("\tBy remove instruction: %d.\n",
+ MR_rbmmp_pages_reclaimed_by_remove_instr);
+
+ /* Info about embedded frames */
+ MR_region_print_profiling_unit("Disj frames used:",
+ &MR_rbmmp_num_disj_frames);
+ MR_region_print_profiling_unit("Words used by disj frames:",
+ &MR_rbmmp_words_used_by_disj_frames);
+ printf("Regions protected at (semi) disj frames: %d.\n",
+ MR_rbmmp_regions_protected_at_semi_disj);
+ printf("Region size records saved at disj frames: %d.\n",
MR_rbmmp_snapshots_saved_at_disj);
- printf("Words instant reclaimed thanks to snapshot: %d.\n",
- MR_rbmmp_words_snapshot_instant_reclaimed);
- printf("Pages instant reclaimed thanks to snapshot: %d.\n",
- MR_rbmmp_pages_snapshot_instant_reclaimed);
MR_region_print_profiling_unit("Ite frames used:",
&MR_rbmmp_num_ite_frames);
- MR_region_print_profiling_unit("Disj frames used:",
- &MR_rbmmp_num_disj_frames);
- MR_region_print_profiling_unit("Commit frames used:",
- &MR_rbmmp_num_commit_frames);
MR_region_print_profiling_unit("Words used by ite frames:",
&MR_rbmmp_words_used_by_ite_frames);
- MR_region_print_profiling_unit("Words used by disj frames:",
- &MR_rbmmp_words_used_by_disj_frames);
+ printf("Regions protected at ite frames: %d.\n",
+ MR_rbmmp_regions_protected_at_ite);
+ printf("Region size records saved at ite frames: %d.\n",
+ MR_rbmmp_snapshots_saved_at_ite);
+ MR_region_print_profiling_unit("Commit frames used:",
+ &MR_rbmmp_num_commit_frames);
MR_region_print_profiling_unit("Words used by commit frames:",
&MR_rbmmp_words_used_by_commit_frames);
+ printf("Regions saved at commit frames: %d.\n",
+ MR_rbmmp_regions_saved_at_commit);
}
#else /* Not define MR_RBMM_PROFILING. */
@@ -988,6 +1110,21 @@
}
void
+MR_region_profile_reclaim_region(MR_RegionHeader *region,
+ unsigned int *regions_reclaimed, unsigned int *pages_reclaimed,
+ unsigned int *words_reclaimed)
+{
+ /* do nothing */
+}
+
+void
+MR_region_profile_reclaim_pages_and_words(MR_RegionHeader *region,
+ unsigned int *pages_reclaimed, unsigned int *words_reclaimed)
+{
+ /* do nothing */
+}
+
+void
MR_region_profile_increase_counter(unsigned int *counter)
{
/* do nothing */
Index: runtime/mercury_region.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.h,v
retrieving revision 1.10
diff -u -r1.10 mercury_region.h
--- runtime/mercury_region.h 30 Dec 2007 04:09:25 -0000 1.10
+++ runtime/mercury_region.h 17 Jan 2008 20:26:32 -0000
@@ -45,16 +45,11 @@
** runtime errors likely happen.
*/
#define MR_REGION_ITE_FRAME_FIXED_SIZE 4
-#define MR_REGION_DISJ_FRAME_FIXED_SIZE 3
+#define MR_REGION_DISJ_FRAME_FIXED_SIZE 4
#define MR_REGION_COMMIT_FRAME_FIXED_SIZE 4
#define MR_REGION_ITE_PROT_SIZE 1
#define MR_REGION_ITE_SNAPSHOT_SIZE 3
-/*
-** XXX The MR_REGION_DISJ_PROT_SIZE is no longer used. It should be removed
-** when the runtime support for RBMM becomes more stable. When removing it,
-** remember to make the compiler/options.m consistent with the removal here.
-*/
-#define MR_REGION_DISJ_PROT_SIZE 0
+#define MR_REGION_SEMI_DISJ_PROT_SIZE 1
#define MR_REGION_DISJ_SNAPSHOT_SIZE 3
#define MR_REGION_COMMIT_SAVE_SIZE 1
@@ -158,6 +153,7 @@
MR_RegionDisjFixedFrame *MR_rdff_previous_disj_frame;
MR_Word MR_rdff_saved_sequence_number;
MR_Word MR_rdff_num_snapshots;
+ MR_Word MR_rdff_num_prot_regions;
};
struct MR_RegionCommitFixedFrame_Struct {
@@ -183,8 +179,8 @@
};
/* Protection information in a disj frame. */
-struct MR_RegionDisjProtect_Struct {
- MR_RegionHeader *MR_disj_prot_region;
+struct MR_RegionSemiDisjProtect_Struct {
+ MR_RegionHeader *MR_semi_disj_prot_region;
};
/* Save information in a commit frame */
@@ -285,6 +281,7 @@
MR_region_disj_sp; \
new_disj_frame->MR_rdff_saved_sequence_number = \
MR_region_sequence_number; \
+ new_disj_frame->MR_rdff_num_prot_regions = 0; \
MR_region_disj_sp = new_disj_frame; \
MR_region_profile_push_disj_frame; \
MR_region_debug_push_disj_frame(new_disj_frame); \
@@ -368,8 +365,9 @@
"fill_ite_snapshot_removed"); \
region = (MR_RegionHeader *) (region_ptr); \
snapshot = (MR_RegionSnapshot *) (snapshot_block); \
- if (region->MR_region_ite_protected != NULL || \
- MR_region_is_disj_protected(region)) \
+ if ((region->MR_region_ite_protected != NULL && \
+ region->MR_region_ite_protected != MR_region_ite_sp \
+ ) || MR_region_is_disj_protected(region)) \
{ \
MR_save_snapshot(region, snapshot); \
MR_region_profile_fill_ite_snapshot; \
@@ -384,6 +382,7 @@
MR_region_debug_end("fill_ite_snapshot_removed"); \
} while (0)
+/* XXX: This can be made more efficient because we will save them all */
#define MR_region_fill_ite_snapshot_not_removed(ite_sp, region_ptr, \
num_snapshots, snapshot_block) \
do { \
@@ -404,11 +403,32 @@
"fill_ite_snapshot_not_removed"); \
} while (0)
-#define MR_region_fill_disj_protect(disj_sp, region_ptr, \
+#define MR_region_fill_semi_disj_protect(disj_sp, region_ptr, \
num_protected_regions, protection_block) \
do { \
+ MR_RegionHeader *region; \
+ MR_RegionSemiDisjProtect *semi_disj_prot; \
+ \
+ MR_region_debug_start("fill_semi_disj_protect"); \
+ region = (MR_RegionHeader *) (region_ptr); \
+ if (!MR_region_is_disj_protected(region) && \
+ region->MR_region_ite_protected == NULL) \
+ { \
+ semi_disj_prot = \
+ (MR_RegionSemiDisjProtect *) (protection_block); \
+ semi_disj_prot->MR_semi_disj_prot_region = region; \
+ (num_protected_regions)++; \
+ (protection_block) = (MR_Word)(semi_disj_prot + 1); \
+ MR_region_profile_fill_semi_disj_protect; \
+ MR_region_debug_fill_semi_disj_protect(semi_disj_prot, \
+ region); \
+ } else { \
+ MR_region_debug_fill_semi_disj_protect(NULL, region); \
+ } \
+ MR_region_debug_end("fill_ite_protect"); \
} while (0)
+/* XXX: This can be made more efficient because we will save them all */
#define MR_region_fill_disj_snapshot(disj_sp, region_ptr, \
num_snapshots, snapshot_block) \
do { \
@@ -432,7 +452,7 @@
** Set the commit_frame field in these regions to point to the frame.
*/
#define MR_region_fill_commit(commit_sp, region_ptr, \
- num_saved_region_reg, region_slot_reg) \
+ num_saved_region_reg, region_slot_reg) \
do { \
MR_RegionHeader *region; \
MR_RegionCommitSave *commit_save; \
@@ -478,6 +498,10 @@
#define MR_region_set_disj_num_protects(disj_sp, num) \
do { \
+ MR_RegionDisjFixedFrame *top_disj_frame; \
+ \
+ top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
+ top_disj_frame->MR_rdff_num_prot_regions = (num); \
} while (0)
#define MR_region_set_disj_num_snapshots(disj_sp, num) \
@@ -616,10 +640,20 @@
#define MR_use_region_disj_nonlast_semi_commit(disj_sp) \
do { \
MR_RegionDisjFixedFrame *top_disj_frame; \
+ MR_RegionSemiDisjProtect *semi_disj_prot; \
+ int i; \
\
- MR_region_debug_start("use_region_disj_nonlast_semi_commit"); \
+ MR_region_debug_start( \
+ "use_region_disj_nonlast_semi_commit"); \
top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
/* XXX destroy any regions protected by the disj frame */ \
+ semi_disj_prot = (MR_RegionSemiDisjProtect *) ( (disj_sp) + \
+ MR_REGION_DISJ_FRAME_FIXED_SIZE); \
+ for (i = 0; i < top_disj_frame->MR_rdff_num_prot_regions; \
+ i++, semi_disj_prot++) { \
+ MR_region_destroy_region( \
+ semi_disj_prot->MR_semi_disj_prot_region); \
+ } \
MR_pop_region_disj_frame(top_disj_frame); \
MR_region_debug_end("use_region_disj_nonlast_semi_commit"); \
} while (0)
@@ -781,7 +815,8 @@
MR_region_debug_start( \
"ite_destroy_new_regions"); \
MR_region_frame_destroy_new_regions( \
- top_ite_frame->MR_riff_saved_sequence_number); \
+ top_ite_frame->MR_riff_saved_sequence_number, \
+ MR_REGION_ITE_FRAME_TYPE); \
MR_region_debug_end( \
"ite_destroy_new_regions"); \
} while (0)
@@ -800,7 +835,9 @@
"disj_restore_from_snapshots"); \
first_snapshot = (MR_RegionSnapshot *) ( \
(MR_Word *) (top_disj_frame) + \
- MR_REGION_DISJ_FRAME_FIXED_SIZE); \
+ MR_REGION_DISJ_FRAME_FIXED_SIZE + \
+ MR_REGION_SEMI_DISJ_PROT_SIZE * \
+ top_disj_frame->MR_rdff_num_prot_regions); \
MR_restore_snapshots(top_disj_frame->MR_rdff_num_snapshots, \
first_snapshot); \
MR_region_debug_end( \
@@ -816,7 +853,8 @@
MR_region_debug_start( \
"disj_destroy_new_regions"); \
MR_region_frame_destroy_new_regions( \
- top_disj_frame->MR_rdff_saved_sequence_number); \
+ top_disj_frame->MR_rdff_saved_sequence_number, \
+ MR_REGION_DISJ_FRAME_TYPE); \
MR_region_debug_end( \
"disj_destroy_new_regions"); \
} while (0)
@@ -871,7 +909,8 @@
} \
} while(0)
-#define MR_region_frame_destroy_new_regions(saved_sequence_number) \
+#define MR_region_frame_destroy_new_regions(saved_sequence_number, \
+ frame_type) \
do { \
MR_RegionHeader *region; \
\
@@ -882,6 +921,8 @@
{ \
MR_region_destroy_region(region); \
MR_region_debug_destroy_region(region); \
+ MR_region_profile_frame_destroy_region(region, \
+ frame_type); \
region = region->MR_region_next_region; \
} \
MR_live_region_list = region; \
@@ -967,6 +1008,10 @@
#define MR_region_debug_fill_ite_snapshot_removed(snapshot, region) \
MR_region_fill_ite_snapshot_removed_msg(snapshot, region)
+ #define MR_region_debug_fill_semi_disj_protect(semi_disj_prot, \
+ region) \
+ MR_region_fill_semi_disj_protect_msg(semi_disj_prot, region)
+
#define MR_region_debug_fill_disj_snapshot(snapshot, region) \
MR_region_fill_disj_snapshot_msg(snapshot, region)
@@ -1041,6 +1086,10 @@
#define MR_region_debug_fill_ite_snapshot_removed(snapshot, region) \
((void) 0)
+ #define MR_region_debug_fill_semi_disj_protect(semi_disj_prot, \
+ region) \
+ ((void) 0)
+
#define MR_region_debug_fill_disj_snapshot(snapshot, region) \
((void) 0)
@@ -1127,29 +1176,52 @@
int MR_rbmmpu_total;
};
-extern MR_RegionProfUnit MR_rbmmp_words_used;
extern MR_RegionProfUnit MR_rbmmp_regions_used;
+extern unsigned int MR_rbmmp_biggest_region_size;
+extern int MR_rbmmp_biggest_region;
+extern unsigned int MR_rbmmp_regions_instant_reclaimed_at_disj;
+extern unsigned int MR_rbmmp_regions_instant_reclaimed_at_ite;
+extern unsigned int MR_rbmmp_regions_reclaimed_by_remove_instr;
+extern unsigned int MR_rbmmp_regions_reclaimed_at_then_part;
+extern unsigned int MR_rbmmp_regions_reclaimed_at_commit;
+
+extern MR_RegionProfUnit MR_rbmmp_words_used;
+extern unsigned int MR_rbmmp_words_instant_reclaimed_new_alloc;
+extern unsigned int MR_rbmmp_words_instant_reclaimed_new_regions;
+extern unsigned int MR_rbmmp_words_reclaimed_by_remove_instr;
+extern unsigned int MR_rbmmp_words_reclaimed_at_then_part;
+extern unsigned int MR_rbmmp_words_reclaimed_at_commit;
+
extern MR_RegionProfUnit MR_rbmmp_pages_used;
extern unsigned int MR_rbmmp_page_requested;
-extern unsigned int MR_rbmmp_biggest_region_size;
-extern unsigned int MR_rbmmp_regions_saved_at_commit;
-extern unsigned int MR_rbmmp_regions_protected_at_ite;
-extern unsigned int MR_rbmmp_snapshots_saved_at_ite;
-extern unsigned int MR_rbmmp_snapshots_saved_at_disj;
extern double MR_rbmmp_page_utilized;
-extern unsigned int MR_rbmmp_words_snapshot_instant_reclaimed;
-extern unsigned int MR_rbmmp_pages_snapshot_instant_reclaimed;
-extern MR_RegionProfUnit MR_rbmmp_num_ite_frames;
+extern unsigned int MR_rbmmp_pages_instant_reclaimed_new_alloc;
+extern unsigned int MR_rbmmp_pages_instant_reclaimed_new_regions;
+extern unsigned int MR_rbmmp_pages_reclaimed_by_remove_instr;
+extern unsigned int MR_rbmmp_pages_reclaimed_at_then_part;
+extern unsigned int MR_rbmmp_pages_reclaimed_at_commit;
+
extern MR_RegionProfUnit MR_rbmmp_num_disj_frames;
+extern MR_RegionProfUnit MR_rbmmp_words_used_by_disj_frames;
+extern unsigned int MR_rbmmp_regions_protected_at_semi_disj;
+extern unsigned int MR_rbmmp_snapshots_saved_at_disj;
+
+extern MR_RegionProfUnit MR_rbmmp_num_ite_frames;
extern MR_RegionProfUnit MR_rbmmp_num_commit_frames;
+extern unsigned int MR_rbmmp_regions_protected_at_ite;
+extern unsigned int MR_rbmmp_snapshots_saved_at_ite;
+
extern MR_RegionProfUnit MR_rbmmp_words_used_by_ite_frames;
-extern MR_RegionProfUnit MR_rbmmp_words_used_by_disj_frames;
extern MR_RegionProfUnit MR_rbmmp_words_used_by_commit_frames;
+extern unsigned int MR_rbmmp_regions_saved_at_commit;
extern int MR_region_get_ite_frame_size(MR_RegionIteFixedFrame *);
extern int MR_region_get_disj_frame_size(MR_RegionDisjFixedFrame *);
extern int MR_region_get_commit_frame_size(MR_RegionCommitFixedFrame *);
+#define MR_REGION_DISJ_FRAME_TYPE 0
+#define MR_REGION_ITE_FRAME_TYPE 1
+
#define MR_region_profile_push_ite_frame \
do { \
MR_region_update_profiling_unit(&MR_rbmmp_num_ite_frames, \
@@ -1242,6 +1314,15 @@
&MR_rbmmp_snapshots_saved_at_ite); \
} while (0)
+#define MR_region_profile_fill_semi_disj_protect \
+ do { \
+ MR_region_update_profiling_unit( \
+ &MR_rbmmp_words_used_by_disj_frames, \
+ MR_REGION_SEMI_DISJ_PROT_SIZE); \
+ MR_region_profile_increase_counter( \
+ &MR_rbmmp_regions_protected_at_semi_disj); \
+ } while (0)
+
#define MR_region_profile_fill_disj_snapshot \
do { \
MR_region_update_profiling_unit( \
@@ -1251,6 +1332,23 @@
&MR_rbmmp_snapshots_saved_at_disj); \
} while (0)
+#define MR_region_profile_frame_destroy_region(region, frame_type) \
+ do { \
+ switch (frame_type) { \
+ case MR_REGION_DISJ_FRAME_TYPE: \
+ MR_region_profile_increase_counter( \
+ &MR_rbmmp_regions_instant_reclaimed_at_disj); \
+ break; \
+ case MR_REGION_ITE_FRAME_TYPE: \
+ MR_region_profile_increase_counter( \
+ &MR_rbmmp_regions_instant_reclaimed_at_ite); \
+ break; \
+ } \
+ MR_region_profile_reclaim_pages_and_words(region, \
+ &MR_rbmmp_pages_instant_reclaimed_new_regions, \
+ &MR_rbmmp_words_instant_reclaimed_new_regions); \
+ } while (0)
+
#else /* Not define MR_RBMM_PROFILING */
#define MR_region_profile_push_ite_frame \
@@ -1275,6 +1373,9 @@
#define MR_region_profile_fill_ite_protect \
((void) 0)
+#define MR_region_profile_fill_semi_disj_protect \
+ ((void) 0)
+
#define MR_region_profile_fill_commit \
((void) 0)
@@ -1284,12 +1385,18 @@
#define MR_region_profile_fill_disj_snapshot \
((void) 0)
+#define MR_region_profile_frame_destroy_region(region, frame_type) \
+ ((void) 0)
#endif /* End of not define MR_RBMM_PROFILING. */
extern void MR_region_update_profiling_unit(
MR_RegionProfUnit *profiling_unit, int quantity);
extern void MR_region_profile_destroyed_region(MR_RegionHeader *);
extern void MR_region_profile_restore_from_snapshot(MR_RegionSnapshot *);
+extern void MR_region_profile_reclaim_region(MR_RegionHeader *,
+ unsigned int *, unsigned int *, unsigned int*);
+extern void MR_region_profile_reclaim_pages_and_words(MR_RegionHeader *,
+ unsigned int *, unsigned int*);
extern void MR_region_profile_increase_counter(unsigned int *);
extern int MR_region_get_number_of_pages(MR_RegionPage *,
MR_RegionPage *);
Index: runtime/mercury_types.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.54
diff -u -r1.54 mercury_types.h
--- runtime/mercury_types.h 20 Dec 2007 07:43:17 -0000 1.54
+++ runtime/mercury_types.h 17 Jan 2008 20:26:32 -0000
@@ -302,7 +302,7 @@
typedef struct MR_RegionDisjFixedFrame_Struct MR_RegionDisjFixedFrame;
typedef struct MR_RegionCommitFixedFrame_Struct MR_RegionCommitFixedFrame;
typedef struct MR_RegionIteProtect_Struct MR_RegionIteProtect;
-typedef struct MR_RegionDisjProtect_Struct MR_RegionDisjProtect;
+typedef struct MR_RegionSemiDisjProtect_Struct MR_RegionSemiDisjProtect;
typedef struct MR_RegionCommitSave_Struct MR_RegionCommitSave;
typedef struct MR_RegionProfUnit_Struct MR_RegionProfUnit;
More information about the reviews
mailing list