Open Bug 1143794 Opened 9 years ago Updated 2 years ago

assert the structure of the scope chain

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

People

(Reporter: luke, Unassigned)

Details

With all the recent refactorings, we have a pretty clean scope chain structure now:
 zero or more syntactic scope objects followed by
 zero or more non-syntactic with objects followed by 
 zero or one isUnqualifiedVarObj() plain objects
 the global object

(That isUnqualifiedVarObj() plain object is an impl detail of ExecuteInGlobalAndReturnScope() and could possibly be replaced with something more structured if necessary.)

This structure may be useful in the future (perhaps for optimizing scope representation), so it'd be nice to pin it down with a global AssertScopeChainStructure() that we call everywhere.  Giving the isUnqualifiedVarObj() vanilla object its own new class could add further specificity to the assert.
Actually, I forgot one other thing that can live on the scope chain before the global: a DebugScopeObject.  Though I'm not actually 100% sure it must live before the global; it might be able to live in between syntactic scope objects?
Oh, right.  IIUC, this just changes the list to:
 ((zero or more syntactic scope objects) OR (zero or more DebugScopeProxies)) followed by
 zero or more non-syntactic with objects followed by 
 zero or one isUnqualifiedVarObj() plain objects
 the global object
Oops, I forgot that, once running, debugger code can add it's own syntactic scope objects, so we really have:
 zero or more syntactic scope objects followed by
 zero or more DebugScopeProxies followed by
 zero or more non-syntactic with objects followed by 
 zero or one isUnqualifiedVarObj() plain objects
 the global object
(Right?)
Updating from IRC: it seems like you can't have both non-syntactic with AND the isUnqualifiedVarObj():
 zero or more syntactic scope objects followed by
 zero or more DebugScopeProxies followed by
 ((zero or more non-syntactic with objects) OR
  (zero or one isUnqualifiedVarObj() plain object)) followed by
 the global object

Additionally, we'd want to assert:
 - that the final "return global()" case in JSObject::enclosingScope() only hit for the isUnqualifiedVarObj()
 - that the dynamic-scope chain Clone/Execute never clone with an isUnqualifiedVarObj()
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.