Mercurial > hg > xemacs-beta
comparison src/bytecode.c @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 09:49:09 +0200 |
| parents | 15872534500d |
| children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
| 172:a38aed19690b | 173:8eaf7971accc |
|---|---|
| 28 FSF: long ago. | 28 FSF: long ago. |
| 29 | 29 |
| 30 hacked on by jwz@netscape.com 17-jun-91 | 30 hacked on by jwz@netscape.com 17-jun-91 |
| 31 o added a compile-time switch to turn on simple sanity checking; | 31 o added a compile-time switch to turn on simple sanity checking; |
| 32 o put back the obsolete byte-codes for error-detection; | 32 o put back the obsolete byte-codes for error-detection; |
| 33 o added a new instruction, unbind_all, which I will use for | 33 o added a new instruction, unbind_all, which I will use for |
| 34 tail-recursion elimination; | 34 tail-recursion elimination; |
| 35 o made temp_output_buffer_show be called with the right number | 35 o made temp_output_buffer_show be called with the right number |
| 36 of args; | 36 of args; |
| 37 o made the new bytecodes be called with args in the right order; | 37 o made the new bytecodes be called with args in the right order; |
| 38 o added metering support. | 38 o added metering support. |
| 48 #include "lisp.h" | 48 #include "lisp.h" |
| 49 #include "buffer.h" | 49 #include "buffer.h" |
| 50 #include "syntax.h" | 50 #include "syntax.h" |
| 51 | 51 |
| 52 /* | 52 /* |
| 53 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for | 53 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for |
| 54 * debugging the byte compiler...) Somewhat surprisingly, defining this | 54 * debugging the byte compiler...) Somewhat surprisingly, defining this |
| 55 * makes Fbyte_code about 8% slower. | 55 * makes Fbyte_code about 8% slower. |
| 56 * | 56 * |
| 57 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. | 57 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. |
| 58 */ | 58 */ |
| 59 #define BYTE_CODE_SAFE | 59 #define BYTE_CODE_SAFE |
| 60 /* #define BYTE_CODE_METER */ | 60 /* #define BYTE_CODE_METER */ |
| 61 | 61 |
| 62 | 62 |
| 64 | 64 |
| 65 Lisp_Object Vbyte_code_meter, Qbyte_code_meter; | 65 Lisp_Object Vbyte_code_meter, Qbyte_code_meter; |
| 66 int byte_metering_on; | 66 int byte_metering_on; |
| 67 | 67 |
| 68 #define METER_2(code1, code2) \ | 68 #define METER_2(code1, code2) \ |
| 69 XINT (XVECTOR (vector_data (XVECTOR (Vbyte_code_meter))[(code1)]) \ | 69 XINT (XVECTOR_DATA (XVECTOR_DATA (Vbyte_code_meter)[(code1)])[(code2)]) |
| 70 ->contents[(code2)]) | |
| 71 | 70 |
| 72 #define METER_1(code) METER_2 (0, (code)) | 71 #define METER_1(code) METER_2 (0, (code)) |
| 73 | 72 |
| 74 #define METER_CODE(last_code, this_code) \ | 73 #define METER_CODE(last_code, this_code) \ |
| 75 { \ | 74 { \ |
| 281 int pc; | 280 int pc; |
| 282 Lisp_Object *stack; | 281 Lisp_Object *stack; |
| 283 REGISTER Lisp_Object *stackp; | 282 REGISTER Lisp_Object *stackp; |
| 284 Lisp_Object *stacke; | 283 Lisp_Object *stacke; |
| 285 REGISTER Lisp_Object v1, v2; | 284 REGISTER Lisp_Object v1, v2; |
| 286 REGISTER Lisp_Object *vectorp = vector_data (XVECTOR (vector)); | 285 REGISTER Lisp_Object *vectorp = XVECTOR_DATA (vector); |
| 287 #ifdef BYTE_CODE_SAFE | 286 #ifdef BYTE_CODE_SAFE |
| 288 REGISTER int const_length = vector_length (XVECTOR (vector)); | 287 REGISTER int const_length = XVECTOR_LENGTH (vector); |
| 289 #endif | 288 #endif |
| 290 REGISTER Emchar *massaged_code; | 289 REGISTER Emchar *massaged_code; |
| 291 int massaged_code_len; | 290 int massaged_code_len; |
| 292 | 291 |
| 293 CHECK_STRING (bytestr); | 292 CHECK_STRING (bytestr); |
| 313 convert_bufbyte_string_into_emchar_string (XSTRING_DATA (bytestr), | 312 convert_bufbyte_string_into_emchar_string (XSTRING_DATA (bytestr), |
| 314 XSTRING_LENGTH (bytestr), | 313 XSTRING_LENGTH (bytestr), |
| 315 massaged_code); | 314 massaged_code); |
| 316 massaged_code[massaged_code_len] = 0; | 315 massaged_code[massaged_code_len] = 0; |
| 317 pc = 0; | 316 pc = 0; |
| 318 | 317 |
| 319 while (1) | 318 while (1) |
| 320 { | 319 { |
| 321 #ifdef BYTE_CODE_SAFE | 320 #ifdef BYTE_CODE_SAFE |
| 322 if (stackp > stacke) | 321 if (stackp > stacke) |
| 323 error ("Byte code stack overflow (byte compiler bug), pc %d, depth %d", | 322 error ("Byte code stack overflow (byte compiler bug), pc %d, depth %ld", |
| 324 pc, stacke - stackp); | 323 pc, (long) (stacke - stackp)); |
| 325 if (stackp < stack) | 324 if (stackp < stack) |
| 326 error ("Byte code stack underflow (byte compiler bug), pc %d", | 325 error ("Byte code stack underflow (byte compiler bug), pc %d", |
| 327 pc); | 326 pc); |
| 328 #endif | 327 #endif |
| 329 | 328 |
| 1186 byte_metering_on = 0; | 1185 byte_metering_on = 0; |
| 1187 Vbyte_code_meter = make_vector (256, Qzero); | 1186 Vbyte_code_meter = make_vector (256, Qzero); |
| 1188 { | 1187 { |
| 1189 int i = 256; | 1188 int i = 256; |
| 1190 while (i--) | 1189 while (i--) |
| 1191 vector_data (XVECTOR (Vbyte_code_meter))[i] = | 1190 XVECTOR_DATA (Vbyte_code_meter)[i] = |
| 1192 make_vector (256, Qzero); | 1191 make_vector (256, Qzero); |
| 1193 } | 1192 } |
| 1194 #endif | 1193 #endif |
| 1195 } | 1194 } |
