mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix bug and modularity loss introduced by patch for 424405 (424614, r/a=shaver, bug a=beltzner).
This commit is contained in:
parent
cbe8463a59
commit
ac7abb892a
@ -45,6 +45,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "jstypes.h"
|
#include "jstypes.h"
|
||||||
#include "jsutil.h" /* Added by JSIFY */
|
#include "jsutil.h" /* Added by JSIFY */
|
||||||
|
#include "jsclist.h"
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jscntxt.h"
|
#include "jscntxt.h"
|
||||||
#include "jsconfig.h"
|
#include "jsconfig.h"
|
||||||
@ -61,9 +62,18 @@
|
|||||||
#include "jsscript.h"
|
#include "jsscript.h"
|
||||||
#include "jsstr.h"
|
#include "jsstr.h"
|
||||||
|
|
||||||
#ifdef MOZ_SHARK
|
typedef struct JSTrap {
|
||||||
#include <CHUD/CHUD.h>
|
JSCList links;
|
||||||
#endif
|
JSScript *script;
|
||||||
|
jsbytecode *pc;
|
||||||
|
JSOp op;
|
||||||
|
JSTrapHandler handler;
|
||||||
|
void *closure;
|
||||||
|
} JSTrap;
|
||||||
|
|
||||||
|
#define DBG_LOCK(rt) JS_ACQUIRE_LOCK((rt)->debuggerLock)
|
||||||
|
#define DBG_UNLOCK(rt) JS_RELEASE_LOCK((rt)->debuggerLock)
|
||||||
|
#define DBG_LOCK_EVAL(rt,expr) (DBG_LOCK(rt), (expr), DBG_UNLOCK(rt))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: FindTrap must be called with rt->debuggerLock acquired.
|
* NB: FindTrap must be called with rt->debuggerLock acquired.
|
||||||
@ -82,18 +92,32 @@ FindTrap(JSRuntime *rt, JSScript *script, jsbytecode *pc)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
jsbytecode *
|
||||||
js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op)
|
js_UntrapScriptCode(JSContext *cx, JSScript *script)
|
||||||
{
|
{
|
||||||
|
jsbytecode *code;
|
||||||
|
JSRuntime *rt;
|
||||||
JSTrap *trap;
|
JSTrap *trap;
|
||||||
|
|
||||||
DBG_LOCK(cx->runtime);
|
code = script->code;
|
||||||
trap = FindTrap(cx->runtime, script, pc);
|
rt = cx->runtime;
|
||||||
if (trap)
|
DBG_LOCK(rt);
|
||||||
trap->op = op;
|
for (trap = (JSTrap *)rt->trapList.next;
|
||||||
else
|
trap != (JSTrap *)&rt->trapList;
|
||||||
*pc = (jsbytecode)op;
|
trap = (JSTrap *)trap->links.next) {
|
||||||
DBG_UNLOCK(cx->runtime);
|
if (trap->script == script) {
|
||||||
|
if (code == script->code) {
|
||||||
|
code = JS_malloc(cx, script->length * sizeof(jsbytecode));
|
||||||
|
if (!code)
|
||||||
|
break;
|
||||||
|
memcpy(code, script->code,
|
||||||
|
script->length * sizeof(jsbytecode));
|
||||||
|
}
|
||||||
|
code[trap->pc - script->code] = trap->op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBG_UNLOCK(rt);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
@ -1708,6 +1732,8 @@ JS_SetContextDebugHooks(JSContext *cx, JSDebugHooks *hooks)
|
|||||||
|
|
||||||
#ifdef MOZ_SHARK
|
#ifdef MOZ_SHARK
|
||||||
|
|
||||||
|
#include <CHUD/CHUD.h>
|
||||||
|
|
||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_StartChudRemote()
|
JS_StartChudRemote()
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
* vim: set ts=8 sw=4 et tw=78:
|
||||||
*
|
*
|
||||||
* ***** BEGIN LICENSE BLOCK *****
|
* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
@ -43,27 +44,18 @@
|
|||||||
* JS debugger API.
|
* JS debugger API.
|
||||||
*/
|
*/
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsclist.h"
|
|
||||||
#include "jsopcode.h"
|
#include "jsopcode.h"
|
||||||
#include "jsprvtd.h"
|
#include "jsprvtd.h"
|
||||||
|
|
||||||
JS_BEGIN_EXTERN_C
|
JS_BEGIN_EXTERN_C
|
||||||
|
|
||||||
typedef struct JSTrap {
|
/*
|
||||||
JSCList links;
|
* Unexported library-private helper used to unpatch all traps in a script.
|
||||||
JSScript *script;
|
* Returns script->code if script has no traps, else a JS_malloc'ed copy of
|
||||||
jsbytecode *pc;
|
* script->code which the caller must JS_free, or null on JS_malloc OOM.
|
||||||
JSOp op;
|
*/
|
||||||
JSTrapHandler handler;
|
extern jsbytecode *
|
||||||
void *closure;
|
js_UntrapScriptCode(JSContext *cx, JSScript *script);
|
||||||
} JSTrap;
|
|
||||||
|
|
||||||
#define DBG_LOCK(rt) JS_ACQUIRE_LOCK((rt)->debuggerLock)
|
|
||||||
#define DBG_UNLOCK(rt) JS_RELEASE_LOCK((rt)->debuggerLock)
|
|
||||||
#define DBG_LOCK_EVAL(rt,expr) (DBG_LOCK(rt), (expr), DBG_UNLOCK(rt))
|
|
||||||
|
|
||||||
extern void
|
|
||||||
js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op);
|
|
||||||
|
|
||||||
extern JS_PUBLIC_API(JSBool)
|
extern JS_PUBLIC_API(JSBool)
|
||||||
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||||
@ -436,24 +428,35 @@ extern JS_PUBLIC_API(JSDebugHooks *)
|
|||||||
JS_SetContextDebugHooks(JSContext *cx, JSDebugHooks *hooks);
|
JS_SetContextDebugHooks(JSContext *cx, JSDebugHooks *hooks);
|
||||||
|
|
||||||
#ifdef MOZ_SHARK
|
#ifdef MOZ_SHARK
|
||||||
extern JS_PUBLIC_API(JSBool) JS_StartChudRemote();
|
|
||||||
extern JS_PUBLIC_API(JSBool) JS_StopChudRemote();
|
|
||||||
extern JS_PUBLIC_API(JSBool) JS_ConnectShark();
|
|
||||||
extern JS_PUBLIC_API(JSBool) JS_DisconnectShark();
|
|
||||||
|
|
||||||
extern JS_FRIEND_API(JSBool) js_StopShark(JSContext *cx, JSObject *obj,
|
extern JS_PUBLIC_API(JSBool)
|
||||||
uintN argc, jsval *argv, jsval *rval);
|
JS_StartChudRemote();
|
||||||
|
|
||||||
extern JS_FRIEND_API(JSBool) js_StartShark(JSContext *cx, JSObject *obj,
|
extern JS_PUBLIC_API(JSBool)
|
||||||
uintN argc, jsval *argv, jsval *rval);
|
JS_StopChudRemote();
|
||||||
|
|
||||||
extern JS_FRIEND_API(JSBool) js_ConnectShark(JSContext *cx, JSObject *obj,
|
extern JS_PUBLIC_API(JSBool)
|
||||||
uintN argc, jsval *argv,
|
JS_ConnectShark();
|
||||||
jsval *rval);
|
|
||||||
|
extern JS_PUBLIC_API(JSBool)
|
||||||
|
JS_DisconnectShark();
|
||||||
|
|
||||||
|
extern JS_FRIEND_API(JSBool)
|
||||||
|
js_StopShark(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
|
jsval *rval);
|
||||||
|
|
||||||
|
extern JS_FRIEND_API(JSBool)
|
||||||
|
js_StartShark(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
|
jsval *rval);
|
||||||
|
|
||||||
|
extern JS_FRIEND_API(JSBool)
|
||||||
|
js_ConnectShark(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
|
jsval *rval);
|
||||||
|
|
||||||
|
extern JS_FRIEND_API(JSBool)
|
||||||
|
js_DisconnectShark(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||||
|
jsval *rval);
|
||||||
|
|
||||||
extern JS_FRIEND_API(JSBool) js_DisconnectShark(JSContext *cx, JSObject *obj,
|
|
||||||
uintN argc, jsval *argv,
|
|
||||||
jsval *rval);
|
|
||||||
#endif /* MOZ_SHARK */
|
#endif /* MOZ_SHARK */
|
||||||
|
|
||||||
JS_END_EXTERN_C
|
JS_END_EXTERN_C
|
||||||
|
@ -518,30 +518,14 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
|
|||||||
* Control hereafter must goto error on failure, in order for the
|
* Control hereafter must goto error on failure, in order for the
|
||||||
* DECODE case to destroy script.
|
* DECODE case to destroy script.
|
||||||
*/
|
*/
|
||||||
|
oldscript = xdr->script;
|
||||||
code = script->code;
|
code = script->code;
|
||||||
if (xdr->mode == JSXDR_ENCODE) {
|
if (xdr->mode == JSXDR_ENCODE) {
|
||||||
JSTrap *trap;
|
code = js_UntrapScriptCode(cx, script);
|
||||||
JSRuntime *rt;
|
if (!code)
|
||||||
|
goto error;
|
||||||
rt = cx->runtime;
|
|
||||||
DBG_LOCK(rt);
|
|
||||||
for (trap = (JSTrap *)rt->trapList.next;
|
|
||||||
trap != (JSTrap *)&rt->trapList;
|
|
||||||
trap = (JSTrap *)trap->links.next) {
|
|
||||||
if (trap->script == script) {
|
|
||||||
if (code == script->code) {
|
|
||||||
code = JS_malloc(cx, length * sizeof(jsbytecode));
|
|
||||||
if (!code)
|
|
||||||
goto error;
|
|
||||||
memcpy(code, script->code, length * sizeof(jsbytecode));
|
|
||||||
}
|
|
||||||
code[trap->pc - script->code] = trap->op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DBG_UNLOCK(rt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oldscript = xdr->script;
|
|
||||||
xdr->script = script;
|
xdr->script = script;
|
||||||
ok = JS_XDRBytes(xdr, (char *) code, length * sizeof(jsbytecode));
|
ok = JS_XDRBytes(xdr, (char *) code, length * sizeof(jsbytecode));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user