From 37a3ca330fca12a9f939f923c5d590410e5d9f11 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 15 Mar 2010 23:29:10 +0100 Subject: [PATCH] Reorder various structs to reduce padding (thanks to /usr/bin/pahole). --- src/lj_asm.c | 6 +++--- src/lj_gc.c | 8 ++++---- src/lj_jit.h | 6 +++--- src/lj_lex.h | 4 ++-- src/lj_obj.h | 2 +- src/lj_state.c | 2 +- src/luajit.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lj_asm.c b/src/lj_asm.c index 9e8f1fc0..81589cf9 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -60,9 +60,6 @@ typedef struct ASMState { SnapNo snapno; /* Current snapshot number. */ SnapNo loopsnapno; /* Loop snapshot number. */ - Trace *T; /* Trace to assemble. */ - Trace *parent; /* Parent trace (or NULL). */ - IRRef fuseref; /* Fusion limit (loopref, 0 or FUSE_DISABLED). */ IRRef sectref; /* Section base reference (loopref or 0). */ IRRef loopref; /* Reference of LOOP instruction (or 0). */ @@ -70,6 +67,9 @@ typedef struct ASMState { BCReg topslot; /* Number of slots for stack check (unless 0). */ MSize gcsteps; /* Accumulated number of GC steps (per section). */ + Trace *T; /* Trace to assemble. */ + Trace *parent; /* Parent trace (or NULL). */ + MCode *mcbot; /* Bottom of reserved MCode. */ MCode *mctop; /* Top of generated MCode. */ MCode *mcloop; /* Pointer to loop MCode (or NULL). */ diff --git a/src/lj_gc.c b/src/lj_gc.c index 276cd4da..d38238dd 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c @@ -540,7 +540,7 @@ static void atomic(global_State *g, lua_State *L) /* Prepare for sweep phase. */ g->gc.currentwhite = cast_byte(otherwhite(g)); /* Flip current white. */ g->gc.sweepstr = 0; - g->gc.sweep = &g->gc.root; + setmref(g->gc.sweep, &g->gc.root); g->gc.state = GCSsweepstring; g->gc.estimate = g->gc.total - (MSize)udsize; /* Initial estimate. */ } @@ -569,8 +569,8 @@ static size_t gc_onestep(lua_State *L) } case GCSsweep: { MSize old = g->gc.total; - g->gc.sweep = gc_sweep(g, g->gc.sweep, GCSWEEPMAX); /* Partial sweep. */ - if (gcref(*g->gc.sweep) == NULL) { + setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); + if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { gc_shrink(g, L); g->gc.state = GCSfinalize; /* End of sweep phase. */ } @@ -649,7 +649,7 @@ void lj_gc_fullgc(lua_State *L) setvmstate(g, GC); if (g->gc.state <= GCSpropagate) { /* Caught somewhere in the middle. */ g->gc.sweepstr = 0; - g->gc.sweep = &g->gc.root; /* Sweep everything (preserving it). */ + setmref(g->gc.sweep, &g->gc.root); /* Sweep everything (preserving it). */ setgcrefnull(g->gc.gray); /* Reset lists from partial propagation. */ setgcrefnull(g->gc.grayagain); setgcrefnull(g->gc.weak); diff --git a/src/lj_jit.h b/src/lj_jit.h index 76d7942b..7850878d 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h @@ -304,14 +304,14 @@ typedef struct jit_State { BCIns *patchpc; /* PC for pending re-patch. */ BCIns patchins; /* Instruction for pending re-patch. */ - TValue errinfo; /* Additional info element for trace errors. */ - + int mcprot; /* Protection of current mcode area. */ MCode *mcarea; /* Base of current mcode area. */ MCode *mctop; /* Top of current mcode area. */ MCode *mcbot; /* Bottom of current mcode area. */ size_t szmcarea; /* Size of current mcode area. */ size_t szallmcarea; /* Total size of all allocated mcode areas. */ - int mcprot; /* Protection of current mcode area. */ + + TValue errinfo; /* Additional info element for trace errors. */ } jit_State; /* Trivial PRNG e.g. used for penalty randomization. */ diff --git a/src/lj_lex.h b/src/lj_lex.h index 9bcd3cdb..0718f5a6 100644 --- a/src/lj_lex.h +++ b/src/lj_lex.h @@ -47,9 +47,9 @@ typedef struct LexState { int current; /* Current character (charint). */ LexToken token; /* Current token. */ LexToken lookahead; /* Lookahead token. */ - SBuf sb; /* String buffer for tokens. */ - const char *p; /* Current position in input buffer. */ MSize n; /* Bytes left in input buffer. */ + const char *p; /* Current position in input buffer. */ + SBuf sb; /* String buffer for tokens. */ lua_Reader rfunc; /* Reader callback. */ void *rdata; /* Reader callback data. */ BCLine linenumber; /* Input line counter. */ diff --git a/src/lj_obj.h b/src/lj_obj.h index d463cb2c..a37c0882 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h @@ -532,7 +532,7 @@ typedef struct GCState { uint8_t unused2; MSize sweepstr; /* Sweep position in string table. */ GCRef root; /* List of all collectable objects. */ - GCRef *sweep; /* Sweep position in root list. */ + MRef sweep; /* Sweep position in root list. */ GCRef gray; /* List of gray objects. */ GCRef grayagain; /* List of objects for atomic traversal. */ GCRef weak; /* List of weak tables (to be cleared). */ diff --git a/src/lj_state.c b/src/lj_state.c index 2164b900..1e490b28 100644 --- a/src/lj_state.c +++ b/src/lj_state.c @@ -203,7 +203,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) lj_str_initbuf(L, &g->tmpbuf); g->gc.state = GCSpause; setgcref(g->gc.root, obj2gco(L)); - g->gc.sweep = &g->gc.root; + setmref(g->gc.sweep, &g->gc.root); g->gc.total = sizeof(GG_State); g->gc.pause = LUAI_GCPAUSE; g->gc.stepmul = LUAI_GCMUL; diff --git a/src/luajit.c b/src/luajit.c index a6cc7ce3..cc2bf710 100644 --- a/src/luajit.c +++ b/src/luajit.c @@ -454,8 +454,8 @@ static int handle_luainit(lua_State *L) } struct Smain { - int argc; char **argv; + int argc; int status; };