Split up FORALL_SLOTS_IN_PENDING_FRAMES macro in a macro that processes a frame, and a macro that uses that macro to process all pending frames.

This commit is contained in:
Andreas Gal 2008-08-01 22:27:39 -07:00
parent d7a10439bc
commit 3fea3f5d53

View File

@ -406,7 +406,7 @@ public:
#define INC_VPNUM() ((void)0)
#endif
/* This macro can be used to iterate over all interned global variables. */
/* Iterate over all interned global variables. */
#define FORALL_GLOBAL_SLOTS(cx, ngslots, gslots, code) \
JS_BEGIN_MACRO \
DEF_VPNAME; \
@ -421,16 +421,35 @@ public:
} \
JS_END_MACRO
/*
* This macro can be used to iterate over all slots in currently pending
* frames that make up the native frame, consisting of args, vars, and stack
* (except for the top-level frame which does not have args or vars
*/
/* Iterate over all slots in the frame, consisting of args, vars, and stack
(except for the top-level frame which does not have args or vars. */
#define FORALL_FRAME_SLOTS(f, depth, code) \
JS_BEGIN_MACRO \
jsval* vp; \
jsval* vpstop; \
if (f->callee) { \
if (depth == 0) { \
SET_VPNAME("this"); \
vp = &f->argv[-1]; \
code; \
SET_VPNAME("argv"); \
vp = &f->argv[0]; vpstop = &f->argv[f->fun->nargs]; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
} \
SET_VPNAME("vars"); \
vp = f->slots; vpstop = &f->slots[f->script->nfixed]; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
} \
SET_VPNAME("stack"); \
vp = StackBase(f); vpstop = f->regs->sp; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
JS_END_MACRO
/* Iterate over all slots in each pending frame. */
#define FORALL_SLOTS_IN_PENDING_FRAMES(cx, callDepth, code) \
JS_BEGIN_MACRO \
DEF_VPNAME; \
unsigned n; \
jsval* vp; \
JSStackFrame* currentFrame = cx->fp; \
JSStackFrame* entryFrame; \
JSStackFrame* fp = currentFrame; \
@ -442,25 +461,10 @@ public:
JSStackFrame** fsp = fspstop-1; \
fp = currentFrame; \
for (;; fp = fp->down) { *fsp-- = fp; if (fp == entryFrame) break; } \
for (fsp = fstack; fsp < fspstop; ++fsp) { \
JSStackFrame* f = *fsp; \
jsval* vpstop; \
if (f->callee) { \
if (fsp == fstack) { \
SET_VPNAME("this"); \
vp = &f->argv[-1]; \
code; \
SET_VPNAME("argv"); \
vp = &f->argv[0]; vpstop = &f->argv[f->fun->nargs]; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
} \
SET_VPNAME("vars"); \
vp = f->slots; vpstop = &f->slots[f->script->nfixed]; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
} \
SET_VPNAME("stack"); \
vp = StackBase(f); vpstop = f->regs->sp; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
unsigned depth; \
for (depth = 0, fsp = fstack; fsp < fspstop; ++fsp, ++depth) { \
JSStackFrame* f = (*fsp); \
FORALL_FRAME_SLOTS(f, depth, code); \
} \
JS_END_MACRO