Open Bug 1289918 Opened 8 years ago Updated 2 years ago

Make bindingsAccessedDynamically a smaller gun

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

REOPENED

People

(Reporter: shu, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: triage-deferred)

bindingsAccessedDynamically in a SharedContext currently end up causing *all* scopes in the script to have environments, even things that still can't be accessed dynamically. For example, function f() { eval(...); { let x; // has an environment slot } } We should refine this notion after bug 1263355.
Depends on: 1263355
Keywords: triage-deferred
Priority: -- → P3
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INCOMPLETE

Whoops; I thought this was fixed but a test case suggests no, we still store x in an environment:

function f(s) {
  eval(s)

  {
    let x; // has an environment slot
  }
}
dis(f)

{
  "file": "typein",
  "lineno": 8,
  "column": 10,
  "immutableFlags": [
    "IsFunction",
    "HasDirectEval",
    "BindingsAccessedDynamically",
    "FunHasExtensibleScope",
    "FunctionHasThisBinding",
    "NeedsFunctionEnvironmentObjects",
    "ShouldDeclareArguments",
    "NeedsArgsObj",
    "HasMappedArgsObj",
    "FunctionHasNewTargetBinding"
  ],
  "functionName": "f",
  "functionFlags": [
    "NORMAL_KIND",
    "BASESCRIPT",
    "CONSTRUCTOR"
  ]
}
loc   line  op
----- ----  --
00000:   8  Arguments                   # arguments
00001:   8  SetAliasedVar "arguments" (hops = 0, slot = 3) # arguments
00006:   8  Pop                         # 
00007:   8  FunctionThis                # THIS
00008:   8  SetAliasedVar ".this" (hops = 0, slot = 4) # THIS
00013:   8  Pop                         # 
00014:   8  NewTarget                   # new.target
00015:   8  SetAliasedVar ".newTarget" (hops = 0, slot = 5) # new.target
00020:   8  Pop                         # 
main:
00021:   9  GetName "eval"              # eval
00026:   9  Undefined                   # eval undefined
00027:   9  GetAliasedVar "s" (hops = 0, slot = 2) # eval undefined s
00032:   9  Eval 1                      # eval(...)
00035:   9  Lineno 9                    # eval(...)
00040:   9  Pop                         # 
00041:  11  PushLexicalEnv lexical {x: env slot 2} # 
00046:  12  Undefined                   # undefined
00047:  12  InitAliasedLexical "x" (hops = 0, slot = 2) # undefined
00052:  12  Pop                         # 
00053:  12  PopLexicalEnv               # 
00054:  14  RetRval                     # 

Source notes:
 ofs line column    pc  delta desc       args
---- ---- ------ ----- ------ ---------- ------
  0:    8     10    21 [  21] xdelta    
  1:    8     10    21 [   0] newline   
  2:    9      0    21 [   0] colspan    colspan 2
  4:    9      2    21 [   0] step-sep  
  5:    9      2    21 [   0] breakpoint
  6:    9      2    41 [  20] xdelta    
  7:    9      2    41 [   0] setline    lineno 11
  9:   11      0    41 [   0] colspan    colspan 2
 11:   11      2    46 [   5] newline   
 12:   12      0    54 [   8] setline    lineno 14
 14:   14      0    54 [   0] breakpoint

Exception table:
kind               stack    start      end

Scope notes:
   index   parent    start      end
       2   (none)       46       54

GC things:
   index   type       value
       0   Scope      function {
                         0: formal parameter s (env slot 2)
                         1: var arguments (env slot 3)
                         2: var .this (env slot 4)
                         3: var .newTarget (env slot 5)
                      } -> global
       1   Atom       "eval"
       2   Scope      lexical {
                         0: let x (env slot 2)
                      } -> function -> global
Blocks: sm-frontend
Status: RESOLVED → REOPENED
Resolution: INCOMPLETE → ---
You need to log in before you can comment on or make changes to this bug.