Commit 38efa482 authored by Robert Foss's avatar Robert Foss
Browse files

Merge remote-tracking branch 'upstream/dev' into dev

parents d2fc8782 340edbbe
...@@ -13,7 +13,19 @@ ...@@ -13,7 +13,19 @@
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) #ifdef LUA_OPTIMIZE_DEBUG
# include "lvm.h"
# define getline(f,pc) (((f)->packedlineinfo) ? luaG_getline((f), pc) : 0)
# define INFO_FILL_BYTE 0x7F
# define INFO_DELTA_MASK 0x80
# define INFO_SIGN_MASK 0x40
# define INFO_DELTA_6BITS 0x3F
# define INFO_DELTA_7BITS 0x7F
# define INFO_MAX_LINECNT 126
# define lineInfoTop(fs) ((fs)->f->packedlineinfo + (fs)->lastlineOffset)
#else
# define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
#endif
#define resethookcount(L) (L->hookcount = L->basehookcount) #define resethookcount(L) (L->hookcount = L->basehookcount)
...@@ -29,5 +41,9 @@ LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); ...@@ -29,5 +41,9 @@ LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC void luaG_errormsg (lua_State *L); LUAI_FUNC void luaG_errormsg (lua_State *L);
LUAI_FUNC int luaG_checkcode (const Proto *pt); LUAI_FUNC int luaG_checkcode (const Proto *pt);
LUAI_FUNC int luaG_checkopenop (Instruction i); LUAI_FUNC int luaG_checkopenop (Instruction i);
#ifdef LUA_OPTIMIZE_DEBUG
LUAI_FUNC int luaG_getline (const Proto *f, int pc);
LUAI_FUNC int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv);
#endif
#endif #endif
...@@ -4,15 +4,14 @@ ...@@ -4,15 +4,14 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include <setjmp.h> #include <setjmp.h>
#include "c_stdlib.h"
#include "c_string.h"
#define ldo_c #define ldo_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "ldebug.h" #include "ldebug.h"
#include "ldo.h" #include "ldo.h"
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_stddef.h"
#include "c_string.h"
#define ldump_c #define ldump_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lobject.h" #include "lobject.h"
#include "lstate.h" #include "lstate.h"
...@@ -73,18 +72,18 @@ static void DumpIntWithSize(int x, int sizeof_int, DumpState* D) ...@@ -73,18 +72,18 @@ static void DumpIntWithSize(int x, int sizeof_int, DumpState* D)
/* dump signed integer */ /* dump signed integer */
switch(sizeof_int) { switch(sizeof_int) {
case 1: { case 1: {
if (x>0x7F || x<(-0x80)) D->status=LUA_ERR_CC_INTOVERFLOW; if (x>0x7F || x<(-0x80)) D->status=LUA_ERR_CC_INTOVERFLOW;
DumpChar(x,D); DumpChar(x,D);
} break; } break;
case 2: { case 2: {
if (x>0x7FFF || x<(-0x8000)) D->status=LUA_ERR_CC_INTOVERFLOW; if (x>0x7FFF || x<(-0x8000)) D->status=LUA_ERR_CC_INTOVERFLOW;
int16_t y=(int16_t)x; int16_t y=(int16_t)x;
MaybeByteSwap((char*)&y,2,D); MaybeByteSwap((char*)&y,2,D);
DumpVar(y,D); DumpVar(y,D);
} break; } break;
case 4: { case 4: {
/* Need to reduce bounds by 1 to avoid messing 32-bit compilers up */ /* Need to reduce bounds by 1 to avoid messing 32-bit compilers up */
if (x>0x7FFFFFFE || x<(-0x7FFFFFFF)) D->status=LUA_ERR_CC_INTOVERFLOW; if (x>0x7FFFFFFE || x<(-0x7FFFFFFF)) D->status=LUA_ERR_CC_INTOVERFLOW;
int32_t y=(int32_t)x; int32_t y=(int32_t)x;
MaybeByteSwap((char*)&y,4,D); MaybeByteSwap((char*)&y,4,D);
DumpVar(y,D); DumpVar(y,D);
...@@ -103,7 +102,7 @@ static void DumpSize(uint32_t x, DumpState* D) ...@@ -103,7 +102,7 @@ static void DumpSize(uint32_t x, DumpState* D)
/* dump unsigned integer */ /* dump unsigned integer */
switch(D->target.sizeof_strsize_t) { switch(D->target.sizeof_strsize_t) {
case 1: { case 1: {
if (x>0xFF) D->status=LUA_ERR_CC_INTOVERFLOW; if (x>0xFF) D->status=LUA_ERR_CC_INTOVERFLOW;
DumpChar(x,D); DumpChar(x,D);
} break; } break;
case 2: { case 2: {
...@@ -145,8 +144,8 @@ static void DumpNumber(lua_Number x, DumpState* D) ...@@ -145,8 +144,8 @@ static void DumpNumber(lua_Number x, DumpState* D)
} break; } break;
case 8: { case 8: {
double y=x; double y=x;
// ARM FPA mode: keep endianness, but swap high and low parts of the // ARM FPA mode: keep endianness, but swap high and low parts of the
// memory representation. This is the default compilation mode for ARM // memory representation. This is the default compilation mode for ARM
// targets with non-EABI gcc // targets with non-EABI gcc
if(D->target.is_arm_fpa) if(D->target.is_arm_fpa)
{ {
...@@ -154,7 +153,7 @@ static void DumpNumber(lua_Number x, DumpState* D) ...@@ -154,7 +153,7 @@ static void DumpNumber(lua_Number x, DumpState* D)
c_memcpy(temp,pnum,4); c_memcpy(temp,pnum,4);
c_memcpy(pnum,pnum+4,4); c_memcpy(pnum,pnum+4,4);
c_memcpy(pnum+4,temp,4); c_memcpy(pnum+4,temp,4);
} }
MaybeByteSwap((char*)&y,8,D); MaybeByteSwap((char*)&y,8,D);
DumpVar(y,D); DumpVar(y,D);
} break; } break;
...@@ -229,6 +228,16 @@ static void DumpConstants(const Proto* f, DumpState* D) ...@@ -229,6 +228,16 @@ static void DumpConstants(const Proto* f, DumpState* D)
static void DumpDebug(const Proto* f, DumpState* D) static void DumpDebug(const Proto* f, DumpState* D)
{ {
int i,n; int i,n;
#ifdef LUA_OPTIMIZE_DEBUG
n = (D->strip || f->packedlineinfo == NULL) ? 0: c_strlen(cast(char *,f->packedlineinfo))+1;
DumpInt(n,D);
Align4(D);
if (n)
{
DumpBlock(f->packedlineinfo, n, D);
}
#else
n= (D->strip) ? 0 : f->sizelineinfo; n= (D->strip) ? 0 : f->sizelineinfo;
DumpInt(n,D); DumpInt(n,D);
Align4(D); Align4(D);
...@@ -236,7 +245,8 @@ static void DumpDebug(const Proto* f, DumpState* D) ...@@ -236,7 +245,8 @@ static void DumpDebug(const Proto* f, DumpState* D)
{ {
DumpInt(f->lineinfo[i],D); DumpInt(f->lineinfo[i],D);
} }
#endif
n= (D->strip) ? 0 : f->sizelocvars; n= (D->strip) ? 0 : f->sizelocvars;
DumpInt(n,D); DumpInt(n,D);
for (i=0; i<n; i++) for (i=0; i<n; i++)
...@@ -269,7 +279,7 @@ static void DumpHeader(DumpState* D) ...@@ -269,7 +279,7 @@ static void DumpHeader(DumpState* D)
{ {
char buf[LUAC_HEADERSIZE]; char buf[LUAC_HEADERSIZE];
char *h=buf; char *h=buf;
/* This code must be kept in sync wiht luaU_header */ /* This code must be kept in sync wiht luaU_header */
c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
h+=sizeof(LUA_SIGNATURE)-1; h+=sizeof(LUA_SIGNATURE)-1;
...@@ -281,7 +291,7 @@ static void DumpHeader(DumpState* D) ...@@ -281,7 +291,7 @@ static void DumpHeader(DumpState* D)
*h++=(char)sizeof(Instruction); *h++=(char)sizeof(Instruction);
*h++=(char)D->target.sizeof_lua_Number; *h++=(char)D->target.sizeof_lua_Number;
*h++=(char)D->target.lua_Number_integral; *h++=(char)D->target.lua_Number_integral;
DumpBlock(buf,LUAC_HEADERSIZE,D); DumpBlock(buf,LUAC_HEADERSIZE,D);
} }
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_stddef.h"
#define lfunc_c #define lfunc_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lfunc.h" #include "lfunc.h"
#include "lgc.h" #include "lgc.h"
...@@ -121,14 +120,18 @@ Proto *luaF_newproto (lua_State *L) { ...@@ -121,14 +120,18 @@ Proto *luaF_newproto (lua_State *L) {
f->sizep = 0; f->sizep = 0;
f->code = NULL; f->code = NULL;
f->sizecode = 0; f->sizecode = 0;
f->sizelineinfo = 0;
f->sizeupvalues = 0; f->sizeupvalues = 0;
f->nups = 0; f->nups = 0;
f->upvalues = NULL; f->upvalues = NULL;
f->numparams = 0; f->numparams = 0;
f->is_vararg = 0; f->is_vararg = 0;
f->maxstacksize = 0; f->maxstacksize = 0;
#ifdef LUA_OPTIMIZE_DEBUG
f->packedlineinfo = NULL;
#else
f->sizelineinfo = 0;
f->lineinfo = NULL; f->lineinfo = NULL;
#endif
f->sizelocvars = 0; f->sizelocvars = 0;
f->locvars = NULL; f->locvars = NULL;
f->linedefined = 0; f->linedefined = 0;
...@@ -145,7 +148,13 @@ void luaF_freeproto (lua_State *L, Proto *f) { ...@@ -145,7 +148,13 @@ void luaF_freeproto (lua_State *L, Proto *f) {
luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
if (!proto_is_readonly(f)) { if (!proto_is_readonly(f)) {
luaM_freearray(L, f->code, f->sizecode, Instruction); luaM_freearray(L, f->code, f->sizecode, Instruction);
#ifdef LUA_OPTIMIZE_DEBUG
if (f->packedlineinfo) {
luaM_freearray(L, f->packedlineinfo, c_strlen(cast(char *, f->packedlineinfo))+1, unsigned char);
}
#else
luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
#endif
} }
luaM_free(L, f); luaM_free(L, f);
} }
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_string.h"
#define lgc_c #define lgc_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "ldebug.h" #include "ldebug.h"
#include "ldo.h" #include "ldo.h"
...@@ -312,12 +312,19 @@ static l_mem propagatemark (global_State *g) { ...@@ -312,12 +312,19 @@ static l_mem propagatemark (global_State *g) {
Proto *p = gco2p(o); Proto *p = gco2p(o);
g->gray = p->gclist; g->gray = p->gclist;
traverseproto(g, p); traverseproto(g, p);
return sizeof(Proto) + sizeof(Proto *) * p->sizep + return sizeof(Proto) + sizeof(Proto *) * p->sizep +
sizeof(TValue) * p->sizek + sizeof(TValue) * p->sizek +
sizeof(LocVar) * p->sizelocvars + sizeof(LocVar) * p->sizelocvars +
sizeof(TString *) * p->sizeupvalues + sizeof(TString *) * p->sizeupvalues +
(proto_is_readonly(p) ? 0 : sizeof(Instruction) * p->sizecode + (proto_is_readonly(p) ? 0 : sizeof(Instruction) * p->sizecode +
#ifdef LUA_OPTIMIZE_DEBUG
(p->packedlineinfo ?
c_strlen(cast(char *, p->packedlineinfo))+1 :
0));
#else
sizeof(int) * p->sizelineinfo); sizeof(int) * p->sizelineinfo);
#endif
} }
default: lua_assert(0); return 0; default: lua_assert(0); return 0;
} }
...@@ -729,7 +736,7 @@ void luaC_linkupval (lua_State *L, UpVal *uv) { ...@@ -729,7 +736,7 @@ void luaC_linkupval (lua_State *L, UpVal *uv) {
GCObject *o = obj2gco(uv); GCObject *o = obj2gco(uv);
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
g->rootgc = o; g->rootgc = o;
if (isgray(o)) { if (isgray(o)) {
if (g->gcstate == GCSpropagate) { if (g->gcstate == GCSpropagate) {
gray2black(o); /* closed upvalues need barrier */ gray2black(o); /* closed upvalues need barrier */
luaC_barrier(L, uv, uv->v); luaC_barrier(L, uv, uv->v);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment