mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 562991 - Change JS_SetTrap closure argument type from void* to jsval (r=brendan)
This commit is contained in:
parent
f574b6dcec
commit
ba4adc8ba7
@ -715,9 +715,9 @@ _isActiveHook(JSDContext* jsdc, JSScript *script, JSDExecHook* jsdhook)
|
||||
|
||||
JSTrapStatus
|
||||
jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
jsval closure)
|
||||
{
|
||||
JSDExecHook* jsdhook = (JSDExecHook*) JSVAL_TO_PRIVATE(((jsval)closure));
|
||||
JSDExecHook* jsdhook = (JSDExecHook*) JSVAL_TO_PRIVATE(closure);
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
JSDContext* jsdc;
|
||||
@ -799,8 +799,8 @@ jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
jsdhook->callerdata = callerdata;
|
||||
|
||||
if( ! JS_SetTrap(jsdc->dumbContext, jsdscript->script,
|
||||
(jsbytecode*)pc, jsd_TrapHandler,
|
||||
(void*) PRIVATE_TO_JSVAL(jsdhook)) )
|
||||
(jsbytecode*)pc, jsd_TrapHandler,
|
||||
PRIVATE_TO_JSVAL(jsdhook)) )
|
||||
{
|
||||
free(jsdhook);
|
||||
JSD_UNLOCK();
|
||||
|
@ -5,10 +5,11 @@ static int emptyTrapCallCount = 0;
|
||||
|
||||
static JSTrapStatus
|
||||
EmptyTrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
jsval closure)
|
||||
{
|
||||
JS_GC(cx);
|
||||
++emptyTrapCallCount;
|
||||
if (JSVAL_IS_STRING(closure))
|
||||
++emptyTrapCallCount;
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
@ -49,8 +50,8 @@ BEGIN_TEST(testTrap_gc)
|
||||
static const char trapClosureText[] = "some trap closure";
|
||||
JSString *trapClosure = JS_NewStringCopyZ(cx, trapClosureText);
|
||||
CHECK(trapClosure);
|
||||
JS_SetTrap(cx, script, line2, EmptyTrapHandler, trapClosure);
|
||||
JS_SetTrap(cx, script, line6, EmptyTrapHandler, trapClosure);
|
||||
JS_SetTrap(cx, script, line2, EmptyTrapHandler, STRING_TO_JSVAL(trapClosure));
|
||||
JS_SetTrap(cx, script, line6, EmptyTrapHandler, STRING_TO_JSVAL(trapClosure));
|
||||
|
||||
JS_GC(cx);
|
||||
|
||||
|
@ -865,7 +865,7 @@ struct JSRuntime {
|
||||
#ifdef JS_TRACER
|
||||
/* True if any debug hooks not supported by the JIT are enabled. */
|
||||
bool debuggerInhibitsJIT() const {
|
||||
return (globalDebugHooks.interruptHandler ||
|
||||
return (globalDebugHooks.interruptHook ||
|
||||
globalDebugHooks.callHook ||
|
||||
globalDebugHooks.objectHook);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ typedef struct JSTrap {
|
||||
jsbytecode *pc;
|
||||
JSOp op;
|
||||
JSTrapHandler handler;
|
||||
void *closure;
|
||||
jsval closure;
|
||||
} JSTrap;
|
||||
|
||||
#define DBG_LOCK(rt) JS_ACQUIRE_LOCK((rt)->debuggerLock)
|
||||
@ -142,7 +142,7 @@ js_UntrapScriptCode(JSContext *cx, JSScript *script)
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
JSTrapHandler handler, void *closure)
|
||||
JSTrapHandler handler, jsval closure)
|
||||
{
|
||||
JSTrap *junk, *trap, *twin;
|
||||
JSRuntime *rt;
|
||||
@ -168,7 +168,7 @@ JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
trap = (JSTrap *) cx->malloc(sizeof *trap);
|
||||
if (!trap)
|
||||
return JS_FALSE;
|
||||
trap->closure = NULL;
|
||||
trap->closure = JSVAL_NULL;
|
||||
DBG_LOCK(rt);
|
||||
twin = (rt->debuggerMutations != sample)
|
||||
? FindTrap(rt, script, pc)
|
||||
@ -220,7 +220,7 @@ DestroyTrapAndUnlock(JSContext *cx, JSTrap *trap)
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
JSTrapHandler *handlerp, void **closurep)
|
||||
JSTrapHandler *handlerp, jsval *closurep)
|
||||
{
|
||||
JSTrap *trap;
|
||||
|
||||
@ -229,7 +229,7 @@ JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
if (handlerp)
|
||||
*handlerp = trap ? trap->handler : NULL;
|
||||
if (closurep)
|
||||
*closurep = trap ? trap->closure : NULL;
|
||||
*closurep = trap ? trap->closure : JSVAL_NULL;
|
||||
if (trap)
|
||||
DestroyTrapAndUnlock(cx, trap);
|
||||
else
|
||||
@ -295,10 +295,8 @@ js_MarkTraps(JSTracer *trc)
|
||||
for (JSTrap *trap = (JSTrap *) rt->trapList.next;
|
||||
&trap->links != &rt->trapList;
|
||||
trap = (JSTrap *) trap->links.next) {
|
||||
if (trap->closure) {
|
||||
JS_SET_TRACING_NAME(trc, "trap->closure");
|
||||
js_CallValueTracerIfGCThing(trc, (jsval) trap->closure);
|
||||
}
|
||||
JS_SET_TRACING_NAME(trc, "trap->closure");
|
||||
js_CallValueTracerIfGCThing(trc, trap->closure);
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,15 +373,15 @@ LeaveTraceRT(JSRuntime *rt)
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure)
|
||||
JS_SetInterrupt(JSRuntime *rt, JSInterruptHook hook, void *closure)
|
||||
{
|
||||
#ifdef JS_TRACER
|
||||
{
|
||||
AutoLockGC lock(rt);
|
||||
bool wasInhibited = rt->debuggerInhibitsJIT();
|
||||
#endif
|
||||
rt->globalDebugHooks.interruptHandler = handler;
|
||||
rt->globalDebugHooks.interruptHandlerData = closure;
|
||||
rt->globalDebugHooks.interruptHook = hook;
|
||||
rt->globalDebugHooks.interruptHookData = closure;
|
||||
#ifdef JS_TRACER
|
||||
JITInhibitingHookChange(rt, wasInhibited);
|
||||
}
|
||||
@ -393,18 +391,18 @@ JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep)
|
||||
JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *hoop, void **closurep)
|
||||
{
|
||||
#ifdef JS_TRACER
|
||||
AutoLockGC lock(rt);
|
||||
bool wasInhibited = rt->debuggerInhibitsJIT();
|
||||
#endif
|
||||
if (handlerp)
|
||||
*handlerp = rt->globalDebugHooks.interruptHandler;
|
||||
if (hoop)
|
||||
*hoop = rt->globalDebugHooks.interruptHook;
|
||||
if (closurep)
|
||||
*closurep = rt->globalDebugHooks.interruptHandlerData;
|
||||
rt->globalDebugHooks.interruptHandler = 0;
|
||||
rt->globalDebugHooks.interruptHandlerData = 0;
|
||||
*closurep = rt->globalDebugHooks.interruptHookData;
|
||||
rt->globalDebugHooks.interruptHook = 0;
|
||||
rt->globalDebugHooks.interruptHookData = 0;
|
||||
#ifdef JS_TRACER
|
||||
JITInhibitingHookChange(rt, wasInhibited);
|
||||
#endif
|
||||
@ -1561,7 +1559,7 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda)
|
||||
/************************************************************************/
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetDebuggerHandler(JSRuntime *rt, JSTrapHandler handler, void *closure)
|
||||
JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler handler, void *closure)
|
||||
{
|
||||
rt->globalDebugHooks.debuggerHandler = handler;
|
||||
rt->globalDebugHooks.debuggerHandlerData = closure;
|
||||
@ -1623,7 +1621,7 @@ JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSTrapHandler hook, void *closure)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure)
|
||||
{
|
||||
rt->globalDebugHooks.throwHook = hook;
|
||||
rt->globalDebugHooks.throwHookData = closure;
|
||||
|
@ -57,16 +57,17 @@ JS_BEGIN_EXTERN_C
|
||||
extern jsbytecode *
|
||||
js_UntrapScriptCode(JSContext *cx, JSScript *script);
|
||||
|
||||
/* The closure argument will be marked. */
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
JSTrapHandler handler, void *closure);
|
||||
JSTrapHandler handler, jsval closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSOp)
|
||||
JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
JSTrapHandler *handlerp, void **closurep);
|
||||
JSTrapHandler *handlerp, jsval *closurep);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearScriptTraps(JSContext *cx, JSScript *script);
|
||||
@ -78,10 +79,10 @@ extern JS_PUBLIC_API(JSTrapStatus)
|
||||
JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure);
|
||||
JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep);
|
||||
JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
@ -337,7 +338,7 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
|
||||
/************************************************************************/
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetDebuggerHandler(JSRuntime *rt, JSTrapHandler handler, void *closure);
|
||||
JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
|
||||
@ -352,7 +353,7 @@ extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSTrapHandler hook, void *closure);
|
||||
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
|
||||
|
@ -2519,7 +2519,7 @@ js_Interpret(JSContext *cx)
|
||||
|
||||
# define CHECK_INTERRUPT_HANDLER() \
|
||||
JS_BEGIN_MACRO \
|
||||
if (cx->debugHooks->interruptHandler) \
|
||||
if (cx->debugHooks->interruptHook) \
|
||||
ENABLE_INTERRUPTS(); \
|
||||
JS_END_MACRO
|
||||
|
||||
@ -2679,7 +2679,7 @@ js_Interpret(JSContext *cx)
|
||||
/* This is an error, not a catchable exception, quit the frame ASAP. */
|
||||
ok = JS_FALSE;
|
||||
} else {
|
||||
JSTrapHandler handler;
|
||||
JSThrowHook handler;
|
||||
JSTryNote *tn, *tnlimit;
|
||||
uint32 offset;
|
||||
|
||||
|
@ -48,14 +48,14 @@
|
||||
#endif /* !JS_THREADED_INTERP */
|
||||
{
|
||||
bool moreInterrupts = false;
|
||||
JSTrapHandler handler = cx->debugHooks->interruptHandler;
|
||||
if (handler) {
|
||||
JSInterruptHook hook = cx->debugHooks->interruptHook;
|
||||
if (hook) {
|
||||
#ifdef JS_TRACER
|
||||
if (TRACE_RECORDER(cx))
|
||||
AbortRecording(cx, "interrupt handler");
|
||||
AbortRecording(cx, "interrupt hook");
|
||||
#endif
|
||||
switch (handler(cx, script, regs.pc, &rval,
|
||||
cx->debugHooks->interruptHandlerData)) {
|
||||
switch (hook(cx, script, regs.pc, &rval,
|
||||
cx->debugHooks->interruptHookData)) {
|
||||
case JSTRAP_ERROR:
|
||||
goto error;
|
||||
case JSTRAP_CONTINUE:
|
||||
@ -3647,7 +3647,7 @@ END_CASE(JSOP_INSTANCEOF)
|
||||
#if JS_HAS_DEBUGGER_KEYWORD
|
||||
BEGIN_CASE(JSOP_DEBUGGER)
|
||||
{
|
||||
JSTrapHandler handler = cx->debugHooks->debuggerHandler;
|
||||
JSDebuggerHandler handler = cx->debugHooks->debuggerHandler;
|
||||
if (handler) {
|
||||
switch (handler(cx, script, regs.pc, &rval, cx->debugHooks->debuggerHandlerData)) {
|
||||
case JSTRAP_ERROR:
|
||||
|
@ -212,7 +212,19 @@ typedef enum JSTrapStatus {
|
||||
|
||||
typedef JSTrapStatus
|
||||
(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure);
|
||||
jsval closure);
|
||||
|
||||
typedef JSTrapStatus
|
||||
(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure);
|
||||
|
||||
typedef JSTrapStatus
|
||||
(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure);
|
||||
|
||||
typedef JSTrapStatus
|
||||
(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure);
|
||||
|
||||
typedef JSBool
|
||||
(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id, jsval old,
|
||||
@ -274,13 +286,13 @@ typedef JSBool
|
||||
void *closure);
|
||||
|
||||
typedef struct JSDebugHooks {
|
||||
JSTrapHandler interruptHandler;
|
||||
void *interruptHandlerData;
|
||||
JSInterruptHook interruptHook;
|
||||
void *interruptHookData;
|
||||
JSNewScriptHook newScriptHook;
|
||||
void *newScriptHookData;
|
||||
JSDestroyScriptHook destroyScriptHook;
|
||||
void *destroyScriptHookData;
|
||||
JSTrapHandler debuggerHandler;
|
||||
JSDebuggerHandler debuggerHandler;
|
||||
void *debuggerHandlerData;
|
||||
JSSourceHandler sourceHandler;
|
||||
void *sourceHandlerData;
|
||||
@ -290,7 +302,7 @@ typedef struct JSDebugHooks {
|
||||
void *callHookData;
|
||||
JSObjectHook objectHook;
|
||||
void *objectHookData;
|
||||
JSTrapHandler throwHook;
|
||||
JSThrowHook throwHook;
|
||||
void *throwHookData;
|
||||
JSDebugErrorHook debugErrorHook;
|
||||
void *debugErrorHookData;
|
||||
|
@ -1457,12 +1457,12 @@ GetTrapArgs(JSContext *cx, uintN argc, jsval *argv, JSScript **scriptp,
|
||||
|
||||
static JSTrapStatus
|
||||
TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
jsval closure)
|
||||
{
|
||||
JSString *str;
|
||||
JSStackFrame *caller;
|
||||
|
||||
str = (JSString *) closure;
|
||||
str = JSVAL_TO_STRING(closure);
|
||||
caller = JS_GetScriptedCaller(cx, NULL);
|
||||
if (!JS_EvaluateUCInStackFrame(cx, caller,
|
||||
JS_GetStringChars(str), JS_GetStringLength(str),
|
||||
@ -1493,7 +1493,7 @@ Trap(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
argv[argc] = STRING_TO_JSVAL(str);
|
||||
if (!GetTrapArgs(cx, argc, argv, &script, &i))
|
||||
return JS_FALSE;
|
||||
return JS_SetTrap(cx, script, script->code + i, TrapHandler, str);
|
||||
return JS_SetTrap(cx, script, script->code + i, TrapHandler, STRING_TO_JSVAL(str));
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
Loading…
Reference in New Issue
Block a user