[Webkit-unassigned] [Bug 31813] Add support for block scope const

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Dec 4 07:57:08 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=31813





--- Comment #18 from Andy Wingo <wingo at igalia.com>  2011-12-04 07:57:07 PST ---
So, a status update.  I added the compile-time and run-time flags for harmony block scoping.  When the flags are on, we parse `const' in strict-mode as having block scope.  I check correctly for conflicting variable declarations, I think.

I extended the Parser::Scope object to track block-scoped declarations.  I push a scope when parsing block statements in harmony mode, and if the scope contains lexical bindings, I make a BlockScopeNode instad of a BlockStatementNode.  This works but does not currently catch

if (1)
  const x = 10;

which should be an error AFAIK.  Block-scoped declarations outside of functions are also collected at the top level; currently they result in lexical bindings, not read-only, non-configurable properties, but that can be fixed.

Anyway, that's the parser and the AST.  It used to be that ProgramNode, EvalNode, and FunctionBodyNode all descended from ScopeNode, but I changed them to descend from an interposed CodeNode, and then BlockScopeNode descends from ScopeNode but without the toplevel baggage of the others.  I'm not sure if this was useful though.

Implementation-wise, things are pretty terrible: I have a JSBlockScopeObject like the StaticScopeObject, but with more slots.  Entering in a block scope will allocate that object and push it on the scope chain.  Currently findScopedProperty punts in that case; something to fix.  So the lookup is not fast.  It's a shame though; in strict mode, it should be possible to do much better (with assignment conversion).

There is a new VM op to create a blockscope.  Perhaps that should merge with JSStaticScope.

I have not yet modified either JIT.  I have not yet implemented the read- or write-barriers.  They will probably require additional vm ops.

Unless you want the patches now, I'll clean them up before posting for review.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list