[m-rev.] diff: make_spec_ho_call/make_spec_method_call

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Sep 12 12:59:48 AEST 2005


I haven't had a chance yet to test the performance effects of this change;
I will do that later this week.

Zoltan.

Auto-generate the code for performing higher order calls and method calls.
This way, we can vary the number of explicit arguments we specialize for
independently of the number of hidden arguments we specialize for.
(Previously, we did not specialize on the number of hidden arguments at all.)

tools/make_spec_ho_call:
	A new script to auto-generate the code for performing higher order
	calls.

tools/make_spec_method_call:
	A new script to auto-generate the code for performing method calls.

runtime/mercury_ho_call.c:
	Replace the old handwritten code for performing higher order and
	method calls with #includes of the auto-generated files.

runtime/Mmakefile:
	Make the object files of mercury_ho_call.c depend on the auto-generated
	files, and through them, on the scripts.

compiler/options.m:
	Conform to the new parameters in the scripts.

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/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.464
diff -u -b -r1.464 options.m
--- compiler/options.m	29 Aug 2005 15:44:22 -0000	1.464
+++ compiler/options.m	12 Sep 2005 02:48:38 -0000
@@ -1094,14 +1094,20 @@
 	pic			-	bool(no),
 	max_jump_table_size	-	int(0),
 					% 0 indicates any size.
-	max_specialized_do_call_closure - int(3),
+	max_specialized_do_call_closure - int(5),
 					% mercury__do_call_closure_N
 					% exists for N <= option_value;
 					% set to -1 to disable.
-	max_specialized_do_call_class_method - int(-1),
+					% Should be less than or equal to
+					% max_spec_explicit_arg
+					% in tools/make_spec_ho_call.
+	max_specialized_do_call_class_method - int(6),
 					% mercury__do_call_class_method_N
 					% exists for N <= option_value;
 					% set to -1 to disable.
+					% Should be less than or equal to
+					% max_spec_explicit_arg
+					% in tools/make_spec_method_call.
 	compare_specialization	-	int(-1),
 					% -1 asks handle_options.m to give
 					% the value, which may be grade
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/aditi
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/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
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/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
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/odbc
cvs diff: Diffing extras/posix
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/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
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
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.125
diff -u -b -r1.125 Mmakefile
--- runtime/Mmakefile	30 Aug 2005 23:02:29 -0000	1.125
+++ runtime/Mmakefile	11 Sep 2005 02:30:43 -0000
@@ -287,6 +287,33 @@
 				../tools/make_port_code
 	../tools/make_port_code
 
+mercury_ho_call.$(O):				mercury_ho_call_codes.i
+mercury_ho_call.$(O):				mercury_ho_call_declares.i
+mercury_ho_call.$(O):				mercury_ho_call_inits.i
+mercury_ho_call.$(O):				mercury_method_call_codes.i
+mercury_ho_call.$(O):				mercury_method_call_declares.i
+mercury_ho_call.$(O):				mercury_method_call_inits.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_ho_call_codes.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_ho_call_declares.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_ho_call_inits.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_method_call_codes.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_method_call_declares.i
+mercury_ho_call.$(EXT_FOR_PIC_OBJECTS):		mercury_method_call_inits.i
+
+# ../tools/make_spec_ho_call generates mercury_ho_call_declares.i
+# and mercury_ho_call_inits.i as side-effects.
+mercury_ho_call_codes.i \
+mercury_ho_call_declares.i \
+mercury_ho_call_inits.i: ../tools/make_spec_ho_call
+	../tools/make_spec_ho_call > mercury_ho_call_codes.i
+
+# ../tools/make_spec_method_call generates mercury_method_call_declares.i
+# and mercury_method_call_inits.i as side-effects.
+mercury_method_call_codes.i \
+mercury_method_call_declares.i \
+mercury_method_call_inits.i: ../tools/make_spec_method_call
+	../tools/make_spec_method_call > mercury_method_call_codes.i
+
 #-----------------------------------------------------------------------------#
 
 .PHONY: all
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.76
diff -u -b -r1.76 mercury_ho_call.c
--- runtime/mercury_ho_call.c	29 Aug 2005 15:44:27 -0000	1.76
+++ runtime/mercury_ho_call.c	9 Sep 2005 08:48:21 -0000
@@ -430,16 +430,8 @@
 ** These are the real implementations of higher order calls and method calls.
 */
 
