[m-rev.] for review: version array reimplementation
Zoltan Somogyi
zs at csse.unimelb.edu.au
Tue Jul 28 16:34:08 AEST 2009
On 27-Jul-2009, Peter Wang <novalazy at gmail.com> wrote:
> +static void
> +ML_va_rewind_into(ML_va_ptr VA, const ML_va_ptr VA0)
> +{
> + MR_Integer I;
> + MR_Word X;
> +
> + if (ML_va_latest_version(VA0)) {
> + return;
> + }
> +
> + ML_va_rewind_into(VA, VA0->rest.next);
> +
> + I = VA0->index;
> + X = VA0->value;
> + if (I < VA->rest.array->size) {
> + VA->rest.array->elements[I] = X;
> + }
> +}
What is the average and maximum recursion depth here? If it is significant,
you could cut the cost of recursion here (which will include setting up
a stack frame of at least five words) by having your own array of <I, X>
pairs, pushing them on the stack until you find the latest version and
then applying the assignments. If you run out of array before then, you
can always recurse then.
This is basically middle-recursion optimization applied to C code.
Zoltan.
--------------------------------------------------------------------------
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