Mercurial > hg > xemacs-beta
comparison src/bytecode.c @ 3092:141c2920ea48
[xemacs-hg @ 2005-11-25 01:41:31 by crestani]
Incremental Garbage Collector
author | crestani |
---|---|
date | Fri, 25 Nov 2005 01:42:08 +0000 |
parents | 6fa9919a9a0b |
children | d674024a8674 |
comparison
equal
deleted
inserted
replaced
3091:c22d8984148c | 3092:141c2920ea48 |
---|---|
55 #include "buffer.h" | 55 #include "buffer.h" |
56 #include "bytecode.h" | 56 #include "bytecode.h" |
57 #include "opaque.h" | 57 #include "opaque.h" |
58 #include "syntax.h" | 58 #include "syntax.h" |
59 #include "window.h" | 59 #include "window.h" |
60 | |
61 #ifdef NEW_GC | |
62 static Lisp_Object | |
63 make_compiled_function_args (int totalargs) | |
64 { | |
65 Lisp_Compiled_Function_Args *args; | |
66 args = (Lisp_Compiled_Function_Args *) | |
67 alloc_lrecord | |
68 (FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_Compiled_Function_Args, | |
69 Lisp_Object, args, totalargs), | |
70 &lrecord_compiled_function_args); | |
71 args->size = totalargs; | |
72 return wrap_compiled_function_args (args); | |
73 } | |
74 | |
75 static Bytecount | |
76 size_compiled_function_args (const void *lheader) | |
77 { | |
78 return FLEXIBLE_ARRAY_STRUCT_SIZEOF (Lisp_Compiled_Function_Args, | |
79 Lisp_Object, args, | |
80 ((Lisp_Compiled_Function_Args *) | |
81 lheader)->size); | |
82 } | |
83 | |
84 static const struct memory_description compiled_function_args_description[] = { | |
85 { XD_LONG, offsetof (Lisp_Compiled_Function_Args, size) }, | |
86 { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Compiled_Function_Args, args), | |
87 XD_INDIRECT(0, 0) }, | |
88 { XD_END } | |
89 }; | |
90 | |
91 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION ("compiled-function-args", | |
92 compiled_function_args, | |
93 1, /*dumpable-flag*/ | |
94 0, 0, 0, 0, 0, | |
95 compiled_function_args_description, | |
96 size_compiled_function_args, | |
97 Lisp_Compiled_Function_Args); | |
98 #endif /* NEW_GC */ | |
60 | 99 |
61 EXFUN (Ffetch_bytecode, 1); | 100 EXFUN (Ffetch_bytecode, 1); |
62 | 101 |
63 Lisp_Object Qbyte_code, Qcompiled_functionp, Qinvalid_byte_code; | 102 Lisp_Object Qbyte_code, Qcompiled_functionp, Qinvalid_byte_code; |
64 | 103 |
2020 } | 2059 } |
2021 } | 2060 } |
2022 } | 2061 } |
2023 | 2062 |
2024 if (totalargs) | 2063 if (totalargs) |
2064 #ifdef NEW_GC | |
2065 f->arguments = make_compiled_function_args (totalargs); | |
2066 #else /* not NEW_GC */ | |
2025 f->args = xnew_array (Lisp_Object, totalargs); | 2067 f->args = xnew_array (Lisp_Object, totalargs); |
2068 #endif /* not NEW_GC */ | |
2026 | 2069 |
2027 { | 2070 { |
2028 LIST_LOOP_2 (arg, f->arglist) | 2071 LIST_LOOP_2 (arg, f->arglist) |
2029 { | 2072 { |
2030 if (!EQ (arg, Qand_optional) && !EQ (arg, Qand_rest)) | 2073 if (!EQ (arg, Qand_optional) && !EQ (arg, Qand_rest)) |
2074 #ifdef NEW_GC | |
2075 XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i++] = arg; | |
2076 #else /* not NEW_GC */ | |
2031 f->args[i++] = arg; | 2077 f->args[i++] = arg; |
2078 #endif /* not NEW_GC */ | |
2032 } | 2079 } |
2033 } | 2080 } |
2034 | 2081 |
2035 f->max_args = maxargs; | 2082 f->max_args = maxargs; |
2036 f->min_args = minargs; | 2083 f->min_args = minargs; |
2059 } | 2106 } |
2060 | 2107 |
2061 /************************************************************************/ | 2108 /************************************************************************/ |
2062 /* The compiled-function object type */ | 2109 /* The compiled-function object type */ |
2063 /************************************************************************/ | 2110 /************************************************************************/ |
2111 | |
2064 static void | 2112 static void |
2065 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun, | 2113 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun, |
2066 int escapeflag) | 2114 int escapeflag) |
2067 { | 2115 { |
2068 /* This function can GC */ | 2116 /* This function can GC */ |
2141 mark_object (f->doc_and_interactive); | 2189 mark_object (f->doc_and_interactive); |
2142 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | 2190 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK |
2143 mark_object (f->annotated); | 2191 mark_object (f->annotated); |
2144 #endif | 2192 #endif |
2145 for (i = 0; i < f->args_in_array; i++) | 2193 for (i = 0; i < f->args_in_array; i++) |
2194 #ifdef NEW_GC | |
2195 mark_object (XCOMPILED_FUNCTION_ARGS_DATA (f->arguments)[i]); | |
2196 #else /* not NEW_GC */ | |
2146 mark_object (f->args[i]); | 2197 mark_object (f->args[i]); |
2198 #endif /* not NEW_GC */ | |
2147 | 2199 |
2148 /* tail-recurse on constants */ | 2200 /* tail-recurse on constants */ |
2149 return f->constants; | 2201 return f->constants; |
2150 } | 2202 } |
2151 | 2203 |
2177 internal_hash (f->constants, depth + 1)); | 2229 internal_hash (f->constants, depth + 1)); |
2178 } | 2230 } |
2179 | 2231 |
2180 static const struct memory_description compiled_function_description[] = { | 2232 static const struct memory_description compiled_function_description[] = { |
2181 { XD_INT, offsetof (Lisp_Compiled_Function, args_in_array) }, | 2233 { XD_INT, offsetof (Lisp_Compiled_Function, args_in_array) }, |
2182 { XD_BLOCK_PTR, offsetof (Lisp_Compiled_Function, args), | 2234 #ifdef NEW_GC |
2235 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arguments) }, | |
2236 #else /* not NEW_GC */ | |
2237 { XD_BLOCK_PTR, offsetof (Lisp_Compiled_Function, args), | |
2183 XD_INDIRECT (0, 0), { &lisp_object_description } }, | 2238 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
2239 #endif /* not NEW_GC */ | |
2184 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, instructions) }, | 2240 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, instructions) }, |
2185 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, constants) }, | 2241 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, constants) }, |
2186 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arglist) }, | 2242 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, arglist) }, |
2187 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, doc_and_interactive) }, | 2243 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, doc_and_interactive) }, |
2188 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK | 2244 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK |
2189 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, annotated) }, | 2245 { XD_LISP_OBJECT, offsetof (Lisp_Compiled_Function, annotated) }, |
2190 #endif | 2246 #endif |
2191 { XD_END } | 2247 { XD_END } |
2192 }; | 2248 }; |
2193 | 2249 |
2194 #ifdef MC_ALLOC | 2250 #if defined(MC_ALLOC) && !defined(NEW_GC) |
2195 static void | 2251 static void |
2196 finalize_compiled_function (void *header, int for_disksave) | 2252 finalize_compiled_function (void *header, int for_disksave) |
2197 { | 2253 { |
2198 if (!for_disksave) | 2254 if (!for_disksave) |
2199 { | 2255 { |
2211 finalize_compiled_function, | 2267 finalize_compiled_function, |
2212 compiled_function_equal, | 2268 compiled_function_equal, |
2213 compiled_function_hash, | 2269 compiled_function_hash, |
2214 compiled_function_description, | 2270 compiled_function_description, |
2215 Lisp_Compiled_Function); | 2271 Lisp_Compiled_Function); |
2216 #else /* not MC_ALLOC */ | 2272 #else /* !MC_ALLOC || NEW_GC */ |
2217 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("compiled-function", compiled_function, | 2273 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("compiled-function", compiled_function, |
2218 1, /*dumpable_flag*/ | 2274 1, /*dumpable_flag*/ |
2219 mark_compiled_function, | 2275 mark_compiled_function, |
2220 print_compiled_function, 0, | 2276 print_compiled_function, 0, |
2221 compiled_function_equal, | 2277 compiled_function_equal, |
2222 compiled_function_hash, | 2278 compiled_function_hash, |
2223 compiled_function_description, | 2279 compiled_function_description, |
2224 Lisp_Compiled_Function); | 2280 Lisp_Compiled_Function); |
2225 #endif /* not MC_ALLOC */ | 2281 #endif /* !MC_ALLOC || NEW_GC */ |
2282 | |
2226 | 2283 |
2227 DEFUN ("compiled-function-p", Fcompiled_function_p, 1, 1, 0, /* | 2284 DEFUN ("compiled-function-p", Fcompiled_function_p, 1, 1, 0, /* |
2228 Return t if OBJECT is a byte-compiled function object. | 2285 Return t if OBJECT is a byte-compiled function object. |
2229 */ | 2286 */ |
2230 (object)) | 2287 (object)) |
2592 | 2649 |
2593 void | 2650 void |
2594 syms_of_bytecode (void) | 2651 syms_of_bytecode (void) |
2595 { | 2652 { |
2596 INIT_LRECORD_IMPLEMENTATION (compiled_function); | 2653 INIT_LRECORD_IMPLEMENTATION (compiled_function); |
2654 #ifdef NEW_GC | |
2655 INIT_LRECORD_IMPLEMENTATION (compiled_function_args); | |
2656 #endif /* NEW_GC */ | |
2597 | 2657 |
2598 DEFERROR_STANDARD (Qinvalid_byte_code, Qinvalid_state); | 2658 DEFERROR_STANDARD (Qinvalid_byte_code, Qinvalid_state); |
2599 DEFSYMBOL (Qbyte_code); | 2659 DEFSYMBOL (Qbyte_code); |
2600 DEFSYMBOL_MULTIWORD_PREDICATE (Qcompiled_functionp); | 2660 DEFSYMBOL_MULTIWORD_PREDICATE (Qcompiled_functionp); |
2601 | 2661 |