comparison src/bytecode.h @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents c5d627a313b1
children 74fd4e045ea6
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
28 */ 28 */
29 29
30 #ifndef _XEMACS_BYTECODE_H_ 30 #ifndef _XEMACS_BYTECODE_H_
31 #define _XEMACS_BYTECODE_H_ 31 #define _XEMACS_BYTECODE_H_
32 32
33 /* Meanings of slots in a Lisp_Compiled_Function. */ 33 /* Meanings of slots in a Lisp_Compiled_Function.
34 #define COMPILED_ARGLIST 0 34 Don't use these! For backward compatibility only. */
35 #define COMPILED_BYTECODE 1 35 #define COMPILED_ARGLIST 0
36 #define COMPILED_CONSTANTS 2 36 #define COMPILED_INSTRUCTIONS 1
37 #define COMPILED_STACK_DEPTH 3 37 #define COMPILED_CONSTANTS 2
38 #define COMPILED_DOC_STRING 4 38 #define COMPILED_STACK_DEPTH 3
39 #define COMPILED_INTERACTIVE 5 39 #define COMPILED_DOC_STRING 4
40 #define COMPILED_DOMAIN 6 40 #define COMPILED_INTERACTIVE 5
41 #define COMPILED_DOMAIN 6
41 42
42 /* It doesn't make sense to have this and also have load-history */ 43 /* It doesn't make sense to have this and also have load-history */
43 /* #define COMPILED_FUNCTION_ANNOTATION_HACK */ 44 /* #define COMPILED_FUNCTION_ANNOTATION_HACK */
44 45
45 struct Lisp_Compiled_Function 46 struct Lisp_Compiled_Function
46 { 47 {
47 struct lrecord_header lheader; 48 struct lrecord_header lheader;
48 unsigned short maxdepth; 49 unsigned short stack_depth;
50 unsigned short specpdl_depth;
49 struct 51 struct
50 { 52 {
51 unsigned int documentationp: 1; 53 unsigned int documentationp: 1;
52 unsigned int interactivep: 1; 54 unsigned int interactivep: 1;
53 /* Only used if I18N3, but always defined for simplicity. */ 55 /* Only used if I18N3, but always defined for simplicity. */
54 unsigned int domainp: 1; 56 unsigned int domainp: 1;
55 /* Non-zero if this bytecode came from a v18 or v19 file. 57 /* Non-zero if this bytecode came from a v18 or v19 file.
56 We need to Ebolify the `assoc', `delq', etc. functions. */ 58 We need to Ebolify the `assoc', `delq', etc. functions. */
57 unsigned int ebolified: 1; 59 unsigned int ebolified: 1;
58 } flags; 60 } flags;
59 Lisp_Object bytecodes; 61 Lisp_Object instructions;
60 Lisp_Object constants; 62 Lisp_Object constants;
61 Lisp_Object arglist; 63 Lisp_Object arglist;
62 /* This uses the minimal number of conses; see accessors in data.c. */ 64 /* This uses the minimal number of conses; see accessors in data.c. */
63 Lisp_Object doc_and_interactive; 65 Lisp_Object doc_and_interactive;
64 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK 66 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
65 /* Something indicating where the bytecode came from */ 67 /* Something indicating where the bytecode came from */
66 Lisp_Object annotated; 68 Lisp_Object annotated;
67 #endif 69 #endif
68 }; 70 };
71 typedef struct Lisp_Compiled_Function Lisp_Compiled_Function;
69 72
70 Lisp_Object compiled_function_documentation (struct Lisp_Compiled_Function *b); 73 Lisp_Object run_byte_code (Lisp_Object compiled_function_or_instructions, ...);
71 Lisp_Object compiled_function_interactive (struct Lisp_Compiled_Function *b);
72 Lisp_Object compiled_function_domain (struct Lisp_Compiled_Function *b);
73 void set_compiled_function_documentation (struct Lisp_Compiled_Function *b,
74 Lisp_Object);
75 Lisp_Object compiled_function_annotation (struct Lisp_Compiled_Function *b);
76 74
77 DECLARE_LRECORD (compiled_function, struct Lisp_Compiled_Function); 75 Lisp_Object compiled_function_arglist (Lisp_Compiled_Function *f);
76 Lisp_Object compiled_function_instructions (Lisp_Compiled_Function *f);
77 Lisp_Object compiled_function_constants (Lisp_Compiled_Function *f);
78 int compiled_function_stack_depth (Lisp_Compiled_Function *f);
79 Lisp_Object compiled_function_documentation (Lisp_Compiled_Function *f);
80 Lisp_Object compiled_function_annotation (Lisp_Compiled_Function *f);
81 Lisp_Object compiled_function_domain (Lisp_Compiled_Function *f);
82 Lisp_Object compiled_function_interactive (Lisp_Compiled_Function *f);
83
84 void set_compiled_function_documentation (Lisp_Compiled_Function *f,
85 Lisp_Object new_doc);
86
87 Lisp_Object funcall_compiled_function (Lisp_Object fun,
88 int nargs, Lisp_Object args[]);
89 void optimize_compiled_function (Lisp_Object compiled_function);
90
91 DECLARE_LRECORD (compiled_function, Lisp_Compiled_Function);
78 #define XCOMPILED_FUNCTION(x) XRECORD (x, compiled_function, \ 92 #define XCOMPILED_FUNCTION(x) XRECORD (x, compiled_function, \
79 struct Lisp_Compiled_Function) 93 Lisp_Compiled_Function)
80 #define XSETCOMPILED_FUNCTION(x, p) XSETRECORD (x, p, compiled_function) 94 #define XSETCOMPILED_FUNCTION(x, p) XSETRECORD (x, p, compiled_function)
81 #define COMPILED_FUNCTIONP(x) RECORDP (x, compiled_function) 95 #define COMPILED_FUNCTIONP(x) RECORDP (x, compiled_function)
82 #define GC_COMPILED_FUNCTIONP(x) GC_RECORDP (x, compiled_function) 96 #define GC_COMPILED_FUNCTIONP(x) GC_RECORDP (x, compiled_function)
83 #define CHECK_COMPILED_FUNCTION(x) CHECK_RECORD (x, compiled_function) 97 #define CHECK_COMPILED_FUNCTION(x) CHECK_RECORD (x, compiled_function)
84 #define CONCHECK_COMPILED_FUNCTION(x) CONCHECK_RECORD (x, compiled_function) 98 #define CONCHECK_COMPILED_FUNCTION(x) CONCHECK_RECORD (x, compiled_function)
85
86 EXFUN (Fbyte_code, 3);
87 99
88 extern Lisp_Object Qbyte_code; 100 extern Lisp_Object Qbyte_code;
89 101
90 /* total 1765 internal 101 doc-and-int 775 doc-only 389 int-only 42 neither 559 102 /* total 1765 internal 101 doc-and-int 775 doc-only 389 int-only 42 neither 559
91 no doc slot, no int slot 103 no doc slot, no int slot