diff --git a/compiler/par_conj_gen.m b/compiler/par_conj_gen.m index 5aff96b1c..2ef270d1c 100644 --- a/compiler/par_conj_gen.m +++ b/compiler/par_conj_gen.m @@ -457,24 +457,23 @@ copy_slots_to_child_stack(FrameSize, LCVarLocn, LCSVarLocn, StackSlots, unexpected($module, $pred, "cannot convert to string") ), - BaseVarName = "BaseSp", FirstLine = "{\n", - DeclLine = string.format("\tMR_Word *%s;\n", [s(BaseVarName)]), - AssignLine = string.format("\t%s = MR_lc_child_stack_sp(%s, %s, %d);\n", - [s(BaseVarName), s(LCVarName), s(LCSVarName), i(FrameSize)]), - list.map(copy_one_slot_to_child_stack(BaseVarName), + IncrLine = string.format("\tMR_lc_inc_worker_sp(%s, %s, %d);\n", + [s(LCVarName), s(LCSVarName), i(FrameSize)]), + list.map(copy_one_slot_to_child_stack(LCVarName, LCSVarName), StackSlots, CopyStrs), string.append_list(CopyStrs, CopyLines), LastLine = "\t}\n", - CodeStr = FirstLine ++ DeclLine ++ AssignLine ++ CopyLines ++ LastLine. + CodeStr = FirstLine ++ IncrLine ++ CopyLines ++ LastLine. -:- pred copy_one_slot_to_child_stack(string::in, lval::in, string::out) is det. +:- pred copy_one_slot_to_child_stack(string::in, string::in, lval::in, + string::out) is det. -copy_one_slot_to_child_stack(BaseVarName, StackSlot, CopyStr) :- +copy_one_slot_to_child_stack(LCVarName, LCSVarName, StackSlot, CopyStr) :- ( StackSlotName = lval_to_string(StackSlot) -> ( StackSlot = stackvar(N) -> - CopyStr = string.format("\tMR_based_stackvar(%s, %d) = %s;\n", - [s(BaseVarName), i(N), s(StackSlotName)]) + CopyStr = string.format("\tMR_lc_worker_sv(%s, %s, %d) = %s;\n", + [s(LCVarName), s(LCSVarName), i(N), s(StackSlotName)]) ; unexpected($module, $pred, "not stack slot") ) diff --git a/runtime/mercury_par_builtin.h b/runtime/mercury_par_builtin.h index a12af6a8c..5a45543fe 100644 --- a/runtime/mercury_par_builtin.h +++ b/runtime/mercury_par_builtin.h @@ -530,15 +530,16 @@ extern MR_Bool MR_lc_try_get_free_slot(MR_LoopControl *lc, do { \ MR_Context *ctxt; \ \ - ctxt = (lc)->MR_lc_slots[lcs_idx].MR_lcs_context; \ - MR_lcs_context->MR_ctxt_sp += N; \ + ctxt = ((MR_LoopControl*)lc)->MR_lc_slots[lcs_idx].MR_lcs_context; \ + ctxt->MR_ctxt_sp += N; \ } while (0); /* ** Access a slot on the stack of the worker context in the loop control slot. */ #define MR_lc_worker_sv(lc, lcs_idx, N) \ - MR_based_stackvar((lc)->MR_lc_slots[lc_idx].MR_lcs_context->MR_ctxt_sp, (N)) + MR_based_stackvar(((MR_LoopControl*)lc)->MR_lc_slots[lcs_idx]. \ + MR_lcs_context->MR_ctxt_sp, (N)) /* ** Try to spawn off this code using the free slot.