mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 739512: Patch 10: add JSScripts::hasConsts() et al. r=dvander.
This commit is contained in:
parent
f6ceffe212
commit
0449d38c5c
@ -112,7 +112,7 @@ DefineGlobals(JSContext *cx, GlobalScope &globalScope, JSScript* script)
|
|||||||
JSScript *outer = worklist.back();
|
JSScript *outer = worklist.back();
|
||||||
worklist.popBack();
|
worklist.popBack();
|
||||||
|
|
||||||
if (JSScript::isValidOffset(outer->objectsOffset)) {
|
if (outer->hasObjects()) {
|
||||||
JSObjectArray *arr = outer->objects();
|
JSObjectArray *arr = outer->objects();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -132,16 +132,14 @@ DefineGlobals(JSContext *cx, GlobalScope &globalScope, JSScript* script)
|
|||||||
outer->isOuterFunction = true;
|
outer->isOuterFunction = true;
|
||||||
inner->isInnerFunction = true;
|
inner->isInnerFunction = true;
|
||||||
}
|
}
|
||||||
if (!JSScript::isValidOffset(inner->globalsOffset) &&
|
if (!inner->hasGlobals() && !inner->hasObjects())
|
||||||
!JSScript::isValidOffset(inner->objectsOffset)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (!worklist.append(inner))
|
if (!worklist.append(inner))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JSScript::isValidOffset(outer->globalsOffset))
|
if (!outer->hasGlobals())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GlobalSlotArray *globalUses = outer->globals();
|
GlobalSlotArray *globalUses = outer->globals();
|
||||||
|
@ -1017,7 +1017,7 @@ JS_GetScriptTotalSize(JSContext *cx, JSScript *script)
|
|||||||
continue;
|
continue;
|
||||||
nbytes += (sn - notes + 1) * sizeof *sn;
|
nbytes += (sn - notes + 1) * sizeof *sn;
|
||||||
|
|
||||||
if (JSScript::isValidOffset(script->objectsOffset)) {
|
if (script->hasObjects()) {
|
||||||
objarray = script->objects();
|
objarray = script->objects();
|
||||||
size_t i = objarray->length;
|
size_t i = objarray->length;
|
||||||
nbytes += sizeof *objarray + i * sizeof objarray->vector[0];
|
nbytes += sizeof *objarray + i * sizeof objarray->vector[0];
|
||||||
@ -1026,7 +1026,7 @@ JS_GetScriptTotalSize(JSContext *cx, JSScript *script)
|
|||||||
} while (i != 0);
|
} while (i != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSScript::isValidOffset(script->regexpsOffset)) {
|
if (script->hasRegexps()) {
|
||||||
objarray = script->regexps();
|
objarray = script->regexps();
|
||||||
size_t i = objarray->length;
|
size_t i = objarray->length;
|
||||||
nbytes += sizeof *objarray + i * sizeof objarray->vector[0];
|
nbytes += sizeof *objarray + i * sizeof objarray->vector[0];
|
||||||
@ -1035,7 +1035,7 @@ JS_GetScriptTotalSize(JSContext *cx, JSScript *script)
|
|||||||
} while (i != 0);
|
} while (i != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSScript::isValidOffset(script->trynotesOffset)) {
|
if (script->hasTrynotes()) {
|
||||||
nbytes += sizeof(JSTryNoteArray) +
|
nbytes += sizeof(JSTryNoteArray) +
|
||||||
script->trynotes()->length * sizeof(JSTryNote);
|
script->trynotes()->length * sizeof(JSTryNote);
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ TryNoteIter::TryNoteIter(const FrameRegs ®s)
|
|||||||
script(regs.fp()->script()),
|
script(regs.fp()->script()),
|
||||||
pcOffset(regs.pc - script->main())
|
pcOffset(regs.pc - script->main())
|
||||||
{
|
{
|
||||||
if (JSScript::isValidOffset(script->trynotesOffset)) {
|
if (script->hasTrynotes()) {
|
||||||
tn = script->trynotes()->vector;
|
tn = script->trynotes()->vector;
|
||||||
tnEnd = tn + script->trynotes()->length;
|
tnEnd = tn + script->trynotes()->length;
|
||||||
} else {
|
} else {
|
||||||
|
@ -817,7 +817,7 @@ EvalCacheLookup(JSContext *cx, JSLinearString *str, StackFrame *caller, unsigned
|
|||||||
*/
|
*/
|
||||||
JS_ASSERT(script->objects()->length >= 1);
|
JS_ASSERT(script->objects()->length >= 1);
|
||||||
if (script->objects()->length == 1 &&
|
if (script->objects()->length == 1 &&
|
||||||
!JSScript::isValidOffset(script->regexpsOffset)) {
|
!script->hasRegexps()) {
|
||||||
JS_ASSERT(staticLevel == script->staticLevel);
|
JS_ASSERT(staticLevel == script->staticLevel);
|
||||||
*scriptp = script->evalHashLink();
|
*scriptp = script->evalHashLink();
|
||||||
script->evalHashLink() = NULL;
|
script->evalHashLink() = NULL;
|
||||||
|
@ -1822,7 +1822,7 @@ GetLocal(SprintStack *ss, int i)
|
|||||||
* not in a block. In either case, return GetStr(ss, i).
|
* not in a block. In either case, return GetStr(ss, i).
|
||||||
*/
|
*/
|
||||||
JSScript *script = ss->printer->script;
|
JSScript *script = ss->printer->script;
|
||||||
if (!JSScript::isValidOffset(script->objectsOffset))
|
if (!script->hasObjects())
|
||||||
return GetStr(ss, i);
|
return GetStr(ss, i);
|
||||||
|
|
||||||
// In case of a let variable, the stack points to a JSOP_ENTERBLOCK opcode.
|
// In case of a let variable, the stack points to a JSOP_ENTERBLOCK opcode.
|
||||||
|
@ -428,7 +428,7 @@ js::XDRScript(XDRState<mode> *xdr, JSScript **scriptp, JSScript *parentScript)
|
|||||||
JS_ASSERT_IF(parentScript, parentScript->compartment() == script->compartment());
|
JS_ASSERT_IF(parentScript, parentScript->compartment() == script->compartment());
|
||||||
|
|
||||||
/* Should not XDR scripts optimized for a single global object. */
|
/* Should not XDR scripts optimized for a single global object. */
|
||||||
JS_ASSERT(!JSScript::isValidOffset(script->globalsOffset));
|
JS_ASSERT(!script->hasGlobals());
|
||||||
|
|
||||||
nargs = script->bindings.numArgs();
|
nargs = script->bindings.numArgs();
|
||||||
nvars = script->bindings.numVars();
|
nvars = script->bindings.numVars();
|
||||||
@ -535,13 +535,13 @@ js::XDRScript(XDRState<mode> *xdr, JSScript **scriptp, JSScript *parentScript)
|
|||||||
notes = script->notes();
|
notes = script->notes();
|
||||||
nsrcnotes = script->numNotes();
|
nsrcnotes = script->numNotes();
|
||||||
|
|
||||||
if (JSScript::isValidOffset(script->constsOffset))
|
if (script->hasConsts())
|
||||||
nconsts = script->consts()->length;
|
nconsts = script->consts()->length;
|
||||||
if (JSScript::isValidOffset(script->objectsOffset))
|
if (script->hasObjects())
|
||||||
nobjects = script->objects()->length;
|
nobjects = script->objects()->length;
|
||||||
if (JSScript::isValidOffset(script->regexpsOffset))
|
if (script->hasRegexps())
|
||||||
nregexps = script->regexps()->length;
|
nregexps = script->regexps()->length;
|
||||||
if (JSScript::isValidOffset(script->trynotesOffset))
|
if (script->hasTrynotes())
|
||||||
ntrynotes = script->trynotes()->length;
|
ntrynotes = script->trynotes()->length;
|
||||||
/* no globals when encoding; see assertion above */
|
/* no globals when encoding; see assertion above */
|
||||||
nClosedArgs = script->numClosedArgs();
|
nClosedArgs = script->numClosedArgs();
|
||||||
@ -1993,17 +1993,17 @@ JSScript::markChildren(JSTracer *trc)
|
|||||||
MarkString(trc, &atoms[i], "atom");
|
MarkString(trc, &atoms[i], "atom");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSScript::isValidOffset(objectsOffset)) {
|
if (hasObjects()) {
|
||||||
JSObjectArray *objarray = objects();
|
JSObjectArray *objarray = objects();
|
||||||
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
|
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSScript::isValidOffset(regexpsOffset)) {
|
if (hasRegexps()) {
|
||||||
JSObjectArray *objarray = regexps();
|
JSObjectArray *objarray = regexps();
|
||||||
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
|
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSScript::isValidOffset(constsOffset)) {
|
if (hasConsts()) {
|
||||||
JSConstArray *constarray = consts();
|
JSConstArray *constarray = consts();
|
||||||
MarkValueRange(trc, constarray->length, constarray->vector, "consts");
|
MarkValueRange(trc, constarray->length, constarray->vector, "consts");
|
||||||
}
|
}
|
||||||
|
@ -736,47 +736,55 @@ struct JSScript : public js::gc::Cell
|
|||||||
static const uint8_t INVALID_OFFSET = 0xFF;
|
static const uint8_t INVALID_OFFSET = 0xFF;
|
||||||
static bool isValidOffset(uint8_t offset) { return offset != INVALID_OFFSET; }
|
static bool isValidOffset(uint8_t offset) { return offset != INVALID_OFFSET; }
|
||||||
|
|
||||||
|
bool hasConsts() { return isValidOffset(constsOffset); }
|
||||||
|
bool hasObjects() { return isValidOffset(objectsOffset); }
|
||||||
|
bool hasRegexps() { return isValidOffset(regexpsOffset); }
|
||||||
|
bool hasTrynotes() { return isValidOffset(trynotesOffset); }
|
||||||
|
bool hasGlobals() { return isValidOffset(globalsOffset); }
|
||||||
|
bool hasClosedArgs() { return isValidOffset(closedArgsOffset); }
|
||||||
|
bool hasClosedVars() { return isValidOffset(closedVarsOffset); }
|
||||||
|
|
||||||
JSConstArray *consts() {
|
JSConstArray *consts() {
|
||||||
JS_ASSERT(isValidOffset(constsOffset));
|
JS_ASSERT(hasConsts());
|
||||||
return reinterpret_cast<JSConstArray *>(data + constsOffset);
|
return reinterpret_cast<JSConstArray *>(data + constsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObjectArray *objects() {
|
JSObjectArray *objects() {
|
||||||
JS_ASSERT(isValidOffset(objectsOffset));
|
JS_ASSERT(hasObjects());
|
||||||
return reinterpret_cast<JSObjectArray *>(data + objectsOffset);
|
return reinterpret_cast<JSObjectArray *>(data + objectsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObjectArray *regexps() {
|
JSObjectArray *regexps() {
|
||||||
JS_ASSERT(isValidOffset(regexpsOffset));
|
JS_ASSERT(hasRegexps());
|
||||||
return reinterpret_cast<JSObjectArray *>(data + regexpsOffset);
|
return reinterpret_cast<JSObjectArray *>(data + regexpsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSTryNoteArray *trynotes() {
|
JSTryNoteArray *trynotes() {
|
||||||
JS_ASSERT(isValidOffset(trynotesOffset));
|
JS_ASSERT(hasTrynotes());
|
||||||
return reinterpret_cast<JSTryNoteArray *>(data + trynotesOffset);
|
return reinterpret_cast<JSTryNoteArray *>(data + trynotesOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
js::GlobalSlotArray *globals() {
|
js::GlobalSlotArray *globals() {
|
||||||
JS_ASSERT(isValidOffset(globalsOffset));
|
JS_ASSERT(hasGlobals());
|
||||||
return reinterpret_cast<js::GlobalSlotArray *>(data + globalsOffset);
|
return reinterpret_cast<js::GlobalSlotArray *>(data + globalsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
js::ClosedSlotArray *closedArgs() {
|
js::ClosedSlotArray *closedArgs() {
|
||||||
JS_ASSERT(isValidOffset(closedArgsOffset));
|
JS_ASSERT(hasClosedArgs());
|
||||||
return reinterpret_cast<js::ClosedSlotArray *>(data + closedArgsOffset);
|
return reinterpret_cast<js::ClosedSlotArray *>(data + closedArgsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
js::ClosedSlotArray *closedVars() {
|
js::ClosedSlotArray *closedVars() {
|
||||||
JS_ASSERT(isValidOffset(closedVarsOffset));
|
JS_ASSERT(hasClosedVars());
|
||||||
return reinterpret_cast<js::ClosedSlotArray *>(data + closedVarsOffset);
|
return reinterpret_cast<js::ClosedSlotArray *>(data + closedVarsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t numClosedArgs() {
|
uint32_t numClosedArgs() {
|
||||||
return isValidOffset(closedArgsOffset) ? closedArgs()->length : 0;
|
return hasClosedArgs() ? closedArgs()->length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t numClosedVars() {
|
uint32_t numClosedVars() {
|
||||||
return isValidOffset(closedVarsOffset) ? closedVars()->length : 0;
|
return hasClosedVars() ? closedVars()->length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
js::HeapPtrAtom &getAtom(size_t index) const {
|
js::HeapPtrAtom &getAtom(size_t index) const {
|
||||||
|
@ -78,7 +78,7 @@ FindExceptionHandler(JSContext *cx)
|
|||||||
StackFrame *fp = cx->fp();
|
StackFrame *fp = cx->fp();
|
||||||
JSScript *script = fp->script();
|
JSScript *script = fp->script();
|
||||||
|
|
||||||
if (!JSScript::isValidOffset(script->trynotesOffset))
|
if (!script->hasTrynotes())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -1661,7 +1661,7 @@ TryNotes(JSContext *cx, JSScript *script, Sprinter *sp)
|
|||||||
{
|
{
|
||||||
JSTryNote *tn, *tnlimit;
|
JSTryNote *tn, *tnlimit;
|
||||||
|
|
||||||
if (!JSScript::isValidOffset(script->trynotesOffset))
|
if (!script->hasTrynotes())
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
tn = script->trynotes()->vector;
|
tn = script->trynotes()->vector;
|
||||||
@ -1705,7 +1705,7 @@ DisassembleScript(JSContext *cx, JSScript *script, JSFunction *fun, bool lines,
|
|||||||
SrcNotes(cx, script, sp);
|
SrcNotes(cx, script, sp);
|
||||||
TryNotes(cx, script, sp);
|
TryNotes(cx, script, sp);
|
||||||
|
|
||||||
if (recursive && JSScript::isValidOffset(script->objectsOffset)) {
|
if (recursive && script->hasObjects()) {
|
||||||
JSObjectArray *objects = script->objects();
|
JSObjectArray *objects = script->objects();
|
||||||
for (unsigned i = 0; i != objects->length; ++i) {
|
for (unsigned i = 0; i != objects->length; ++i) {
|
||||||
JSObject *obj = objects->vector[i];
|
JSObject *obj = objects->vector[i];
|
||||||
|
@ -2531,7 +2531,7 @@ DebuggerScript_getChildScripts(JSContext *cx, unsigned argc, Value *vp)
|
|||||||
JSObject *result = NewDenseEmptyArray(cx);
|
JSObject *result = NewDenseEmptyArray(cx);
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
if (JSScript::isValidOffset(script->objectsOffset)) {
|
if (script->hasObjects()) {
|
||||||
/*
|
/*
|
||||||
* script->savedCallerFun indicates that this is a direct eval script
|
* script->savedCallerFun indicates that this is a direct eval script
|
||||||
* and the calling function is stored as script->objects()->vector[0].
|
* and the calling function is stored as script->objects()->vector[0].
|
||||||
|
@ -906,7 +906,7 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, JSScript *script, StaticBlockObjec
|
|||||||
uint32_t depthAndCount = 0;
|
uint32_t depthAndCount = 0;
|
||||||
if (mode == XDR_ENCODE) {
|
if (mode == XDR_ENCODE) {
|
||||||
obj = *objp;
|
obj = *objp;
|
||||||
parentId = JSScript::isValidOffset(script->objectsOffset)
|
parentId = script->hasObjects()
|
||||||
? FindObjectIndex(script->objects(), obj->enclosingBlock())
|
? FindObjectIndex(script->objects(), obj->enclosingBlock())
|
||||||
: NO_PARENT_INDEX;
|
: NO_PARENT_INDEX;
|
||||||
uint32_t depth = obj->stackDepth();
|
uint32_t depth = obj->stackDepth();
|
||||||
|
Loading…
Reference in New Issue
Block a user