mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 797695 (part 4) - Exactly root jsscript.cpp. r=terrence.
--HG-- extra : rebase_source : b6cc292b092b30e339a75921245d4605275c104d
This commit is contained in:
parent
1b5371c422
commit
2d9d809e6a
@ -430,14 +430,14 @@ js::InternNonIntElementId(JSContext *cx, JSObject *obj, const Value &idval,
|
||||
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
js::XDRAtom(XDRState<mode> *xdr, JSAtom **atomp)
|
||||
js::XDRAtom(XDRState<mode> *xdr, MutableHandleAtom atomp)
|
||||
{
|
||||
if (mode == XDR_ENCODE) {
|
||||
uint32_t nchars = (*atomp)->length();
|
||||
uint32_t nchars = atomp->length();
|
||||
if (!xdr->codeUint32(&nchars))
|
||||
return false;
|
||||
|
||||
jschar *chars = const_cast<jschar *>((*atomp)->getChars(xdr->cx()));
|
||||
jschar *chars = const_cast<jschar *>(atomp->getChars(xdr->cx()));
|
||||
if (!chars)
|
||||
return false;
|
||||
|
||||
@ -483,13 +483,13 @@ js::XDRAtom(XDRState<mode> *xdr, JSAtom **atomp)
|
||||
|
||||
if (!atom)
|
||||
return false;
|
||||
*atomp = atom;
|
||||
atomp.set(atom);
|
||||
return true;
|
||||
}
|
||||
|
||||
template bool
|
||||
js::XDRAtom(XDRState<XDR_ENCODE> *xdr, JSAtom **atomp);
|
||||
js::XDRAtom(XDRState<XDR_ENCODE> *xdr, MutableHandleAtom atomp);
|
||||
|
||||
template bool
|
||||
js::XDRAtom(XDRState<XDR_DECODE> *xdr, JSAtom **atomp);
|
||||
js::XDRAtom(XDRState<XDR_DECODE> *xdr, MutableHandleAtom atomp);
|
||||
|
||||
|
@ -272,7 +272,7 @@ InternNonIntElementId(JSContext *cx, JSObject *obj, const Value &idval, jsid *id
|
||||
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
XDRAtom(XDRState<mode> *xdr, JSAtom **atomp);
|
||||
XDRAtom(XDRState<mode> *xdr, js::MutableHandleAtom atomp);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
|
@ -120,9 +120,6 @@ struct GSNCache {
|
||||
void purge();
|
||||
};
|
||||
|
||||
inline GSNCache *
|
||||
GetGSNCache(JSContext *cx);
|
||||
|
||||
typedef Vector<ScriptAndCounts, 0, SystemAllocPolicy> ScriptAndCountsVector;
|
||||
|
||||
struct ConservativeGCData
|
||||
|
@ -134,12 +134,6 @@ struct PreserveRegsGuard
|
||||
FrameRegs ®s_;
|
||||
};
|
||||
|
||||
inline GSNCache *
|
||||
GetGSNCache(JSContext *cx)
|
||||
{
|
||||
return &cx->runtime->gsnCache;
|
||||
}
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
|
||||
class AutoNamespaceArray : protected AutoGCRooter {
|
||||
|
@ -405,7 +405,7 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
|
||||
if (!xdr->codeUint32(&firstword))
|
||||
return false;
|
||||
if ((firstword & 1U) && !XDRAtom(xdr, atom.address()))
|
||||
if ((firstword & 1U) && !XDRAtom(xdr, &atom))
|
||||
return false;
|
||||
if (!xdr->codeUint32(&flagsword))
|
||||
return false;
|
||||
|
@ -298,7 +298,7 @@ typedef void
|
||||
/* called just before script destruction */
|
||||
typedef void
|
||||
(* JSDestroyScriptHook)(JSFreeOp *fop,
|
||||
JSScript *script,
|
||||
JSRawScript script,
|
||||
void *callerdata);
|
||||
|
||||
typedef void
|
||||
|
@ -187,7 +187,7 @@ XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, un
|
||||
|
||||
if (mode == XDR_ENCODE) {
|
||||
for (BindingIter bi(script); bi; bi++) {
|
||||
JSAtom *atom = bi->name();
|
||||
RootedAtom atom(cx, bi->name());
|
||||
if (!XDRAtom(xdr, &atom))
|
||||
return false;
|
||||
}
|
||||
@ -204,7 +204,7 @@ XDRScriptBindings(XDRState<mode> *xdr, LifoAllocScope &las, unsigned numArgs, un
|
||||
if (!atoms.resize(nameCount))
|
||||
return false;
|
||||
for (unsigned i = 0; i < nameCount; i++) {
|
||||
JSAtom *atom;
|
||||
RootedAtom atom(cx);
|
||||
if (!XDRAtom(xdr, &atom))
|
||||
return false;
|
||||
atoms[i] = StringValue(atom);
|
||||
@ -275,6 +275,8 @@ template<XDRMode mode>
|
||||
static bool
|
||||
XDRScriptConst(XDRState<mode> *xdr, HeapValue *vp)
|
||||
{
|
||||
JSContext *cx = xdr->cx();
|
||||
|
||||
/*
|
||||
* A script constant can be an arbitrary primitive value as they are used
|
||||
* to implement JSOP_LOOKUPSWITCH. But they cannot be objects, see
|
||||
@ -335,7 +337,7 @@ XDRScriptConst(XDRState<mode> *xdr, HeapValue *vp)
|
||||
break;
|
||||
}
|
||||
case SCRIPT_ATOM: {
|
||||
JSAtom *atom;
|
||||
RootedAtom atom(cx);
|
||||
if (mode == XDR_ENCODE)
|
||||
atom = &vp->toString()->asAtom();
|
||||
if (!XDRAtom(xdr, &atom))
|
||||
@ -365,7 +367,7 @@ XDRScriptConst(XDRState<mode> *xdr, HeapValue *vp)
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
FindBlockIndex(JSScript *script, StaticBlockObject &block)
|
||||
FindBlockIndex(RawScript script, StaticBlockObject &block)
|
||||
{
|
||||
ObjectArray *objects = script->objects();
|
||||
HeapPtrObject *vector = objects->vector;
|
||||
@ -633,12 +635,12 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
|
||||
for (i = 0; i != natoms; ++i) {
|
||||
if (mode == XDR_DECODE) {
|
||||
JSAtom *tmp = NULL;
|
||||
RootedAtom tmp(cx);
|
||||
if (!XDRAtom(xdr, &tmp))
|
||||
return false;
|
||||
script->atoms[i].init(tmp);
|
||||
} else {
|
||||
JSAtom *tmp = script->atoms[i];
|
||||
RootedAtom tmp(cx, script->atoms[i]);
|
||||
if (!XDRAtom(xdr, &tmp))
|
||||
return false;
|
||||
}
|
||||
@ -653,7 +655,7 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
HeapPtr<JSObject> *objp = &script->objects()->vector[i];
|
||||
uint32_t isBlock;
|
||||
if (mode == XDR_ENCODE) {
|
||||
JSObject *obj = *objp;
|
||||
RawObject obj = *objp;
|
||||
JS_ASSERT(obj->isFunction() || obj->isStaticBlock());
|
||||
isBlock = obj->isBlock() ? 1 : 0;
|
||||
}
|
||||
@ -1487,11 +1489,11 @@ JSScript::Create(JSContext *cx, HandleObject enclosingScope, bool savedCallerFun
|
||||
const CompileOptions &options, unsigned staticLevel,
|
||||
ScriptSource *ss, uint32_t bufStart, uint32_t bufEnd)
|
||||
{
|
||||
JSScript *script = js_NewGCScript(cx);
|
||||
RootedScript script(cx, js_NewGCScript(cx));
|
||||
if (!script)
|
||||
return NULL;
|
||||
|
||||
PodZero(script);
|
||||
PodZero(script.get());
|
||||
new (&script->bindings) Bindings;
|
||||
|
||||
script->enclosingScope_ = enclosingScope;
|
||||
@ -1778,10 +1780,10 @@ JSScript::enclosingScriptsCompiledSuccessfully() const
|
||||
* compiles. Thus, we can detect failed compilation by looking for
|
||||
* JSFunctions in the enclosingScope chain without scripts.
|
||||
*/
|
||||
JSObject *enclosing = enclosingScope_;
|
||||
RawObject enclosing = enclosingScope_;
|
||||
while (enclosing) {
|
||||
if (enclosing->isFunction()) {
|
||||
JSFunction *fun = enclosing->toFunction();
|
||||
RawFunction fun = enclosing->toFunction();
|
||||
if (!fun->script())
|
||||
return false;
|
||||
enclosing = fun->script()->enclosingScope_;
|
||||
@ -1804,7 +1806,7 @@ js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun)
|
||||
}
|
||||
|
||||
void
|
||||
js::CallDestroyScriptHook(FreeOp *fop, JSScript *script)
|
||||
js::CallDestroyScriptHook(FreeOp *fop, RawScript script)
|
||||
{
|
||||
if (JSDestroyScriptHook hook = fop->runtime()->debugHooks.destroyScriptHook)
|
||||
hook(fop, script, fop->runtime()->debugHooks.destroyScriptHookData);
|
||||
@ -1865,13 +1867,15 @@ GSNCache::purge()
|
||||
} /* namespace js */
|
||||
|
||||
jssrcnote *
|
||||
js_GetSrcNote(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||
js_GetSrcNote(JSContext *cx, RawScript script, jsbytecode *pc)
|
||||
{
|
||||
GSNCache *cache = &cx->runtime->gsnCache;
|
||||
cx = NULL; // nulling |cx| ensures GC can't be triggered, so |RawScript script| is safe
|
||||
|
||||
size_t target = pc - script->code;
|
||||
if (target >= size_t(script->length))
|
||||
return NULL;
|
||||
|
||||
GSNCache *cache = GetGSNCache(cx);
|
||||
if (cache->code == script->code) {
|
||||
JS_ASSERT(cache->map.initialized());
|
||||
GSNCache::Map::Ptr p = cache->map.lookup(pc);
|
||||
@ -1966,21 +1970,20 @@ js::PCToLineNumber(unsigned startLine, jssrcnote *notes, jsbytecode *code, jsbyt
|
||||
}
|
||||
|
||||
unsigned
|
||||
js::PCToLineNumber(JSScript *script, jsbytecode *pc, unsigned *columnp)
|
||||
js::PCToLineNumber(RawScript script, jsbytecode *pc, unsigned *columnp)
|
||||
{
|
||||
/* Cope with StackFrame.pc value prior to entering js_Interpret. */
|
||||
if (!pc)
|
||||
return 0;
|
||||
|
||||
return PCToLineNumber(script->lineno, script->notes(), script->code, pc,
|
||||
columnp);
|
||||
return PCToLineNumber(script->lineno, script->notes(), script->code, pc, columnp);
|
||||
}
|
||||
|
||||
/* The line number limit is the same as the jssrcnote offset limit. */
|
||||
#define SN_LINE_LIMIT (SN_3BYTE_OFFSET_FLAG << 16)
|
||||
|
||||
jsbytecode *
|
||||
js_LineNumberToPC(JSScript *script, unsigned target)
|
||||
js_LineNumberToPC(RawScript script, unsigned target)
|
||||
{
|
||||
ptrdiff_t offset = 0;
|
||||
ptrdiff_t best = -1;
|
||||
@ -2015,7 +2018,7 @@ out:
|
||||
}
|
||||
|
||||
JS_FRIEND_API(unsigned)
|
||||
js_GetScriptLineExtent(JSScript *script)
|
||||
js_GetScriptLineExtent(RawScript script)
|
||||
{
|
||||
unsigned lineno = script->lineno;
|
||||
unsigned maxLineNo = 0;
|
||||
@ -2064,7 +2067,7 @@ CurrentScriptFileLineOriginSlow(JSContext *cx, const char **file, unsigned *line
|
||||
return;
|
||||
}
|
||||
|
||||
JSScript *script = iter.script();
|
||||
RootedScript script(cx, iter.script());
|
||||
*file = script->filename;
|
||||
*linenop = PCToLineNumber(iter.script(), iter.pc());
|
||||
*origin = script->originPrincipals;
|
||||
@ -2074,7 +2077,7 @@ CurrentScriptFileLineOriginSlow(JSContext *cx, const char **file, unsigned *line
|
||||
|
||||
template <class T>
|
||||
static inline T *
|
||||
Rebase(JSScript *dst, JSScript *src, T *srcp)
|
||||
Rebase(RawScript dst, RawScript src, T *srcp)
|
||||
{
|
||||
size_t off = reinterpret_cast<uint8_t *>(srcp) - src->data;
|
||||
return reinterpret_cast<T *>(dst->data + off);
|
||||
@ -2113,12 +2116,12 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
if (nobjects != 0) {
|
||||
HeapPtrObject *vector = src->objects()->vector;
|
||||
for (unsigned i = 0; i < nobjects; i++) {
|
||||
JSObject &obj = *vector[i];
|
||||
JSObject *clone;
|
||||
if (obj.isStaticBlock()) {
|
||||
Rooted<StaticBlockObject*> innerBlock(cx, &obj.asStaticBlock());
|
||||
RootedObject obj(cx, vector[i]);
|
||||
RootedObject clone(cx);
|
||||
if (obj->isStaticBlock()) {
|
||||
Rooted<StaticBlockObject*> innerBlock(cx, &obj->asStaticBlock());
|
||||
|
||||
Rooted<JSObject*> enclosingScope(cx);
|
||||
RootedObject enclosingScope(cx);
|
||||
if (StaticBlockObject *enclosingBlock = innerBlock->enclosingBlock())
|
||||
enclosingScope = objects[FindBlockIndex(src, *enclosingBlock)];
|
||||
else
|
||||
@ -2126,10 +2129,10 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
|
||||
clone = CloneStaticBlockObject(cx, enclosingScope, innerBlock);
|
||||
} else {
|
||||
Rooted<JSFunction*> innerFun(cx, obj.toFunction());
|
||||
RootedFunction innerFun(cx, obj->toFunction());
|
||||
|
||||
StaticScopeIter ssi(innerFun->script()->enclosingStaticScope());
|
||||
Rooted<JSObject*> enclosingScope(cx);
|
||||
RootedObject enclosingScope(cx);
|
||||
if (!ssi.done() && ssi.type() == StaticScopeIter::BLOCK)
|
||||
enclosingScope = objects[FindBlockIndex(src, ssi.block())];
|
||||
else
|
||||
@ -2148,7 +2151,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
for (unsigned i = 0; i < nregexps; i++) {
|
||||
HeapPtrObject *vector = src->regexps()->vector;
|
||||
for (unsigned i = 0; i < nregexps; i++) {
|
||||
JSObject *clone = CloneScriptRegExpObject(cx, vector[i]->asRegExp());
|
||||
RawObject clone = CloneScriptRegExpObject(cx, vector[i]->asRegExp());
|
||||
if (!clone || !regexps.append(clone))
|
||||
return NULL;
|
||||
}
|
||||
@ -2162,9 +2165,9 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
.setCompileAndGo(src->compileAndGo)
|
||||
.setNoScriptRval(src->noScriptRval)
|
||||
.setVersion(src->getVersion());
|
||||
JSScript *dst = JSScript::Create(cx, enclosingScope, src->savedCallerFun,
|
||||
RootedScript dst(cx, JSScript::Create(cx, enclosingScope, src->savedCallerFun,
|
||||
options, src->staticLevel,
|
||||
src->scriptSource(), src->sourceStart, src->sourceEnd);
|
||||
src->scriptSource(), src->sourceStart, src->sourceEnd));
|
||||
if (!dst) {
|
||||
js_free(data);
|
||||
return NULL;
|
||||
@ -2421,7 +2424,7 @@ JSScript::destroyBreakpointSite(FreeOp *fop, jsbytecode *pc)
|
||||
}
|
||||
|
||||
void
|
||||
JSScript::clearBreakpointsIn(FreeOp *fop, js::Debugger *dbg, JSObject *handler)
|
||||
JSScript::clearBreakpointsIn(FreeOp *fop, js::Debugger *dbg, RawObject handler)
|
||||
{
|
||||
if (!hasAnyBreakpointsOrStepMode())
|
||||
return;
|
||||
@ -2536,10 +2539,8 @@ JSScript::setNeedsArgsObj(bool needsArgsObj)
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
JSScript::argumentsOptimizationFailed(JSContext *cx, JSScript *script_)
|
||||
JSScript::argumentsOptimizationFailed(JSContext *cx, HandleScript script)
|
||||
{
|
||||
Rooted<JSScript*> script(cx, script_);
|
||||
|
||||
JS_ASSERT(script->analyzedArgsUsage());
|
||||
JS_ASSERT(script->argumentsHasVarBinding());
|
||||
JS_ASSERT(!script->isGenerator);
|
||||
|
@ -531,7 +531,7 @@ struct JSScript : public js::gc::Cell
|
||||
bool analyzedArgsUsage() const { return !needsArgsAnalysis_; }
|
||||
bool needsArgsObj() const { JS_ASSERT(analyzedArgsUsage()); return needsArgsObj_; }
|
||||
void setNeedsArgsObj(bool needsArgsObj);
|
||||
static bool argumentsOptimizationFailed(JSContext *cx, JSScript *script);
|
||||
static bool argumentsOptimizationFailed(JSContext *cx, js::HandleScript script);
|
||||
|
||||
/*
|
||||
* Arguments access (via JSOP_*ARG* opcodes) must access the canonical
|
||||
@ -848,7 +848,7 @@ struct JSScript : public js::gc::Cell
|
||||
|
||||
void destroyBreakpointSite(js::FreeOp *fop, jsbytecode *pc);
|
||||
|
||||
void clearBreakpointsIn(js::FreeOp *fop, js::Debugger *dbg, JSObject *handler);
|
||||
void clearBreakpointsIn(js::FreeOp *fop, js::Debugger *dbg, js::RawObject handler);
|
||||
void clearTraps(js::FreeOp *fop);
|
||||
|
||||
void markTrapClosures(JSTracer *trc);
|
||||
@ -1159,7 +1159,7 @@ struct SourceCompressionToken
|
||||
};
|
||||
|
||||
extern void
|
||||
CallDestroyScriptHook(FreeOp *fop, JSScript *script);
|
||||
CallDestroyScriptHook(FreeOp *fop, js::RawScript script);
|
||||
|
||||
extern const char *
|
||||
SaveScriptFilename(JSContext *cx, const char *filename);
|
||||
@ -1210,18 +1210,18 @@ struct ScriptAndCounts
|
||||
} /* namespace js */
|
||||
|
||||
extern jssrcnote *
|
||||
js_GetSrcNote(JSContext *cx, JSScript *script, jsbytecode *pc);
|
||||
js_GetSrcNote(JSContext *cx, js::RawScript script, jsbytecode *pc);
|
||||
|
||||
extern jsbytecode *
|
||||
js_LineNumberToPC(JSScript *script, unsigned lineno);
|
||||
js_LineNumberToPC(js::RawScript script, unsigned lineno);
|
||||
|
||||
extern JS_FRIEND_API(unsigned)
|
||||
js_GetScriptLineExtent(JSScript *script);
|
||||
js_GetScriptLineExtent(js::RawScript script);
|
||||
|
||||
namespace js {
|
||||
|
||||
extern unsigned
|
||||
PCToLineNumber(JSScript *script, jsbytecode *pc, unsigned *columnp = NULL);
|
||||
PCToLineNumber(js::RawScript script, jsbytecode *pc, unsigned *columnp = NULL);
|
||||
|
||||
extern unsigned
|
||||
PCToLineNumber(unsigned startLine, jssrcnote *notes, jsbytecode *code, jsbytecode *pc,
|
||||
|
@ -680,7 +680,7 @@ js::XDRScriptRegExpObject(XDRState<mode> *xdr, HeapPtrObject *objp)
|
||||
source = reobj.getSource();
|
||||
flagsword = reobj.getFlags();
|
||||
}
|
||||
if (!XDRAtom(xdr, source.address()) || !xdr->codeUint32(&flagsword))
|
||||
if (!XDRAtom(xdr, &source) || !xdr->codeUint32(&flagsword))
|
||||
return false;
|
||||
if (mode == XDR_DECODE) {
|
||||
RegExpFlag flags = RegExpFlag(flagsword);
|
||||
|
@ -741,7 +741,7 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, HandleObject enclosingScope, Handl
|
||||
* properties to XDR, stored as id/shortid pairs.
|
||||
*/
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
JSAtom *atom;
|
||||
RootedAtom atom(cx);
|
||||
if (!XDRAtom(xdr, &atom))
|
||||
return false;
|
||||
|
||||
@ -786,10 +786,9 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, HandleObject enclosingScope, Handl
|
||||
JS_ASSERT(JSID_IS_ATOM(propid) || JSID_IS_INT(propid));
|
||||
|
||||
/* The empty string indicates an int id. */
|
||||
JSAtom *atom = JSID_IS_ATOM(propid)
|
||||
RootedAtom atom(cx, JSID_IS_ATOM(propid)
|
||||
? JSID_TO_ATOM(propid)
|
||||
: cx->runtime->emptyString;
|
||||
|
||||
: cx->runtime->emptyString);
|
||||
if (!XDRAtom(xdr, &atom))
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user