[m-rev.] diff: consecutive temp stack slots

Zoltan Somogyi zs at csse.unimelb.edu.au
Fri Jul 13 13:26:12 AEST 2007


Provide a capability we will need to implement code generation for RBMM:
the ability to allocate several consecutive temp stack slots.

compiler/code_info.m:
	Add predicates to acquire and release several consecutive temp stack
	slots.

	Factor out some commonalities with existing code.

	Revamp the interface for acquiring temp stack slots, to require an
	explicit parameter that says whether the temp stack slot should be
	automatically released when the code generator resets its
	location-dependent state.

compiler/disj_gen.m:
compiler/lookup_switch.m:
compiler/par_conj_gen.m:
	Specify the extra parameter when acquiring (and releasing) temp stack
	slots.

compiler/llds.m:
	Fix typo in comment.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
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/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.345
diff -u -r1.345 code_info.m
--- compiler/code_info.m	9 Jul 2007 13:28:28 -0000	1.345
+++ compiler/code_info.m	12 Jul 2007 07:12:43 -0000
@@ -1529,7 +1529,8 @@
     ->
         % Here ResumeKnown must be resume_point_unknown
         % or resume_point_known(wont_be_done).
-        acquire_temp_slot(lval(redoip_slot(lval(curfr))), RedoipSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(curfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
         HijackInfo = disj_half_hijack(RedoipSlot),
         Code = node([
             llds_instr(assign(RedoipSlot, lval(redoip_slot(lval(curfr)))),
@@ -1537,8 +1538,10 @@
         ])
     ;
         % Here CurfrMaxfr must be may_be_different.
-        acquire_temp_slot(lval(redoip_slot(lval(maxfr))), RedoipSlot, !CI),
-        acquire_temp_slot(lval(redofr_slot(lval(maxfr))), RedofrSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
+        acquire_temp_slot(lval(redofr_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedofrSlot, !CI),
         HijackInfo = disj_full_hijack(RedoipSlot, RedofrSlot),
         Code = node([
             llds_instr(assign(RedoipSlot, lval(redoip_slot(lval(maxfr)))),
@@ -1652,7 +1655,8 @@
     ;
         ( Allow = not_allowed ; CondEnv = inside_non_condition )
     ->
-        acquire_temp_slot(lval(maxfr), MaxfrSlot, !CI),
+        acquire_temp_slot(lval(maxfr), non_persistent_temp_slot, MaxfrSlot,
+            !CI),
         HijackType = ite_temp_frame(MaxfrSlot),
         create_temp_frame(do_fail, "prepare for ite", TempFrameCode, !CI),
         MaxfrCode = node([
@@ -1671,7 +1675,8 @@
         CurfrMaxfr = must_be_equal
     ->
         % Here ResumeKnown must be resume_point_unknown.
-        acquire_temp_slot(lval(redoip_slot(lval(curfr))), RedoipSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(curfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
         HijackType = ite_half_hijack(RedoipSlot),
         Code = node([
             llds_instr(assign(RedoipSlot, lval(redoip_slot(lval(curfr)))),
@@ -1679,9 +1684,12 @@
         ])
     ;
         % Here CurfrMaxfr must be may_be_different.
-        acquire_temp_slot(lval(redoip_slot(lval(maxfr))), RedoipSlot, !CI),
-        acquire_temp_slot(lval(redofr_slot(lval(maxfr))), RedofrSlot, !CI),
-        acquire_temp_slot(lval(maxfr), MaxfrSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
+        acquire_temp_slot(lval(redofr_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedofrSlot, !CI),
+        acquire_temp_slot(lval(maxfr),
+            non_persistent_temp_slot, MaxfrSlot, !CI),
         HijackType = ite_full_hijack(RedoipSlot, RedofrSlot, MaxfrSlot),
         Code = node([
             llds_instr(assign(MaxfrSlot, lval(maxfr)),
@@ -1817,7 +1825,8 @@
     FailInfo0 = fail_info(_, _, CurfrMaxfr, _, _),
     (
         CurfrMaxfr = may_be_different,
-        acquire_temp_slot(lval(maxfr), MaxfrSlot, !CI),
+        acquire_temp_slot(lval(maxfr), non_persistent_temp_slot, MaxfrSlot,
+            !CI),
         SaveMaxfrCode = node([
             llds_instr(save_maxfr(MaxfrSlot), "save the value of maxfr")
         ]),
@@ -1839,7 +1848,7 @@
             llds_instr(restore_maxfr(MaxfrSlot),
                 "restore the value of maxfr - perform commit")
         ]),
-        release_temp_slot(MaxfrSlot, !CI)
+        release_temp_slot(MaxfrSlot, non_persistent_temp_slot, !CI)
     ;
         MaybeMaxfrSlot = no,
         RestoreMaxfrCode = node([
@@ -1898,7 +1907,8 @@
     (
         ( Allow = not_allowed ; CondEnv = inside_non_condition )
     ->
-        acquire_temp_slot(lval(maxfr), MaxfrSlot, !CI),
+        acquire_temp_slot(lval(maxfr), non_persistent_temp_slot, MaxfrSlot,
+            !CI),
         MaxfrCode = node([
             llds_instr(save_maxfr(MaxfrSlot),
                 "prepare for temp frame commit")
@@ -1957,7 +1967,8 @@
         % Here ResumeKnown must be resume_point_unknown or
         % resume_point_known(wont_be_done).
 
-        acquire_temp_slot(lval(redoip_slot(lval(curfr))), RedoipSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(curfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
         HijackInfo = commit_half_hijack(RedoipSlot),
         HijackCode = node([
             llds_instr(assign(RedoipSlot, lval(redoip_slot(lval(curfr)))),
@@ -1967,9 +1978,12 @@
         ])
     ;
         % Here CurfrMaxfr must be may_be_different.
-        acquire_temp_slot(lval(redoip_slot(lval(maxfr))), RedoipSlot, !CI),
-        acquire_temp_slot(lval(redofr_slot(lval(maxfr))), RedofrSlot, !CI),
-        acquire_temp_slot(lval(maxfr), MaxfrSlot, !CI),
+        acquire_temp_slot(lval(redoip_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedoipSlot, !CI),
+        acquire_temp_slot(lval(redofr_slot(lval(maxfr))),
+            non_persistent_temp_slot, RedofrSlot, !CI),
+        acquire_temp_slot(lval(maxfr),
+            non_persistent_temp_slot, MaxfrSlot, !CI),
         HijackInfo = commit_full_hijack(RedoipSlot, RedofrSlot, MaxfrSlot),
         HijackCode = node([
             llds_instr(assign(RedoipSlot, lval(redoip_slot(lval(maxfr)))),
@@ -2660,8 +2674,10 @@
 maybe_save_trail_info(AddTrailOps, MaybeTrailSlots, SaveTrailCode, !CI) :-
     (
         AddTrailOps = yes,
-        acquire_temp_slot(ticket_counter, CounterSlot, !CI),
-        acquire_temp_slot(ticket, TrailPtrSlot, !CI),
+        acquire_temp_slot(ticket_counter, non_persistent_temp_slot,
+            CounterSlot, !CI),
+        acquire_temp_slot(ticket, non_persistent_temp_slot,
+            TrailPtrSlot, !CI),
         MaybeTrailSlots = yes(CounterSlot - TrailPtrSlot),
         SaveTrailCode = node([
             llds_instr(mark_ticket_stack(CounterSlot),
@@ -2697,8 +2713,8 @@
             llds_instr(discard_ticket,
                 "restore ticket counter and high water mark")
         ]),
-        release_temp_slot(CounterSlot, !CI),
-        release_temp_slot(TrailPtrSlot, !CI)
+        release_temp_slot(CounterSlot, non_persistent_temp_slot, !CI),
+        release_temp_slot(TrailPtrSlot, non_persistent_temp_slot, !CI)
     ).
 
 %---------------------------------------------------------------------------%
@@ -2937,7 +2953,7 @@
 :- implementation.
 
 save_hp(Code, HpSlot, !CI) :-
-    acquire_temp_slot(lval(hp), HpSlot, !CI),
+    acquire_temp_slot(lval(hp), non_persistent_temp_slot, HpSlot, !CI),
     Code = node([
         llds_instr(mark_hp(HpSlot), "Save heap pointer")
     ]).
@@ -2948,7 +2964,7 @@
     ]).
 
 release_hp(HpSlot, !CI) :-
-    release_temp_slot(HpSlot, !CI).
+    release_temp_slot(HpSlot, non_persistent_temp_slot, !CI).
 
 restore_and_release_hp(HpSlot, Code, !CI) :-
     restore_hp(HpSlot, Code),
@@ -2996,7 +3012,7 @@
 %---------------------------------------------------------------------------%
 
 save_ticket(Code, TicketSlot, !CI) :-
-    acquire_temp_slot(ticket, TicketSlot, !CI),
+    acquire_temp_slot(ticket, non_persistent_temp_slot, TicketSlot, !CI),
     Code = node([
         llds_instr(store_ticket(TicketSlot), "Save trail state")
     ]).
@@ -3007,7 +3023,7 @@
     ]).
 
 release_ticket(TicketSlot, !CI) :-
-    release_temp_slot(TicketSlot, !CI).
+    release_temp_slot(TicketSlot, non_persistent_temp_slot, !CI).
 
 reset_and_prune_ticket(TicketSlot, Reason, Code) :-
     Code = node([
@@ -3020,7 +3036,7 @@
         llds_instr(reset_ticket(lval(TicketSlot), Reason), "Release trail"),
         llds_instr(prune_ticket, "Prune ticket stack")
     ]),
-    release_temp_slot(TicketSlot, !CI).
+    release_temp_slot(TicketSlot, non_persistent_temp_slot, !CI).
 
 reset_and_discard_ticket(TicketSlot, Reason, Code) :-
     Code = node([
@@ -3033,13 +3049,13 @@
         llds_instr(reset_ticket(lval(TicketSlot), Reason), "Release trail"),
         llds_instr(discard_ticket, "Pop ticket stack")
     ]),
-    release_temp_slot(TicketSlot, !CI).
+    release_temp_slot(TicketSlot, non_persistent_temp_slot, !CI).
 
 discard_and_release_ticket(TicketSlot, Code, !CI) :-
     Code = node([
         llds_instr(discard_ticket, "Pop ticket stack")
     ]),
-    release_temp_slot(TicketSlot, !CI).
+    release_temp_slot(TicketSlot, non_persistent_temp_slot, !CI).
 
 %---------------------------------------------------------------------------%
 
@@ -3780,31 +3796,44 @@
     %
 :- pred get_total_stackslot_count(code_info::in, int::out) is det.
 
+    % If a stack slot is persistent, then the stack slot is not implicitly
+    % released when the code generator resets its location-dependent state,
+    % usually when entering the next arm of a disjunction, switch, etc.
+
+:- type temp_slot_persistence
+    --->    persistent_temp_slot
+    ;       non_persistent_temp_slot.
+
     % Acquire a stack slot for storing a temporary. The slot_contents
     % description is for accurate gc.
     %
-:- pred acquire_temp_slot(slot_contents::in, lval::out,
-    code_info::in, code_info::out) is det.
+:- pred acquire_temp_slot(slot_contents::in, temp_slot_persistence::in,
+    lval::out, code_info::in, code_info::out) is det.
 
     % Release a stack slot acquired earlier for a temporary value.
+    % The persistence argument should match the acquire operation.
     %
-:- pred release_temp_slot(lval::in, code_info::in, code_info::out) is det.
+:- pred release_temp_slot(lval::in, temp_slot_persistence::in,
+    code_info::in, code_info::out) is det.
 
-    % Acquire a stack slot for storing a temporary. The stack slot is not
-    % implicitly released when the code generator resets its location-dependent
-    % state. The slot_contents description is for accurate gc.
+    % Perform an acquire_temp_slot operation for each element of the
+    % input list, all with the same persistence.
+    %
+    % Given an input list of length N, the returned list will contain
+    % N consecutive stack slots.
     %
-:- pred acquire_persistent_temp_slot(slot_contents::in, lval::out,
+:- pred acquire_several_temp_slots(list(slot_contents)::in,
+    temp_slot_persistence::in, list(lval)::out,
     code_info::in, code_info::out) is det.
 
-    % Release a persistent stack slot acquired earlier for a temporary value.
+    % Release the stack slots acquired by an earlier acquire_several_temp_slots
+    % operation. The persistence argument should match the acquire operation.
     %
-:- pred release_persistent_temp_slot(lval::in, code_info::in, code_info::out)
-    is det.
+:- pred release_several_temp_slots(list(lval)::in, temp_slot_persistence::in,
+    code_info::in, code_info::out) is det.
 
-    % Return the lval of the stack slot in which the given variable
-    % is stored. Aborts if the variable does not have a stack slot
-    % an assigned to it.
+    % Return the lval of the stack slot in which the given variable is stored.
+    % Aborts if the variable does not have a stack slot an assigned to it.
     %
 :- pred get_variable_slot(code_info::in, prog_var::in, lval::out) is det.
 
@@ -3813,49 +3842,154 @@
 
 :- implementation.
 
-acquire_temp_slot(Item, StackVar, !CI) :-
+acquire_temp_slot(Item, Persistence, StackVar, !CI) :-
+    get_temp_content_map(!.CI, TempContentMap0),
+    map.to_assoc_list(TempContentMap0, TempContentList),
     get_temps_in_use(!.CI, TempsInUse0),
-    IsTempUsable = (pred(TempContent::in, Lval::out) is semidet :-
-        TempContent = Lval - ContentType,
-        ContentType = Item,
-        \+ set.member(Lval, TempsInUse0)
+    (
+        find_unused_slot_for_item(TempContentList, Item, TempsInUse0,
+            ChosenStackVar, _)
+    ->
+        StackVar = ChosenStackVar
+    ;
+        new_temp_slot(Item, StackVar, !CI)
     ),
+    set.insert(TempsInUse0, StackVar, TempsInUse),
+    set_temps_in_use(TempsInUse, !CI),
+    (
+        Persistence = persistent_temp_slot,
+        get_persistent_temps(!.CI, PersistentTemps0),
+        set.insert(PersistentTemps0, StackVar, PersistentTemps),
+        set_persistent_temps(PersistentTemps, !CI)
+    ;
+        Persistence = non_persistent_temp_slot
+    ).
+
+acquire_several_temp_slots([], _, _, !CI) :-
+    % We could return an empty list of stack vars, but currently,
+    % this is always an error.
+    unexpected(this_file, "acquire_several_temp_slots: []").
+acquire_several_temp_slots([HeadItem | TailItems], Persistence, StackVars,
+        !CI) :-
     get_temp_content_map(!.CI, TempContentMap0),
     map.to_assoc_list(TempContentMap0, TempContentList),
-    list.filter_map(IsTempUsable, TempContentList, UsableLvals),
+    get_temps_in_use(!.CI, TempsInUse0),
     (
-        UsableLvals = [UsableLval | _],
-        StackVar = UsableLval
+        find_unused_slots_for_items(TempContentList, HeadItem, TailItems,
+            TempsInUse0, ChosenStackVars)
+    ->
+        StackVars = ChosenStackVars
     ;
-        UsableLvals = [],
-        get_var_slot_count(!.CI, VarSlots),
-        get_max_temp_slot_count(!.CI, TempSlots0),
-        TempSlots = TempSlots0 + 1,
-        Slot = VarSlots + TempSlots,
-        stack_variable(!.CI, Slot, StackVar),
-        set_max_temp_slot_count(TempSlots, !CI),
-        map.det_insert(TempContentMap0, StackVar, Item, TempContentMap),
-        set_temp_content_map(TempContentMap, !CI)
+        list.map_foldl(new_temp_slot, [HeadItem | TailItems], StackVars, !CI)
     ),
-    set.insert(TempsInUse0, StackVar, TempsInUse),
-    set_temps_in_use(TempsInUse, !CI).
+    (
+        Persistence = persistent_temp_slot,
+        get_persistent_temps(!.CI, PersistentTemps0),
+        set.insert_list(PersistentTemps0, StackVars, PersistentTemps),
+        set_persistent_temps(PersistentTemps, !CI)
+    ;
+        Persistence = non_persistent_temp_slot
+    ).
+
+:- pred new_temp_slot(slot_contents::in, lval::out,
+    code_info::in, code_info::out) is det.
+
+new_temp_slot(Item, StackVar, !CI) :-
+    get_var_slot_count(!.CI, VarSlots),
+    get_max_temp_slot_count(!.CI, TempSlots0),
+    TempSlots = TempSlots0 + 1,
+    Slot = VarSlots + TempSlots,
+    stack_variable(!.CI, Slot, StackVar),
+    set_max_temp_slot_count(TempSlots, !CI),
 
-release_temp_slot(StackVar, !CI) :-
+    get_temp_content_map(!.CI, TempContentMap0),
+    map.det_insert(TempContentMap0, StackVar, Item, TempContentMap),
+    set_temp_content_map(TempContentMap, !CI).
+
+:- pred find_unused_slot_for_item(assoc_list(lval, slot_contents)::in,
+    slot_contents::in, set(lval)::in, lval::out,
+    assoc_list(lval, slot_contents)::out) is semidet.
+
+find_unused_slot_for_item([Head | Tail], Item, TempsInUse,
+        ChosenStackVar, Remainder) :-
+    Head = HeadStackVar - HeadSlotType,
+    (
+        HeadSlotType = Item,
+        \+ set.member(HeadStackVar, TempsInUse)
+    ->
+        ChosenStackVar = HeadStackVar,
+        Remainder = Tail
+    ;
+        find_unused_slot_for_item(Tail, Item, TempsInUse,
+            ChosenStackVar, Remainder)
+    ).
+
+:- pred find_unused_slots_for_items(assoc_list(lval, slot_contents)::in,
+    slot_contents::in, list(slot_contents)::in, set(lval)::in, list(lval)::out)
+    is semidet.
+
+find_unused_slots_for_items([Head | Tail], HeadItem, TailItems,
+        TempsInUse, ChosenStackVars) :-
+    (
+        find_unused_slot_for_item([Head | Tail], HeadItem, TempsInUse,
+            ChosenHeadStackVar, Remainder),
+        find_next_slots_for_items(Remainder, ChosenHeadStackVar, TailItems,
+            TempsInUse, ChosenTailStackVars)
+    ->
+        ChosenStackVars = [ChosenHeadStackVar | ChosenTailStackVars]
+    ;
+        find_unused_slots_for_items(Tail, HeadItem, TailItems,
+            TempsInUse, ChosenStackVars)
+    ).
+
+:- pred find_next_slots_for_items(assoc_list(lval, slot_contents)::in,
+    lval::in, list(slot_contents)::in, set(lval)::in, list(lval)::out)
+    is semidet.
+
+find_next_slots_for_items([], _, [], _, []).
+find_next_slots_for_items([Head | Tail], PrevStackVar, [HeadItem | TailItems],
+        TempsInUse, [HeadStackVar | TailStackVars]) :-
+    Head = HeadStackVar - HeadSlotType,
+    HeadStackVar = get_next_stack_var(PrevStackVar),
+    HeadSlotType = HeadItem,
+    \+ set.member(HeadStackVar, TempsInUse),
+    find_next_slots_for_items(Tail, HeadStackVar, TailItems,
+        TempsInUse, TailStackVars).
+
+:- func get_next_stack_var(lval) = lval.
+
+get_next_stack_var(Lval) = NextLval :-
+    ( Lval = stackvar(N) ->
+        NextLval = stackvar(N+1)
+    ; Lval = framevar(N) ->
+        NextLval = framevar(N+1)
+    ;
+        unexpected(this_file, "get_next_stack_var: not stackvar or framevar")
+    ).
+
+release_temp_slot(StackVar, Persistence, !CI) :-
     get_temps_in_use(!.CI, TempsInUse0),
     set.delete(TempsInUse0, StackVar, TempsInUse),
-    set_temps_in_use(TempsInUse, !CI).
+    set_temps_in_use(TempsInUse, !CI),
 
-acquire_persistent_temp_slot(Item, StackVar, !CI) :-
-    acquire_temp_slot(Item, StackVar, !CI),
     get_persistent_temps(!.CI, PersistentTemps0),
-    set.insert(PersistentTemps0, StackVar, PersistentTemps),
-    set_persistent_temps(PersistentTemps, !CI).
-
-release_persistent_temp_slot(StackVar, !CI) :-
-    release_temp_slot(StackVar, !CI),
-    get_persistent_temps(!.CI, PersistentTemps0),
-    set.delete(PersistentTemps0, StackVar, PersistentTemps),
-    set_persistent_temps(PersistentTemps, !CI).
+    set.is_member(StackVar, PersistentTemps0, IsInPersistentTemps0),
+    (
+        Persistence = persistent_temp_slot,
+        expect(unify(IsInPersistentTemps0, yes),
+            this_file, "released stack slot should be persistent"),
+        set.delete(PersistentTemps0, StackVar, PersistentTemps),
+        set_persistent_temps(PersistentTemps, !CI)
+    ;
+        Persistence = non_persistent_temp_slot,
+        expect(unify(IsInPersistentTemps0, no),
+            this_file, "released stack slot should not be persistent")
+    ).
+
+release_several_temp_slots([], _Persistence, !CI).
+release_several_temp_slots([StackVar | StackVars], Persistence, !CI) :-
+    release_temp_slot(StackVar, Persistence, !CI),
+    release_several_temp_slots(StackVars, Persistence, !CI).
 
 %---------------------------------------------------------------------------%
 
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.101
diff -u -r1.101 disj_gen.m
--- compiler/disj_gen.m	6 Jan 2007 09:23:30 -0000	1.101
+++ compiler/disj_gen.m	12 Jul 2007 06:30:28 -0000
@@ -140,9 +140,13 @@
 
     code_info.produce_vars(ResumeVars, ResumeMap, FlushCode, !CI),
 
-    % We cannot release this stack slot anywhere, since it will be needed
-    % after backtracking.
-    code_info.acquire_temp_slot(lookup_disj_cur, CurSlot, !CI),
+    % We cannot release this stack slot anywhere within the disjunction,
+    % since it will be needed after backtracking to later disjuncts.
+    % However, if we are inside an outer branched control structure
+    % (disjunction, switch, if-then-else), it may be released (implicitly)
+    % when we get into the next branch of that outer control structure.
+    code_info.acquire_temp_slot(lookup_disj_cur, non_persistent_temp_slot,
+        CurSlot, !CI),
     code_info.maybe_save_ticket(AddTrailOps, SaveTicketCode, MaybeTicketSlot,
         !CI),
     code_info.get_globals(!.CI, Globals),
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.349
diff -u -r1.349 llds.m
--- compiler/llds.m	9 Jul 2007 13:28:30 -0000	1.349
+++ compiler/llds.m	12 Jul 2007 04:53:50 -0000
@@ -734,7 +734,7 @@
     % as the same would compare as different. The live_value_types and
     % var_infos containing them would compare as different as well,
     % which can lead to a variable being listed more than once in
-    % a label's list of live variable.
+    % a label's list of live variables.
     %
     % At the moment, the LLDS only handles ground insts. When this changes,
     % the argument type of partial will have to be changed.
Index: compiler/lookup_switch.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lookup_switch.m,v
retrieving revision 1.74
diff -u -r1.74 lookup_switch.m
--- compiler/lookup_switch.m	6 Jan 2007 09:23:39 -0000	1.74
+++ compiler/lookup_switch.m	12 Jul 2007 06:33:03 -0000
@@ -586,10 +586,12 @@
     % of the resume point will clobber the set of acquired registers.
     %
     % We cannot release the stack slots anywhere, since they will be needed
-    % after backtracking.
+    % after backtracking to later alternatives of any model_non switch arm.
     code_info.acquire_reg_not_in_storemap(StoreMap, BaseReg, !CI),
-    code_info.acquire_temp_slot(lookup_switch_cur, CurSlot, !CI),
-    code_info.acquire_temp_slot(lookup_switch_max, MaxSlot, !CI),
+    code_info.acquire_temp_slot(lookup_switch_cur, non_persistent_temp_slot,
+        CurSlot, !CI),
+    code_info.acquire_temp_slot(lookup_switch_max, non_persistent_temp_slot,
+        MaxSlot, !CI),
     % IndexRval has already had Start subtracted from it.
     BaseRval = binop(int_mul, IndexRval, const(llconst_int(MainRowWidth))),
     BaseRegInitCode = node([
Index: compiler/par_conj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/par_conj_gen.m,v
retrieving revision 1.32
diff -u -r1.32 par_conj_gen.m
--- compiler/par_conj_gen.m	9 Jul 2007 13:28:34 -0000	1.32
+++ compiler/par_conj_gen.m	12 Jul 2007 06:58:33 -0000
@@ -151,7 +151,8 @@
     % finishes.
     code_info.get_par_conj_depth(!.CI, Depth),
     ( Depth = 0 ->
-        code_info.acquire_temp_slot(lval(parent_sp), ParentSpSlot, !CI),
+        code_info.acquire_temp_slot(lval(parent_sp), non_persistent_temp_slot,
+            ParentSpSlot, !CI),
         MaybeSetParentSpCode = node([
             llds_instr(assign(ParentSpSlot, lval(parent_sp)),
                 "save the old parent stack pointer"),
@@ -182,7 +183,8 @@
 
     list.length(Goals, NumGoals),
     code_info.acquire_reg(reg_r, RegLval, !CI),
-    code_info.acquire_persistent_temp_slot(sync_term, SyncSlot, !CI),
+    code_info.acquire_temp_slot(sync_term, persistent_temp_slot, SyncSlot,
+        !CI),
     ( SyncSlot = stackvar(SlotNum) ->
         ParentSyncSlot = parent_stackvar(SlotNum)
     ;
@@ -212,8 +214,12 @@
         llds_instr(label(EndLabel), "end of parallel conjunction")
     ]),
     Code = tree_list([
-        MaybeSetParentSpCode, SaveCode, MakeSyncTermCode,
-        GoalCode, EndLabelCode, MaybeRestoreParentSpCode
+        MaybeSetParentSpCode,
+        SaveCode,
+        MakeSyncTermCode,
+        GoalCode,
+        EndLabelCode,
+        MaybeRestoreParentSpCode
     ]),
 
     % We can't release the sync slot right now, in case we are in a
@@ -235,13 +241,14 @@
     % XXX release sync slots of nested parallel conjunctions
     %
     ( Depth = 0 ->
-        code_info.release_persistent_temp_slot(SyncSlot, !CI)
+        code_info.release_temp_slot(SyncSlot, persistent_temp_slot, !CI)
     ;
         true
     ),
     (
         MaybeReleaseParentSpSlot = yes(ParentSpSlot1),
-        code_info.release_temp_slot(ParentSpSlot1, !CI)
+        code_info.release_temp_slot(ParentSpSlot1, non_persistent_temp_slot,
+            !CI)
     ;
         MaybeReleaseParentSpSlot = no
     ),
@@ -300,19 +307,21 @@
     % context.
     %
 :- pred replace_stack_vars_by_parent_sv(code_tree::in, code_tree::out) is det.
-:- pred replace_stack_vars_by_parent_sv_instrs(list(instruction)::in,
-    list(instruction)::out) is det.
-:- pred replace_stack_vars_by_parent_sv_lval(lval::in, lval::out,
-    unit::in, unit::out) is det.
 
 replace_stack_vars_by_parent_sv(!Code) :-
     tree.map(replace_stack_vars_by_parent_sv_instrs, !Code).
 
+:- pred replace_stack_vars_by_parent_sv_instrs(list(instruction)::in,
+    list(instruction)::out) is det.
+
 replace_stack_vars_by_parent_sv_instrs(!Instrs) :-
     list.map_foldl(
         transform_lval_in_instr(replace_stack_vars_by_parent_sv_lval),
         !Instrs, unit, _).
 
+:- pred replace_stack_vars_by_parent_sv_lval(lval::in, lval::out,
+    unit::in, unit::out) is det.
+
 replace_stack_vars_by_parent_sv_lval(Lval0, Lval, !Acc) :-
     TransformRval = replace_stack_vars_by_parent_sv_lval,
     (
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
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/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
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/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
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/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
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/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
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/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
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 slice
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/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
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/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list