[m-rev.] for review: speed up the declarative debugger

Ian MacLarty maclarty at cs.mu.OZ.AU
Thu Aug 4 02:05:40 AEST 2005


On Tue, 2 Aug 2005, Zoltan Somogyi wrote:

> For review and benchmarking by Ian.
>

This change makes the declarative debugger 12.7% faster on a session
which uses divide and query on the Mercury compiler to find a bug in a
leaf node.

> Index: trace/mercury_trace.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
> retrieving revision 1.83
> diff -u -r1.83 mercury_trace.c
> --- trace/mercury_trace.c	1 Aug 2005 02:26:25 -0000	1.83
> +++ trace/mercury_trace.c	2 Aug 2005 07:17:14 -0000
> @@ -119,8 +120,51 @@
>  ** MR_trace_real() is called via a function pointer from MR_trace()
>  ** in runtime/mercury_trace_base.c, which in turn is called from
>  ** compiled code whenever an event to be traced occurs.
> +**
> +** The initial part, MR_TRACE_REAL_SETUP_CODE, is shared by MR_trace_real and
> +** MR_trace_real_decl.
>  */
>
> +#if defined(MR_USE_MINIMAL_MODEL_STACK_COPY) && defined(MR_MINIMAL_MODEL_DEBUG)
> +  #define MR_TRACE_SETUP_MAYBE_SAVE_SUBGOAL_CUR_PROC                          \
> +        if ((MR_Trace_Port) layout->MR_sll_port == MR_PORT_CALL) {            \
> +            MR_subgoal_debug_cur_proc = layout->MR_sll_entry;                 \
> +        }
> +#else
> +  #define MR_TRACE_SETUP_MAYBE_SAVE_SUBGOAL_CUR_PROC
> +#endif
> +
> +#define MR_TRACE_REAL_SETUP_CODE()                                            \
> +    do {                                                                      \
> +        /* In case MR_sp or MR_curfr is transient. */                         \
> +        MR_restore_transient_registers();                                     \
> +                                                                              \
> +        maybe_from_full = layout->MR_sll_entry->MR_sle_maybe_from_full;       \
> +        if (MR_DETISM_DET_STACK(layout->MR_sll_entry->MR_sle_detism)) {       \
> +            if (maybe_from_full > 0 && ! MR_stackvar(maybe_from_full)) {      \
> +                return NULL;                                                  \
> +            }                                                                 \
> +                                                                              \
> +            seqno = (MR_Unsigned) MR_call_num_stackvar(MR_sp);                \
> +            depth = (MR_Unsigned) MR_call_depth_stackvar(MR_sp);              \
> +        } else {                                                              \
> +            if (maybe_from_full > 0 && ! MR_framevar(maybe_from_full)) {      \
> +                return NULL;                                                  \
> +            }                                                                 \
> +                                                                              \
> +            seqno = (MR_Unsigned) MR_call_num_framevar(MR_curfr);             \
> +            depth = (MR_Unsigned) MR_call_depth_framevar(MR_curfr);           \
> +        }                                                                     \
> +                                                                              \
> +        MR_TRACE_SETUP_MAYBE_SAVE_SUBGOAL_CUR_PROC                            \
> +                                                                              \
> +        if (layout->MR_sll_hidden && !MR_trace_unhide_events) {               \
> +            return NULL;                                                      \
> +        }                                                                     \
> +                                                                              \
> +        MR_trace_event_number++;                                              \
> +    } while (0)
> +

Just curious: why do we normally put macros in "do { ... } while(0)"
instead of just "{ ... }"?

Otherwise that all looks good.

Ian.

--------------------------------------------------------------------------
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