-MR_define_extern_entry(mercury__do_call_closure_compact);
-MR_define_extern_entry(mercury__do_call_closure_0);
-MR_define_extern_entry(mercury__do_call_closure_1);
-MR_define_extern_entry(mercury__do_call_closure_2);
-MR_define_extern_entry(mercury__do_call_closure_3);
-MR_define_extern_entry(mercury__do_call_class_method_compact);
-MR_define_extern_entry(mercury__do_call_class_method_0);
-MR_define_extern_entry(mercury__do_call_class_method_1);
-MR_define_extern_entry(mercury__do_call_class_method_2);
-MR_define_extern_entry(mercury__do_call_class_method_3);
+#include "mercury_ho_call_declares.i"
+#include "mercury_method_call_declares.i"
 
 /*
 ** These are the real implementations of unify and compare.
@@ -454,16 +446,8 @@
 MR_define_extern_entry(mercury__builtin__compare_representation_3_0);
 
 MR_BEGIN_MODULE(call_module)
-    MR_init_entry_an(mercury__do_call_closure_compact);
-    MR_init_entry_an(mercury__do_call_closure_0);
-    MR_init_entry_an(mercury__do_call_closure_1);
-    MR_init_entry_an(mercury__do_call_closure_2);
-    MR_init_entry_an(mercury__do_call_closure_3);
-    MR_init_entry_an(mercury__do_call_class_method_compact);
-    MR_init_entry_an(mercury__do_call_class_method_0);
-    MR_init_entry_an(mercury__do_call_class_method_1);
-    MR_init_entry_an(mercury__do_call_class_method_2);
-    MR_init_entry_an(mercury__do_call_class_method_3);
+#include "mercury_ho_call_inits.i"
+#include "mercury_method_call_inits.i"
 
     MR_init_entry_an(mercury__builtin__unify_2_0);
     MR_init_entry_an(mercury__builtin__compare_3_0);
@@ -474,11 +458,12 @@
 MR_BEGIN_CODE
 
 /*
-** The following comments apply to all variants of do_call_closure and
-** do_call_class_method.
+** The various variants of do_call_closure and do_call_class_method are
+** created by tools/make_spec_ho_call and tools/make_spec_method_call
+** respectively.
 **
-** Each of the following routines starts by picking up its input arguments
-** from Mercury abstract machine registers and putting them in local variables.
+** Each of routine starts by picking up its input arguments from the relevant
+** Mercury abstract machine registers and putting them in local variables.
 ** This allows the values of these arguments to be printed in gdb without
 ** worrying about which real machine registers, if any, hold them.
 **
@@ -490,324 +475,10 @@
 ** Each of these routines get ignored for profiling. That means they should be
 ** called using noprof_call() rather than call(). See the comment in
 ** output_call in compiler/llds_out for the explanation.
-**
-** Any change in one variant probably has to be made in all variants.
 */
 
