summaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 6f945723d38..08a02ea921d 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -35,8 +35,8 @@ by Hallvard:
#include <config.h>
#include <setjmp.h>
#include "lisp.h"
-#include "buffer.h"
#include "character.h"
+#include "buffer.h"
#include "syntax.h"
#include "window.h"
@@ -58,21 +58,21 @@ by Hallvard:
#ifdef BYTE_CODE_METER
Lisp_Object Qbyte_code_meter;
-#define METER_2(code1, code2) \
- XFASTINT (XVECTOR (XVECTOR (Vbyte_code_meter)->contents[(code1)]) \
- ->contents[(code2)])
-
-#define METER_1(code) METER_2 (0, (code))
+#define METER_2(code1, code2) AREF (AREF (Vbyte_code_meter, code1), code2)
+#define METER_1(code) METER_2 (0, code)
#define METER_CODE(last_code, this_code) \
{ \
if (byte_metering_on) \
{ \
- if (METER_1 (this_code) < MOST_POSITIVE_FIXNUM) \
- METER_1 (this_code)++; \
+ if (XFASTINT (METER_1 (this_code)) < MOST_POSITIVE_FIXNUM) \
+ XSETFASTINT (METER_1 (this_code), \
+ XFASTINT (METER_1 (this_code)) + 1); \
if (last_code \
- && METER_2 (last_code, this_code) < MOST_POSITIVE_FIXNUM) \
- METER_2 (last_code, this_code)++; \
+ && (XFASTINT (METER_2 (last_code, this_code)) \
+ < MOST_POSITIVE_FIXNUM)) \
+ XSETFASTINT (METER_2 (last_code, this_code), \
+ XFASTINT (METER_2 (last_code, this_code)) + 1); \
} \
}
@@ -318,7 +318,7 @@ unmark_byte_stack (void)
{
if (stack->byte_string_start != SDATA (stack->byte_string))
{
- int offset = stack->pc - stack->byte_string_start;
+ ptrdiff_t offset = stack->pc - stack->byte_string_start;
stack->byte_string_start = SDATA (stack->byte_string);
stack->pc = stack->byte_string_start + offset;
}
@@ -435,7 +435,7 @@ Lisp_Object
exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
{
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
#ifdef BYTE_CODE_METER
int this_op = 0;
int prev_op;
@@ -446,7 +446,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
#ifdef BYTE_CODE_SAFE
ptrdiff_t const_length;
Lisp_Object *stacke;
- int bytestr_length;
+ ptrdiff_t bytestr_length;
#endif
struct byte_stack stack;
Lisp_Object *top;
@@ -486,15 +486,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
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))
+ if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth))
memory_full (SIZE_MAX);
- top = (Lisp_Object *) alloca (XFASTINT (maxdepth)
+ top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1)
* sizeof (Lisp_Object));
#if BYTE_MAINTAIN_TOP
- stack.bottom = top;
+ stack.bottom = top + 1;
stack.top = NULL;
#endif
- top -= 1;
stack.next = byte_stack_list;
byte_stack_list = &stack;
@@ -943,7 +942,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
case Bsave_window_excursion: /* Obsolete since 24.1. */
{
- register int count1 = SPECPDL_INDEX ();
+ register ptrdiff_t count1 = SPECPDL_INDEX ();
record_unwind_protect (Fset_window_configuration,
Fcurrent_window_configuration (Qnil));
BEFORE_POTENTIAL_GC ();
@@ -1007,13 +1006,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
case Bnth:
{
Lisp_Object v1, v2;
+ EMACS_INT n;
BEFORE_POTENTIAL_GC ();
v1 = POP;
v2 = TOP;
CHECK_NUMBER (v2);
- op = XINT (v2);
+ n = XINT (v2);
immediate_quit = 1;
- while (--op >= 0 && CONSP (v1))
+ while (--n >= 0 && CONSP (v1))
v1 = XCDR (v1);
immediate_quit = 0;
TOP = CAR (v1);
@@ -1640,14 +1640,15 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
if (CONSP (TOP))
{
/* Exchange args and then do nth. */
+ EMACS_INT n;
BEFORE_POTENTIAL_GC ();
v2 = POP;
v1 = TOP;
CHECK_NUMBER (v2);
AFTER_POTENTIAL_GC ();
- op = XINT (v2);
+ n = XINT (v2);
immediate_quit = 1;
- while (--op >= 0 && CONSP (v1))
+ while (--n >= 0 && CONSP (v1))
v1 = XCDR (v1);
immediate_quit = 0;
TOP = CAR (v1);
@@ -1866,8 +1867,8 @@ integer, it is incremented each time that symbol's function is called. */);
{
int i = 256;
while (i--)
- XVECTOR (Vbyte_code_meter)->contents[i] =
- Fmake_vector (make_number (256), make_number (0));
+ ASET (Vbyte_code_meter, i,
+ Fmake_vector (make_number (256), make_number (0)));
}
#endif
}