mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 838014 - More rooting in Debugger, plus some minor rooting in JSD and xpconnect for some should-be-private JSAPI changes. r=terrence
--HG-- extra : rebase_source : 46febe5421f6e1901f0d5ac2707fb3fdde1894db
This commit is contained in:
parent
af901cc613
commit
231eada73a
@ -698,7 +698,7 @@ jsd_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
JSBool eatExceptions, jsval *rval);
|
||||
JSBool eatExceptions, JS::MutableHandleValue rval);
|
||||
|
||||
extern JSBool
|
||||
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
@ -706,7 +706,7 @@ jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
JSBool eatExceptions, jsval *rval);
|
||||
JSBool eatExceptions, JS::MutableHandleValue rval);
|
||||
|
||||
extern JSString*
|
||||
jsd_ValToStringInStackFrame(JSDContext* jsdc,
|
||||
|
@ -94,7 +94,7 @@ jsd_NewThreadState(JSDContext* jsdc, JSContext *cx )
|
||||
JSAbstractFramePtr frame = iter.abstractFramePtr();
|
||||
JSScript* script = frame.script();
|
||||
uintptr_t pc = (uintptr_t)iter.pc();
|
||||
jsval dummyThis;
|
||||
js::RootedValue dummyThis(cx);
|
||||
|
||||
/*
|
||||
* don't construct a JSDStackFrame for dummy frames (those without a
|
||||
@ -311,7 +311,7 @@ jsd_GetThisForStackFrame(JSDContext* jsdc,
|
||||
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
|
||||
{
|
||||
JSBool ok;
|
||||
jsval thisval;
|
||||
js::RootedValue thisval(jsdthreadstate->context);
|
||||
JS_BeginRequest(jsdthreadstate->context);
|
||||
ok = jsdframe->frame.getThisValue(jsdthreadstate->context, &thisval);
|
||||
JS_EndRequest(jsdthreadstate->context);
|
||||
@ -392,7 +392,7 @@ jsd_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
JSBool eatExceptions, jsval *rval)
|
||||
JSBool eatExceptions, JS::MutableHandleValue rval)
|
||||
{
|
||||
JSBool retval;
|
||||
JSBool valid;
|
||||
@ -430,7 +430,7 @@ jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
JSBool eatExceptions, jsval *rval)
|
||||
JSBool eatExceptions, JS::MutableHandleValue rval)
|
||||
{
|
||||
JSBool retval;
|
||||
JSBool valid;
|
||||
|
@ -95,7 +95,7 @@ _callHook(JSDContext *jsdc, JSContext *cx, JSAbstractFramePtr frame, bool isCons
|
||||
}
|
||||
|
||||
if (before && isConstructing) {
|
||||
jsval newObj;
|
||||
js::RootedValue newObj(cx);
|
||||
if (!frame.getThisValue(cx, &newObj))
|
||||
return JS_FALSE;
|
||||
jsd_Constructing(jsdc, cx, JSVAL_TO_OBJECT(newObj), frame);
|
||||
|
@ -2025,10 +2025,10 @@ jsdStackFrame::Eval (const nsAString &bytes, const nsACString &fileName,
|
||||
const jschar *char_bytes = reinterpret_cast<const jschar *>(h.get());
|
||||
|
||||
JSExceptionState *estate = 0;
|
||||
jsval jv;
|
||||
|
||||
JSContext *cx = JSD_GetJSContext (mCx, mThreadState);
|
||||
|
||||
js::RootedValue jv(cx);
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
estate = JS_SaveExceptionState (cx);
|
||||
@ -2050,7 +2050,7 @@ jsdStackFrame::Eval (const nsAString &bytes, const nsACString &fileName,
|
||||
line, &jv);
|
||||
if (!*_rval) {
|
||||
if (JS_IsExceptionPending(cx))
|
||||
JS_GetPendingException (cx, &jv);
|
||||
JS_GetPendingException (cx, jv.address());
|
||||
else
|
||||
jv = JSVAL_NULL;
|
||||
}
|
||||
|
@ -765,17 +765,16 @@ JSD_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval)
|
||||
const char *filename, unsigned lineno, JS::MutableHandleValue rval)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
JS_ASSERT(bytes);
|
||||
JS_ASSERT(length);
|
||||
JS_ASSERT(filename);
|
||||
JS_ASSERT(rval);
|
||||
|
||||
return jsd_EvaluateUCScriptInStackFrame(jsdc, jsdthreadstate,jsdframe,
|
||||
bytes, length, filename, lineno,
|
||||
JS_TRUE, rval);
|
||||
JS_TRUE, rval);
|
||||
}
|
||||
|
||||
JSD_PUBLIC_API(JSBool)
|
||||
@ -784,13 +783,12 @@ JSD_AttemptUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval)
|
||||
JS::MutableHandleValue rval)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
JS_ASSERT(bytes);
|
||||
JS_ASSERT(length);
|
||||
JS_ASSERT(filename);
|
||||
JS_ASSERT(rval);
|
||||
|
||||
return jsd_EvaluateUCScriptInStackFrame(jsdc, jsdthreadstate,jsdframe,
|
||||
bytes, length, filename, lineno,
|
||||
@ -802,13 +800,12 @@ JSD_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval)
|
||||
const char *filename, unsigned lineno, JS::MutableHandleValue rval)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
JS_ASSERT(bytes);
|
||||
JS_ASSERT(length);
|
||||
JS_ASSERT(filename);
|
||||
JS_ASSERT(rval);
|
||||
|
||||
return jsd_EvaluateScriptInStackFrame(jsdc, jsdthreadstate,jsdframe,
|
||||
bytes, length,
|
||||
@ -820,13 +817,12 @@ JSD_AttemptScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval)
|
||||
const char *filename, unsigned lineno, JS::MutableHandleValue rval)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
JS_ASSERT(bytes);
|
||||
JS_ASSERT(length);
|
||||
JS_ASSERT(filename);
|
||||
JS_ASSERT(rval);
|
||||
|
||||
return jsd_EvaluateScriptInStackFrame(jsdc, jsdthreadstate,jsdframe,
|
||||
bytes, length,
|
||||
|
@ -990,7 +990,7 @@ JSD_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandleValue rval);
|
||||
|
||||
/*
|
||||
* Same as above, but does not eat exceptions.
|
||||
@ -1001,7 +1001,7 @@ JSD_AttemptUCScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const jschar *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandleValue rval);
|
||||
|
||||
/* single byte character version of JSD_EvaluateUCScriptInStackFrame */
|
||||
extern JSD_PUBLIC_API(JSBool)
|
||||
@ -1009,7 +1009,7 @@ JSD_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval);
|
||||
const char *filename, unsigned lineno, JS::MutableHandleValue rval);
|
||||
|
||||
/*
|
||||
* Same as above, but does not eat exceptions.
|
||||
@ -1019,7 +1019,7 @@ JSD_AttemptScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno, jsval *rval);
|
||||
const char *filename, unsigned lineno, JS::MutableHandleValue rval);
|
||||
|
||||
/*
|
||||
* Convert the given jsval to a string
|
||||
|
@ -18,7 +18,7 @@ callCountHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, JSBo
|
||||
{
|
||||
callCount[before]++;
|
||||
|
||||
jsval thisv;
|
||||
js::RootedValue thisv(cx);
|
||||
frame.getThisValue(cx, &thisv); // assert if fp is incomplete
|
||||
|
||||
return cx; // any non-null value causes the hook to be called again after
|
||||
@ -45,7 +45,7 @@ nonStrictThisHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
|
||||
if (before) {
|
||||
bool *allWrapped = (bool *) closure;
|
||||
js::RootedValue thisv(cx);
|
||||
frame.getThisValue(cx, thisv.address());
|
||||
frame.getThisValue(cx, &thisv);
|
||||
*allWrapped = *allWrapped && !JSVAL_IS_PRIMITIVE(thisv);
|
||||
}
|
||||
return NULL;
|
||||
@ -84,7 +84,7 @@ strictThisHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, JSB
|
||||
if (before) {
|
||||
bool *anyWrapped = (bool *) closure;
|
||||
js::RootedValue thisv(cx);
|
||||
frame.getThisValue(cx, thisv.address());
|
||||
frame.getThisValue(cx, &thisv);
|
||||
*anyWrapped = *anyWrapped || !JSVAL_IS_PRIMITIVE(thisv);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1362,7 +1362,7 @@ JSAbstractFramePtr::script()
|
||||
}
|
||||
|
||||
bool
|
||||
JSAbstractFramePtr::getThisValue(JSContext *cx, jsval *thisv)
|
||||
JSAbstractFramePtr::getThisValue(JSContext *cx, MutableHandleValue thisv)
|
||||
{
|
||||
AbstractFramePtr frame = Valueify(*this);
|
||||
|
||||
@ -1371,7 +1371,7 @@ JSAbstractFramePtr::getThisValue(JSContext *cx, jsval *thisv)
|
||||
if (!ComputeThis(cx, frame))
|
||||
return false;
|
||||
|
||||
*thisv = frame.thisValue();
|
||||
thisv.set(frame.thisValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1386,7 +1386,7 @@ bool
|
||||
JSAbstractFramePtr::evaluateInStackFrame(JSContext *cx,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval)
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
if (!CheckDebugMode(cx))
|
||||
return false;
|
||||
@ -1407,7 +1407,7 @@ bool
|
||||
JSAbstractFramePtr::evaluateUCInStackFrame(JSContext *cx,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval)
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
if (!CheckDebugMode(cx))
|
||||
return false;
|
||||
|
@ -308,19 +308,19 @@ class JS_PUBLIC_API(JSAbstractFramePtr)
|
||||
JSFunction *maybeFun();
|
||||
JSScript *script();
|
||||
|
||||
bool getThisValue(JSContext *cx, jsval *thisv);
|
||||
bool getThisValue(JSContext *cx, JS::MutableHandleValue thisv);
|
||||
|
||||
bool isDebuggerFrame();
|
||||
|
||||
bool evaluateInStackFrame(JSContext *cx,
|
||||
const char *bytes, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandleValue rval);
|
||||
|
||||
bool evaluateUCInStackFrame(JSContext *cx,
|
||||
const jschar *chars, unsigned length,
|
||||
const char *filename, unsigned lineno,
|
||||
jsval *rval);
|
||||
JS::MutableHandleValue rval);
|
||||
};
|
||||
|
||||
class JS_PUBLIC_API(JSNullFramePtr) : public JSAbstractFramePtr
|
||||
|
@ -2085,7 +2085,7 @@ extern bool
|
||||
js::IsValidBytecodeOffset(JSContext *cx, JSScript *script, size_t offset)
|
||||
{
|
||||
// This could be faster (by following jump instructions if the target is <= offset).
|
||||
for (BytecodeRange r(script); !r.empty(); r.popFront()) {
|
||||
for (BytecodeRange r(cx, script); !r.empty(); r.popFront()) {
|
||||
size_t here = r.frontOffset();
|
||||
if (here >= offset)
|
||||
return here == offset;
|
||||
|
@ -31,8 +31,8 @@ GetNameFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op)
|
||||
|
||||
class BytecodeRange {
|
||||
public:
|
||||
BytecodeRange(JSScript *script)
|
||||
: script(script), pc(script->code), end(pc + script->length) {}
|
||||
BytecodeRange(JSContext *cx, JSScript *script)
|
||||
: script(cx, script), pc(script->code), end(pc + script->length) {}
|
||||
bool empty() const { return pc == end; }
|
||||
jsbytecode *frontPC() const { return pc; }
|
||||
JSOp frontOpcode() const { return JSOp(*pc); }
|
||||
@ -40,7 +40,7 @@ class BytecodeRange {
|
||||
void popFront() { pc += GetBytecodeLength(pc); }
|
||||
|
||||
private:
|
||||
JSScript *script;
|
||||
RootedScript script;
|
||||
jsbytecode *pc, *end;
|
||||
};
|
||||
|
||||
|
@ -1506,10 +1506,11 @@ GetScriptAndPCArgs(JSContext *cx, unsigned argc, jsval *argv, MutableHandleScrip
|
||||
}
|
||||
|
||||
static JSTrapStatus
|
||||
TrapHandler(JSContext *cx, RawScript, jsbytecode *pc, jsval *rval,
|
||||
TrapHandler(JSContext *cx, RawScript, jsbytecode *pc, jsval *rvalArg,
|
||||
jsval closure)
|
||||
{
|
||||
JSString *str = JSVAL_TO_STRING(closure);
|
||||
RootedValue rval(cx, *rvalArg);
|
||||
|
||||
ScriptFrameIter iter(cx);
|
||||
JS_ASSERT(!iter.done());
|
||||
@ -1526,11 +1527,13 @@ TrapHandler(JSContext *cx, RawScript, jsbytecode *pc, jsval *rval,
|
||||
if (!frame.evaluateUCInStackFrame(cx, chars, length,
|
||||
script->filename,
|
||||
script->lineno,
|
||||
rval))
|
||||
&rval))
|
||||
{
|
||||
*rvalArg = rval;
|
||||
return JSTRAP_ERROR;
|
||||
}
|
||||
if (!JSVAL_IS_VOID(*rval))
|
||||
*rvalArg = rval;
|
||||
if (!rval.isUndefined())
|
||||
return JSTRAP_RETURN;
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
@ -2596,7 +2599,7 @@ EvalInFrame(JSContext *cx, unsigned argc, jsval *vp)
|
||||
fpscript->filename,
|
||||
JS_PCToLineNumber(cx, fpscript,
|
||||
fi.pc()),
|
||||
vp);
|
||||
MutableHandleValue::fromMarkedLocation(vp));
|
||||
|
||||
if (saved)
|
||||
JS_RestoreFrameChain(cx);
|
||||
|
@ -2897,7 +2897,7 @@ class BytecodeRangeWithLineNumbers : private BytecodeRange
|
||||
using BytecodeRange::frontOffset;
|
||||
|
||||
BytecodeRangeWithLineNumbers(JSContext *cx, JSScript *script)
|
||||
: BytecodeRange(script), lineno(script->lineno), sn(script->notes()), snpc(script->code), skip(cx, thisForCtor())
|
||||
: BytecodeRange(cx, script), lineno(script->lineno), sn(script->notes()), snpc(script->code)
|
||||
{
|
||||
if (!SN_IS_TERMINATOR(sn))
|
||||
snpc += SN_DELTA(sn);
|
||||
@ -2915,8 +2915,6 @@ class BytecodeRangeWithLineNumbers : private BytecodeRange
|
||||
size_t frontLineNumber() const { return lineno; }
|
||||
|
||||
private:
|
||||
BytecodeRangeWithLineNumbers *thisForCtor() { return this; }
|
||||
|
||||
void updateLine() {
|
||||
/*
|
||||
* Determine the current line number by reading all source notes up to
|
||||
@ -2937,8 +2935,6 @@ class BytecodeRangeWithLineNumbers : private BytecodeRange
|
||||
size_t lineno;
|
||||
jssrcnote *sn;
|
||||
jsbytecode *snpc;
|
||||
|
||||
SkipRoot skip;
|
||||
};
|
||||
|
||||
static const size_t NoEdges = -1;
|
||||
@ -3699,7 +3695,7 @@ DebuggerFrame_setOnPop(JSContext *cx, unsigned argc, Value *vp)
|
||||
JSBool
|
||||
js::EvaluateInEnv(JSContext *cx, Handle<Env*> env, HandleValue thisv, AbstractFramePtr frame,
|
||||
StableCharPtr chars, unsigned length, const char *filename, unsigned lineno,
|
||||
Value *rval)
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
assertSameCompartment(cx, env, frame);
|
||||
JS_ASSERT_IF(frame, thisv.get() == frame.thisValue());
|
||||
@ -3724,7 +3720,7 @@ js::EvaluateInEnv(JSContext *cx, Handle<Env*> env, HandleValue thisv, AbstractFr
|
||||
|
||||
script->isActiveEval = true;
|
||||
ExecuteType type = !frame && env->isGlobal() ? EXECUTE_DEBUG_GLOBAL : EXECUTE_DEBUG;
|
||||
return ExecuteKernel(cx, script, *env, thisv, type, frame, rval);
|
||||
return ExecuteKernel(cx, script, *env, thisv, type, frame, rval.address());
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
@ -699,7 +699,7 @@ Debugger::onNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global)
|
||||
extern JSBool
|
||||
EvaluateInEnv(JSContext *cx, Handle<Env*> env, HandleValue thisv, AbstractFramePtr frame,
|
||||
StableCharPtr chars, unsigned length, const char *filename, unsigned lineno,
|
||||
Value *rval);
|
||||
MutableHandleValue rval);
|
||||
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ xpc_DumpEvalInJSStackFrame(JSContext* cx, uint32_t frameno, const char* text)
|
||||
JSExceptionState* exceptionState = JS_SaveExceptionState(cx);
|
||||
JSErrorReporter older = JS_SetErrorReporter(cx, xpcDumpEvalErrorReporter);
|
||||
|
||||
jsval rval;
|
||||
js::RootedValue rval(cx);
|
||||
JSString* str;
|
||||
JSAutoByteString bytes;
|
||||
if (frame.evaluateInStackFrame(cx, text, strlen(text), "eval", 1, &rval) &&
|
||||
|
Loading…
Reference in New Issue
Block a user