-MR_define_entry(mercury__do_call_closure_compact);
-{
-    MR_Closure  *closure;
-    int         num_input_args; /* # of args provided by our caller */
-    int         num_hidden_args;/* # of args hidden in the closure  */
-    int         i;
-
-    closure = (MR_Closure *) MR_r1;
-    num_input_args = MR_r2;
-    num_hidden_args = closure->MR_closure_num_hidden_args;
-    MR_maybe_record_closure_histogram(num_input_args, num_hidden_args);
-
-    MR_save_registers();
-
-    if (num_hidden_args < MR_HO_CALL_INPUTS_COMPACT) {
-        /* copy to the left, from the left */
-        for (i = 1; i <= num_input_args; i++) {
-            MR_virtual_reg_assign(i + num_hidden_args,
-                MR_virtual_reg_value(i + MR_HO_CALL_INPUTS_COMPACT));
-        }
-    } else if (num_hidden_args > MR_HO_CALL_INPUTS_COMPACT) {
-        /* copy to the right, from the right */
-        for (i = num_input_args; i > 0; i--) {
-            MR_virtual_reg_assign(i + num_hidden_args,
-                MR_virtual_reg_value(i + MR_HO_CALL_INPUTS_COMPACT));
-        }
-    } /* else the new args are in the right place */
-
-    for (i = 1; i <= num_hidden_args; i++) {
-        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_closure_0);
-{
-    MR_Closure  *closure;
-    int         num_hidden_args;/* # of args hidden in the closure  */
-    int         i;
-
-    closure = (MR_Closure *) MR_r1;
-    num_hidden_args = closure->MR_closure_num_hidden_args;
-    MR_maybe_record_closure_histogram(0, num_hidden_args);
-
-    MR_save_registers();
-
-    for (i = 1; i <= num_hidden_args; i++) {
-        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_closure_1);
-{
-    MR_Closure  *closure;
-    int         num_hidden_args;/* # of args hidden in the closure  */
-    int         i;
-    MR_Word     arg1;
-
-    closure = (MR_Closure *) MR_r1;
-    arg1 = MR_r2;
-    num_hidden_args = closure->MR_closure_num_hidden_args;
-    MR_maybe_record_closure_histogram(1, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    for (i = 1; i <= num_hidden_args; i++) {
-        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_closure_2);
-{
-    MR_Closure  *closure;
-    int         num_hidden_args;/* # of args hidden in the closure  */
-    int         i;
-    MR_Word     arg1;
-    MR_Word     arg2;
-
-    closure = (MR_Closure *) MR_r1;
-    arg1 = MR_r2;
-    arg2 = MR_r3;
-    num_hidden_args = closure->MR_closure_num_hidden_args;
-    MR_maybe_record_closure_histogram(2, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    MR_virtual_reg_assign(num_hidden_args + 2, arg2);
-    for (i = 1; i <= num_hidden_args; i++) {
-        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_closure_3);
-{
-    MR_Closure  *closure;
-    int         num_hidden_args;/* # of args hidden in the closure  */
-    int         i;
-    MR_Word     arg1;
-    MR_Word     arg2;
-    MR_Word     arg3;
-
-    closure = (MR_Closure *) MR_r1;
-    arg1 = MR_r2;
-    arg2 = MR_r3;
-    arg3 = MR_r4;
-    num_hidden_args = closure->MR_closure_num_hidden_args;
-    MR_maybe_record_closure_histogram(3, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    MR_virtual_reg_assign(num_hidden_args + 2, arg2);
-    MR_virtual_reg_assign(num_hidden_args + 3, arg3);
-    for (i = 1; i <= num_hidden_args; i++) {
-        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_class_method_compact);
-{
-    MR_Word     type_class_info;
-    MR_Integer  method_index;
-    MR_Integer  num_input_args;
-    MR_Integer  num_hidden_args;
-    MR_Code     *dest;
-    int         i;
-
-    type_class_info = MR_r1;
-    method_index = (MR_Integer) MR_r2;
-    num_input_args = MR_r3;
-
-    dest = MR_typeclass_info_class_method(type_class_info, method_index);
-    num_hidden_args = (MR_Integer)
-        MR_typeclass_info_num_extra_instance_args(type_class_info);
-    MR_maybe_record_method_histogram(num_input_args, num_hidden_args);
-
-    MR_save_registers();
-
-    if (num_hidden_args < MR_CLASS_METHOD_CALL_INPUTS_COMPACT) {
-        /* copy to the left, from the left */
-        for (i = 1; i <= num_input_args; i++) {
-            MR_virtual_reg_assign(i + num_hidden_args,
-                MR_virtual_reg_value(i + MR_CLASS_METHOD_CALL_INPUTS_COMPACT));
-        }
-    } else if (num_hidden_args >
-            MR_CLASS_METHOD_CALL_INPUTS_COMPACT)
-    {
-        /* copy to the right, from the right */
-        for (i = num_input_args; i > 0; i--) {
-            MR_virtual_reg_assign(i + num_hidden_args,
-                MR_virtual_reg_value(i + MR_CLASS_METHOD_CALL_INPUTS_COMPACT));
-        }
-    } /* else the new args are in the right place */
-
-    for (i = num_hidden_args; i > 0; i--) {
-        MR_virtual_reg_assign(i,
-            MR_typeclass_info_extra_instance_arg(type_class_info, i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(dest, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_class_method_0);
-{
-    MR_Word     type_class_info;
-    MR_Integer  method_index;
-    MR_Integer  num_hidden_args;
-    MR_Code     *dest;
-    int         i;
-
-    type_class_info = MR_r1;
-    method_index = (MR_Integer) MR_r2;
-
-    dest = MR_typeclass_info_class_method(type_class_info, method_index);
-    num_hidden_args = (MR_Integer)
-        MR_typeclass_info_num_extra_instance_args(type_class_info);
-    MR_maybe_record_method_histogram(0, num_hidden_args);
-
-    MR_save_registers();
-
-    for (i = num_hidden_args; i > 0; i--) {
-        MR_virtual_reg_assign(i,
-            MR_typeclass_info_extra_instance_arg(type_class_info, i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(dest, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_class_method_1);
-{
-    MR_Word     type_class_info;
-    MR_Integer  method_index;
-    MR_Integer  num_hidden_args;
-    MR_Code     *dest;
-    int         i;
-    MR_Word     arg1;
-
-    type_class_info = MR_r1;
-    method_index = (MR_Integer) MR_r2;
-    arg1 = MR_r3;
-
-    dest = MR_typeclass_info_class_method(type_class_info, method_index);
-    num_hidden_args = (MR_Integer)
-        MR_typeclass_info_num_extra_instance_args(type_class_info);
-    MR_maybe_record_method_histogram(1, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    for (i = num_hidden_args; i > 0; i--) {
-        MR_virtual_reg_assign(i,
-            MR_typeclass_info_extra_instance_arg(type_class_info, i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(dest, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_class_method_2);
-{
-    MR_Word     type_class_info;
-    MR_Integer  method_index;
-    MR_Integer  num_hidden_args;
-    MR_Code     *dest;
-    int         i;
-    MR_Word     arg1;
-    MR_Word     arg2;
-
-    type_class_info = MR_r1;
-    method_index = (MR_Integer) MR_r2;
-    arg1 = MR_r3;
-    arg2 = MR_r4;
-
-    dest = MR_typeclass_info_class_method(type_class_info, method_index);
-    num_hidden_args = (MR_Integer)
-        MR_typeclass_info_num_extra_instance_args(type_class_info);
-    MR_maybe_record_method_histogram(2, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    MR_virtual_reg_assign(num_hidden_args + 2, arg2);
-    for (i = num_hidden_args; i > 0; i--) {
-        MR_virtual_reg_assign(i,
-            MR_typeclass_info_extra_instance_arg(type_class_info, i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(dest, MR_prof_ho_caller_proc);
-}
-
-MR_define_entry(mercury__do_call_class_method_3);
-{
-    MR_Word     type_class_info;
-    MR_Integer  method_index;
-    MR_Integer  num_hidden_args;
-    MR_Code     *dest;
-    int         i;
-    MR_Word     arg1;
-    MR_Word     arg2;
-    MR_Word     arg3;
-
-    type_class_info = MR_r1;
-    method_index = (MR_Integer) MR_r2;
-    arg1 = MR_r3;
-    arg2 = MR_r4;
-    arg3 = MR_r5;
-
-    dest = MR_typeclass_info_class_method(type_class_info, method_index);
-    num_hidden_args = (MR_Integer)
-        MR_typeclass_info_num_extra_instance_args(type_class_info);
-    MR_maybe_record_method_histogram(3, num_hidden_args);
-
-    MR_save_registers();
-
-    MR_virtual_reg_assign(num_hidden_args + 1, arg1);
-    MR_virtual_reg_assign(num_hidden_args + 2, arg2);
-    MR_virtual_reg_assign(num_hidden_args + 3, arg3);
-    for (i = num_hidden_args; i > 0; i--) {
-        MR_virtual_reg_assign(i,
-            MR_typeclass_info_extra_instance_arg(type_class_info, i));
-    }
-
-    MR_restore_registers();
-
-    MR_tailcall(dest, MR_prof_ho_caller_proc);
-}
+#include "mercury_ho_call_codes.i"
+#include "mercury_method_call_codes.i"
 
 /*
 ** mercury__builtin__unify_2_0 is called as `unify(TypeInfo, X, Y)'
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/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
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/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/make_spec_ho_call
===================================================================
RCS file: tools/make_spec_ho_call
diff -N tools/make_spec_ho_call
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tools/make_spec_ho_call	12 Sep 2005 02:47:20 -0000
@@ -0,0 +1,130 @@
+#!/bin/sh
+# vim: ts=4 sw=4 et
+
+# If you change max_spec_explicit_arg, you should consider changing
+# the value of the max_specialized_do_call_closure option in
+# compiler/options.m.
+max_spec_explicit_arg=5
+max_spec_hidden_arg=5
+
+> mercury_ho_call_declares.i
+> mercury_ho_call_inits.i
+
+spec_explicit_arg=-1
+while test $spec_explicit_arg -le $max_spec_explicit_arg
+do
+    if test $spec_explicit_arg -lt 0
+    then
+        variant="compact"
+    else
+        variant="$spec_explicit_arg"
+    fi
+
+    echo "MR_define_entry(mercury__do_call_closure_$variant);"
+    echo "{"
+    echo "    MR_Closure    *closure;"
+    echo "    int           num_explicit_args;"
+    echo "    int           num_hidden_args;"
+    echo "    int           i;"
+
+    i=1;
+    while test $i -le $spec_explicit_arg
+    do
+        echo "    MR_Word       arg$i;"
+        i=`expr $i + 1`
+    done
+
+    echo
+    echo "    closure = (MR_Closure *) MR_r1;"
+    echo "    num_hidden_args = closure->MR_closure_num_hidden_args;"
+    if test $spec_explicit_arg -lt 0
+    then
+        echo "    num_explicit_args = MR_r2;"
+        num_explicit_args="num_explicit_args"
+    else
+        i=1;
+        while test $i -le $spec_explicit_arg
+        do
+            j=`expr $i + 1`
+            echo "    arg$i = MR_r$j;"
+            i=`expr $i + 1`
+        done
+        num_explicit_args="$spec_explicit_arg"
+    fi
+    echo
+    echo "    MR_maybe_record_closure_histogram($num_explicit_args, num_hidden_args);"
+    echo
+
+    if test $max_spec_hidden_arg -ge 0 -a $spec_explicit_arg -ge 0
+    then
+        echo "    switch (num_hidden_args) {"
+        spec_hidden_arg=0
+        while test $spec_hidden_arg -le $max_spec_hidden_arg
+        do
+            echo "        case $spec_hidden_arg:"
+            i=1;
+            while test $i -le $spec_hidden_arg
+            do
+                echo "            MR_r$i = closure->MR_closure_hidden_args($i);"
+                i=`expr $i + 1`
+            done
+            j=1
+            while test $j -le $spec_explicit_arg
+            do
+                echo "            MR_r$i = arg$j;"
+                i=`expr $i + 1`
+                j=`expr $j + 1`
+            done
+
+            echo "            MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);"
+            echo "            break;"
+            echo
+            spec_hidden_arg=`expr $spec_hidden_arg + 1`
+        done
+        echo "        default:"
+        echo "            /* fall through to the general case below */"
+        echo "            break;"
+        echo "    }"
+        echo
+    fi
+
+    echo "    MR_save_registers();"
+    if test $spec_explicit_arg -lt 0
+    then
+        echo "    if (num_hidden_args < MR_HO_CALL_INPUTS_COMPACT) {"
+        echo "        /* copy the explicit args to the left, from the left */"
+        echo "        for (i = 1; i <= num_explicit_args; i++) {"
+        echo "            MR_virtual_reg_assign(i + num_hidden_args,"
+        echo "                MR_virtual_reg_value(i + MR_HO_CALL_INPUTS_COMPACT));"
+        echo "        }"
+        echo "    } else if (num_hidden_args > MR_HO_CALL_INPUTS_COMPACT) {"
+        echo "        /* copy the explicit args to the right, from the right */"
+        echo "        for (i = num_explicit_args; i > 0 ; i--) {"
+        echo "            MR_virtual_reg_assign(i + num_hidden_args,"
+        echo "                MR_virtual_reg_value(i + MR_HO_CALL_INPUTS_COMPACT));"
+        echo "        }"
+        echo "    } /* else the explicit args are in the right place */"
+    else
+        i=1
+        while test $i -le $spec_explicit_arg
+        do
+            echo "    MR_virtual_reg_assign(num_hidden_args + $i, arg$i);"
+            i=`expr $i + 1`
+        done
+    fi
+
+    echo
+    echo "    for (i = 1; i <= num_hidden_args; i++) {"
+    echo "        MR_virtual_reg_assign(i, closure->MR_closure_hidden_args(i));"
+    echo "    }"
+    echo "    MR_restore_registers();"
+    echo
+    echo "    MR_tailcall(closure->MR_closure_code, MR_prof_ho_caller_proc);"
+    echo "}"
+    echo
+
+    echo "MR_define_extern_entry(mercury__do_call_closure_$variant);" >> mercury_ho_call_declares.i
+    echo "    MR_init_entry_an(mercury__do_call_closure_$variant);" >> mercury_ho_call_inits.i
+
+    spec_explicit_arg=`expr $spec_explicit_arg + 1`
+done
Index: tools/make_spec_method_call
===================================================================
RCS file: tools/make_spec_method_call
diff -N tools/make_spec_method_call
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tools/make_spec_method_call	12 Sep 2005 02:48:40 -0000
@@ -0,0 +1,138 @@
+#!/bin/sh
+# vim: ts=4 sw=4 et
+
+# If you change max_spec_explicit_arg, you should consider changing
+# the value of the max_specialized_do_call_class_method option in
+# compiler/options.m.
+max_spec_explicit_arg=6
+max_spec_hidden_arg=1
+
+> mercury_method_call_declares.i
+> mercury_method_call_inits.i
+
+spec_explicit_arg=-1
+while test $spec_explicit_arg -le $max_spec_explicit_arg
+do
+    if test $spec_explicit_arg -lt 0
+    then
+        variant="compact"
+    else
+        variant="$spec_explicit_arg"
+    fi
+
+    echo "MR_define_entry(mercury__do_call_class_method_$variant);"
+    echo "{"
+    echo "    MR_Word       type_class_info;"
+    echo "    MR_Integer    method_index;"
+    echo "    MR_Code       *dest;"
+    echo "    int           num_explicit_args;"
+    echo "    int           num_hidden_args;"
+    echo "    int           i;"
+
+    i=1;
+    while test $i -le $spec_explicit_arg
+    do
+        echo "    MR_Word       arg$i;"
+        i=`expr $i + 1`
+    done
+
+    echo
+    echo "    type_class_info = MR_r1;"
+    echo "    method_index = MR_r2;"
+    echo "    dest = MR_typeclass_info_class_method(type_class_info, method_index);"
+    echo "    num_hidden_args ="
+    echo "        MR_typeclass_info_num_extra_instance_args(type_class_info);"
+
+    if test $spec_explicit_arg -lt 0
+    then
+        echo "    num_explicit_args = MR_r3;"
+        num_explicit_args="num_explicit_args"
+    else
+        i=1;
+        while test $i -le $spec_explicit_arg
+        do
+            j=`expr $i + 2`
+            echo "    arg$i = MR_r$j;"
+            i=`expr $i + 1`
+        done
+        num_explicit_args="$spec_explicit_arg"
+    fi
+    echo
+    echo "    MR_maybe_record_method_histogram($num_explicit_args, num_hidden_args);"
+    echo
+
+    if test $max_spec_hidden_arg -ge 0 -a $spec_explicit_arg -ge 0
+    then
+        echo "    switch (num_hidden_args) {"
+        spec_hidden_arg=0
+        while test $spec_hidden_arg -le $max_spec_hidden_arg
+        do
+            echo "        case $spec_hidden_arg:"
+            i=1;
+            while test $i -le $spec_hidden_arg
+            do
+                echo "            MR_r$i = MR_typeclass_info_extra_instance_arg(type_class_info, $i);"
+                i=`expr $i + 1`
+            done
+            j=1
+            while test $j -le $spec_explicit_arg
+            do
+                echo "            MR_r$i = arg$j;"
+                i=`expr $i + 1`
+                j=`expr $j + 1`
+            done
+
+            echo "            MR_tailcall(dest, MR_prof_ho_caller_proc);"
+            echo "            break;"
+            echo
+            spec_hidden_arg=`expr $spec_hidden_arg + 1`
+        done
+        echo "        default:"
+        echo "            /* fall through to the general case below */"
+        echo "            break;"
+        echo "    }"
+        echo
+    fi
+
+    echo "    MR_save_registers();"
+    if test $spec_explicit_arg -lt 0
+    then
+        echo "    if (num_hidden_args < MR_CLASS_METHOD_CALL_INPUTS_COMPACT) {"
+        echo "        /* copy the explicit args to the left, from the left */"
+        echo "        for (i = 1; i <= num_explicit_args; i++) {"
+        echo "            MR_virtual_reg_assign(i + num_hidden_args,"
+        echo "                MR_virtual_reg_value(i + MR_CLASS_METHOD_CALL_INPUTS_COMPACT));"
+        echo "        }"
+        echo "    } else if (num_hidden_args > MR_CLASS_METHOD_CALL_INPUTS_COMPACT) {"
+        echo "        /* copy the explicit args to the right, from the right */"
+        echo "        for (i = num_explicit_args; i > 0 ; i--) {"
+        echo "            MR_virtual_reg_assign(i + num_hidden_args,"
+        echo "                MR_virtual_reg_value(i + MR_CLASS_METHOD_CALL_INPUTS_COMPACT));"
+        echo "        }"
+        echo "    } /* else the explicit args are in the right place */"
+    else
+        i=1
+        while test $i -le $spec_explicit_arg
+        do
+            echo "    MR_virtual_reg_assign(num_hidden_args + $i, arg$i);"
+            i=`expr $i + 1`
+        done
+
+    fi
+    echo
+
+    echo "    for (i = 1; i <= num_hidden_args; i++) {"
+    echo "        MR_virtual_reg_assign(i,"
+    echo "            MR_typeclass_info_extra_instance_arg(type_class_info, i));"
+    echo "    }"
+    echo "    MR_restore_registers();"
+    echo
+    echo "    MR_tailcall(dest, MR_prof_ho_caller_proc);"
+    echo "}"
+    echo
+
+    echo "MR_define_extern_entry(mercury__do_call_class_method_$variant);" >> mercury_method_call_declares.i
+    echo "    MR_init_entry_an(mercury__do_call_class_method_$variant);" >> mercury_method_call_inits.i
+
+    spec_explicit_arg=`expr $spec_explicit_arg + 1`
+done
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:  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