/* Execution of byte code produced by bytecomp.el.
- Copyright (C) 1985-1988, 1993, 2000-2011 Free Software Foundation, Inc.
+ Copyright (C) 1985-1988, 1993, 2000-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define Bcurrent_column 0151
#define Bindent_to 0152
#ifdef BYTE_CODE_SAFE
-#define Bscan_buffer 0153 /* No longer generated as of v18 */
+#define Bscan_buffer 0153 /* No longer generated as of v18. */
#endif
#define Beolp 0154
#define Beobp 0155
/* A list of currently active byte-code execution value stacks.
Fbyte_code adds an entry to the head of this list before it starts
processing byte-code, and it removed the entry again when it is
- done. Signalling an error truncates the list analoguous to
+ done. Signaling an error truncates the list analogous to
gcprolist. */
struct byte_stack *byte_stack_list;
Lisp_Object
exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
- Lisp_Object args_template, int nargs, Lisp_Object *args)
+ Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
{
int count = SPECPDL_INDEX ();
#ifdef BYTE_CODE_METER
/* Lisp_Object v1, v2; */
Lisp_Object *vectorp;
#ifdef BYTE_CODE_SAFE
- int const_length = XVECTOR (vector)->size;
+ ptrdiff_t const_length;
Lisp_Object *stacke;
int bytestr_length;
#endif
CHECK_STRING (bytestr);
CHECK_VECTOR (vector);
- CHECK_NUMBER (maxdepth);
+ CHECK_NATNUM (maxdepth);
+
+#ifdef BYTE_CODE_SAFE
+ const_length = ASIZE (vector);
+#endif
if (STRING_MULTIBYTE (bytestr))
/* BYTESTR must have been produced by Emacs 20.2 or the earlier
stack.byte_string = bytestr;
stack.pc = stack.byte_string_start = SDATA (bytestr);
stack.constants = vector;
+ if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) < XFASTINT (maxdepth))
+ memory_full (SIZE_MAX);
top = (Lisp_Object *) alloca (XFASTINT (maxdepth)
* sizeof (Lisp_Object));
#if BYTE_MAINTAIN_TOP
if (INTEGERP (args_template))
{
- int at = XINT (args_template);
+ ptrdiff_t at = XINT (args_template);
int rest = at & 128;
int mandatory = at & 127;
- int nonrest = at >> 8;
+ ptrdiff_t nonrest = at >> 8;
eassert (mandatory <= nonrest);
if (nargs <= nonrest)
{
- int i;
+ ptrdiff_t i;
for (i = 0 ; i < nargs; i++, args++)
PUSH (*args);
if (nargs < mandatory)
}
else if (rest)
{
- int i;
+ ptrdiff_t i;
for (i = 0 ; i < nonrest; i++, args++)
PUSH (*args);
PUSH (Flist (nargs - nonrest, args));
save_restriction_save ());
break;
- case Bcatch: /* FIXME: ill-suited for lexbind */
+ case Bcatch: /* FIXME: ill-suited for lexbind. */
{
Lisp_Object v1;
BEFORE_POTENTIAL_GC ();
break;
}
- case Bunwind_protect: /* FIXME: avoid closure for lexbind */
+ case Bunwind_protect: /* FIXME: avoid closure for lexbind. */
record_unwind_protect (Fprogn, POP);
break;
- case Bcondition_case: /* FIXME: ill-suited for lexbind */
+ case Bcondition_case: /* FIXME: ill-suited for lexbind. */
{
Lisp_Object handlers, body;
handlers = POP;
PUSH (*ptr);
break;
}
- /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
case Bstack_set:
+ /* stack-set-0 = discard; stack-set-1 = discard-1-preserve-tos. */
{
Lisp_Object *ptr = top - (FETCH);
*ptr = POP;
void
syms_of_bytecode (void)
{
- Qbytecode = intern_c_string ("byte-code");
- staticpro (&Qbytecode);
+ DEFSYM (Qbytecode, "byte-code");
defsubr (&Sbyte_code);
byte_metering_on = 0;
Vbyte_code_meter = Fmake_vector (make_number (256), make_number (0));
- Qbyte_code_meter = intern_c_string ("byte-code-meter");
- staticpro (&Qbyte_code_meter);
+ DEFSYM (Qbyte_code_meter, "byte-code-meter");
{
int i = 256;
while (i--)