comparison src/bytecode.c @ 45617:36bc4f35dc18

(Fbyte_code): Cast `current_column' return value to int.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Mon, 03 Jun 2002 01:34:11 +0000
parents ee16c542dc35
children 1fb8f75062c6
comparison
equal deleted inserted replaced
45616:cdfc05dbbe0d 45617:36bc4f35dc18
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21 21
22 hacked on by jwz@lucid.com 17-jun-91 22 hacked on by jwz@lucid.com 17-jun-91
23 o added a compile-time switch to turn on simple sanity checking; 23 o added a compile-time switch to turn on simple sanity checking;
24 o put back the obsolete byte-codes for error-detection; 24 o put back the obsolete byte-codes for error-detection;
25 o added a new instruction, unbind_all, which I will use for 25 o added a new instruction, unbind_all, which I will use for
26 tail-recursion elimination; 26 tail-recursion elimination;
27 o made temp_output_buffer_show be called with the right number 27 o made temp_output_buffer_show be called with the right number
28 of args; 28 of args;
29 o made the new bytecodes be called with args in the right order; 29 o made the new bytecodes be called with args in the right order;
30 o added metering support. 30 o added metering support.
44 #include "frame.h" 44 #include "frame.h"
45 #include "xterm.h" 45 #include "xterm.h"
46 #endif 46 #endif
47 47
48 /* 48 /*
49 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for 49 * define BYTE_CODE_SAFE to enable some minor sanity checking (useful for
50 * debugging the byte compiler...) 50 * debugging the byte compiler...)
51 * 51 *
52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram. 52 * define BYTE_CODE_METER to enable generation of a byte-op usage histogram.
53 */ 53 */
54 /* #define BYTE_CODE_SAFE */ 54 /* #define BYTE_CODE_SAFE */
55 /* #define BYTE_CODE_METER */ 55 /* #define BYTE_CODE_METER */
56 56
57 57
285 The culprit is found in the frame of Fbyte_code where the 285 The culprit is found in the frame of Fbyte_code where the
286 address of its local variable `stack' is equal to the 286 address of its local variable `stack' is equal to the
287 recorded value of `stack' here. */ 287 recorded value of `stack' here. */
288 if (!stack->top) 288 if (!stack->top)
289 abort (); 289 abort ();
290 290
291 for (obj = stack->bottom; obj <= stack->top; ++obj) 291 for (obj = stack->bottom; obj <= stack->top; ++obj)
292 if (!XMARKBIT (*obj)) 292 if (!XMARKBIT (*obj))
293 { 293 {
294 mark_object (obj); 294 mark_object (obj);
295 XMARK (*obj); 295 XMARK (*obj);
311 311
312 312
313 /* Unmark objects in the stacks on byte_stack_list. Relocate program 313 /* Unmark objects in the stacks on byte_stack_list. Relocate program
314 counters. Called when GC has completed. */ 314 counters. Called when GC has completed. */
315 315
316 void 316 void
317 unmark_byte_stack () 317 unmark_byte_stack ()
318 { 318 {
319 struct byte_stack *stack; 319 struct byte_stack *stack;
320 Lisp_Object *obj; 320 Lisp_Object *obj;
321 321
464 vectorp = XVECTOR (vector)->contents; 464 vectorp = XVECTOR (vector)->contents;
465 465
466 stack.byte_string = bytestr; 466 stack.byte_string = bytestr;
467 stack.pc = stack.byte_string_start = XSTRING (bytestr)->data; 467 stack.pc = stack.byte_string_start = XSTRING (bytestr)->data;
468 stack.constants = vector; 468 stack.constants = vector;
469 stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth) 469 stack.bottom = (Lisp_Object *) alloca (XFASTINT (maxdepth)
470 * sizeof (Lisp_Object)); 470 * sizeof (Lisp_Object));
471 top = stack.bottom - 1; 471 top = stack.bottom - 1;
472 stack.top = NULL; 472 stack.top = NULL;
473 stack.next = byte_stack_list; 473 stack.next = byte_stack_list;
474 byte_stack_list = &stack; 474 byte_stack_list = &stack;
475 475
476 #ifdef BYTE_CODE_SAFE 476 #ifdef BYTE_CODE_SAFE
477 stacke = stack.bottom - 1 + XFASTINT (maxdepth); 477 stacke = stack.bottom - 1 + XFASTINT (maxdepth);
478 #endif 478 #endif
479 479
480 while (1) 480 while (1)
481 { 481 {
482 #ifdef BYTE_CODE_SAFE 482 #ifdef BYTE_CODE_SAFE
483 if (top > stacke) 483 if (top > stacke)
484 abort (); 484 abort ();
498 { 498 {
499 case Bvarref + 7: 499 case Bvarref + 7:
500 op = FETCH2; 500 op = FETCH2;
501 goto varref; 501 goto varref;
502 502
503 case Bvarref: 503 case Bvarref:
504 case Bvarref + 1: 504 case Bvarref + 1:
505 case Bvarref + 2: 505 case Bvarref + 2:
506 case Bvarref + 3: 506 case Bvarref + 3:
507 case Bvarref + 4: 507 case Bvarref + 4:
508 case Bvarref + 5: 508 case Bvarref + 5:
509 op = op - Bvarref; 509 op = op - Bvarref;
510 goto varref; 510 goto varref;
511 511
512 /* This seems to be the most frequently executed byte-code 512 /* This seems to be the most frequently executed byte-code
617 case Bvarset+6: 617 case Bvarset+6:
618 op = FETCH; 618 op = FETCH;
619 varset: 619 varset:
620 { 620 {
621 Lisp_Object sym, val; 621 Lisp_Object sym, val;
622 622
623 sym = vectorp[op]; 623 sym = vectorp[op];
624 val = TOP; 624 val = TOP;
625 625
626 /* Inline the most common case. */ 626 /* Inline the most common case. */
627 if (SYMBOLP (sym) 627 if (SYMBOLP (sym)
1350 1350
1351 case Bcurrent_column: 1351 case Bcurrent_column:
1352 { 1352 {
1353 Lisp_Object v1; 1353 Lisp_Object v1;
1354 BEFORE_POTENTIAL_GC (); 1354 BEFORE_POTENTIAL_GC ();
1355 XSETFASTINT (v1, current_column ()); 1355 XSETFASTINT (v1, (int) current_column ()); /* iftc */
1356 AFTER_POTENTIAL_GC (); 1356 AFTER_POTENTIAL_GC ();
1357 PUSH (v1); 1357 PUSH (v1);
1358 break; 1358 break;
1359 } 1359 }
1360 1360
1729 #ifdef BYTE_CODE_SAFE 1729 #ifdef BYTE_CODE_SAFE
1730 error ("binding stack not balanced (serious byte compiler bug)"); 1730 error ("binding stack not balanced (serious byte compiler bug)");
1731 #else 1731 #else
1732 abort (); 1732 abort ();
1733 #endif 1733 #endif
1734 1734
1735 return result; 1735 return result;
1736 } 1736 }
1737 1737
1738 void 1738 void
1739 syms_of_bytecode () 1739 syms_of_bytecode ()
1750 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte 1750 \(aref (aref byte-code-meter 0) CODE) indicates how many times the byte
1751 opcode CODE has been executed. 1751 opcode CODE has been executed.
1752 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0, 1752 \(aref (aref byte-code-meter CODE1) CODE2), where CODE1 is not 0,
1753 indicates how many times the byte opcodes CODE1 and CODE2 have been 1753 indicates how many times the byte opcodes CODE1 and CODE2 have been
1754 executed in succession. */); 1754 executed in succession. */);
1755 1755
1756 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on, 1756 DEFVAR_BOOL ("byte-metering-on", &byte_metering_on,
1757 doc: /* If non-nil, keep profiling information on byte code usage. 1757 doc: /* If non-nil, keep profiling information on byte code usage.
1758 The variable byte-code-meter indicates how often each byte opcode is used. 1758 The variable byte-code-meter indicates how often each byte opcode is used.
1759 If a symbol has a property named `byte-code-meter' whose value is an 1759 If a symbol has a property named `byte-code-meter' whose value is an
1760 integer, it is incremented each time that symbol's function is called. */); 1760 integer, it is incremented each time that symbol's function is called. */);