Bug 491988 - Annotation fixes required for analyzing JS_REQUIRES_STACK for function pointers, r=jorendorff

This commit is contained in:
Benjamin Smedberg 2009-06-25 15:12:19 -04:00
parent 579d4f6d24
commit 3d4a869324
5 changed files with 31 additions and 7 deletions

View File

@ -2022,6 +2022,15 @@ sort_compare(void *arg, const void *a, const void *b, int *result)
return JS_TRUE;
}
typedef JSBool (JS_REQUIRES_STACK *JSRedComparator)(void*, const void*,
const void*, int *);
static inline JS_IGNORE_STACK JSComparator
comparator_stack_cast(JSRedComparator func)
{
return func;
}
static int
sort_compare_strings(void *arg, const void *a, const void *b, int *result)
{
@ -2263,7 +2272,8 @@ array_sort(JSContext *cx, uintN argc, jsval *vp)
goto out;
}
ok = js_MergeSort(vec, (size_t) newlen, sizeof(jsval),
sort_compare, &ca, mergesort_tmp);
comparator_stack_cast(sort_compare),
&ca, mergesort_tmp);
js_FreeStack(cx, mark);
if (!ok)
goto out;

View File

@ -676,7 +676,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return JS_TRUE;
}
JS_REQUIRES_STACK JSBool
JSBool
js_watch_set_wrapper(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{

View File

@ -120,10 +120,10 @@ extern JSPropertyOp
js_GetWatchedSetter(JSRuntime *rt, JSScope *scope,
const JSScopeProperty *sprop);
extern JS_REQUIRES_STACK JSBool
extern JSBool
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
extern JS_REQUIRES_STACK JSBool
extern JSBool
js_watch_set_wrapper(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval);

View File

@ -1287,9 +1287,18 @@ typedef struct GlobData {
does not pass to caller */
#define GLOBAL_REGEXP 0x10 /* out: regexp had the 'g' flag */
typedef JSBool (*GlobFunc)(JSContext *cx, jsint count, GlobData *data);
typedef JSBool (JS_REQUIRES_STACK *RedGlobFunc)(JSContext *cx, jsint count, GlobData *data);
static inline JS_IGNORE_STACK GlobFunc
globfunc_stack_cast(RedGlobFunc f)
{
return f;
}
static JSBool
match_or_replace(JSContext *cx,
JSBool (*glob)(JSContext *cx, jsint count, GlobData *data),
GlobFunc glob,
void (*destroy)(JSContext *cx, GlobData *data),
GlobData *data, uintN argc, jsval *vp)
{
@ -1794,8 +1803,8 @@ js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,
rdata.index = 0;
rdata.leftIndex = 0;
ok = match_or_replace(cx, replace_glob, replace_destroy, &rdata.base,
argc, vp);
ok = match_or_replace(cx, globfunc_stack_cast(replace_glob),
replace_destroy, &rdata.base, argc, vp);
if (!ok)
return JS_FALSE;

View File

@ -198,9 +198,14 @@
*/
# define JS_REQUIRES_STACK __attribute__((user("JS_REQUIRES_STACK")))
# define JS_FORCES_STACK __attribute__((user("JS_FORCES_STACK")))
/*
* Skip the JS_REQUIRES_STACK analysis within functions with this annotation.
*/
# define JS_IGNORE_STACK __attribute__((user("JS_IGNORE_STACK")))
#else
# define JS_REQUIRES_STACK
# define JS_FORCES_STACK
# define JS_IGNORE_STACK
#endif
/***********************************************************************