1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
If you have akcl version 604 or newer, do not make these patches.
(1) Turbo closure patch
To make the turbo closure stuff work, make the following changes to KCL.
These changes can also work for an IBCL.
The three patches in this file add two features (reflected in the
value of *features*) to your KCL or IBCL:
a feature named :TURBO-CLOSURE which increases the speed of the
code generated by FUNCALLABLE-INSTANCE-DATA-1
(previous versions of the file kcl-mods.text had this feature only),
and
a feature named :TURBO-CLOSURE-ENV-SIZE which increases the speed
of the function FUNCALLABLE-INSTANCE-P.
(This file comprises two features rather than just one to allow the
PCL system to be work in KCL systems that do not have this patch,
or that have the old version of this patch.)
The first of these patches changes the turbo_closure function to
store the size of the environment in the turbo structure.
The second of patch fixes a garbage-collector bug in which
the turbo structure was sometimes ignored, AND also adapts
the garbage-collector to conform to the change made in the
first patch. The bug has been fixed in newer versions of
AKCL, but it is still necessary to apply this patch, if the
first and third patches are applied.
The third change pushes :turbo-closure and :turbo-closure-env-size
on the *features* list so that PCL will know that turbo closures
are enabled.
Note that these changes have to be made before PCL is compiled, and a
PCL which is compiled in a KCL/IBCL with these changes can only be run
in a KCL/IBCL with these changes.
(1-1) edit the function turbo_closure in the file kcl/c/cfun.c,
change the lines
----------
turbo_closure(fun)
object fun;
{
object l;
int n;
for (n = 0, l = fun->cc.cc_env; !endp(l); n++, l = l->c.c_cdr)
;
fun->cc.cc_turbo = (object *)alloc_contblock(n*sizeof(object));
for (n = 0, l = fun->cc.cc_env; !endp(l); n++, l = l->c.c_cdr)
fun->cc.cc_turbo[n] = l;
}
----------
to
----------
turbo_closure(fun)
object fun;
{
object l,*block;
int n;
if(fun->cc.cc_turbo==NULL)
{for (n = 0, l = fun->cc.cc_env; !endp(l); n++, l = l->c.c_cdr);
block=(object *)alloc_contblock((1+n)*sizeof(object));
*block=make_fixnum(n);
fun->cc.cc_turbo = block+1; /* equivalent to &block[1] */
for (n = 0, l = fun->cc.cc_env; !endp(l); n++, l = l->c.c_cdr)
fun->cc.cc_turbo[n] = l;}
}
----------
(1-2) edit the function mark_object in the file kcl/c/gbc.c,
Find the lines following case t_cclosure: in mark_object.
If they look like the ones between the lines marked (KCL),
make the first change, but if the look like the lines marked
(AKCL), apply the second change instead, and if the file
sgbc.c exists, apply the third change to it.
(1-2-1) Change:
(KCL)----------
case t_cclosure:
mark_object(x->cc.cc_name);
mark_object(x->cc.cc_env);
mark_object(x->cc.cc_data);
if (x->cc.cc_start == NULL)
break;
if (what_to_collect == t_contiguous) {
if (get_mark_bit((int *)(x->cc.cc_start)))
break;
mark_contblock(x->cc.cc_start, x->cc.cc_size);
if (x->cc.cc_turbo != NULL) {
for (i = 0, y = x->cc.cc_env;
type_of(y) == t_cons;
i++, y = y->c.c_cdr);
mark_contblock((char *)(x->cc.cc_turbo),
i*sizeof(object));
}
}
break;
(KCL)----------
to
(KCL new)----------
case t_cclosure:
mark_object(x->cc.cc_name);
mark_object(x->cc.cc_env);
mark_object(x->cc.cc_data);
if (what_to_collect == t_contiguous)
if (x->cc.cc_turbo != NULL) {
mark_contblock((char *)(x->cc.cc_turbo-1),
(1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
}
if (x->cc.cc_start == NULL)
break;
if (what_to_collect == t_contiguous) {
if (get_mark_bit((int *)(x->cc.cc_start)))
break;
mark_contblock(x->cc.cc_start, x->cc.cc_size);
}
break;
(KCL new)----------
(1-2-2) Or, Change:
(AKCL)----------
case t_cclosure:
mark_object(x->cc.cc_name);
mark_object(x->cc.cc_env);
mark_object(x->cc.cc_data);
if (what_to_collect == t_contiguous) {
if (x->cc.cc_turbo != NULL) {
for (i = 0, y = x->cc.cc_env;
type_of(y) == t_cons;
i++, y = y->c.c_cdr);
mark_contblock((char *)(x->cc.cc_turbo),
i*sizeof(object));
}
}
break;
(AKCL)----------
To:
(AKCL new)----------
case t_cclosure:
mark_object(x->cc.cc_name);
mark_object(x->cc.cc_env);
mark_object(x->cc.cc_data);
if (what_to_collect == t_contiguous) {
if (x->cc.cc_turbo != NULL)
mark_contblock((char *)(x->cc.cc_turbo-1),
(1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
}
break;
(AKCL new)----------
(1-2-3) In sgbc.c (if it exists), Change:
(AKCL)----------
case t_cclosure:
sgc_mark_object(x->cc.cc_name);
sgc_mark_object(x->cc.cc_env);
sgc_mark_object(x->cc.cc_data);
if (what_to_collect == t_contiguous) {
if (x->cc.cc_turbo != NULL) {
for (i = 0, y = x->cc.cc_env;
type_of(y) == t_cons;
i++, y = y->c.c_cdr);
mark_contblock((char *)(x->cc.cc_turbo),
i*sizeof(object));
}
}
break;
(AKCL)----------
To:
(AKCL new)----------
case t_cclosure:
sgc_mark_object(x->cc.cc_name);
sgc_mark_object(x->cc.cc_env);
sgc_mark_object(x->cc.cc_data);
if (what_to_collect == t_contiguous) {
if (x->cc.cc_turbo != NULL)
mark_contblock((char *)(x->cc.cc_turbo-1),
(1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
}
break;
(AKCL new)----------
(1-3) edit the function init_main in the file kcl/c/main.c,
change the lines where setting the value of *features* to add a :turbo-closure
and a :turbo-closure-env-size into the list in your KCL/IBCL.
For example, in Sun4(SunOS) version of IBCL
changing the lines:
----------
make_special("*FEATURES*",
make_cons(make_ordinary("SUN4"),
make_cons(make_ordinary("SPARC"),
make_cons(make_ordinary("IEEE-FLOATING-POINT"),
make_cons(make_ordinary("UNIX"),
make_cons(make_ordinary("BSD"),
make_cons(make_ordinary("COMMON"),
make_cons(make_ordinary("IBCL"), Cnil))))))));
----------
to
----------
make_special("*FEATURES*",
make_cons(make_ordinary("SUN4"),
make_cons(make_ordinary("SPARC"),
make_cons(make_ordinary("IEEE-FLOATING-POINT"),
make_cons(make_ordinary("UNIX"),
make_cons(make_ordinary("BSD"),
make_cons(make_ordinary("COMMON"),
make_cons(make_ordinary("IBCL"),
make_cons(make_keyword("TURBO-CLOSURE"),
make_cons(make_keyword("TURBO-CLOSURE-ENV-SIZE"),
Cnil))))))))));
----------
But, if the C macro ADD_FEATURE is defined at the end of main.c,
use it instead.
Insert the lines:
ADD_FEATURE("TURBO-CLOSURE");
ADD_FEATURE("TURBO-CLOSURE-ENV-SIZE");
After the line:
ADD_FEATURE("AKCL");
|