If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

assert the structure of the scope chain

NEW
Unassigned

Status

()

Core
JavaScript Engine
3 years ago
2 years ago

People

(Reporter: luke, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
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?
(Reporter)

Comment 2

3 years ago
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
(Reporter)

Comment 3

3 years ago
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?)
(Reporter)

Comment 4

3 years ago
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()
You need to log in before you can comment on or make changes to this bug.