aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-24 14:55:51 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-24 14:55:51 -0300
commit9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b (patch)
tree18a4b30df4e0518580cd6dc7a370892f5f608021
parent082aded149762ec21a7fa58ef0cc8f9a61038ca7 (diff)
downloadlua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.tar.gz
lua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.tar.bz2
lua-9d7bae0b6ab66e7e0cff8871e65ecddb55513d6b.zip
better instrumentation for internal debugging
-rw-r--r--lmem.c19
-rw-r--r--lopcodes.h6
-rw-r--r--lparser.c6
-rw-r--r--lvm.c6
4 files changed, 29 insertions, 8 deletions
diff --git a/lmem.c b/lmem.c
index ccf1a4a8..a1379f24 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.8 1999/01/22 17:28:00 roberto Exp roberto $ 2** $Id: lmem.c,v 1.9 1999/01/22 18:08:57 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -24,6 +24,8 @@
24 24
25 25
26 26
27#ifndef DEBUG
28
27int luaM_growaux (void **block, unsigned long nelems, int size, 29int luaM_growaux (void **block, unsigned long nelems, int size,
28 char *errormsg, unsigned long limit) { 30 char *errormsg, unsigned long limit) {
29 if (nelems >= limit) 31 if (nelems >= limit)
@@ -36,9 +38,6 @@ int luaM_growaux (void **block, unsigned long nelems, int size,
36} 38}
37 39
38 40
39
40#ifndef DEBUG
41
42/* 41/*
43** generic allocation routine. 42** generic allocation routine.
44*/ 43*/
@@ -64,6 +63,18 @@ void *luaM_realloc (void *block, unsigned long size) {
64#include <string.h> 63#include <string.h>
65 64
66 65
66int luaM_growaux (void **block, unsigned long nelems, int size,
67 char *errormsg, unsigned long limit) {
68 if (nelems >= limit)
69 lua_error(errormsg);
70 nelems = nelems+1;
71 if (nelems > limit)
72 nelems = limit;
73 *block = luaM_realloc(*block, nelems*size);
74 return (int)nelems;
75}
76
77
67#define HEADER (sizeof(double)) 78#define HEADER (sizeof(double))
68 79
69#define MARK 55 80#define MARK 55
diff --git a/lopcodes.h b/lopcodes.h
index 886d31d1..f1d6a2e1 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.25 1999/02/09 18:01:55 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.26 1999/02/23 13:38:38 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -107,7 +107,9 @@ SETLINEW,/* w - - LINE=w */
107SETLINE,/* b - - LINE=b */ 107SETLINE,/* b - - LINE=b */
108 108
109LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */ 109LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */
110LONGARG /* b (add b*(1<<16) to arg of next instruction) */ 110LONGARG,/* b (add b*(1<<16) to arg of next instruction) */
111
112CHECKSTACK /* b (assert #temporaries == b; only for internal debuging!) */
111 113
112} OpCode; 114} OpCode;
113 115
diff --git a/lparser.c b/lparser.c
index 2bd65ee3..03e05102 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.20 1999/02/09 18:01:55 roberto Exp roberto $ 2** $Id: lparser.c,v 1.21 1999/02/24 15:37:19 roberto Exp roberto $
3** LL(1) Parser and code generator for Lua 3** LL(1) Parser and code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -403,6 +403,10 @@ static void close_exp (LexState *ls, int pc, int nresults) {
403 deltastack(ls, nresults); /* push results */ 403 deltastack(ls, nresults); /* push results */
404 deltastack(ls, -(code[pc]+1)); /* pop params (at code[pc]) and function */ 404 deltastack(ls, -(code[pc]+1)); /* pop params (at code[pc]) and function */
405 } 405 }
406#ifdef DEBUG
407 if (nresults != MULT_RET)
408 code_oparg(ls, CHECKSTACK, ls->fs->stacksize, 0);
409#endif
406} 410}
407 411
408 412
diff --git a/lvm.c b/lvm.c
index 5eee2799..fb8e87bc 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.49 1999/02/09 18:01:55 roberto Exp roberto $ 2** $Id: lvm.c,v 1.50 1999/02/23 13:38:38 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -643,6 +643,10 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
643 aux = highbyte(highbyte(aux)); 643 aux = highbyte(highbyte(aux));
644 goto switchentry; /* do not reset "aux" */ 644 goto switchentry; /* do not reset "aux" */
645 645
646 case CHECKSTACK: aux = *pc++;
647 LUA_ASSERT((S->top-S->stack)-base == aux, "wrong stack size");
648 break;
649
646 } 650 }
647 } 651 }
648} 652}