Ignore:
Timestamp:
Sep 6, 2012, 6:42:53 PM (13 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Rolled back in <http://trac.webkit.org/changeset/127698> with a fix for
fast/dom/HTMLScriptElement/script-reexecution-pretty-diff.html, which
is to make sure that function declarations don't put their names in scope.

Reviewed by Gavin Barraclough.

Named functions should not allocate scope objects for their names
https://bugs.webkit.org/show_bug.cgi?id=95659

Reviewed by Oliver Hunt.

LayoutTests: Rolled back in <http://trac.webkit.org/changeset/127698> with a fix for
fast/dom/HTMLScriptElement/script-reexecution-pretty-diff.html.

Added a more explicit test for the feature I broke in
fast/dom/HTMLScriptElement/script-reexecution-pretty-diff.html.

Reviewed by Gavin Barraclough.

Named functions should not allocate scope objects for their names
https://bugs.webkit.org/show_bug.cgi?id=95659

Reviewed by Oliver Hunt.

  • fast/dom/HTMLScriptElement/script-reexecution.html:
  • fast/js/function-name-is-in-scope-expected.txt: Added.
  • fast/js/function-name-is-in-scope.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r127809 r127810  
     12012-09-05  Geoffrey Garen  <[email protected]>
     2
     3        Rolled back in <http://trac.webkit.org/changeset/127698> with a fix for
     4        fast/dom/HTMLScriptElement/script-reexecution-pretty-diff.html, which
     5        is to make sure that function declarations don't put their names in scope.
     6
     7        Reviewed by Gavin Barraclough.
     8
     9            Named functions should not allocate scope objects for their names
     10            https://bugs.webkit.org/show_bug.cgi?id=95659
     11
     12            Reviewed by Oliver Hunt.
     13
    1142012-09-06  Michael Saboff  <[email protected]>
    215
     
    8295        * interpreter/Interpreter.cpp:
    8396        (JSC::Interpreter::privateExecute):
     97
     982012-09-05  Geoffrey Garen  <[email protected]>
     99
     100        Named functions should not allocate scope objects for their names
     101        https://bugs.webkit.org/show_bug.cgi?id=95659
     102
     103        Reviewed by Oliver Hunt.
     104
     105        In most cases, we can merge a function expression's name into its symbol
     106        table. This reduces memory footprint per closure from three objects
     107        (function + activation + name scope) to two (function + activation),
     108        speeds up closure allocation, and speeds up recursive calls.
     109
     110        In the case of a named function expression that contains a non-strict
     111        eval, the rules are so bat-poop crazy that I don't know how to model
     112        them without an extra object. Since functions now default to not having
     113        such an object, this case needs to allocate the object on function
     114        entry.
     115
     116        Therefore, this patch makes the slow case a bit slower so the fast case
     117        can be faster and more memory-efficient. (Note that the slow case already
     118        allocates an activation on entry, and until recently also allocated a
     119        scope chain node on entry, so adding one allocation on entry shouldn't
     120        break the bank.)
     121
     122        * bytecode/CodeBlock.cpp:
     123        (JSC::CodeBlock::CodeBlock): Caught a missed initializer. No behavior change.
     124
     125        * bytecompiler/BytecodeGenerator.cpp:
     126        (JSC::BytecodeGenerator::BytecodeGenerator): Put the callee in static scope
     127        during compilation so it doesn't need to be in dynamic scope at runtime.
     128
     129        (JSC::BytecodeGenerator::resolveCallee):
     130        (JSC::BytecodeGenerator::addCallee): Helper functions for either statically
     131        resolving the callee or adding a dynamic scope that will resolve to it,
     132        depending on whether you're in the fast path.
     133
     134        We move the callee into a var location if it's captured because activations
     135        prefer to have contiguous ranges of captured variables.
     136
     137        * bytecompiler/BytecodeGenerator.h:
     138        (JSC::BytecodeGenerator::registerFor):
     139        (BytecodeGenerator):
     140
     141        * dfg/DFGOperations.cpp:
     142        * interpreter/Interpreter.cpp:
     143        (JSC::Interpreter::privateExecute):
     144        * jit/JITStubs.cpp:
     145        (JSC::DEFINE_STUB_FUNCTION):
     146        * llint/LLIntSlowPaths.cpp:
     147        (JSC::LLInt::LLINT_SLOW_PATH_DECL): This is the point of the patch: remove
     148        one allocation in the case of a named function expression.
     149
     150        * parser/Parser.cpp:
     151        (JSC::::Parser):
     152        * parser/Parser.h:
     153        (JSC::Scope::declareCallee):
     154        (Scope):
     155        (Parser):
     156        (JSC::parse):
     157        * runtime/Executable.cpp:
     158        (JSC::EvalExecutable::compileInternal):
     159        (JSC::ProgramExecutable::checkSyntax):
     160        (JSC::ProgramExecutable::compileInternal):
     161        (JSC::FunctionExecutable::produceCodeBlockFor):
     162        (JSC::FunctionExecutable::fromGlobalCode): Pipe the callee's name through
     163        the parser so we get accurate information on whether the callee was captured.
     164
     165        (JSC::FunctionExecutable::FunctionExecutable):
     166        (JSC::EvalExecutable::compileInternal):
     167        (JSC::ProgramExecutable::checkSyntax):
     168        (JSC::ProgramExecutable::compileInternal):
     169        (JSC::FunctionExecutable::produceCodeBlockFor):
     170        (JSC::FunctionExecutable::fromGlobalCode):
     171        * runtime/Executable.h:
     172        (JSC::FunctionExecutable::create):
     173        (FunctionExecutable):
     174        (JSC::FunctionExecutable::finishCreation): I had to refactor function
     175        creation to support the following function constructor quirk: the function
     176        gets a name, but its name is not in lexical scope.
     177
     178        To simplify this, FunctionExecutable now automatically extracts all the
     179        data it needs from the parsed node. The special "fromGlobalCode" path
     180        used by the function constructor creates an anonymous function, and then
     181        quirkily sets the value used by the .name property to be non-null, even
     182        though the parsed name is null.
     183
     184        * runtime/JSNameScope.h:
     185        (JSC::JSNameScope::create):
     186        (JSC::JSNameScope::JSNameScope): Added support for explicitly specifying
     187        your container scope. The compiler uses this for named function expressions.
    84188
    851892012-09-05  Gavin Barraclough  <[email protected]>
Note: See TracChangeset for help on using the changeset viewer.