[m-rev.] for review: conditional structure reuse for LLDS backends

Peter Wang novalazy at gmail.com
Mon Feb 11 11:06:49 AEDT 2008


On 2008-02-11, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Wed, 30 Jan 2008, Peter Wang wrote:
>
>> [Pending bootchecks in more grades.]
>
> Could you please post some benchmarks between conditional structure
> reuse / structure reuse without static data / no structure reuse,
> at some point.

Will do.

>
>> Index: runtime/mercury_heap.h
>> ===================================================================
>> RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_heap.h,v
>> retrieving revision 1.39
>> diff -u -r1.39 mercury_heap.h
>> --- runtime/mercury_heap.h	21 Aug 2007 06:22:04 -0000	1.39
>> +++ runtime/mercury_heap.h	30 Jan 2008 03:58:00 -0000
>> @@ -33,7 +33,7 @@
>> #include "mercury_context.h"            /* for min_heap_reclamation_point() */
>> #include "mercury_heap_profile.h"       /* for MR_record_allocation() */
>> #include "mercury_deep_profiling.h"     /* for MR_current_call_site_dynamic */
>> -#include "mercury_std.h"               /* for MR_EXTERN_INLINE */
>> +#include "mercury_std.h"                /* for MR_EXTERN_INLINE */
>> #include "mercury_reg_workarounds.h"    /* for MR_memcpy */
>> #include "mercury_debug.h"              /* for MR_debugtagoffsetincrhp* */
>> #ifdef MR_HIGHLEVEL_CODE
>> @@ -47,6 +47,8 @@
>>   #ifdef MR_BOEHM_GC
>>     #define GC_I_HIDE_POINTERS
>>     #include "gc.h"
>> +    #include "gc_mark.h"                /* for GC_least_plausible_heap_addr */
>> +                                        /* GC_greatest_plausible_heap_addr */
>>   #endif
>> #endif
>>
>> @@ -396,6 +398,59 @@
>> /***************************************************************************/
>>
>> /*
>> +** Macros to implement structure reuse, conditioned on whether the structure
>
> s/conditioned/conditional/

Changed (although it was fine before).

>> +#ifdef MR_BOEHM_GC
>> +
>> +  #define   MR_in_heap_range(addr)                                          \
>> +            ((void *) (addr) >= GC_least_plausible_heap_addr &&             \
>> +             (void *) (addr) < GC_greatest_plausible_heap_addr)             \
>> +
>> +#else /* ! MR_BOEHM_GC */
>
> Is it still possible to use non-conditional structre reuse with the LLDS
> backend?  If so, how do I do it?  If not, there should be a
> developer-only option that does that.

I have made this possible by defining a C macro that forces the trivial
definition of MR_in_heap_range (always evaluates to true).

Peter

--- ws_reuse_plausible,20080130,e.txt	2008-01-30 16:02:39.000000000 +1100
+++ ws_reuse_plausible,20080211,b.txt	2008-02-11 11:03:43.000000000 +1100
@@ -31,7 +31,7 @@
 
 
 compiler/llds.m:
-	Extend the `incr_hp' instruction to holds information for structure
+	Extend the `incr_hp' instruction to hold information for structure
 	reuse.
 
 compiler/code_info.m:
@@ -49,6 +49,7 @@
 	`var_locn_assign_dynamic_cell_to_var'.
 
 runtime/mercury_heap.h:
+runtime/mercury_conf_param.h:
 	Add a macro to check if an address is between
 	`GC_least_plausible_heap_addr' and `GC_greatest_plausible_heap_addr',
 	which are therefore in the heap.
@@ -56,6 +57,9 @@
 	Add macros to conditionally reuse a cell or otherwise fall back to
 	allocating a new object.
 
+	Make it possible to revert to unconditional structure reuse by
+	defining the C macro `MR_UNCONDITIONAL_STRUCTURE_REUSE'.
+
 compiler/llds_out.m:
 	Call the new macros in `mercury_heap.h' for `incr_hp' instructions
 	with reuse information filled in.


diff -u runtime/mercury_heap.h runtime/mercury_heap.h
--- runtime/mercury_heap.h	30 Jan 2008 03:58:00 -0000
+++ runtime/mercury_heap.h	10 Feb 2008 23:59:59 -0000
@@ -398,7 +398,7 @@
 /***************************************************************************/
 
 /*
-** Macros to implement structure reuse, conditioned on whether the structure
+** Macros to implement structure reuse, conditional on whether the structure
 ** to reuse is really dynamically allocated. If not, fall back to allocating
 ** a new object on the heap.
 */
@@ -418,13 +418,13 @@
                 (void) dummy;                                               \
             } while (0)
 
-#ifdef MR_BOEHM_GC
+#if defined(MR_BOEHM_GC) && !defined(MR_UNCONDITIONAL_STRUCTURE_REUSE)
 
   #define   MR_in_heap_range(addr)                                          \
             ((void *) (addr) >= GC_least_plausible_heap_addr &&             \
              (void *) (addr) < GC_greatest_plausible_heap_addr)             \
 
-#else /* ! MR_BOEHM_GC */
+#else /* ! MR_BOEHM_GC || MR_UNCONDITIONAL_STRUCTURE_REUSE  */
 
   /*
   ** We don't have any way to check whether `addr' is dynamically allocated,
@@ -433,7 +433,7 @@
   */
   #define   MR_in_heap_range(addr)  (MR_TRUE)
 
-#endif /* ! MR_BOEHM_GC */
+#endif /* ! MR_BOEHM_GC || MR_UNCONDITIONAL_STRUCTURE_REUSE  */
 
 #define     MR_tag_reuse_or_alloc_heap_flag(dest, tag, flag, reuse_addr,    \
                 fallback_alloc)                                             \
--- runtime/mercury_conf_param.h	13 Dec 2007 01:14:01 -0000	1.105
+++ runtime/mercury_conf_param.h	10 Feb 2008 23:59:59 -0000
@@ -475,6 +475,10 @@
 ** problems if user-defined unify procedures abort: the exception could be
 ** transmitted to the parent Mercury code only by catching and retransmitting
 ** it, which, for efficiency reasons, the code doesn't do.
+**
+** MR_UNCONDITIONAL_STRUCTURE_REUSE
+** Enable this to bypass the check that a cell was allocated by Boehm GC
+** before reusing it.
 */
 
 #if defined(MR_THREAD_SAFE) && defined(MR_TRACE_HISTOGRAM)




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