Add an API to set aside and restore cx->fp. bug 377090, r=brendan

This commit is contained in:
mrbkap@gmail.com 2007-04-13 12:20:22 -07:00
Родитель f14430e628
Коммит 5817df1531
4 изменённых файлов: 48 добавлений и 1 удалений

Просмотреть файл

@ -4421,6 +4421,34 @@ JS_SetCallReturnValue2(JSContext *cx, jsval v)
#endif
}
JS_PUBLIC_API(JSStackFrame *)
JS_SaveFrameChain(JSContext *cx)
{
JSStackFrame *fp;
fp = cx->fp;
if (!fp)
return fp;
JS_ASSERT(!fp->dormantNext);
fp->dormantNext = cx->dormantFrameChain;
cx->dormantFrameChain = fp;
cx->fp = NULL;
return fp;
}
JS_PUBLIC_API(void)
JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp)
{
JS_ASSERT(!cx->fp);
if (!fp)
return;
cx->fp = fp;
cx->dormantFrameChain = fp->dormantNext;
fp->dormantNext = NULL;
}
/************************************************************************/
JS_PUBLIC_API(JSString *)

Просмотреть файл

@ -1848,6 +1848,25 @@ JS_IsAssigning(JSContext *cx);
extern JS_PUBLIC_API(void)
JS_SetCallReturnValue2(JSContext *cx, jsval v);
/*
* Saving and restoring frame chains.
*
* These two functions are used to set aside cx->fp while that frame is
* inactive. After a call to JS_SaveFrameChain, it looks as if there is no
* code running on cx. Before calling JS_RestoreFrameChain, cx's call stack
* must be balanced and all nested calls to JS_SaveFrameChain must have had
* matching JS_RestoreFrameChain calls.
*
* JS_SaveFrameChain deals with cx not having any code running on it. A null
* return does not signify an error and JS_RestoreFrameChain handles null
* frames.
*/
extern JS_PUBLIC_API(JSStackFrame *)
JS_SaveFrameChain(JSContext *cx);
extern JS_PUBLIC_API(void)
JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp);
/************************************************************************/
/*

Просмотреть файл

@ -116,7 +116,6 @@ typedef struct JSRegExpStatics JSRegExpStatics;
typedef struct JSScope JSScope;
typedef struct JSScopeOps JSScopeOps;
typedef struct JSScopeProperty JSScopeProperty;
typedef struct JSStackFrame JSStackFrame;
typedef struct JSStackHeader JSStackHeader;
typedef struct JSStringBuffer JSStringBuffer;
typedef struct JSSubString JSSubString;

Просмотреть файл

@ -140,6 +140,7 @@ typedef struct JSXMLObjectOps JSXMLObjectOps;
typedef struct JSRuntime JSRuntime;
typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
typedef struct JSScript JSScript;
typedef struct JSStackFrame JSStackFrame;
typedef struct JSString JSString;
typedef struct JSXDRState JSXDRState;
typedef struct JSExceptionState JSExceptionState;