mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1221144 - Part 2: Rename static scope classes away from "ScopeObject". r=shu.
This commit is contained in:
parent
8ed3439807
commit
9eabf52700
@ -293,7 +293,7 @@ EvalKernel(JSContext* cx, const CallArgs& args, EvalType evalType, AbstractFrame
|
||||
enclosing = callerScript->innermostStaticScope(pc);
|
||||
else
|
||||
enclosing = &cx->global()->lexicalScope().staticBlock();
|
||||
Rooted<StaticEvalObject*> staticScope(cx, StaticEvalObject::create(cx, enclosing));
|
||||
Rooted<StaticEvalScope*> staticScope(cx, StaticEvalScope::create(cx, enclosing));
|
||||
if (!staticScope)
|
||||
return false;
|
||||
|
||||
@ -375,7 +375,7 @@ js::DirectEvalStringFromIon(JSContext* cx,
|
||||
introducerFilename = maybeScript->scriptSource()->introducerFilename();
|
||||
|
||||
RootedObject enclosing(cx, callerScript->innermostStaticScope(pc));
|
||||
Rooted<StaticEvalObject*> staticScope(cx, StaticEvalObject::create(cx, enclosing));
|
||||
Rooted<StaticEvalScope*> staticScope(cx, StaticEvalScope::create(cx, enclosing));
|
||||
if (!staticScope)
|
||||
return false;
|
||||
|
||||
@ -458,8 +458,8 @@ js::ExecuteInGlobalAndReturnScope(JSContext* cx, HandleObject global, HandleScri
|
||||
RootedScript script(cx, scriptArg);
|
||||
Rooted<GlobalObject*> globalRoot(cx, &global->as<GlobalObject>());
|
||||
if (script->compartment() != cx->compartment()) {
|
||||
Rooted<StaticScopeObject*> staticScope(cx, &globalRoot->lexicalScope().staticBlock());
|
||||
staticScope = StaticNonSyntacticScopeObjects::create(cx, staticScope);
|
||||
Rooted<StaticScope*> staticScope(cx, &globalRoot->lexicalScope().staticBlock());
|
||||
staticScope = StaticNonSyntacticScope::create(cx, staticScope);
|
||||
if (!staticScope)
|
||||
return false;
|
||||
script = CloneGlobalScript(cx, staticScope, script);
|
||||
|
@ -51,7 +51,7 @@ class MOZ_STACK_CLASS BytecodeCompiler
|
||||
LifoAlloc* alloc,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
SourceBufferHolder& sourceBuffer,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope,
|
||||
Handle<StaticScope*> enclosingStaticScope,
|
||||
TraceLoggerTextId logId);
|
||||
|
||||
// Call setters for optional arguments.
|
||||
@ -99,7 +99,7 @@ class MOZ_STACK_CLASS BytecodeCompiler
|
||||
const ReadOnlyCompileOptions& options;
|
||||
SourceBufferHolder& sourceBuffer;
|
||||
|
||||
Rooted<StaticScopeObject*> enclosingStaticScope;
|
||||
Rooted<StaticScope*> enclosingStaticScope;
|
||||
bool sourceArgumentsNotIncluded;
|
||||
|
||||
RootedScriptSource sourceObject;
|
||||
@ -131,7 +131,7 @@ BytecodeCompiler::BytecodeCompiler(ExclusiveContext* cx,
|
||||
LifoAlloc* alloc,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
SourceBufferHolder& sourceBuffer,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope,
|
||||
Handle<StaticScope*> enclosingStaticScope,
|
||||
TraceLoggerTextId logId)
|
||||
: traceLogger(cx, logId, options),
|
||||
keepAtoms(cx->perThreadData),
|
||||
@ -278,7 +278,7 @@ BytecodeCompiler::createEmitter(SharedContext* sharedContext, HandleScript evalC
|
||||
bool
|
||||
BytecodeCompiler::isEvalCompilationUnit()
|
||||
{
|
||||
return enclosingStaticScope->is<StaticEvalObject>();
|
||||
return enclosingStaticScope->is<StaticEvalScope>();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -286,7 +286,7 @@ BytecodeCompiler::isNonGlobalEvalCompilationUnit()
|
||||
{
|
||||
if (!isEvalCompilationUnit())
|
||||
return false;
|
||||
StaticEvalObject& eval = enclosingStaticScope->as<StaticEvalObject>();
|
||||
StaticEvalScope& eval = enclosingStaticScope->as<StaticEvalScope>();
|
||||
JSObject* enclosing = eval.enclosingScopeForStaticScopeIter();
|
||||
return !IsStaticGlobalLexicalScope(enclosing);
|
||||
}
|
||||
@ -294,7 +294,7 @@ BytecodeCompiler::isNonGlobalEvalCompilationUnit()
|
||||
bool
|
||||
BytecodeCompiler::isNonSyntacticCompilationUnit()
|
||||
{
|
||||
return enclosingStaticScope->is<StaticNonSyntacticScopeObjects>();
|
||||
return enclosingStaticScope->is<StaticNonSyntacticScope>();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -712,7 +712,7 @@ frontend::CreateScriptSourceObject(ExclusiveContext* cx, const ReadOnlyCompileOp
|
||||
|
||||
JSScript*
|
||||
frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject scopeChain,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope,
|
||||
Handle<StaticScope*> enclosingStaticScope,
|
||||
HandleScript evalCaller,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
SourceBufferHolder& srcBuf,
|
||||
@ -769,7 +769,7 @@ frontend::CompileModule(JSContext* cx, HandleObject obj,
|
||||
options.maybeMakeStrictMode(true); // ES6 10.2.1 Module code is always strict mode code.
|
||||
options.setIsRunOnce(true);
|
||||
|
||||
Rooted<StaticScopeObject*> staticScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> staticScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
BytecodeCompiler compiler(cx, &cx->tempLifoAlloc(), options, srcBuf, staticScope,
|
||||
TraceLogger_ParserCompileModule);
|
||||
return compiler.compileModule();
|
||||
@ -841,7 +841,7 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
|
||||
static bool
|
||||
CompileFunctionBody(JSContext* cx, MutableHandleFunction fun, const ReadOnlyCompileOptions& options,
|
||||
Handle<PropertyNameVector> formals, SourceBufferHolder& srcBuf,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope, GeneratorKind generatorKind)
|
||||
Handle<StaticScope*> enclosingStaticScope, GeneratorKind generatorKind)
|
||||
{
|
||||
MOZ_ASSERT(!options.isRunOnce);
|
||||
|
||||
@ -858,7 +858,7 @@ bool
|
||||
frontend::CompileFunctionBody(JSContext* cx, MutableHandleFunction fun,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope)
|
||||
Handle<StaticScope*> enclosingStaticScope)
|
||||
{
|
||||
return CompileFunctionBody(cx, fun, options, formals, srcBuf,
|
||||
enclosingStaticScope, NotGenerator);
|
||||
@ -869,7 +869,7 @@ frontend::CompileFunctionBody(JSContext* cx, MutableHandleFunction fun,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf)
|
||||
{
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
return CompileFunctionBody(cx, fun, options, formals, srcBuf, staticLexical, NotGenerator);
|
||||
}
|
||||
|
||||
@ -880,6 +880,6 @@ frontend::CompileStarGeneratorBody(JSContext* cx, MutableHandleFunction fun,
|
||||
Handle<PropertyNameVector> formals,
|
||||
JS::SourceBufferHolder& srcBuf)
|
||||
{
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
return CompileFunctionBody(cx, fun, options, formals, srcBuf, staticLexical, StarGenerator);
|
||||
}
|
||||
|
@ -19,14 +19,14 @@ class LazyScript;
|
||||
class LifoAlloc;
|
||||
class ModuleObject;
|
||||
class ScriptSourceObject;
|
||||
class StaticScopeObject;
|
||||
class StaticScope;
|
||||
struct SourceCompressionTask;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
JSScript*
|
||||
CompileScript(ExclusiveContext* cx, LifoAlloc* alloc,
|
||||
HandleObject scopeChain, Handle<StaticScopeObject*> enclosingStaticScope,
|
||||
HandleObject scopeChain, Handle<StaticScope*> enclosingStaticScope,
|
||||
HandleScript evalCaller, const ReadOnlyCompileOptions& options,
|
||||
SourceBufferHolder& srcBuf, JSString* source_ = nullptr,
|
||||
SourceCompressionTask* extraSct = nullptr,
|
||||
@ -40,14 +40,14 @@ bool
|
||||
CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length);
|
||||
|
||||
/*
|
||||
* enclosingStaticScope is a static enclosing scope (e.g. a StaticWithObject).
|
||||
* enclosingStaticScope is a static enclosing scope (e.g. a StaticWithScope).
|
||||
* Must be null if the enclosing scope is a global.
|
||||
*/
|
||||
bool
|
||||
CompileFunctionBody(JSContext* cx, MutableHandleFunction fun,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope);
|
||||
Handle<StaticScope*> enclosingStaticScope);
|
||||
|
||||
// As above, but defaults to the global lexical scope as the enclosing static
|
||||
// scope.
|
||||
|
@ -633,7 +633,7 @@ NonLocalExitScope::prepareForNonLocalJump(StmtInfoBCE* toStmt)
|
||||
}
|
||||
|
||||
if (stmt->isBlockScope) {
|
||||
StaticBlockObject& blockObj = stmt->staticBlock();
|
||||
StaticBlockScope& blockObj = stmt->staticBlock();
|
||||
if (blockObj.needsClone()) {
|
||||
if (!bce->emit1(JSOP_POPBLOCKSCOPE))
|
||||
return false;
|
||||
@ -743,7 +743,7 @@ BytecodeEmitter::innermostStaticScope() const
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool
|
||||
AllLocalsAliased(StaticBlockObject& obj)
|
||||
AllLocalsAliased(StaticBlockScope& obj)
|
||||
{
|
||||
for (unsigned i = 0; i < obj.numVariables(); i++)
|
||||
if (!obj.isAliased(i))
|
||||
@ -753,7 +753,7 @@ AllLocalsAliased(StaticBlockObject& obj)
|
||||
#endif
|
||||
|
||||
bool
|
||||
BytecodeEmitter::computeAliasedSlots(Handle<StaticBlockObject*> blockObj)
|
||||
BytecodeEmitter::computeAliasedSlots(Handle<StaticBlockScope*> blockObj)
|
||||
{
|
||||
uint32_t numAliased = script->bindings.numAliasedBodyLevelLocals();
|
||||
|
||||
@ -795,7 +795,7 @@ BytecodeEmitter::computeAliasedSlots(Handle<StaticBlockObject*> blockObj)
|
||||
}
|
||||
|
||||
void
|
||||
BytecodeEmitter::computeLocalOffset(Handle<StaticBlockObject*> blockObj)
|
||||
BytecodeEmitter::computeLocalOffset(Handle<StaticBlockScope*> blockObj)
|
||||
{
|
||||
unsigned nbodyfixed = !sc->isGlobalContext()
|
||||
? script->bindings.numUnaliasedBodyLevelLocals()
|
||||
@ -803,10 +803,10 @@ BytecodeEmitter::computeLocalOffset(Handle<StaticBlockObject*> blockObj)
|
||||
unsigned localOffset = nbodyfixed;
|
||||
|
||||
if (StmtInfoBCE* stmt = innermostScopeStmt()) {
|
||||
Rooted<NestedStaticScopeObject*> outer(cx, stmt->staticScope);
|
||||
Rooted<NestedStaticScope*> outer(cx, stmt->staticScope);
|
||||
for (; outer; outer = outer->enclosingNestedScope()) {
|
||||
if (outer->is<StaticBlockObject>() && !IsStaticGlobalLexicalScope(outer)) {
|
||||
StaticBlockObject& outerBlock = outer->as<StaticBlockObject>();
|
||||
if (outer->is<StaticBlockScope>() && !IsStaticGlobalLexicalScope(outer)) {
|
||||
StaticBlockScope& outerBlock = outer->as<StaticBlockScope>();
|
||||
localOffset = outerBlock.localOffset() + outerBlock.numVariables();
|
||||
break;
|
||||
}
|
||||
@ -839,7 +839,7 @@ BytecodeEmitter::computeLocalOffset(Handle<StaticBlockObject*> blockObj)
|
||||
// To help debuggers, the bytecode emitter arranges to record the PC ranges
|
||||
// comprehended by a nested scope, and ultimately attach them to the JSScript.
|
||||
// An element in the "block scope array" specifies the PC range, and links to a
|
||||
// NestedStaticScopeObject in the object list of the script. That scope object
|
||||
// NestedStaticScope in the object list of the script. That scope object
|
||||
// is linked to the previous link in the static scope chain, if any. The
|
||||
// static scope chain at any pre-retire PC can be retrieved using
|
||||
// JSScript::getStaticScope(jsbytecode* pc).
|
||||
@ -874,12 +874,12 @@ BytecodeEmitter::computeLocalOffset(Handle<StaticBlockObject*> blockObj)
|
||||
bool
|
||||
BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType stmtType)
|
||||
{
|
||||
Rooted<NestedStaticScopeObject*> scopeObj(cx, &objbox->object->as<NestedStaticScopeObject>());
|
||||
Rooted<NestedStaticScope*> scopeObj(cx, &objbox->object->as<NestedStaticScope>());
|
||||
uint32_t scopeObjectIndex = objectList.add(objbox);
|
||||
|
||||
switch (stmtType) {
|
||||
case StmtType::BLOCK: {
|
||||
Rooted<StaticBlockObject*> blockObj(cx, &scopeObj->as<StaticBlockObject>());
|
||||
Rooted<StaticBlockScope*> blockObj(cx, &scopeObj->as<StaticBlockScope>());
|
||||
|
||||
computeLocalOffset(blockObj);
|
||||
|
||||
@ -892,14 +892,14 @@ BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType
|
||||
}
|
||||
|
||||
// Non-global block scopes are non-extensible. At this point the
|
||||
// Parser has added all bindings to the StaticBlockObject, so we make
|
||||
// Parser has added all bindings to the StaticBlockScope, so we make
|
||||
// it non-extensible.
|
||||
if (!blockObj->makeNonExtensible(cx))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case StmtType::WITH:
|
||||
MOZ_ASSERT(scopeObj->is<StaticWithObject>());
|
||||
MOZ_ASSERT(scopeObj->is<StaticWithScope>());
|
||||
if (!emitInternedObjectOp(scopeObjectIndex, JSOP_ENTERWITH))
|
||||
return false;
|
||||
break;
|
||||
@ -948,15 +948,15 @@ BytecodeEmitter::leaveNestedScope(StmtInfoBCE* stmt)
|
||||
MOZ_ASSERT(blockScopeList.list[blockScopeIndex].length == 0);
|
||||
uint32_t blockObjIndex = blockScopeList.list[blockScopeIndex].index;
|
||||
ObjectBox* blockObjBox = objectList.find(blockObjIndex);
|
||||
NestedStaticScopeObject* staticScope = &blockObjBox->object->as<NestedStaticScopeObject>();
|
||||
NestedStaticScope* staticScope = &blockObjBox->object->as<NestedStaticScope>();
|
||||
MOZ_ASSERT(stmt->staticScope == staticScope);
|
||||
MOZ_ASSERT_IF(!stmt->isBlockScope, staticScope->is<StaticWithObject>());
|
||||
MOZ_ASSERT_IF(!stmt->isBlockScope, staticScope->is<StaticWithScope>());
|
||||
#endif
|
||||
|
||||
popStatement();
|
||||
|
||||
if (stmt->isBlockScope) {
|
||||
if (stmt->staticScope->as<StaticBlockObject>().needsClone()) {
|
||||
if (stmt->staticScope->as<StaticBlockScope>().needsClone()) {
|
||||
if (!emit1(JSOP_POPBLOCKSCOPE))
|
||||
return false;
|
||||
} else {
|
||||
@ -1359,11 +1359,11 @@ BytecodeEmitter::atBodyLevel(StmtInfoBCE* stmt) const
|
||||
// 'eval' and non-syntactic scripts are always under an invisible lexical
|
||||
// scope, but since it is not syntactic, it should still be considered at
|
||||
// body level.
|
||||
if (sc->staticScope()->is<StaticEvalObject>()) {
|
||||
if (sc->staticScope()->is<StaticEvalScope>()) {
|
||||
bool bl = !stmt->enclosing;
|
||||
MOZ_ASSERT_IF(bl, stmt->type == StmtType::BLOCK);
|
||||
MOZ_ASSERT_IF(bl, stmt->staticScope
|
||||
->as<StaticBlockObject>()
|
||||
->as<StaticBlockScope>()
|
||||
.enclosingStaticScope() == sc->staticScope());
|
||||
return bl;
|
||||
}
|
||||
@ -3017,7 +3017,7 @@ BytecodeEmitter::pushInitialConstants(JSOp op, unsigned n)
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::initializeBlockScopedLocalsFromStack(Handle<StaticBlockObject*> blockObj)
|
||||
BytecodeEmitter::initializeBlockScopedLocalsFromStack(Handle<StaticBlockScope*> blockObj)
|
||||
{
|
||||
for (unsigned i = blockObj->numVariables(); i > 0; --i) {
|
||||
if (blockObj->isAliased(i - 1)) {
|
||||
@ -3048,7 +3048,7 @@ BytecodeEmitter::enterBlockScope(StmtInfoBCE* stmtInfo, ObjectBox* objbox, JSOp
|
||||
{
|
||||
// This is so terrible. The eval body-level lexical scope needs to be
|
||||
// emitted in the prologue so DEFFUN can pick up the right scope chain.
|
||||
bool isEvalBodyLexicalScope = sc->staticScope()->is<StaticEvalObject>() &&
|
||||
bool isEvalBodyLexicalScope = sc->staticScope()->is<StaticEvalScope>() &&
|
||||
!innermostStmt();
|
||||
if (isEvalBodyLexicalScope) {
|
||||
MOZ_ASSERT(code().length() == 0);
|
||||
@ -3062,7 +3062,7 @@ BytecodeEmitter::enterBlockScope(StmtInfoBCE* stmtInfo, ObjectBox* objbox, JSOp
|
||||
// JS_UNINITIALIZED_LEXICAL magic value depends on the context. The
|
||||
// current way we emit for-in and for-of heads means its let bindings will
|
||||
// always be initialized, so we can initialize them to undefined.
|
||||
Rooted<StaticBlockObject*> blockObj(cx, &objbox->object->as<StaticBlockObject>());
|
||||
Rooted<StaticBlockScope*> blockObj(cx, &objbox->object->as<StaticBlockScope>());
|
||||
if (!pushInitialConstants(initialValueOp, blockObj->numVariables() - alreadyPushed))
|
||||
return false;
|
||||
|
||||
@ -5924,7 +5924,7 @@ BytecodeEmitter::emitCStyleFor(ParseNode* pn)
|
||||
MOZ_ASSERT(enclosing->type == StmtType::BLOCK);
|
||||
MOZ_ASSERT(enclosing->isBlockScope);
|
||||
|
||||
if (enclosing->staticScope->as<StaticBlockObject>().needsClone()) {
|
||||
if (enclosing->staticScope->as<StaticBlockScope>().needsClone()) {
|
||||
if (!emit1(JSOP_FRESHENBLOCKSCOPE))
|
||||
return false;
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ struct BytecodeEmitter
|
||||
bool enterBlockScope(StmtInfoBCE* stmtInfo, ObjectBox* objbox, JSOp initialValueOp,
|
||||
unsigned alreadyPushed = 0);
|
||||
|
||||
bool computeAliasedSlots(Handle<StaticBlockObject*> blockObj);
|
||||
bool computeAliasedSlots(Handle<StaticBlockScope*> blockObj);
|
||||
|
||||
bool lookupAliasedName(HandleScript script, PropertyName* name, uint32_t* pslot,
|
||||
ParseNode* pn = nullptr);
|
||||
@ -396,7 +396,7 @@ struct BytecodeEmitter
|
||||
// fixed part of a stack frame. Outside a function, there are no fixed vars,
|
||||
// but block-scoped locals still form part of the fixed part of a stack frame
|
||||
// and are thus addressable via GETLOCAL and friends.
|
||||
void computeLocalOffset(Handle<StaticBlockObject*> blockObj);
|
||||
void computeLocalOffset(Handle<StaticBlockScope*> blockObj);
|
||||
|
||||
bool flushPops(int* npops);
|
||||
|
||||
@ -639,7 +639,7 @@ struct BytecodeEmitter
|
||||
bool emitLexicalInitialization(ParseNode* pn, JSOp globalDefOp);
|
||||
|
||||
bool pushInitialConstants(JSOp op, unsigned n);
|
||||
bool initializeBlockScopedLocalsFromStack(Handle<StaticBlockObject*> blockObj);
|
||||
bool initializeBlockScopedLocalsFromStack(Handle<StaticBlockScope*> blockObj);
|
||||
|
||||
// Emit bytecode for the spread operator.
|
||||
//
|
||||
|
@ -304,7 +304,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
|
||||
}
|
||||
|
||||
// PNK_WITH is PN_BINARY_OBJ -- that is, PN_BINARY with (irrelevant for
|
||||
// this method's purposes) the addition of the StaticWithObject as
|
||||
// this method's purposes) the addition of the StaticWithScope as
|
||||
// pn_binary_obj. Both left (expression) and right (statement) are
|
||||
// non-null.
|
||||
case PNK_WITH: {
|
||||
|
@ -346,7 +346,7 @@ IsDeleteKind(ParseNodeKind kind)
|
||||
* pn_kid3: catch block statements
|
||||
* PNK_BREAK name pn_atom: label or null
|
||||
* PNK_CONTINUE name pn_atom: label or null
|
||||
* PNK_WITH binary-obj pn_left: head expr; pn_right: body; pn_binary_obj: StaticWithObject
|
||||
* PNK_WITH binary-obj pn_left: head expr; pn_right: body; pn_binary_obj: StaticWithScope
|
||||
* PNK_VAR, list pn_head: list of PNK_NAME or PNK_ASSIGN nodes
|
||||
* PNK_CONST each name node has either
|
||||
* pn_used: false
|
||||
|
@ -71,10 +71,10 @@ JSFunction::AutoParseUsingFunctionBox::~AutoParseUsingFunctionBox()
|
||||
namespace js {
|
||||
namespace frontend {
|
||||
|
||||
typedef Rooted<StaticBlockObject*> RootedStaticBlockObject;
|
||||
typedef Handle<StaticBlockObject*> HandleStaticBlockObject;
|
||||
typedef Rooted<NestedStaticScopeObject*> RootedNestedStaticScopeObject;
|
||||
typedef Handle<NestedStaticScopeObject*> HandleNestedStaticScopeObject;
|
||||
typedef Rooted<StaticBlockScope*> RootedStaticBlockScope;
|
||||
typedef Handle<StaticBlockScope*> HandleStaticBlockScope;
|
||||
typedef Rooted<NestedStaticScope*> RootedNestedStaticScope;
|
||||
typedef Handle<NestedStaticScope*> HandleNestedStaticScope;
|
||||
|
||||
/* Read a token. Report an error and return null() if that token isn't of type tt. */
|
||||
#define MUST_MATCH_TOKEN_MOD(tt, modifier, errno) \
|
||||
@ -874,7 +874,7 @@ Parser<ParseHandler>::parse()
|
||||
* an object lock before it finishes generating bytecode into a script
|
||||
* protected from the GC by a root or a stack frame reference.
|
||||
*/
|
||||
Rooted<StaticScopeObject*> staticLexical(context, &context->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(context, &context->global()->lexicalScope().staticBlock());
|
||||
Directives directives(options().strictOption);
|
||||
GlobalSharedContext globalsc(context, staticLexical, directives,
|
||||
options().extraWarningsOption);
|
||||
@ -1486,7 +1486,7 @@ struct BindData
|
||||
struct LetData {
|
||||
explicit LetData(ExclusiveContext* cx) : blockObj(cx) {}
|
||||
VarContext varContext;
|
||||
RootedStaticBlockObject blockObj;
|
||||
RootedStaticBlockScope blockObj;
|
||||
unsigned overflow;
|
||||
};
|
||||
|
||||
@ -1494,7 +1494,7 @@ struct BindData
|
||||
: kind_(Uninitialized), nameNode_(ParseHandler::null()), letData_(cx)
|
||||
{}
|
||||
|
||||
void initLexical(VarContext varContext, JSOp op, StaticBlockObject* blockObj,
|
||||
void initLexical(VarContext varContext, JSOp op, StaticBlockScope* blockObj,
|
||||
unsigned overflow)
|
||||
{
|
||||
init(LexicalBinding, op, op == JSOP_DEFCONST, false);
|
||||
@ -1740,7 +1740,7 @@ LexicalLookup(ContextT* ct, HandleAtom atom, StmtInfoPC* stmt = nullptr)
|
||||
if (!stmt->isBlockScope)
|
||||
continue;
|
||||
|
||||
StaticBlockObject& blockObj = stmt->staticBlock();
|
||||
StaticBlockScope& blockObj = stmt->staticBlock();
|
||||
Shape* shape = blockObj.lookup(ct->sc->context, id);
|
||||
if (shape)
|
||||
return stmt;
|
||||
@ -3601,9 +3601,9 @@ Parser<FullParseHandler>::bindLexical(BindData<FullParseHandler>* data,
|
||||
return false;
|
||||
}
|
||||
|
||||
Rooted<StaticBlockObject*> blockObj(cx, data->letData().blockObj);
|
||||
Rooted<StaticBlockScope*> blockObj(cx, data->letData().blockObj);
|
||||
|
||||
uint32_t index = StaticBlockObject::LOCAL_INDEX_LIMIT;
|
||||
uint32_t index = StaticBlockScope::LOCAL_INDEX_LIMIT;
|
||||
if (blockObj) {
|
||||
// Leave the scope coordinate free on global lexicals.
|
||||
//
|
||||
@ -3618,7 +3618,7 @@ Parser<FullParseHandler>::bindLexical(BindData<FullParseHandler>* data,
|
||||
// able to parse scripts off-thread in a different compartment.
|
||||
if (!blockObj->isGlobal()) {
|
||||
index = blockObj->numVariables();
|
||||
if (index >= StaticBlockObject::LOCAL_INDEX_LIMIT) {
|
||||
if (index >= StaticBlockScope::LOCAL_INDEX_LIMIT) {
|
||||
parser->report(ParseError, false, pn, data->letData().overflow);
|
||||
return false;
|
||||
}
|
||||
@ -3663,8 +3663,8 @@ Parser<FullParseHandler>::bindLexical(BindData<FullParseHandler>* data,
|
||||
if (!blockObj->isGlobal()) {
|
||||
bool redeclared;
|
||||
RootedId id(cx, NameToId(name));
|
||||
RootedShape shape(cx, StaticBlockObject::addVar(cx, blockObj, id,
|
||||
data->isConst(), index, &redeclared));
|
||||
RootedShape shape(cx, StaticBlockScope::addVar(cx, blockObj, id,
|
||||
data->isConst(), index, &redeclared));
|
||||
if (!shape) {
|
||||
if (redeclared) {
|
||||
// The only way to be redeclared without a previous definition is if we're in a
|
||||
@ -3704,7 +3704,7 @@ Parser<SyntaxParseHandler>::bindLexical(BindData<SyntaxParseHandler>* data,
|
||||
template <typename ParseHandler, class Op>
|
||||
static inline bool
|
||||
ForEachLetDef(TokenStream& ts, ParseContext<ParseHandler>* pc,
|
||||
HandleStaticBlockObject blockObj, Op op)
|
||||
HandleStaticBlockScope blockObj, Op op)
|
||||
{
|
||||
for (Shape::Range<CanGC> r(ts.context(), blockObj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
Shape& shape = r.front();
|
||||
@ -3721,7 +3721,7 @@ ForEachLetDef(TokenStream& ts, ParseContext<ParseHandler>* pc,
|
||||
|
||||
template <typename ParseHandler>
|
||||
struct PopLetDecl {
|
||||
bool operator()(TokenStream&, ParseContext<ParseHandler>* pc, HandleStaticBlockObject,
|
||||
bool operator()(TokenStream&, ParseContext<ParseHandler>* pc, HandleStaticBlockScope,
|
||||
const Shape&, JSAtom* atom)
|
||||
{
|
||||
pc->popLetDecl(atom);
|
||||
@ -3746,7 +3746,7 @@ AccumulateBlockScopeDepth(ParseContext<ParseHandler>* pc)
|
||||
StmtInfoPC* outer = stmt->enclosing;
|
||||
|
||||
if (stmt->isBlockScope)
|
||||
innerDepth += stmt->staticScope->template as<StaticBlockObject>().numVariables();
|
||||
innerDepth += stmt->staticScope->template as<StaticBlockScope>().numVariables();
|
||||
|
||||
if (outer) {
|
||||
if (outer->innerBlockScopeDepth < innerDepth)
|
||||
@ -3770,7 +3770,7 @@ Parser<ParseHandler>::AutoPushStmtInfoPC::AutoPushStmtInfoPC(Parser<ParseHandler
|
||||
template <typename ParseHandler>
|
||||
Parser<ParseHandler>::AutoPushStmtInfoPC::AutoPushStmtInfoPC(Parser<ParseHandler>& parser,
|
||||
StmtType type,
|
||||
NestedStaticScopeObject& staticScope)
|
||||
NestedStaticScope& staticScope)
|
||||
: parser_(parser),
|
||||
stmt_(parser.context)
|
||||
{
|
||||
@ -3791,14 +3791,14 @@ Parser<ParseHandler>::AutoPushStmtInfoPC::~AutoPushStmtInfoPC()
|
||||
TokenStream& ts = parser_.tokenStream;
|
||||
|
||||
MOZ_ASSERT(pc->innermostStmt() == &stmt_);
|
||||
RootedNestedStaticScopeObject scopeObj(parser_.context, stmt_.staticScope);
|
||||
RootedNestedStaticScope scopeObj(parser_.context, stmt_.staticScope);
|
||||
|
||||
AccumulateBlockScopeDepth(pc);
|
||||
pc->stmtStack.pop();
|
||||
|
||||
if (scopeObj) {
|
||||
if (scopeObj->is<StaticBlockObject>()) {
|
||||
RootedStaticBlockObject blockObj(parser_.context, &scopeObj->as<StaticBlockObject>());
|
||||
if (scopeObj->is<StaticBlockScope>()) {
|
||||
RootedStaticBlockScope blockObj(parser_.context, &scopeObj->as<StaticBlockScope>());
|
||||
MOZ_ASSERT(!blockObj->inDictionaryMode());
|
||||
ForEachLetDef(ts, pc, blockObj, PopLetDecl<ParseHandler>());
|
||||
}
|
||||
@ -3815,7 +3815,7 @@ Parser<ParseHandler>::AutoPushStmtInfoPC::generateBlockId()
|
||||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::AutoPushStmtInfoPC::makeInnermostLexicalScope(StaticBlockObject& blockObj)
|
||||
Parser<ParseHandler>::AutoPushStmtInfoPC::makeInnermostLexicalScope(StaticBlockScope& blockObj)
|
||||
{
|
||||
MOZ_ASSERT(parser_.pc->stmtStack.innermost() == &stmt_);
|
||||
parser_.pc->stmtStack.makeInnermostLexicalScope(blockObj);
|
||||
@ -4285,7 +4285,7 @@ Parser<ParseHandler>::destructuringExprWithoutYield(YieldHandling yieldHandling,
|
||||
|
||||
template <typename ParseHandler>
|
||||
typename ParseHandler::Node
|
||||
Parser<ParseHandler>::pushLexicalScope(HandleStaticBlockObject blockObj,
|
||||
Parser<ParseHandler>::pushLexicalScope(HandleStaticBlockScope blockObj,
|
||||
AutoPushStmtInfoPC& stmt)
|
||||
{
|
||||
ObjectBox* blockbox = newObjectBox(blockObj);
|
||||
@ -4307,7 +4307,7 @@ template <typename ParseHandler>
|
||||
typename ParseHandler::Node
|
||||
Parser<ParseHandler>::pushLexicalScope(AutoPushStmtInfoPC& stmt)
|
||||
{
|
||||
RootedStaticBlockObject blockObj(context, StaticBlockObject::create(context));
|
||||
RootedStaticBlockScope blockObj(context, StaticBlockScope::create(context));
|
||||
if (!blockObj)
|
||||
return null();
|
||||
|
||||
@ -4321,7 +4321,7 @@ struct AddLetDecl
|
||||
explicit AddLetDecl(uint32_t blockid) : blockid(blockid) {}
|
||||
|
||||
bool operator()(TokenStream& ts, ParseContext<FullParseHandler>* pc,
|
||||
HandleStaticBlockObject blockObj, const Shape& shape, JSAtom*)
|
||||
HandleStaticBlockScope blockObj, const Shape& shape, JSAtom*)
|
||||
{
|
||||
ParseNode* def = (ParseNode*) blockObj->getSlot(shape.slot()).toPrivate();
|
||||
def->pn_blockid = blockid;
|
||||
@ -4332,7 +4332,7 @@ struct AddLetDecl
|
||||
|
||||
template <>
|
||||
ParseNode*
|
||||
Parser<FullParseHandler>::pushLetScope(HandleStaticBlockObject blockObj, AutoPushStmtInfoPC& stmt)
|
||||
Parser<FullParseHandler>::pushLetScope(HandleStaticBlockScope blockObj, AutoPushStmtInfoPC& stmt)
|
||||
{
|
||||
MOZ_ASSERT(blockObj);
|
||||
ParseNode* pn = pushLexicalScope(blockObj, stmt);
|
||||
@ -4350,7 +4350,7 @@ Parser<FullParseHandler>::pushLetScope(HandleStaticBlockObject blockObj, AutoPus
|
||||
|
||||
template <>
|
||||
SyntaxParseHandler::Node
|
||||
Parser<SyntaxParseHandler>::pushLetScope(HandleStaticBlockObject blockObj,
|
||||
Parser<SyntaxParseHandler>::pushLetScope(HandleStaticBlockScope blockObj,
|
||||
AutoPushStmtInfoPC& stmt)
|
||||
{
|
||||
JS_ALWAYS_FALSE(abortIfSyntaxParser());
|
||||
@ -4693,7 +4693,7 @@ template <typename ParseHandler>
|
||||
typename ParseHandler::Node
|
||||
Parser<ParseHandler>::declarationList(YieldHandling yieldHandling,
|
||||
ParseNodeKind kind,
|
||||
StaticBlockObject* blockObj /* = nullptr */,
|
||||
StaticBlockScope* blockObj /* = nullptr */,
|
||||
ParseNodeKind* forHeadKind /* = nullptr */,
|
||||
Node* forInOrOfExpression /* = nullptr */)
|
||||
{
|
||||
@ -4812,7 +4812,7 @@ Parser<FullParseHandler>::checkAndPrepareLexical(PrepareLexicalKind prepareWhat,
|
||||
MOZ_ASSERT(pc->innermostScopeStmt() == stmt);
|
||||
} else {
|
||||
/* Convert the block statement into a scope statement. */
|
||||
StaticBlockObject* blockObj = StaticBlockObject::create(context);
|
||||
StaticBlockScope* blockObj = StaticBlockScope::create(context);
|
||||
if (!blockObj)
|
||||
return false;
|
||||
blockObj->initEnclosingScopeFromParser(pc->innermostStaticScope());
|
||||
@ -4850,11 +4850,11 @@ Parser<FullParseHandler>::checkAndPrepareLexical(PrepareLexicalKind prepareWhat,
|
||||
return true;
|
||||
}
|
||||
|
||||
static StaticBlockObject*
|
||||
static StaticBlockScope*
|
||||
CurrentLexicalStaticBlock(ParseContext<FullParseHandler>* pc)
|
||||
{
|
||||
if (pc->innermostStaticScope()->is<StaticBlockObject>())
|
||||
return &pc->innermostStaticScope()->as<StaticBlockObject>();
|
||||
if (pc->innermostStaticScope()->is<StaticBlockScope>())
|
||||
return &pc->innermostStaticScope()->as<StaticBlockScope>();
|
||||
MOZ_ASSERT(pc->atBodyLevel() &&
|
||||
(!pc->sc->isGlobalContext() ||
|
||||
HasNonSyntacticStaticScopeChain(pc->innermostStaticScope())));
|
||||
@ -4864,14 +4864,14 @@ CurrentLexicalStaticBlock(ParseContext<FullParseHandler>* pc)
|
||||
template <>
|
||||
void
|
||||
Parser<SyntaxParseHandler>::assertCurrentLexicalStaticBlockIs(ParseContext<SyntaxParseHandler>* pc,
|
||||
Handle<StaticBlockObject*> blockObj)
|
||||
Handle<StaticBlockScope*> blockObj)
|
||||
{
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
Parser<FullParseHandler>::assertCurrentLexicalStaticBlockIs(ParseContext<FullParseHandler>* pc,
|
||||
Handle<StaticBlockObject*> blockObj)
|
||||
Handle<StaticBlockScope*> blockObj)
|
||||
{
|
||||
MOZ_ASSERT(CurrentLexicalStaticBlock(pc) == blockObj);
|
||||
}
|
||||
@ -5685,7 +5685,7 @@ Parser<ParseHandler>::forHeadStart(YieldHandling yieldHandling,
|
||||
ParseNodeKind* forHeadKind,
|
||||
Node* forInitialPart,
|
||||
Maybe<AutoPushStmtInfoPC>& letStmt,
|
||||
MutableHandle<StaticBlockObject*> blockObj,
|
||||
MutableHandle<StaticBlockScope*> blockObj,
|
||||
Node* forLetImpliedBlock,
|
||||
Node* forInOrOfExpression)
|
||||
{
|
||||
@ -5740,7 +5740,7 @@ Parser<ParseHandler>::forHeadStart(YieldHandling yieldHandling,
|
||||
handler.disableSyntaxParser();
|
||||
|
||||
// Set up the block chain for the lexical declaration.
|
||||
blockObj.set(StaticBlockObject::create(context));
|
||||
blockObj.set(StaticBlockScope::create(context));
|
||||
if (!blockObj)
|
||||
return false;
|
||||
blockObj->initEnclosingScopeFromParser(pc->innermostStaticScope());
|
||||
@ -5857,7 +5857,7 @@ Parser<ParseHandler>::forStatement(YieldHandling yieldHandling)
|
||||
// All three variables remain null/none if the loop is any other form.
|
||||
//
|
||||
// blockObj is the static block object for the implicit block scope.
|
||||
RootedStaticBlockObject blockObj(context);
|
||||
RootedStaticBlockScope blockObj(context);
|
||||
|
||||
// The PNK_LEXICALSCOPE node containing blockObj's ObjectBox.
|
||||
Node forLetImpliedBlock = null();
|
||||
@ -6459,7 +6459,7 @@ Parser<FullParseHandler>::withStatement(YieldHandling yieldHandling)
|
||||
return null();
|
||||
MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_WITH);
|
||||
|
||||
Rooted<StaticWithObject*> staticWith(context, StaticWithObject::create(context));
|
||||
Rooted<StaticWithScope*> staticWith(context, StaticWithScope::create(context));
|
||||
if (!staticWith)
|
||||
return null();
|
||||
|
||||
@ -6634,7 +6634,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||
* an intentional change that anticipates ECMA Ed. 4.
|
||||
*/
|
||||
data.initLexical(HoistVars, JSOP_DEFLET,
|
||||
&stmtInfo->staticScope->template as<StaticBlockObject>(),
|
||||
&stmtInfo->staticScope->template as<StaticBlockScope>(),
|
||||
JSMSG_TOO_MANY_CATCH_VARS);
|
||||
MOZ_ASSERT(data.letData().blockObj);
|
||||
|
||||
@ -8067,7 +8067,7 @@ Parser<ParseHandler>::comprehensionFor(GeneratorKind comprehensionKind)
|
||||
AutoPushStmtInfoPC stmtInfo(*this, StmtType::BLOCK);
|
||||
BindData<ParseHandler> data(context);
|
||||
|
||||
RootedStaticBlockObject blockObj(context, StaticBlockObject::create(context));
|
||||
RootedStaticBlockScope blockObj(context, StaticBlockScope::create(context));
|
||||
if (!blockObj)
|
||||
return null();
|
||||
|
||||
|
@ -307,11 +307,11 @@ struct MOZ_STACK_CLASS ParseContext : public GenericParseContext
|
||||
// 'eval' and non-syntactic scripts are always under an invisible
|
||||
// lexical scope, but since it is not syntactic, it should still be
|
||||
// considered at body level.
|
||||
if (sc->staticScope()->is<StaticEvalObject>()) {
|
||||
if (sc->staticScope()->is<StaticEvalScope>()) {
|
||||
bool bl = !stmt->enclosing;
|
||||
MOZ_ASSERT_IF(bl, stmt->type == StmtType::BLOCK);
|
||||
MOZ_ASSERT_IF(bl, stmt->staticScope
|
||||
->template as<StaticBlockObject>()
|
||||
->template as<StaticBlockScope>()
|
||||
.enclosingStaticScope() == sc->staticScope());
|
||||
return bl;
|
||||
}
|
||||
@ -389,11 +389,11 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
||||
public:
|
||||
AutoPushStmtInfoPC(Parser<ParseHandler>& parser, StmtType type);
|
||||
AutoPushStmtInfoPC(Parser<ParseHandler>& parser, StmtType type,
|
||||
NestedStaticScopeObject& staticScope);
|
||||
NestedStaticScope& staticScope);
|
||||
~AutoPushStmtInfoPC();
|
||||
|
||||
bool generateBlockId();
|
||||
bool makeInnermostLexicalScope(StaticBlockObject& blockObj);
|
||||
bool makeInnermostLexicalScope(StaticBlockScope& blockObj);
|
||||
|
||||
StmtInfoPC& operator*() { return stmt_; }
|
||||
StmtInfoPC* operator->() { return &stmt_; }
|
||||
@ -670,14 +670,14 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
||||
ParseNodeKind* forHeadKind,
|
||||
Node* forInitialPart,
|
||||
mozilla::Maybe<AutoPushStmtInfoPC>& letStmt,
|
||||
MutableHandle<StaticBlockObject*> blockObj,
|
||||
MutableHandle<StaticBlockScope*> blockObj,
|
||||
Node* forLetImpliedBlock,
|
||||
Node* forInOrOfExpression);
|
||||
bool validateForInOrOfLHSExpression(Node target);
|
||||
Node expressionAfterForInOrOf(ParseNodeKind forHeadKind, YieldHandling yieldHandling);
|
||||
|
||||
void assertCurrentLexicalStaticBlockIs(ParseContext<ParseHandler>* pc,
|
||||
Handle<StaticBlockObject*> blockObj);
|
||||
Handle<StaticBlockScope*> blockObj);
|
||||
|
||||
Node switchStatement(YieldHandling yieldHandling);
|
||||
Node continueStatement(YieldHandling yieldHandling);
|
||||
@ -717,7 +717,7 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
||||
// parsed into |*forInOrOfExpression|.
|
||||
Node declarationList(YieldHandling yieldHandling,
|
||||
ParseNodeKind kind,
|
||||
StaticBlockObject* blockObj = nullptr,
|
||||
StaticBlockScope* blockObj = nullptr,
|
||||
ParseNodeKind* forHeadKind = nullptr,
|
||||
Node* forInOrOfExpression = nullptr);
|
||||
|
||||
@ -884,8 +884,8 @@ class Parser : private JS::AutoGCRooter, public StrictModeGetter
|
||||
bool defineArg(Node funcpn, HandlePropertyName name,
|
||||
bool disallowDuplicateArgs = false, Node* duplicatedArg = nullptr);
|
||||
Node pushLexicalScope(AutoPushStmtInfoPC& stmt);
|
||||
Node pushLexicalScope(Handle<StaticBlockObject*> blockObj, AutoPushStmtInfoPC& stmt);
|
||||
Node pushLetScope(Handle<StaticBlockObject*> blockObj, AutoPushStmtInfoPC& stmt);
|
||||
Node pushLexicalScope(Handle<StaticBlockScope*> blockObj, AutoPushStmtInfoPC& stmt);
|
||||
Node pushLetScope(Handle<StaticBlockScope*> blockObj, AutoPushStmtInfoPC& stmt);
|
||||
bool noteNameUse(HandlePropertyName name, Node pn);
|
||||
Node propertyName(YieldHandling yieldHandling, Node propList,
|
||||
PropertyType* propType, MutableHandleAtom propAtom);
|
||||
|
@ -285,12 +285,11 @@ class SharedContext
|
||||
|
||||
class MOZ_STACK_CLASS GlobalSharedContext : public SharedContext
|
||||
{
|
||||
Rooted<StaticScopeObject*> staticScope_;
|
||||
Rooted<StaticScope*> staticScope_;
|
||||
|
||||
public:
|
||||
GlobalSharedContext(ExclusiveContext* cx, StaticScopeObject* staticScope,
|
||||
Directives directives, bool extraWarnings,
|
||||
JSFunction* maybeEvalCaller = nullptr)
|
||||
GlobalSharedContext(ExclusiveContext* cx, StaticScope* staticScope, Directives directives,
|
||||
bool extraWarnings, JSFunction* maybeEvalCaller = nullptr)
|
||||
: SharedContext(cx, directives, extraWarnings),
|
||||
staticScope_(cx, staticScope)
|
||||
{
|
||||
@ -531,7 +530,7 @@ struct StmtInfoBase
|
||||
RootedAtom label;
|
||||
|
||||
// Compile-time scope chain node for this scope.
|
||||
Rooted<NestedStaticScopeObject*> staticScope;
|
||||
Rooted<NestedStaticScope*> staticScope;
|
||||
|
||||
explicit StmtInfoBase(ExclusiveContext* cx)
|
||||
: isBlockScope(false), isForLetBlock(false),
|
||||
@ -555,10 +554,10 @@ struct StmtInfoBase
|
||||
type == StmtType::CATCH;
|
||||
}
|
||||
|
||||
StaticBlockObject& staticBlock() const {
|
||||
StaticBlockScope& staticBlock() const {
|
||||
MOZ_ASSERT(staticScope);
|
||||
MOZ_ASSERT(isBlockScope);
|
||||
return staticScope->as<StaticBlockObject>();
|
||||
return staticScope->as<StaticBlockScope>();
|
||||
}
|
||||
|
||||
bool isLoop() const {
|
||||
@ -605,7 +604,7 @@ class MOZ_STACK_CLASS StmtInfoStack
|
||||
innermostStmt_ = stmt;
|
||||
}
|
||||
|
||||
void pushNestedScope(StmtInfo* stmt, StmtType type, NestedStaticScopeObject& staticScope) {
|
||||
void pushNestedScope(StmtInfo* stmt, StmtType type, NestedStaticScope& staticScope) {
|
||||
push(stmt, type);
|
||||
linkAsInnermostScopeStmt(stmt, staticScope);
|
||||
}
|
||||
@ -617,7 +616,7 @@ class MOZ_STACK_CLASS StmtInfoStack
|
||||
innermostScopeStmt_ = stmt->enclosingScope;
|
||||
}
|
||||
|
||||
void linkAsInnermostScopeStmt(StmtInfo* stmt, NestedStaticScopeObject& staticScope) {
|
||||
void linkAsInnermostScopeStmt(StmtInfo* stmt, NestedStaticScope& staticScope) {
|
||||
MOZ_ASSERT(stmt != innermostScopeStmt_);
|
||||
MOZ_ASSERT(!stmt->enclosingScope);
|
||||
stmt->enclosingScope = innermostScopeStmt_;
|
||||
@ -625,7 +624,7 @@ class MOZ_STACK_CLASS StmtInfoStack
|
||||
stmt->staticScope = &staticScope;
|
||||
}
|
||||
|
||||
void makeInnermostLexicalScope(StaticBlockObject& blockObj) {
|
||||
void makeInnermostLexicalScope(StaticBlockScope& blockObj) {
|
||||
MOZ_ASSERT(!innermostStmt_->isBlockScope);
|
||||
MOZ_ASSERT(innermostStmt_->canBeBlockScope());
|
||||
innermostStmt_->isBlockScope = true;
|
||||
|
@ -3382,13 +3382,13 @@ BaselineCompiler::emit_JSOP_RETSUB()
|
||||
return emitOpIC(stubCompiler.getStub(&stubSpace_));
|
||||
}
|
||||
|
||||
typedef bool (*PushBlockScopeFn)(JSContext*, BaselineFrame*, Handle<StaticBlockObject*>);
|
||||
typedef bool (*PushBlockScopeFn)(JSContext*, BaselineFrame*, Handle<StaticBlockScope*>);
|
||||
static const VMFunction PushBlockScopeInfo = FunctionInfo<PushBlockScopeFn>(jit::PushBlockScope);
|
||||
|
||||
bool
|
||||
BaselineCompiler::emit_JSOP_PUSHBLOCKSCOPE()
|
||||
{
|
||||
StaticBlockObject& blockObj = script->getObject(pc)->as<StaticBlockObject>();
|
||||
StaticBlockScope& blockObj = script->getObject(pc)->as<StaticBlockScope>();
|
||||
|
||||
// Call a stub to push the block on the block chain.
|
||||
prepareVMCall();
|
||||
@ -3466,13 +3466,13 @@ BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK()
|
||||
return callVM(DebugLeaveBlockInfo);
|
||||
}
|
||||
|
||||
typedef bool (*EnterWithFn)(JSContext*, BaselineFrame*, HandleValue, Handle<StaticWithObject*>);
|
||||
typedef bool (*EnterWithFn)(JSContext*, BaselineFrame*, HandleValue, Handle<StaticWithScope*>);
|
||||
static const VMFunction EnterWithInfo = FunctionInfo<EnterWithFn>(jit::EnterWith);
|
||||
|
||||
bool
|
||||
BaselineCompiler::emit_JSOP_ENTERWITH()
|
||||
{
|
||||
StaticWithObject& withObj = script->getObject(pc)->as<StaticWithObject>();
|
||||
StaticWithScope& withObj = script->getObject(pc)->as<StaticWithScope>();
|
||||
|
||||
// Pop "with" object to R0.
|
||||
frame.popRegsAndSync(1);
|
||||
|
@ -53,7 +53,7 @@ BaselineFrame::replaceInnermostScope(ScopeObject& scope)
|
||||
}
|
||||
|
||||
inline bool
|
||||
BaselineFrame::pushBlock(JSContext* cx, Handle<StaticBlockObject*> block)
|
||||
BaselineFrame::pushBlock(JSContext* cx, Handle<StaticBlockScope*> block)
|
||||
{
|
||||
MOZ_ASSERT(block->needsClone());
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool
|
||||
BaselineFrame::isNonGlobalEvalFrame() const
|
||||
{
|
||||
return isEvalFrame() &&
|
||||
script()->enclosingStaticScope()->as<StaticEvalObject>().isNonGlobal();
|
||||
script()->enclosingStaticScope()->as<StaticEvalScope>().isNonGlobal();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -260,7 +260,7 @@ class BaselineFrame
|
||||
return &flags_;
|
||||
}
|
||||
|
||||
inline bool pushBlock(JSContext* cx, Handle<StaticBlockObject*> block);
|
||||
inline bool pushBlock(JSContext* cx, Handle<StaticBlockScope*> block);
|
||||
inline void popBlock(JSContext* cx);
|
||||
inline bool freshenBlock(JSContext* cx);
|
||||
|
||||
|
@ -259,7 +259,7 @@ class CompileInfo
|
||||
jsbytecode* osrPc() const {
|
||||
return osrPc_;
|
||||
}
|
||||
NestedStaticScopeObject* osrStaticScope() const {
|
||||
NestedStaticScope* osrStaticScope() const {
|
||||
return osrStaticScope_;
|
||||
}
|
||||
InlineScriptTree* inlineScriptTree() const {
|
||||
@ -407,7 +407,7 @@ class CompileInfo
|
||||
return nimplicit() + nargs() + nlocals();
|
||||
}
|
||||
|
||||
bool isSlotAliased(uint32_t index, NestedStaticScopeObject* staticScope) const {
|
||||
bool isSlotAliased(uint32_t index, NestedStaticScope* staticScope) const {
|
||||
MOZ_ASSERT(index >= startArgSlot());
|
||||
|
||||
if (funMaybeLazy() && index == thisSlot())
|
||||
@ -431,9 +431,9 @@ class CompileInfo
|
||||
|
||||
// Otherwise, it might be part of a block scope.
|
||||
for (; staticScope; staticScope = staticScope->enclosingNestedScope()) {
|
||||
if (!staticScope->is<StaticBlockObject>())
|
||||
if (!staticScope->is<StaticBlockScope>())
|
||||
continue;
|
||||
StaticBlockObject& blockObj = staticScope->as<StaticBlockObject>();
|
||||
StaticBlockScope& blockObj = staticScope->as<StaticBlockScope>();
|
||||
if (blockObj.localOffset() < local) {
|
||||
if (local - blockObj.localOffset() < blockObj.numVariables())
|
||||
return blockObj.isAliased(local - blockObj.localOffset());
|
||||
@ -570,7 +570,7 @@ class CompileInfo
|
||||
JSScript* script_;
|
||||
JSFunction* fun_;
|
||||
jsbytecode* osrPc_;
|
||||
NestedStaticScopeObject* osrStaticScope_;
|
||||
NestedStaticScope* osrStaticScope_;
|
||||
bool constructing_;
|
||||
AnalysisMode analysisMode_;
|
||||
|
||||
|
@ -984,7 +984,7 @@ GlobalHasLiveOnDebuggerStatement(JSContext* cx)
|
||||
}
|
||||
|
||||
bool
|
||||
PushBlockScope(JSContext* cx, BaselineFrame* frame, Handle<StaticBlockObject*> block)
|
||||
PushBlockScope(JSContext* cx, BaselineFrame* frame, Handle<StaticBlockScope*> block)
|
||||
{
|
||||
return frame->pushBlock(cx, block);
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ DebugLeaveBlock(JSContext* cx, BaselineFrame* frame, jsbytecode* pc)
|
||||
}
|
||||
|
||||
bool
|
||||
EnterWith(JSContext* cx, BaselineFrame* frame, HandleValue val, Handle<StaticWithObject*> templ)
|
||||
EnterWith(JSContext* cx, BaselineFrame* frame, HandleValue val, Handle<StaticWithScope*> templ)
|
||||
{
|
||||
return EnterWithOperation(cx, frame, val, templ);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace js {
|
||||
|
||||
class DeclEnvObject;
|
||||
class StaticWithObject;
|
||||
class StaticWithScope;
|
||||
class InlineTypedObject;
|
||||
class GeneratorObject;
|
||||
|
||||
@ -282,8 +282,8 @@ template <> struct TypeToDataType<Handle<InlineTypedObject*> > { static const Da
|
||||
template <> struct TypeToDataType<Handle<ArrayObject*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<GeneratorObject*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<PlainObject*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<StaticWithObject*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<StaticBlockObject*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<StaticWithScope*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<Handle<StaticBlockScope*> > { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<HandleScript> { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<HandleValue> { static const DataType result = Type_Handle; };
|
||||
template <> struct TypeToDataType<MutableHandleValue> { static const DataType result = Type_Handle; };
|
||||
@ -323,11 +323,11 @@ template <> struct TypeToArgProperties<Handle<GeneratorObject*> > {
|
||||
template <> struct TypeToArgProperties<Handle<PlainObject*> > {
|
||||
static const uint32_t result = TypeToArgProperties<PlainObject*>::result | VMFunction::ByRef;
|
||||
};
|
||||
template <> struct TypeToArgProperties<Handle<StaticWithObject*> > {
|
||||
static const uint32_t result = TypeToArgProperties<StaticWithObject*>::result | VMFunction::ByRef;
|
||||
template <> struct TypeToArgProperties<Handle<StaticWithScope*> > {
|
||||
static const uint32_t result = TypeToArgProperties<StaticWithScope*>::result | VMFunction::ByRef;
|
||||
};
|
||||
template <> struct TypeToArgProperties<Handle<StaticBlockObject*> > {
|
||||
static const uint32_t result = TypeToArgProperties<StaticBlockObject*>::result | VMFunction::ByRef;
|
||||
template <> struct TypeToArgProperties<Handle<StaticBlockScope*> > {
|
||||
static const uint32_t result = TypeToArgProperties<StaticBlockScope*>::result | VMFunction::ByRef;
|
||||
};
|
||||
template <> struct TypeToArgProperties<HandleScript> {
|
||||
static const uint32_t result = TypeToArgProperties<JSScript*>::result | VMFunction::ByRef;
|
||||
@ -400,10 +400,10 @@ template <> struct TypeToRootType<Handle<GeneratorObject*> > {
|
||||
template <> struct TypeToRootType<Handle<PlainObject*> > {
|
||||
static const uint32_t result = VMFunction::RootObject;
|
||||
};
|
||||
template <> struct TypeToRootType<Handle<StaticBlockObject*> > {
|
||||
template <> struct TypeToRootType<Handle<StaticBlockScope*> > {
|
||||
static const uint32_t result = VMFunction::RootObject;
|
||||
};
|
||||
template <> struct TypeToRootType<Handle<StaticWithObject*> > {
|
||||
template <> struct TypeToRootType<Handle<StaticWithScope*> > {
|
||||
static const uint32_t result = VMFunction::RootCell;
|
||||
};
|
||||
template <class T> struct TypeToRootType<Handle<T> > {
|
||||
@ -673,10 +673,10 @@ bool OnDebuggerStatement(JSContext* cx, BaselineFrame* frame, jsbytecode* pc, bo
|
||||
bool GlobalHasLiveOnDebuggerStatement(JSContext* cx);
|
||||
|
||||
bool EnterWith(JSContext* cx, BaselineFrame* frame, HandleValue val,
|
||||
Handle<StaticWithObject*> templ);
|
||||
Handle<StaticWithScope*> templ);
|
||||
bool LeaveWith(JSContext* cx, BaselineFrame* frame);
|
||||
|
||||
bool PushBlockScope(JSContext* cx, BaselineFrame* frame, Handle<StaticBlockObject*> block);
|
||||
bool PushBlockScope(JSContext* cx, BaselineFrame* frame, Handle<StaticBlockScope*> block);
|
||||
bool PopBlockScope(JSContext* cx, BaselineFrame* frame);
|
||||
bool DebugLeaveThenPopBlockScope(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
|
||||
bool FreshenBlockScope(JSContext* cx, BaselineFrame* frame);
|
||||
|
@ -3447,7 +3447,7 @@ JS::NewFunctionFromSpec(JSContext* cx, const JSFunctionSpec* fs, HandleId id)
|
||||
static bool
|
||||
CreateNonSyntacticScopeChain(JSContext* cx, AutoObjectVector& scopeChain,
|
||||
MutableHandleObject dynamicScopeObj,
|
||||
MutableHandle<StaticScopeObject*> staticScopeObj)
|
||||
MutableHandle<StaticScope*> staticScopeObj)
|
||||
{
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
if (!js::CreateScopeObjectsForScopeChain(cx, scopeChain, globalLexical, dynamicScopeObj))
|
||||
@ -3455,7 +3455,7 @@ CreateNonSyntacticScopeChain(JSContext* cx, AutoObjectVector& scopeChain,
|
||||
|
||||
staticScopeObj.set(&globalLexical->staticBlock());
|
||||
if (!scopeChain.empty()) {
|
||||
staticScopeObj.set(StaticNonSyntacticScopeObjects::create(cx, staticScopeObj));
|
||||
staticScopeObj.set(StaticNonSyntacticScope::create(cx, staticScopeObj));
|
||||
if (!staticScopeObj)
|
||||
return false;
|
||||
|
||||
@ -3501,13 +3501,13 @@ IsFunctionCloneable(HandleFunction fun)
|
||||
|
||||
// If the script already deals with non-syntactic scopes, we can clone
|
||||
// it.
|
||||
if (scope->is<StaticNonSyntacticScopeObjects>())
|
||||
if (scope->is<StaticNonSyntacticScope>())
|
||||
return true;
|
||||
|
||||
// 'eval' scopes are always scoped immediately under a non-extensible
|
||||
// lexical scope.
|
||||
if (scope->is<StaticBlockObject>()) {
|
||||
StaticBlockObject& block = scope->as<StaticBlockObject>();
|
||||
if (scope->is<StaticBlockScope>()) {
|
||||
StaticBlockScope& block = scope->as<StaticBlockScope>();
|
||||
if (block.needsClone())
|
||||
return false;
|
||||
|
||||
@ -3515,8 +3515,8 @@ IsFunctionCloneable(HandleFunction fun)
|
||||
|
||||
// If the script is an indirect eval that is immediately scoped
|
||||
// under the global, we can clone it.
|
||||
if (enclosing->is<StaticEvalObject>())
|
||||
return !enclosing->as<StaticEvalObject>().isNonGlobal();
|
||||
if (enclosing->is<StaticEvalScope>())
|
||||
return !enclosing->as<StaticEvalScope>().isNonGlobal();
|
||||
}
|
||||
|
||||
// Any other enclosing static scope (e.g., function, block) cannot be
|
||||
@ -3529,7 +3529,7 @@ IsFunctionCloneable(HandleFunction fun)
|
||||
|
||||
static JSObject*
|
||||
CloneFunctionObject(JSContext* cx, HandleObject funobj, HandleObject dynamicScope,
|
||||
Handle<StaticScopeObject*> staticScope)
|
||||
Handle<StaticScope*> staticScope)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
@ -3598,7 +3598,7 @@ JS_PUBLIC_API(JSObject*)
|
||||
JS::CloneFunctionObject(JSContext* cx, HandleObject funobj)
|
||||
{
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
return CloneFunctionObject(cx, funobj, globalLexical, staticLexical);
|
||||
}
|
||||
|
||||
@ -3606,7 +3606,7 @@ extern JS_PUBLIC_API(JSObject*)
|
||||
JS::CloneFunctionObject(JSContext* cx, HandleObject funobj, AutoObjectVector& scopeChain)
|
||||
{
|
||||
RootedObject dynamicScope(cx);
|
||||
Rooted<StaticScopeObject*> staticScope(cx);
|
||||
Rooted<StaticScope*> staticScope(cx);
|
||||
if (!CreateNonSyntacticScopeChain(cx, scopeChain, &dynamicScope, &staticScope))
|
||||
return nullptr;
|
||||
|
||||
@ -3951,9 +3951,9 @@ Compile(JSContext* cx, const ReadOnlyCompileOptions& options, SyntacticScopeOpti
|
||||
CHECK_REQUEST(cx);
|
||||
AutoLastFrameCheck lfc(cx);
|
||||
|
||||
Rooted<StaticScopeObject*> staticScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> staticScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
if (scopeOption == HasNonSyntacticScope) {
|
||||
staticScope = StaticNonSyntacticScopeObjects::create(cx, staticScope);
|
||||
staticScope = StaticNonSyntacticScope::create(cx, staticScope);
|
||||
if (!staticScope)
|
||||
return false;
|
||||
}
|
||||
@ -4221,7 +4221,7 @@ JS_GetFunctionScript(JSContext* cx, HandleFunction fun)
|
||||
|
||||
/*
|
||||
* enclosingStaticScope is a static enclosing scope, if any (e.g. a
|
||||
* StaticWithObject). If the enclosing scope is the global scope, this must be
|
||||
* StaticWithScope). If the enclosing scope is the global scope, this must be
|
||||
* null.
|
||||
*
|
||||
* enclosingDynamicScope is a dynamic scope to use, if it's not the global.
|
||||
@ -4231,7 +4231,7 @@ CompileFunction(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
|
||||
const char* name, unsigned nargs, const char* const* argnames,
|
||||
SourceBufferHolder& srcBuf,
|
||||
HandleObject enclosingDynamicScope,
|
||||
Handle<StaticScopeObject*> enclosingStaticScope,
|
||||
Handle<StaticScope*> enclosingStaticScope,
|
||||
MutableHandleFunction fun)
|
||||
{
|
||||
MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
|
||||
@ -4280,7 +4280,7 @@ JS::CompileFunction(JSContext* cx, AutoObjectVector& scopeChain,
|
||||
SourceBufferHolder& srcBuf, MutableHandleFunction fun)
|
||||
{
|
||||
RootedObject dynamicScopeObj(cx);
|
||||
Rooted<StaticScopeObject*> staticScopeObj(cx);
|
||||
Rooted<StaticScope*> staticScopeObj(cx);
|
||||
if (!CreateNonSyntacticScopeChain(cx, scopeChain, &dynamicScopeObj, &staticScopeObj))
|
||||
return false;
|
||||
|
||||
@ -4360,7 +4360,7 @@ static bool
|
||||
ExecuteScript(JSContext* cx, AutoObjectVector& scopeChain, HandleScript scriptArg, Value* rval)
|
||||
{
|
||||
RootedObject dynamicScope(cx);
|
||||
Rooted<StaticScopeObject*> staticScope(cx);
|
||||
Rooted<StaticScope*> staticScope(cx);
|
||||
if (!CreateNonSyntacticScopeChain(cx, scopeChain, &dynamicScope, &staticScope))
|
||||
return false;
|
||||
|
||||
@ -4409,7 +4409,7 @@ JS::CloneAndExecuteScript(JSContext* cx, HandleScript scriptArg)
|
||||
RootedScript script(cx, scriptArg);
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
if (script->compartment() != cx->compartment()) {
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
script = CloneGlobalScript(cx, staticLexical, script);
|
||||
if (!script)
|
||||
return false;
|
||||
@ -4422,7 +4422,7 @@ JS::CloneAndExecuteScript(JSContext* cx, HandleScript scriptArg)
|
||||
static const unsigned LARGE_SCRIPT_LENGTH = 500*1024;
|
||||
|
||||
static bool
|
||||
Evaluate(JSContext* cx, HandleObject scope, Handle<StaticScopeObject*> staticScope,
|
||||
Evaluate(JSContext* cx, HandleObject scope, Handle<StaticScope*> staticScope,
|
||||
const ReadOnlyCompileOptions& optionsArg,
|
||||
SourceBufferHolder& srcBuf, MutableHandleValue rval)
|
||||
{
|
||||
@ -4471,7 +4471,7 @@ Evaluate(JSContext* cx, AutoObjectVector& scopeChain, const ReadOnlyCompileOptio
|
||||
SourceBufferHolder& srcBuf, MutableHandleValue rval)
|
||||
{
|
||||
RootedObject dynamicScope(cx);
|
||||
Rooted<StaticScopeObject*> staticScope(cx);
|
||||
Rooted<StaticScope*> staticScope(cx);
|
||||
if (!CreateNonSyntacticScopeChain(cx, scopeChain, &dynamicScope, &staticScope))
|
||||
return false;
|
||||
return ::Evaluate(cx, dynamicScope, staticScope, optionsArg, srcBuf, rval);
|
||||
@ -4483,7 +4483,7 @@ Evaluate(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
|
||||
{
|
||||
SourceBufferHolder srcBuf(chars, length, SourceBufferHolder::NoOwnership);
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
return ::Evaluate(cx, globalLexical, staticLexical, optionsArg, srcBuf, rval);
|
||||
}
|
||||
|
||||
@ -4501,7 +4501,7 @@ JS::Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
|
||||
SourceBufferHolder srcBuf(chars, length, SourceBufferHolder::GiveOwnership);
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
bool ok = ::Evaluate(cx, globalLexical, staticLexical, options, srcBuf, rval);
|
||||
return ok;
|
||||
}
|
||||
@ -4527,7 +4527,7 @@ JS::Evaluate(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
|
||||
SourceBufferHolder& srcBuf, MutableHandleValue rval)
|
||||
{
|
||||
Rooted<ClonedBlockObject*> globalLexical(cx, &cx->global()->lexicalScope());
|
||||
Rooted<StaticScopeObject*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticLexical(cx, &globalLexical->staticBlock());
|
||||
return ::Evaluate(cx, globalLexical, staticLexical, optionsArg, srcBuf, rval);
|
||||
}
|
||||
|
||||
|
@ -6875,7 +6875,7 @@ gc::MergeCompartments(JSCompartment* source, JSCompartment* target)
|
||||
for (uint32_t i = 0; i < scopes->length; i++) {
|
||||
uint32_t scopeIndex = scopes->vector[i].index;
|
||||
if (scopeIndex != BlockScopeNote::NoBlockScopeIndex) {
|
||||
StaticScopeObject* scope = &script->getObject(scopeIndex)->as<StaticScopeObject>();
|
||||
StaticScope* scope = &script->getObject(scopeIndex)->as<StaticScope>();
|
||||
MOZ_ASSERT(!IsStaticGlobalLexicalScope(scope));
|
||||
JSObject* enclosing = scope->enclosingScope();
|
||||
if (IsStaticGlobalLexicalScope(enclosing))
|
||||
|
@ -747,8 +747,8 @@ ToDisassemblySource(JSContext* cx, HandleValue v, JSAutoByteString* bytes)
|
||||
|
||||
if (v.isObject()) {
|
||||
JSObject& obj = v.toObject();
|
||||
if (obj.is<StaticBlockObject>()) {
|
||||
Rooted<StaticBlockObject*> block(cx, &obj.as<StaticBlockObject>());
|
||||
if (obj.is<StaticBlockScope>()) {
|
||||
Rooted<StaticBlockScope*> block(cx, &obj.as<StaticBlockScope>());
|
||||
char* source = JS_sprintf_append(nullptr, "depth %d {", block->localOffset());
|
||||
if (!source) {
|
||||
ReportOutOfMemory(cx);
|
||||
@ -1260,13 +1260,13 @@ ExpressionDecompiler::getLocal(uint32_t local, jsbytecode* pc)
|
||||
|
||||
MOZ_CRASH("No binding");
|
||||
}
|
||||
for (NestedStaticScopeObject* chain = script->getStaticBlockScope(pc);
|
||||
for (NestedStaticScope* chain = script->getStaticBlockScope(pc);
|
||||
chain;
|
||||
chain = chain->enclosingNestedScope())
|
||||
{
|
||||
if (!chain->is<StaticBlockObject>())
|
||||
if (!chain->is<StaticBlockScope>())
|
||||
continue;
|
||||
StaticBlockObject& block = chain->as<StaticBlockObject>();
|
||||
StaticBlockScope& block = chain->as<StaticBlockScope>();
|
||||
if (local < block.localOffset())
|
||||
continue;
|
||||
local -= block.localOffset();
|
||||
|
@ -566,7 +566,7 @@ XDRRelazificationInfo(XDRState<mode>* xdr, HandleFunction fun, HandleScript scri
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
FindScopeObjectIndex(JSScript* script, NestedStaticScopeObject& scope)
|
||||
FindScopeObjectIndex(JSScript* script, NestedStaticScope& scope)
|
||||
{
|
||||
ObjectArray* objects = script->objects();
|
||||
HeapPtrObject* vector = objects->vector;
|
||||
@ -843,7 +843,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScopeArg, HandleScript
|
||||
if (scriptBits & (1 << HasNonSyntacticScope) &&
|
||||
IsStaticGlobalLexicalScope(enclosingScope))
|
||||
{
|
||||
enclosingScope = StaticNonSyntacticScopeObjects::create(cx, enclosingScope);
|
||||
enclosingScope = StaticNonSyntacticScope::create(cx, enclosingScope);
|
||||
if (!enclosingScope)
|
||||
return false;
|
||||
}
|
||||
@ -1013,7 +1013,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScopeArg, HandleScript
|
||||
JSObject* obj = *objp;
|
||||
if (obj->is<BlockObject>())
|
||||
classk = CK_BlockObject;
|
||||
else if (obj->is<StaticWithObject>())
|
||||
else if (obj->is<StaticWithScope>())
|
||||
classk = CK_WithObject;
|
||||
else if (obj->is<JSFunction>())
|
||||
classk = CK_JSFunction;
|
||||
@ -1032,8 +1032,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScopeArg, HandleScript
|
||||
/* Code the nested block's enclosing scope. */
|
||||
uint32_t enclosingStaticScopeIndex = 0;
|
||||
if (mode == XDR_ENCODE) {
|
||||
NestedStaticScopeObject& scope = (*objp)->as<NestedStaticScopeObject>();
|
||||
if (NestedStaticScopeObject* enclosing = scope.enclosingNestedScope()) {
|
||||
NestedStaticScope& scope = (*objp)->as<NestedStaticScope>();
|
||||
if (NestedStaticScope* enclosing = scope.enclosingNestedScope()) {
|
||||
if (IsStaticGlobalLexicalScope(enclosing))
|
||||
enclosingStaticScopeIndex = UINT32_MAX;
|
||||
else
|
||||
@ -1060,13 +1060,13 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScopeArg, HandleScript
|
||||
}
|
||||
|
||||
if (classk == CK_BlockObject) {
|
||||
Rooted<StaticBlockObject*> tmp(cx, static_cast<StaticBlockObject*>(objp->get()));
|
||||
Rooted<StaticBlockScope*> tmp(cx, static_cast<StaticBlockScope*>(objp->get()));
|
||||
if (!XDRStaticBlockObject(xdr, enclosingStaticScope, &tmp))
|
||||
return false;
|
||||
*objp = tmp;
|
||||
} else {
|
||||
Rooted<StaticWithObject*> tmp(cx, static_cast<StaticWithObject*>(objp->get()));
|
||||
if (!XDRStaticWithObject(xdr, enclosingStaticScope, &tmp))
|
||||
Rooted<StaticWithScope*> tmp(cx, static_cast<StaticWithScope*>(objp->get()));
|
||||
if (!XDRStaticWithScope(xdr, enclosingStaticScope, &tmp))
|
||||
return false;
|
||||
*objp = tmp;
|
||||
}
|
||||
@ -3480,14 +3480,14 @@ js::detail::CopyScript(JSContext* cx, HandleObject scriptStaticScope, HandleScri
|
||||
for (unsigned i = 0; i < nobjects; i++) {
|
||||
RootedObject obj(cx, vector[i]);
|
||||
RootedObject clone(cx);
|
||||
if (obj->is<NestedStaticScopeObject>()) {
|
||||
Rooted<NestedStaticScopeObject*> innerBlock(cx, &obj->as<NestedStaticScopeObject>());
|
||||
if (obj->is<NestedStaticScope>()) {
|
||||
Rooted<NestedStaticScope*> innerBlock(cx, &obj->as<NestedStaticScope>());
|
||||
|
||||
RootedObject enclosingScope(cx);
|
||||
if (NestedStaticScopeObject* enclosingBlock = innerBlock->enclosingNestedScope()) {
|
||||
if (NestedStaticScope* enclosingBlock = innerBlock->enclosingNestedScope()) {
|
||||
if (IsStaticGlobalLexicalScope(enclosingBlock)) {
|
||||
MOZ_ASSERT(IsStaticGlobalLexicalScope(scriptStaticScope) ||
|
||||
scriptStaticScope->is<StaticNonSyntacticScopeObjects>());
|
||||
scriptStaticScope->is<StaticNonSyntacticScope>());
|
||||
enclosingScope = scriptStaticScope;
|
||||
} else {
|
||||
enclosingScope = objects[FindScopeObjectIndex(src, *enclosingBlock)];
|
||||
@ -3523,7 +3523,7 @@ js::detail::CopyScript(JSContext* cx, HandleObject scriptStaticScope, HandleScri
|
||||
} else if (ssi.type() == StaticScopeIter<CanGC>::Block) {
|
||||
if (ssi.block().isGlobal()) {
|
||||
MOZ_ASSERT(IsStaticGlobalLexicalScope(scriptStaticScope) ||
|
||||
scriptStaticScope->is<StaticNonSyntacticScopeObjects>());
|
||||
scriptStaticScope->is<StaticNonSyntacticScope>());
|
||||
enclosingScope = scriptStaticScope;
|
||||
} else {
|
||||
enclosingScope = objects[FindScopeObjectIndex(src, ssi.block())];
|
||||
@ -3679,10 +3679,10 @@ CreateEmptyScriptForClone(JSContext* cx, HandleObject enclosingScope, HandleScri
|
||||
}
|
||||
|
||||
JSScript*
|
||||
js::CloneGlobalScript(JSContext* cx, Handle<StaticScopeObject*> enclosingScope, HandleScript src)
|
||||
js::CloneGlobalScript(JSContext* cx, Handle<StaticScope*> enclosingScope, HandleScript src)
|
||||
{
|
||||
MOZ_ASSERT(IsStaticGlobalLexicalScope(enclosingScope) ||
|
||||
enclosingScope->is<StaticNonSyntacticScopeObjects>());
|
||||
enclosingScope->is<StaticNonSyntacticScope>());
|
||||
|
||||
RootedScript dst(cx, CreateEmptyScriptForClone(cx, enclosingScope, src));
|
||||
if (!dst)
|
||||
@ -3997,17 +3997,17 @@ JSScript::calculateLiveFixed(jsbytecode* pc)
|
||||
size_t nlivefixed = nbodyfixed();
|
||||
|
||||
if (nfixed() != nlivefixed) {
|
||||
NestedStaticScopeObject* staticScope = getStaticBlockScope(pc);
|
||||
NestedStaticScope* staticScope = getStaticBlockScope(pc);
|
||||
if (staticScope)
|
||||
staticScope = MaybeForwarded(staticScope);
|
||||
while (staticScope && !staticScope->is<StaticBlockObject>()) {
|
||||
while (staticScope && !staticScope->is<StaticBlockScope>()) {
|
||||
staticScope = staticScope->enclosingNestedScope();
|
||||
if (staticScope)
|
||||
staticScope = MaybeForwarded(staticScope);
|
||||
}
|
||||
|
||||
if (staticScope && !IsStaticGlobalLexicalScope(staticScope)) {
|
||||
StaticBlockObject& blockObj = staticScope->as<StaticBlockObject>();
|
||||
StaticBlockScope& blockObj = staticScope->as<StaticBlockScope>();
|
||||
nlivefixed = blockObj.localOffset() + blockObj.numVariables();
|
||||
}
|
||||
}
|
||||
@ -4018,7 +4018,7 @@ JSScript::calculateLiveFixed(jsbytecode* pc)
|
||||
return nlivefixed;
|
||||
}
|
||||
|
||||
NestedStaticScopeObject*
|
||||
NestedStaticScope*
|
||||
JSScript::getStaticBlockScope(jsbytecode* pc)
|
||||
{
|
||||
MOZ_ASSERT(containsPC(pc));
|
||||
@ -4029,7 +4029,7 @@ JSScript::getStaticBlockScope(jsbytecode* pc)
|
||||
size_t offset = pc - code();
|
||||
|
||||
BlockScopeArray* scopes = blockScopes();
|
||||
NestedStaticScopeObject* blockChain = nullptr;
|
||||
NestedStaticScope* blockChain = nullptr;
|
||||
|
||||
// Find the innermost block chain using a binary search.
|
||||
size_t bottom = 0;
|
||||
@ -4054,7 +4054,7 @@ JSScript::getStaticBlockScope(jsbytecode* pc)
|
||||
if (checkNote->index == BlockScopeNote::NoBlockScopeIndex)
|
||||
blockChain = nullptr;
|
||||
else
|
||||
blockChain = &getObject(checkNote->index)->as<NestedStaticScopeObject>();
|
||||
blockChain = &getObject(checkNote->index)->as<NestedStaticScope>();
|
||||
break;
|
||||
}
|
||||
if (checkNote->parent == UINT32_MAX)
|
||||
|
@ -48,8 +48,8 @@ class BindingIter;
|
||||
class Debugger;
|
||||
class LazyScript;
|
||||
class ModuleObject;
|
||||
class NestedStaticScopeObject;
|
||||
class StaticScopeObject;
|
||||
class NestedStaticScope;
|
||||
class StaticScope;
|
||||
class RegExpObject;
|
||||
struct SourceCompressionTask;
|
||||
class Shape;
|
||||
@ -115,7 +115,7 @@ namespace js {
|
||||
struct BlockScopeNote {
|
||||
static const uint32_t NoBlockScopeIndex = UINT32_MAX;
|
||||
|
||||
uint32_t index; // Index of NestedStaticScopeObject in the object
|
||||
uint32_t index; // Index of NestedStaticScope in the object
|
||||
// array, or NoBlockScopeIndex if there is no
|
||||
// block scope in this range.
|
||||
uint32_t start; // Bytecode offset at which this scope starts,
|
||||
@ -1869,7 +1869,7 @@ class JSScript : public js::gc::TenuredCell
|
||||
// The following 4 functions find the static scope just before the
|
||||
// execution of the instruction pointed to by pc.
|
||||
|
||||
js::NestedStaticScopeObject* getStaticBlockScope(jsbytecode* pc);
|
||||
js::NestedStaticScope* getStaticBlockScope(jsbytecode* pc);
|
||||
|
||||
// Returns the innermost static scope at pc if it falls within the extent
|
||||
// of the script. Returns nullptr otherwise.
|
||||
@ -2534,7 +2534,7 @@ CloneScriptIntoFunction(JSContext* cx, HandleObject enclosingScope, HandleFuncti
|
||||
HandleScript src);
|
||||
|
||||
JSScript*
|
||||
CloneGlobalScript(JSContext* cx, Handle<StaticScopeObject*> enclosingScope, HandleScript src);
|
||||
CloneGlobalScript(JSContext* cx, Handle<StaticScope*> enclosingScope, HandleScript src);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
|
@ -6693,19 +6693,19 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, AbstractFramePtr frame,
|
||||
MOZ_ASSERT_IF(frame, pc);
|
||||
|
||||
/*
|
||||
* Pass in a StaticEvalObject *not* linked to env for evalStaticScope, as
|
||||
* Pass in a StaticEvalScope *not* linked to env for evalStaticScope, as
|
||||
* ScopeIter should stop at any non-ScopeObject or non-syntactic With
|
||||
* boundaries, and we are putting a DebugScopeProxy or non-syntactic With on
|
||||
* the scope chain.
|
||||
*/
|
||||
Rooted<StaticScopeObject*> enclosingStaticScope(cx);
|
||||
Rooted<StaticScope*> enclosingStaticScope(cx);
|
||||
if (!IsGlobalLexicalScope(env)) {
|
||||
// If we are doing a global evalWithBindings, we will still need to
|
||||
// link the static global lexical scope to the static non-syntactic
|
||||
// scope.
|
||||
if (IsGlobalLexicalScope(env->enclosingScope()))
|
||||
enclosingStaticScope = &cx->global()->lexicalScope().staticBlock();
|
||||
enclosingStaticScope = StaticNonSyntacticScopeObjects::create(cx, enclosingStaticScope);
|
||||
enclosingStaticScope = StaticNonSyntacticScope::create(cx, enclosingStaticScope);
|
||||
if (!enclosingStaticScope)
|
||||
return false;
|
||||
} else {
|
||||
@ -6717,9 +6717,9 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, AbstractFramePtr frame,
|
||||
// circumvent the fresh lexical scope that all eval have, so that the
|
||||
// users of executeInGlobal, like the web console, may add new bindings to
|
||||
// the global scope.
|
||||
Rooted<StaticScopeObject*> staticScope(cx);
|
||||
Rooted<StaticScope*> staticScope(cx);
|
||||
if (frame) {
|
||||
staticScope = StaticEvalObject::create(cx, enclosingStaticScope);
|
||||
staticScope = StaticEvalScope::create(cx, enclosingStaticScope);
|
||||
if (!staticScope)
|
||||
return false;
|
||||
} else {
|
||||
@ -6745,7 +6745,7 @@ EvaluateInEnv(JSContext* cx, Handle<Env*> env, AbstractFramePtr frame,
|
||||
// Again, executeInGlobal is not considered eval.
|
||||
if (frame) {
|
||||
if (script->strict())
|
||||
staticScope->as<StaticEvalObject>().setStrict();
|
||||
staticScope->as<StaticEvalScope>().setStrict();
|
||||
script->setActiveEval();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ InitSharedArrayBufferClass(JSContext* cx, HandleObject obj);
|
||||
|
||||
class Debugger;
|
||||
class TypedObjectModuleObject;
|
||||
class StaticBlockObject;
|
||||
class StaticBlockScope;
|
||||
class ClonedBlockObject;
|
||||
|
||||
class SimdTypeDescr;
|
||||
|
@ -1401,7 +1401,7 @@ HelperThread::handleParseWorkload()
|
||||
// ! WARNING WARNING WARNING !
|
||||
ExclusiveContext* parseCx = task->cx;
|
||||
Rooted<ClonedBlockObject*> globalLexical(parseCx, &parseCx->global()->lexicalScope());
|
||||
Rooted<StaticScopeObject*> staticScope(parseCx, &globalLexical->staticBlock());
|
||||
Rooted<StaticScope*> staticScope(parseCx, &globalLexical->staticBlock());
|
||||
task->script = frontend::CompileScript(parseCx, &task->alloc,
|
||||
globalLexical, staticScope, nullptr,
|
||||
task->options, srcBuf,
|
||||
|
@ -928,7 +928,7 @@ bool
|
||||
js::EnterWithOperation(JSContext* cx, AbstractFramePtr frame, HandleValue val,
|
||||
HandleObject staticWith)
|
||||
{
|
||||
MOZ_ASSERT(staticWith->is<StaticWithObject>());
|
||||
MOZ_ASSERT(staticWith->is<StaticWithScope>());
|
||||
RootedObject obj(cx);
|
||||
if (val.isObject()) {
|
||||
obj = &val.toObject();
|
||||
@ -3634,7 +3634,7 @@ END_CASE(JSOP_DEBUGGER)
|
||||
|
||||
CASE(JSOP_PUSHBLOCKSCOPE)
|
||||
{
|
||||
StaticBlockObject& blockObj = script->getObject(REGS.pc)->as<StaticBlockObject>();
|
||||
StaticBlockScope& blockObj = script->getObject(REGS.pc)->as<StaticBlockScope>();
|
||||
|
||||
MOZ_ASSERT(blockObj.needsClone());
|
||||
// Clone block and push on scope chain.
|
||||
@ -3647,9 +3647,9 @@ CASE(JSOP_POPBLOCKSCOPE)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// Pop block from scope chain.
|
||||
NestedStaticScopeObject* scope = script->getStaticBlockScope(REGS.pc);
|
||||
MOZ_ASSERT(scope && scope->is<StaticBlockObject>());
|
||||
StaticBlockObject& blockObj = scope->as<StaticBlockObject>();
|
||||
NestedStaticScope* scope = script->getStaticBlockScope(REGS.pc);
|
||||
MOZ_ASSERT(scope && scope->is<StaticBlockScope>());
|
||||
StaticBlockScope& blockObj = scope->as<StaticBlockScope>();
|
||||
MOZ_ASSERT(blockObj.needsClone());
|
||||
#endif
|
||||
|
||||
@ -3664,8 +3664,8 @@ END_CASE(JSOP_POPBLOCKSCOPE)
|
||||
CASE(JSOP_DEBUGLEAVEBLOCK)
|
||||
{
|
||||
MOZ_ASSERT(script->getStaticBlockScope(REGS.pc));
|
||||
MOZ_ASSERT(script->getStaticBlockScope(REGS.pc)->is<StaticBlockObject>());
|
||||
MOZ_ASSERT(!script->getStaticBlockScope(REGS.pc)->as<StaticBlockObject>().needsClone());
|
||||
MOZ_ASSERT(script->getStaticBlockScope(REGS.pc)->is<StaticBlockScope>());
|
||||
MOZ_ASSERT(!script->getStaticBlockScope(REGS.pc)->as<StaticBlockScope>().needsClone());
|
||||
|
||||
// FIXME: This opcode should not be necessary. The debugger shouldn't need
|
||||
// help from bytecode to do its job. See bug 927782.
|
||||
@ -4828,11 +4828,11 @@ js::ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber,
|
||||
// Failing that, it must be a block-local let.
|
||||
if (!name) {
|
||||
// Skip to the right scope.
|
||||
Rooted<NestedStaticScopeObject*> scope(cx, script->getStaticBlockScope(pc));
|
||||
MOZ_ASSERT(scope && scope->is<StaticBlockObject>());
|
||||
Rooted<StaticBlockObject*> block(cx, &scope->as<StaticBlockObject>());
|
||||
Rooted<NestedStaticScope*> scope(cx, script->getStaticBlockScope(pc));
|
||||
MOZ_ASSERT(scope && scope->is<StaticBlockScope>());
|
||||
Rooted<StaticBlockScope*> block(cx, &scope->as<StaticBlockScope>());
|
||||
while (slot < block->localOffset())
|
||||
block = &block->enclosingNestedScope()->as<StaticBlockObject>();
|
||||
block = &block->enclosingNestedScope()->as<StaticBlockScope>();
|
||||
|
||||
// Translate the frame slot to the block slot, then find the name
|
||||
// of the slot.
|
||||
|
@ -84,12 +84,12 @@ template <AllowGC allowGC>
|
||||
inline void
|
||||
StaticScopeIter<allowGC>::operator++(int)
|
||||
{
|
||||
if (obj->template is<NestedStaticScopeObject>()) {
|
||||
obj = obj->template as<NestedStaticScopeObject>().enclosingScope();
|
||||
} else if (obj->template is<StaticEvalObject>()) {
|
||||
obj = obj->template as<StaticEvalObject>().enclosingScope();
|
||||
} else if (obj->template is<StaticNonSyntacticScopeObjects>()) {
|
||||
obj = obj->template as<StaticNonSyntacticScopeObjects>().enclosingScope();
|
||||
if (obj->template is<NestedStaticScope>()) {
|
||||
obj = obj->template as<NestedStaticScope>().enclosingScope();
|
||||
} else if (obj->template is<StaticEvalScope>()) {
|
||||
obj = obj->template as<StaticEvalScope>().enclosingScope();
|
||||
} else if (obj->template is<StaticNonSyntacticScope>()) {
|
||||
obj = obj->template as<StaticNonSyntacticScope>().enclosingScope();
|
||||
} else if (obj->template is<ModuleObject>()) {
|
||||
obj = obj->template as<ModuleObject>().enclosingStaticScope();
|
||||
} else if (onNamedLambda || !obj->template as<JSFunction>().isNamedLambda()) {
|
||||
@ -118,15 +118,15 @@ StaticScopeIter<allowGC>::hasSyntacticDynamicScopeObject() const
|
||||
}
|
||||
if (obj->template is<ModuleObject>())
|
||||
return true;
|
||||
if (obj->template is<StaticBlockObject>()) {
|
||||
return obj->template as<StaticBlockObject>().needsClone() ||
|
||||
obj->template as<StaticBlockObject>().isGlobal();
|
||||
if (obj->template is<StaticBlockScope>()) {
|
||||
return obj->template as<StaticBlockScope>().needsClone() ||
|
||||
obj->template as<StaticBlockScope>().isGlobal();
|
||||
}
|
||||
if (obj->template is<StaticWithObject>())
|
||||
if (obj->template is<StaticWithScope>())
|
||||
return true;
|
||||
if (obj->template is<StaticEvalObject>())
|
||||
return obj->template as<StaticEvalObject>().isStrict();
|
||||
MOZ_ASSERT(obj->template is<StaticNonSyntacticScopeObjects>());
|
||||
if (obj->template is<StaticEvalScope>())
|
||||
return obj->template as<StaticEvalScope>().isStrict();
|
||||
MOZ_ASSERT(obj->template is<StaticNonSyntacticScope>());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -149,13 +149,13 @@ StaticScopeIter<allowGC>::type() const
|
||||
{
|
||||
if (onNamedLambda)
|
||||
return NamedLambda;
|
||||
if (obj->template is<StaticBlockObject>())
|
||||
if (obj->template is<StaticBlockScope>())
|
||||
return Block;
|
||||
if (obj->template is<StaticWithObject>())
|
||||
if (obj->template is<StaticWithScope>())
|
||||
return With;
|
||||
if (obj->template is<StaticEvalObject>())
|
||||
if (obj->template is<StaticEvalScope>())
|
||||
return Eval;
|
||||
if (obj->template is<StaticNonSyntacticScopeObjects>())
|
||||
if (obj->template is<StaticNonSyntacticScope>())
|
||||
return NonSyntactic;
|
||||
if (obj->template is<ModuleObject>())
|
||||
return Module;
|
||||
@ -164,35 +164,35 @@ StaticScopeIter<allowGC>::type() const
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline StaticBlockObject&
|
||||
inline StaticBlockScope&
|
||||
StaticScopeIter<allowGC>::block() const
|
||||
{
|
||||
MOZ_ASSERT(type() == Block);
|
||||
return obj->template as<StaticBlockObject>();
|
||||
return obj->template as<StaticBlockScope>();
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline StaticWithObject&
|
||||
inline StaticWithScope&
|
||||
StaticScopeIter<allowGC>::staticWith() const
|
||||
{
|
||||
MOZ_ASSERT(type() == With);
|
||||
return obj->template as<StaticWithObject>();
|
||||
return obj->template as<StaticWithScope>();
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline StaticEvalObject&
|
||||
inline StaticEvalScope&
|
||||
StaticScopeIter<allowGC>::eval() const
|
||||
{
|
||||
MOZ_ASSERT(type() == Eval);
|
||||
return obj->template as<StaticEvalObject>();
|
||||
return obj->template as<StaticEvalScope>();
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline StaticNonSyntacticScopeObjects&
|
||||
inline StaticNonSyntacticScope&
|
||||
StaticScopeIter<allowGC>::nonSyntactic() const
|
||||
{
|
||||
MOZ_ASSERT(type() == NonSyntactic);
|
||||
return obj->template as<StaticNonSyntacticScopeObjects>();
|
||||
return obj->template as<StaticNonSyntacticScope>();
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
|
@ -40,29 +40,29 @@ typedef MutableHandle<ArgumentsObject*> MutableHandleArgumentsObject;
|
||||
/*** Static scope objects ************************************************************************/
|
||||
|
||||
void
|
||||
StaticScopeObject::setEnclosingScope(HandleObject obj)
|
||||
StaticScope::setEnclosingScope(HandleObject obj)
|
||||
{
|
||||
MOZ_ASSERT_IF(obj->is<StaticBlockObject>(), obj->isDelegate());
|
||||
MOZ_ASSERT_IF(obj->is<StaticBlockScope>(), obj->isDelegate());
|
||||
setFixedSlot(ENCLOSING_SCOPE_SLOT, ObjectValue(*obj));
|
||||
}
|
||||
|
||||
bool
|
||||
StaticBlockObject::isExtensible() const
|
||||
StaticBlockScope::isExtensible() const
|
||||
{
|
||||
return nonProxyIsExtensible();
|
||||
}
|
||||
|
||||
StaticBlockObject*
|
||||
StaticBlockObject::create(ExclusiveContext* cx)
|
||||
StaticBlockScope*
|
||||
StaticBlockScope::create(ExclusiveContext* cx)
|
||||
{
|
||||
Rooted<TaggedProto> nullProto(cx, TaggedProto(nullptr));
|
||||
JSObject* obj = NewObjectWithGivenTaggedProto(cx, &ClonedBlockObject::class_, nullProto,
|
||||
TenuredObject, BaseShape::DELEGATE);
|
||||
return obj ? &obj->as<StaticBlockObject>() : nullptr;
|
||||
return obj ? &obj->as<StaticBlockScope>() : nullptr;
|
||||
}
|
||||
|
||||
Shape*
|
||||
StaticBlockObject::lookupAliasedName(PropertyName* name)
|
||||
StaticBlockScope::lookupAliasedName(PropertyName* name)
|
||||
{
|
||||
Shape::Range<NoGC> r(lastProperty());
|
||||
while (!r.empty()) {
|
||||
@ -75,7 +75,7 @@ StaticBlockObject::lookupAliasedName(PropertyName* name)
|
||||
}
|
||||
|
||||
bool
|
||||
StaticBlockObject::makeNonExtensible(ExclusiveContext* cx)
|
||||
StaticBlockScope::makeNonExtensible(ExclusiveContext* cx)
|
||||
{
|
||||
// Do not do all the work of js::PreventExtensions, as BlockObjects are
|
||||
// known to be NativeObjects, have no lazy properties, and no dense
|
||||
@ -87,8 +87,8 @@ StaticBlockObject::makeNonExtensible(ExclusiveContext* cx)
|
||||
}
|
||||
|
||||
/* static */ Shape*
|
||||
StaticBlockObject::addVar(ExclusiveContext* cx, Handle<StaticBlockObject*> block, HandleId id,
|
||||
bool constant, unsigned index, bool* redeclared)
|
||||
StaticBlockScope::addVar(ExclusiveContext* cx, Handle<StaticBlockScope*> block, HandleId id,
|
||||
bool constant, unsigned index, bool* redeclared)
|
||||
{
|
||||
MOZ_ASSERT(JSID_IS_ATOM(id));
|
||||
MOZ_ASSERT(index < LOCAL_INDEX_LIMIT);
|
||||
@ -119,43 +119,43 @@ StaticBlockObject::addVar(ExclusiveContext* cx, Handle<StaticBlockObject*> block
|
||||
/* allowDictionary = */ false);
|
||||
}
|
||||
|
||||
const Class StaticWithObject::class_ = {
|
||||
const Class StaticWithScope::class_ = {
|
||||
"WithTemplate",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticWithObject::RESERVED_SLOTS) |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticWithScope::RESERVED_SLOTS) |
|
||||
JSCLASS_IS_ANONYMOUS
|
||||
};
|
||||
|
||||
StaticWithObject*
|
||||
StaticWithObject::create(ExclusiveContext* cx)
|
||||
StaticWithScope*
|
||||
StaticWithScope::create(ExclusiveContext* cx)
|
||||
{
|
||||
return NewObjectWithNullTaggedProto<StaticWithObject>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
return NewObjectWithNullTaggedProto<StaticWithScope>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
}
|
||||
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
js::XDRStaticWithObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticWithObject*> objp)
|
||||
js::XDRStaticWithScope(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticWithScope*> objp)
|
||||
{
|
||||
if (mode == XDR_DECODE) {
|
||||
JSContext* cx = xdr->cx();
|
||||
Rooted<StaticWithObject*> obj(cx, StaticWithObject::create(cx));
|
||||
Rooted<StaticWithScope*> obj(cx, StaticWithScope::create(cx));
|
||||
if (!obj)
|
||||
return false;
|
||||
obj->initEnclosingScope(enclosingScope);
|
||||
objp.set(obj);
|
||||
}
|
||||
// For encoding, there is nothing to do. The only information that is
|
||||
// encoded by a StaticWithObject is its presence on the scope chain, and the
|
||||
// encoded by a StaticWithScope is its presence on the scope chain, and the
|
||||
// script XDR handler already takes care of that.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template bool
|
||||
js::XDRStaticWithObject(XDRState<XDR_ENCODE>*, HandleObject, MutableHandle<StaticWithObject*>);
|
||||
js::XDRStaticWithScope(XDRState<XDR_ENCODE>*, HandleObject, MutableHandle<StaticWithScope*>);
|
||||
|
||||
template bool
|
||||
js::XDRStaticWithObject(XDRState<XDR_DECODE>*, HandleObject, MutableHandle<StaticWithObject*>);
|
||||
js::XDRStaticWithScope(XDRState<XDR_DECODE>*, HandleObject, MutableHandle<StaticWithScope*>);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -708,9 +708,9 @@ DeclEnvObject::create(JSContext* cx, HandleObject enclosing, HandleFunction call
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
CloneStaticWithObject(JSContext* cx, HandleObject enclosingScope, Handle<StaticWithObject*> srcWith)
|
||||
CloneStaticWithObject(JSContext* cx, HandleObject enclosingScope, Handle<StaticWithScope*> srcWith)
|
||||
{
|
||||
Rooted<StaticWithObject*> clone(cx, StaticWithObject::create(cx));
|
||||
Rooted<StaticWithScope*> clone(cx, StaticWithScope::create(cx));
|
||||
if (!clone)
|
||||
return nullptr;
|
||||
|
||||
@ -723,7 +723,7 @@ DynamicWithObject*
|
||||
DynamicWithObject::create(JSContext* cx, HandleObject object, HandleObject enclosing,
|
||||
HandleObject staticWith, WithKind kind)
|
||||
{
|
||||
MOZ_ASSERT(staticWith->is<StaticWithObject>());
|
||||
MOZ_ASSERT(staticWith->is<StaticWithScope>());
|
||||
|
||||
Rooted<TaggedProto> proto(cx, TaggedProto(staticWith));
|
||||
Rooted<DynamicWithObject*> obj(cx);
|
||||
@ -846,11 +846,11 @@ const Class DynamicWithObject::class_ = {
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ StaticEvalObject*
|
||||
StaticEvalObject::create(JSContext* cx, HandleObject enclosing)
|
||||
/* static */ StaticEvalScope*
|
||||
StaticEvalScope::create(JSContext* cx, HandleObject enclosing)
|
||||
{
|
||||
StaticEvalObject* obj =
|
||||
NewObjectWithNullTaggedProto<StaticEvalObject>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
StaticEvalScope* obj =
|
||||
NewObjectWithNullTaggedProto<StaticEvalScope>(cx, TenuredObject, BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -859,17 +859,17 @@ StaticEvalObject::create(JSContext* cx, HandleObject enclosing)
|
||||
return obj;
|
||||
}
|
||||
|
||||
const Class StaticEvalObject::class_ = {
|
||||
const Class StaticEvalScope::class_ = {
|
||||
"StaticEval",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticEvalObject::RESERVED_SLOTS) |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticEvalScope::RESERVED_SLOTS) |
|
||||
JSCLASS_IS_ANONYMOUS
|
||||
};
|
||||
|
||||
/* static */ StaticNonSyntacticScopeObjects*
|
||||
StaticNonSyntacticScopeObjects::create(JSContext*cx, HandleObject enclosing)
|
||||
/* static */ StaticNonSyntacticScope*
|
||||
StaticNonSyntacticScope::create(JSContext*cx, HandleObject enclosing)
|
||||
{
|
||||
StaticNonSyntacticScopeObjects* obj =
|
||||
NewObjectWithNullTaggedProto<StaticNonSyntacticScopeObjects>(cx, TenuredObject,
|
||||
StaticNonSyntacticScope* obj =
|
||||
NewObjectWithNullTaggedProto<StaticNonSyntacticScope>(cx, TenuredObject,
|
||||
BaseShape::DELEGATE);
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
@ -878,9 +878,9 @@ StaticNonSyntacticScopeObjects::create(JSContext*cx, HandleObject enclosing)
|
||||
return obj;
|
||||
}
|
||||
|
||||
const Class StaticNonSyntacticScopeObjects::class_ = {
|
||||
"StaticNonSyntacticScopeObjects",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticNonSyntacticScopeObjects::RESERVED_SLOTS) |
|
||||
const Class StaticNonSyntacticScope::class_ = {
|
||||
"StaticNonSyntacticScope",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(StaticNonSyntacticScope::RESERVED_SLOTS) |
|
||||
JSCLASS_IS_ANONYMOUS
|
||||
};
|
||||
|
||||
@ -918,7 +918,7 @@ BlockObject::isExtensible() const
|
||||
}
|
||||
|
||||
/* static */ ClonedBlockObject*
|
||||
ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockObject*> block, HandleObject enclosing)
|
||||
ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockScope*> block, HandleObject enclosing)
|
||||
{
|
||||
MOZ_ASSERT(block->getClass() == &BlockObject::class_);
|
||||
|
||||
@ -953,7 +953,7 @@ ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockObject*> block, Handl
|
||||
}
|
||||
|
||||
/* static */ ClonedBlockObject*
|
||||
ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockObject*> block, AbstractFramePtr frame)
|
||||
ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockScope*> block, AbstractFramePtr frame)
|
||||
{
|
||||
assertSameCompartment(cx, frame);
|
||||
RootedObject enclosing(cx, frame.scopeChain());
|
||||
@ -963,7 +963,7 @@ ClonedBlockObject::create(JSContext* cx, Handle<StaticBlockObject*> block, Abstr
|
||||
/* static */ ClonedBlockObject*
|
||||
ClonedBlockObject::createGlobal(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
Rooted<StaticBlockObject*> staticLexical(cx, StaticBlockObject::create(cx));
|
||||
Rooted<StaticBlockScope*> staticLexical(cx, StaticBlockScope::create(cx));
|
||||
if (!staticLexical)
|
||||
return nullptr;
|
||||
|
||||
@ -983,10 +983,10 @@ ClonedBlockObject::createGlobal(JSContext* cx, Handle<GlobalObject*> global)
|
||||
ClonedBlockObject::createNonSyntactic(JSContext* cx, HandleObject enclosingStatic,
|
||||
HandleObject enclosingScope)
|
||||
{
|
||||
MOZ_ASSERT(enclosingStatic->is<StaticNonSyntacticScopeObjects>());
|
||||
MOZ_ASSERT(enclosingStatic->is<StaticNonSyntacticScope>());
|
||||
MOZ_ASSERT(!IsSyntacticScope(enclosingScope));
|
||||
|
||||
Rooted<StaticBlockObject*> staticLexical(cx, StaticBlockObject::create(cx));
|
||||
Rooted<StaticBlockScope*> staticLexical(cx, StaticBlockScope::create(cx));
|
||||
if (!staticLexical)
|
||||
return nullptr;
|
||||
|
||||
@ -1000,7 +1000,7 @@ ClonedBlockObject::createNonSyntactic(JSContext* cx, HandleObject enclosingStati
|
||||
}
|
||||
|
||||
/* static */ ClonedBlockObject*
|
||||
ClonedBlockObject::createHollowForDebug(JSContext* cx, Handle<StaticBlockObject*> block)
|
||||
ClonedBlockObject::createHollowForDebug(JSContext* cx, Handle<StaticBlockScope*> block)
|
||||
{
|
||||
MOZ_ASSERT(!block->needsClone());
|
||||
|
||||
@ -1023,7 +1023,7 @@ ClonedBlockObject::createHollowForDebug(JSContext* cx, Handle<StaticBlockObject*
|
||||
void
|
||||
ClonedBlockObject::copyUnaliasedValues(AbstractFramePtr frame)
|
||||
{
|
||||
StaticBlockObject& block = staticBlock();
|
||||
StaticBlockScope& block = staticBlock();
|
||||
for (unsigned i = 0; i < numVariables(); ++i) {
|
||||
if (!block.isAliased(i)) {
|
||||
Value& val = frame.unaliasedLocal(block.blockIndexToLocalIndex(i));
|
||||
@ -1035,7 +1035,7 @@ ClonedBlockObject::copyUnaliasedValues(AbstractFramePtr frame)
|
||||
/* static */ ClonedBlockObject*
|
||||
ClonedBlockObject::clone(JSContext* cx, Handle<ClonedBlockObject*> clonedBlock)
|
||||
{
|
||||
Rooted<StaticBlockObject*> staticBlock(cx, &clonedBlock->staticBlock());
|
||||
Rooted<StaticBlockScope*> staticBlock(cx, &clonedBlock->staticBlock());
|
||||
MOZ_ASSERT(!staticBlock->isExtensible());
|
||||
RootedObject enclosing(cx, &clonedBlock->enclosingScope());
|
||||
|
||||
@ -1100,13 +1100,13 @@ const Class BlockObject::class_ = {
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
js::XDRStaticBlockObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticBlockObject*> objp)
|
||||
MutableHandle<StaticBlockScope*> objp)
|
||||
{
|
||||
/* NB: Keep this in sync with CloneStaticBlockObject. */
|
||||
|
||||
JSContext* cx = xdr->cx();
|
||||
|
||||
Rooted<StaticBlockObject*> obj(cx);
|
||||
Rooted<StaticBlockScope*> obj(cx);
|
||||
uint32_t count = 0, offset = 0;
|
||||
uint8_t extensible = 0;
|
||||
|
||||
@ -1118,7 +1118,7 @@ js::XDRStaticBlockObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
}
|
||||
|
||||
if (mode == XDR_DECODE) {
|
||||
obj = StaticBlockObject::create(cx);
|
||||
obj = StaticBlockScope::create(cx);
|
||||
if (!obj)
|
||||
return false;
|
||||
obj->initEnclosingScope(enclosingScope);
|
||||
@ -1156,7 +1156,7 @@ js::XDRStaticBlockObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
bool readonly = !!(propFlags & 1);
|
||||
|
||||
bool redeclared;
|
||||
if (!StaticBlockObject::addVar(cx, obj, id, readonly, i, &redeclared)) {
|
||||
if (!StaticBlockScope::addVar(cx, obj, id, readonly, i, &redeclared)) {
|
||||
MOZ_ASSERT(!redeclared);
|
||||
return false;
|
||||
}
|
||||
@ -1205,17 +1205,17 @@ js::XDRStaticBlockObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
}
|
||||
|
||||
template bool
|
||||
js::XDRStaticBlockObject(XDRState<XDR_ENCODE>*, HandleObject, MutableHandle<StaticBlockObject*>);
|
||||
js::XDRStaticBlockObject(XDRState<XDR_ENCODE>*, HandleObject, MutableHandle<StaticBlockScope*>);
|
||||
|
||||
template bool
|
||||
js::XDRStaticBlockObject(XDRState<XDR_DECODE>*, HandleObject, MutableHandle<StaticBlockObject*>);
|
||||
js::XDRStaticBlockObject(XDRState<XDR_DECODE>*, HandleObject, MutableHandle<StaticBlockScope*>);
|
||||
|
||||
static JSObject*
|
||||
CloneStaticBlockObject(JSContext* cx, HandleObject enclosingScope, Handle<StaticBlockObject*> srcBlock)
|
||||
CloneStaticBlockObject(JSContext* cx, HandleObject enclosingScope, Handle<StaticBlockScope*> srcBlock)
|
||||
{
|
||||
/* NB: Keep this in sync with XDRStaticBlockObject. */
|
||||
|
||||
Rooted<StaticBlockObject*> clone(cx, StaticBlockObject::create(cx));
|
||||
Rooted<StaticBlockScope*> clone(cx, StaticBlockScope::create(cx));
|
||||
if (!clone)
|
||||
return nullptr;
|
||||
|
||||
@ -1236,7 +1236,7 @@ CloneStaticBlockObject(JSContext* cx, HandleObject enclosingScope, Handle<Static
|
||||
unsigned i = srcBlock->shapeToIndex(*shape);
|
||||
|
||||
bool redeclared;
|
||||
if (!StaticBlockObject::addVar(cx, clone, id, !shape->writable(), i, &redeclared)) {
|
||||
if (!StaticBlockScope::addVar(cx, clone, id, !shape->writable(), i, &redeclared)) {
|
||||
MOZ_ASSERT(!redeclared);
|
||||
return nullptr;
|
||||
}
|
||||
@ -1254,13 +1254,13 @@ CloneStaticBlockObject(JSContext* cx, HandleObject enclosingScope, Handle<Static
|
||||
|
||||
JSObject*
|
||||
js::CloneNestedScopeObject(JSContext* cx, HandleObject enclosingScope,
|
||||
Handle<NestedStaticScopeObject*> srcBlock)
|
||||
Handle<NestedStaticScope*> srcBlock)
|
||||
{
|
||||
if (srcBlock->is<StaticBlockObject>()) {
|
||||
Rooted<StaticBlockObject*> blockObj(cx, &srcBlock->as<StaticBlockObject>());
|
||||
if (srcBlock->is<StaticBlockScope>()) {
|
||||
Rooted<StaticBlockScope*> blockObj(cx, &srcBlock->as<StaticBlockScope>());
|
||||
return CloneStaticBlockObject(cx, enclosingScope, blockObj);
|
||||
} else {
|
||||
Rooted<StaticWithObject*> withObj(cx, &srcBlock->as<StaticWithObject>());
|
||||
Rooted<StaticWithScope*> withObj(cx, &srcBlock->as<StaticWithScope>());
|
||||
return CloneStaticWithObject(cx, enclosingScope, withObj);
|
||||
}
|
||||
}
|
||||
@ -2945,7 +2945,7 @@ GetDebugScopeForMissing(JSContext* cx, const ScopeIter& si)
|
||||
case ScopeIter::Block: {
|
||||
// Generators should always reify their scopes, except in this one
|
||||
// weird case of deprecated let expressions where we can create a
|
||||
// 0-variable StaticBlockObject inside a generator that does not need
|
||||
// 0-variable StaticBlockScope inside a generator that does not need
|
||||
// cloning.
|
||||
//
|
||||
// For example, |let ({} = "") { yield evalInFrame("foo"); }|.
|
||||
@ -2954,7 +2954,7 @@ GetDebugScopeForMissing(JSContext* cx, const ScopeIter& si)
|
||||
si.initialFrame().isFunctionFrame(),
|
||||
!si.initialFrame().callee()->isGenerator());
|
||||
|
||||
Rooted<StaticBlockObject*> staticBlock(cx, &si.staticBlock());
|
||||
Rooted<StaticBlockScope*> staticBlock(cx, &si.staticBlock());
|
||||
ClonedBlockObject* block;
|
||||
if (si.withinInitialFrame())
|
||||
block = ClonedBlockObject::create(cx, staticBlock, si.initialFrame());
|
||||
@ -3075,12 +3075,12 @@ js::CreateScopeObjectsForScopeChain(JSContext* cx, AutoObjectVector& scopeChain,
|
||||
|
||||
// Construct With object wrappers for the things on this scope
|
||||
// chain and use the result as the thing to scope the function to.
|
||||
Rooted<StaticWithObject*> staticWith(cx);
|
||||
Rooted<StaticWithScope*> staticWith(cx);
|
||||
RootedObject staticEnclosingScope(cx);
|
||||
Rooted<DynamicWithObject*> dynamicWith(cx);
|
||||
RootedObject dynamicEnclosingScope(cx, dynamicTerminatingScope);
|
||||
for (size_t i = scopeChain.length(); i > 0; ) {
|
||||
staticWith = StaticWithObject::create(cx);
|
||||
staticWith = StaticWithScope::create(cx);
|
||||
if (!staticWith)
|
||||
return false;
|
||||
staticWith->initEnclosingScope(staticEnclosingScope);
|
||||
|
@ -25,9 +25,9 @@ class FunctionBox;
|
||||
class ModuleBox;
|
||||
}
|
||||
|
||||
class StaticWithObject;
|
||||
class StaticEvalObject;
|
||||
class StaticNonSyntacticScopeObjects;
|
||||
class StaticWithScope;
|
||||
class StaticEvalScope;
|
||||
class StaticNonSyntacticScope;
|
||||
|
||||
class ModuleObject;
|
||||
typedef Handle<ModuleObject*> HandleModuleObject;
|
||||
@ -47,7 +47,7 @@ typedef Handle<ModuleObject*> HandleModuleObject;
|
||||
*
|
||||
* The following are syntactic static scopes:
|
||||
*
|
||||
* StaticBlockObject
|
||||
* StaticBlockScope
|
||||
* Scope for non-function body blocks. e.g., |{ let x; }|
|
||||
*
|
||||
* JSFunction
|
||||
@ -56,27 +56,27 @@ typedef Handle<ModuleObject*> HandleModuleObject;
|
||||
* ModuleObject
|
||||
* Scope for moddules.
|
||||
*
|
||||
* StaticWithObject
|
||||
* StaticWithScope
|
||||
* Scope for |with|. e.g., |with ({}) { ... }|
|
||||
*
|
||||
* StaticEvalObject
|
||||
* StaticEvalScope
|
||||
* Scope for |eval|. e.g., |eval(...)|
|
||||
*
|
||||
* The following are non-syntactic static scopes:
|
||||
*
|
||||
* StaticNonSyntacticScopeObjects
|
||||
* Signals presence of "polluting" scope objects. Used by Gecko.
|
||||
* StaticNonSyntacticScope
|
||||
* Signals presence of "polluting" scopes. Used by Gecko.
|
||||
*
|
||||
* There is an additional scope for named lambdas without a static scope
|
||||
* object. E.g., in:
|
||||
*
|
||||
* (function f() { var x; function g() { } })
|
||||
*
|
||||
* All static scope objects are StaticScopeObjects with the exception of
|
||||
* All static scope objects are StaticScope objects with the exception of
|
||||
* JSFunction and ModuleObject, which keep their enclosing scope link on
|
||||
* |JSScript::enclosingStaticScope()|.
|
||||
*/
|
||||
class StaticScopeObject : public NativeObject
|
||||
class StaticScope : public NativeObject
|
||||
{
|
||||
public:
|
||||
static const uint32_t ENCLOSING_SCOPE_SLOT = 0;
|
||||
@ -94,14 +94,14 @@ class StaticScopeObject : public NativeObject
|
||||
void setEnclosingScope(HandleObject obj);
|
||||
};
|
||||
|
||||
class NestedStaticScopeObject : public StaticScopeObject
|
||||
class NestedStaticScope : public StaticScope
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* A refinement of enclosingScope that returns nullptr if the enclosing
|
||||
* scope is not a NestedScopeObject.
|
||||
*/
|
||||
inline NestedStaticScopeObject* enclosingNestedScope() const;
|
||||
inline NestedStaticScope* enclosingNestedScope() const;
|
||||
|
||||
/*
|
||||
* Note: in the case of hoisting, this prev-link will not ultimately be
|
||||
@ -128,9 +128,9 @@ class NestedStaticScopeObject : public StaticScopeObject
|
||||
* The static block keeps the Shape rooted, and cloning the block
|
||||
* is fast.
|
||||
*/
|
||||
class StaticBlockObject : public NestedStaticScopeObject
|
||||
class StaticBlockScope : public NestedStaticScope
|
||||
{
|
||||
static const unsigned LOCAL_OFFSET_SLOT = NestedStaticScopeObject::RESERVED_SLOTS;
|
||||
static const unsigned LOCAL_OFFSET_SLOT = NestedStaticScope::RESERVED_SLOTS;
|
||||
static const unsigned RESERVED_SLOTS = LOCAL_OFFSET_SLOT + 1;
|
||||
|
||||
public:
|
||||
@ -154,7 +154,7 @@ class StaticBlockObject : public NestedStaticScopeObject
|
||||
}
|
||||
|
||||
public:
|
||||
static StaticBlockObject* create(ExclusiveContext* cx);
|
||||
static StaticBlockScope* create(ExclusiveContext* cx);
|
||||
|
||||
/*
|
||||
* Among block scopes, only the global lexical scope is extensible.
|
||||
@ -181,7 +181,7 @@ class StaticBlockObject : public NestedStaticScopeObject
|
||||
* A refinement of enclosingStaticScope that returns nullptr if the enclosing
|
||||
* static scope is a JSFunction.
|
||||
*/
|
||||
inline StaticBlockObject* enclosingBlock() const;
|
||||
inline StaticBlockScope* enclosingBlock() const;
|
||||
|
||||
uint32_t localOffset() {
|
||||
return getReservedSlot(LOCAL_OFFSET_SLOT).toPrivateUint32();
|
||||
@ -281,38 +281,38 @@ class StaticBlockObject : public NestedStaticScopeObject
|
||||
*/
|
||||
static const unsigned LOCAL_INDEX_LIMIT = JS_BIT(16);
|
||||
|
||||
static Shape* addVar(ExclusiveContext* cx, Handle<StaticBlockObject*> block, HandleId id,
|
||||
static Shape* addVar(ExclusiveContext* cx, Handle<StaticBlockScope*> block, HandleId id,
|
||||
bool constant, unsigned index, bool* redeclared);
|
||||
};
|
||||
|
||||
// Represents the lexical scope of a 'with' statement.
|
||||
class StaticWithObject : public NestedStaticScopeObject
|
||||
class StaticWithScope : public NestedStaticScope
|
||||
{
|
||||
public:
|
||||
static const Class class_;
|
||||
|
||||
static StaticWithObject* create(ExclusiveContext* cx);
|
||||
static StaticWithScope* create(ExclusiveContext* cx);
|
||||
};
|
||||
|
||||
template <XDRMode mode>
|
||||
bool
|
||||
XDRStaticWithObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticWithObject*> objp);
|
||||
XDRStaticWithScope(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticWithScope*> objp);
|
||||
|
||||
/*
|
||||
* Static eval scope placeholder objects on the static scope chain. Created at
|
||||
* the time of compiling the eval script, and set as its static enclosing
|
||||
* scope.
|
||||
*/
|
||||
class StaticEvalObject : public StaticScopeObject
|
||||
class StaticEvalScope : public StaticScope
|
||||
{
|
||||
static const uint32_t STRICT_SLOT = StaticScopeObject::RESERVED_SLOTS;
|
||||
static const uint32_t STRICT_SLOT = StaticScope::RESERVED_SLOTS;
|
||||
static const unsigned RESERVED_SLOTS = STRICT_SLOT + 1;
|
||||
|
||||
public:
|
||||
static const Class class_;
|
||||
|
||||
static StaticEvalObject* create(JSContext* cx, HandleObject enclosing);
|
||||
static StaticEvalScope* create(JSContext* cx, HandleObject enclosing);
|
||||
|
||||
JSObject* enclosingScopeForStaticScopeIter() {
|
||||
return getReservedSlot(ENCLOSING_SCOPE_SLOT).toObjectOrNull();
|
||||
@ -330,10 +330,10 @@ class StaticEvalObject : public StaticScopeObject
|
||||
};
|
||||
|
||||
/*
|
||||
* Non-syntactic scope objects
|
||||
* Non-syntactic scopes
|
||||
*
|
||||
* A non-syntactic scope is one that was not created due to source code. On
|
||||
* the static scope chain, a single StaticNonSyntacticScopeObjects maps to 0+
|
||||
* the static scope chain, a single StaticNonSyntacticScope maps to 0+
|
||||
* non-syntactic dynamic scope objects. This is contrasted with syntactic
|
||||
* scopes, where each syntactic static scope corresponds to 0 or 1 dynamic
|
||||
* scope objects.
|
||||
@ -436,13 +436,13 @@ class StaticEvalObject : public StaticScopeObject
|
||||
* ClonedBlockObject
|
||||
*
|
||||
*/
|
||||
class StaticNonSyntacticScopeObjects : public StaticScopeObject
|
||||
class StaticNonSyntacticScope : public StaticScope
|
||||
{
|
||||
public:
|
||||
static const unsigned RESERVED_SLOTS = StaticScopeObject::RESERVED_SLOTS;
|
||||
static const unsigned RESERVED_SLOTS = StaticScope::RESERVED_SLOTS;
|
||||
static const Class class_;
|
||||
|
||||
static StaticNonSyntacticScopeObjects* create(JSContext* cx, HandleObject enclosing);
|
||||
static StaticNonSyntacticScope* create(JSContext* cx, HandleObject enclosing);
|
||||
|
||||
JSObject* enclosingScopeForStaticScopeIter() {
|
||||
return getReservedSlot(ENCLOSING_SCOPE_SLOT).toObjectOrNull();
|
||||
@ -456,10 +456,10 @@ class StaticScopeIter
|
||||
bool onNamedLambda;
|
||||
|
||||
static bool IsStaticScope(JSObject* obj) {
|
||||
return obj->is<StaticBlockObject>() ||
|
||||
obj->is<StaticWithObject>() ||
|
||||
obj->is<StaticEvalObject>() ||
|
||||
obj->is<StaticNonSyntacticScopeObjects>() ||
|
||||
return obj->is<StaticBlockScope>() ||
|
||||
obj->is<StaticWithScope>() ||
|
||||
obj->is<StaticEvalScope>() ||
|
||||
obj->is<StaticNonSyntacticScope>() ||
|
||||
obj->is<JSFunction>() ||
|
||||
obj->is<ModuleObject>();
|
||||
}
|
||||
@ -511,10 +511,10 @@ class StaticScopeIter
|
||||
enum Type { Module, Function, Block, With, NamedLambda, Eval, NonSyntactic };
|
||||
Type type() const;
|
||||
|
||||
StaticBlockObject& block() const;
|
||||
StaticWithObject& staticWith() const;
|
||||
StaticEvalObject& eval() const;
|
||||
StaticNonSyntacticScopeObjects& nonSyntactic() const;
|
||||
StaticBlockScope& block() const;
|
||||
StaticWithScope& staticWith() const;
|
||||
StaticEvalScope& eval() const;
|
||||
StaticNonSyntacticScope& nonSyntactic() const;
|
||||
JSScript* funScript() const;
|
||||
JSFunction& fun() const;
|
||||
frontend::FunctionBox* maybeFunctionBox() const;
|
||||
@ -589,17 +589,17 @@ ScopeCoordinateFunctionScript(JSScript* script, jsbytecode* pc);
|
||||
*
|
||||
* JSObject Generic object
|
||||
* | |
|
||||
* | StaticScopeObject Created at compile time
|
||||
* | StaticScope Created at compile time
|
||||
* | | | |
|
||||
* | | | StaticNonSyntacticScopeObjects See "Non-syntactic scope objects"
|
||||
* | | | StaticNonSyntacticScope See "Non-syntactic scopes"
|
||||
* | | |
|
||||
* | | StaticEvalObject Placeholder so eval scopes may be iterated through
|
||||
* | | StaticEvalScope Placeholder so eval scopes may be iterated through
|
||||
* | |
|
||||
* | NestedStaticScopeObject Enclosing scope is in the same JSScript
|
||||
* | NestedStaticScope Enclosing scope is in the same JSScript
|
||||
* | | |
|
||||
* | | StaticBlockObject See NB
|
||||
* | | StaticBlockScope See NB
|
||||
* | |
|
||||
* | StaticWithObject Template for "with" object in static scope chain
|
||||
* | StaticWithScope Template for "with" object in static scope chain
|
||||
* |
|
||||
* ScopeObject Engine-internal scope
|
||||
* | | |
|
||||
@ -845,8 +845,8 @@ class NestedScopeObject : public ScopeObject
|
||||
{
|
||||
public:
|
||||
// Return the static scope corresponding to this scope chain object.
|
||||
inline NestedStaticScopeObject* staticScope() {
|
||||
return &getProto()->as<NestedStaticScopeObject>();
|
||||
inline NestedStaticScope* staticScope() {
|
||||
return &getProto()->as<NestedStaticScope>();
|
||||
}
|
||||
|
||||
void initEnclosingScope(JSObject* obj) {
|
||||
@ -875,8 +875,8 @@ class DynamicWithObject : public NestedScopeObject
|
||||
create(JSContext* cx, HandleObject object, HandleObject enclosing, HandleObject staticWith,
|
||||
WithKind kind = SyntacticWith);
|
||||
|
||||
StaticWithObject& staticWith() const {
|
||||
return getProto()->as<StaticWithObject>();
|
||||
StaticWithScope& staticWith() const {
|
||||
return getProto()->as<StaticWithScope>();
|
||||
}
|
||||
|
||||
/* Return the 'o' in 'with (o)'. */
|
||||
@ -939,11 +939,11 @@ class ClonedBlockObject : public BlockObject
|
||||
{
|
||||
static const unsigned THIS_VALUE_SLOT = 1;
|
||||
|
||||
static ClonedBlockObject* create(JSContext* cx, Handle<StaticBlockObject*> block,
|
||||
static ClonedBlockObject* create(JSContext* cx, Handle<StaticBlockScope*> block,
|
||||
HandleObject enclosing);
|
||||
|
||||
public:
|
||||
static ClonedBlockObject* create(JSContext* cx, Handle<StaticBlockObject*> block,
|
||||
static ClonedBlockObject* create(JSContext* cx, Handle<StaticBlockScope*> block,
|
||||
AbstractFramePtr frame);
|
||||
|
||||
static ClonedBlockObject* createGlobal(JSContext* cx, Handle<GlobalObject*> global);
|
||||
@ -952,11 +952,11 @@ class ClonedBlockObject : public BlockObject
|
||||
HandleObject enclosingScope);
|
||||
|
||||
static ClonedBlockObject* createHollowForDebug(JSContext* cx,
|
||||
Handle<StaticBlockObject*> block);
|
||||
Handle<StaticBlockScope*> block);
|
||||
|
||||
/* The static block from which this block was cloned. */
|
||||
StaticBlockObject& staticBlock() const {
|
||||
return getProto()->as<StaticBlockObject>();
|
||||
StaticBlockScope& staticBlock() const {
|
||||
return getProto()->as<StaticBlockScope>();
|
||||
}
|
||||
|
||||
/* Assuming 'put' has been called, return the value of the ith let var. */
|
||||
@ -1035,11 +1035,11 @@ class RuntimeLexicalErrorObject : public ScopeObject
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
XDRStaticBlockObject(XDRState<mode>* xdr, HandleObject enclosingScope,
|
||||
MutableHandle<StaticBlockObject*> objp);
|
||||
MutableHandle<StaticBlockScope*> objp);
|
||||
|
||||
extern JSObject*
|
||||
CloneNestedScopeObject(JSContext* cx, HandleObject enclosingScope,
|
||||
Handle<NestedStaticScopeObject*> src);
|
||||
Handle<NestedStaticScope*> src);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -1094,10 +1094,10 @@ class MOZ_RAII ScopeIter
|
||||
ScopeObject& scope() const;
|
||||
|
||||
JSObject* maybeStaticScope() const;
|
||||
StaticBlockObject& staticBlock() const { return ssi_.block(); }
|
||||
StaticWithObject& staticWith() const { return ssi_.staticWith(); }
|
||||
StaticEvalObject& staticEval() const { return ssi_.eval(); }
|
||||
StaticNonSyntacticScopeObjects& staticNonSyntactic() const { return ssi_.nonSyntactic(); }
|
||||
StaticBlockScope& staticBlock() const { return ssi_.block(); }
|
||||
StaticWithScope& staticWith() const { return ssi_.staticWith(); }
|
||||
StaticEvalScope& staticEval() const { return ssi_.eval(); }
|
||||
StaticNonSyntacticScope& staticNonSyntactic() const { return ssi_.nonSyntactic(); }
|
||||
JSFunction& fun() const { return ssi_.fun(); }
|
||||
ModuleObject& module() const { return ssi_.module(); }
|
||||
|
||||
@ -1330,26 +1330,26 @@ class DebugScopes
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
JSObject::is<js::StaticBlockObject>() const
|
||||
JSObject::is<js::StaticBlockScope>() const
|
||||
{
|
||||
return hasClass(&js::ClonedBlockObject::class_) && !getProto();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
JSObject::is<js::NestedStaticScopeObject>() const
|
||||
JSObject::is<js::NestedStaticScope>() const
|
||||
{
|
||||
return is<js::StaticBlockObject>() ||
|
||||
is<js::StaticWithObject>();
|
||||
return is<js::StaticBlockScope>() ||
|
||||
is<js::StaticWithScope>();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
JSObject::is<js::StaticScopeObject>() const
|
||||
JSObject::is<js::StaticScope>() const
|
||||
{
|
||||
return is<js::NestedStaticScopeObject>() ||
|
||||
is<js::StaticEvalObject>() ||
|
||||
is<js::StaticNonSyntacticScopeObjects>();
|
||||
return is<js::NestedStaticScope>() ||
|
||||
is<js::StaticEvalScope>() ||
|
||||
is<js::StaticNonSyntacticScope>();
|
||||
}
|
||||
|
||||
template<>
|
||||
@ -1413,7 +1413,7 @@ IsSyntacticScope(JSObject* scope)
|
||||
inline bool
|
||||
IsStaticGlobalLexicalScope(JSObject* scope)
|
||||
{
|
||||
return scope->is<StaticBlockObject>() && scope->as<StaticBlockObject>().isGlobal();
|
||||
return scope->is<StaticBlockScope>() && scope->as<StaticBlockScope>().isGlobal();
|
||||
}
|
||||
|
||||
inline bool
|
||||
@ -1428,17 +1428,17 @@ IsGlobalLexicalScope(JSObject* scope)
|
||||
return scope->is<ClonedBlockObject>() && scope->as<ClonedBlockObject>().isGlobal();
|
||||
}
|
||||
|
||||
inline NestedStaticScopeObject*
|
||||
NestedStaticScopeObject::enclosingNestedScope() const
|
||||
inline NestedStaticScope*
|
||||
NestedStaticScope::enclosingNestedScope() const
|
||||
{
|
||||
JSObject* obj = getReservedSlot(ENCLOSING_SCOPE_SLOT).toObjectOrNull();
|
||||
return obj && obj->is<NestedStaticScopeObject>()
|
||||
? &obj->as<NestedStaticScopeObject>()
|
||||
return obj && obj->is<NestedStaticScope>()
|
||||
? &obj->as<NestedStaticScope>()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
inline bool
|
||||
StaticEvalObject::isNonGlobal() const
|
||||
StaticEvalScope::isNonGlobal() const
|
||||
{
|
||||
if (isStrict())
|
||||
return true;
|
||||
|
@ -2326,7 +2326,7 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
|
||||
// global lexical scope on the scope chain is for uniformity and engine
|
||||
// invariants.
|
||||
MOZ_ASSERT(IsStaticGlobalLexicalScope(sourceScript->enclosingStaticScope()));
|
||||
Rooted<StaticScopeObject*> enclosingScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
Rooted<StaticScope*> enclosingScope(cx, &cx->global()->lexicalScope().staticBlock());
|
||||
if (!CloneScriptIntoFunction(cx, enclosingScope, targetFun, sourceScript))
|
||||
return false;
|
||||
MOZ_ASSERT(!targetFun->isInterpretedLazy());
|
||||
|
@ -110,7 +110,7 @@
|
||||
namespace js {
|
||||
|
||||
class Bindings;
|
||||
class StaticBlockObject;
|
||||
class StaticBlockScope;
|
||||
class TenuringTracer;
|
||||
|
||||
typedef JSGetterOp GetterOp;
|
||||
@ -532,7 +532,7 @@ class Shape : public gc::TenuredCell
|
||||
friend class Bindings;
|
||||
friend class NativeObject;
|
||||
friend class PropertyTree;
|
||||
friend class StaticBlockObject;
|
||||
friend class StaticBlockScope;
|
||||
friend class TenuringTracer;
|
||||
friend struct StackBaseShape;
|
||||
friend struct StackShape;
|
||||
|
@ -76,7 +76,7 @@ bool
|
||||
InterpreterFrame::isNonGlobalEvalFrame() const
|
||||
{
|
||||
return isEvalFrame() &&
|
||||
script()->enclosingStaticScope()->as<StaticEvalObject>().isNonGlobal();
|
||||
script()->enclosingStaticScope()->as<StaticEvalScope>().isNonGlobal();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -312,11 +312,11 @@ InterpreterFrame::checkReturn(JSContext* cx, HandleValue thisv)
|
||||
}
|
||||
|
||||
bool
|
||||
InterpreterFrame::pushBlock(JSContext* cx, StaticBlockObject& block)
|
||||
InterpreterFrame::pushBlock(JSContext* cx, StaticBlockScope& block)
|
||||
{
|
||||
MOZ_ASSERT(block.needsClone());
|
||||
|
||||
Rooted<StaticBlockObject*> blockHandle(cx, &block);
|
||||
Rooted<StaticBlockScope*> blockHandle(cx, &block);
|
||||
ClonedBlockObject* clone = ClonedBlockObject::create(cx, blockHandle, this);
|
||||
if (!clone)
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ class ScopeObject;
|
||||
class ScriptFrameIter;
|
||||
class SPSProfiler;
|
||||
class InterpreterFrame;
|
||||
class StaticBlockObject;
|
||||
class StaticBlockScope;
|
||||
class ClonedBlockObject;
|
||||
|
||||
class ScopeCoordinate;
|
||||
@ -560,7 +560,7 @@ class InterpreterFrame
|
||||
* bindings per iteration of a for-loop.
|
||||
*/
|
||||
|
||||
bool pushBlock(JSContext* cx, StaticBlockObject& block);
|
||||
bool pushBlock(JSContext* cx, StaticBlockScope& block);
|
||||
void popBlock(JSContext* cx);
|
||||
bool freshenBlock(JSContext* cx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user