Changeset 26621 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Oct 15, 2007, 1:44:09 PM (18 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Darin Adler.


Removed surprising self-named "hack" that made nested functions
available as named properties of their containing functions, and placed
containing function objects in the scope chains of nested functions.


There were a few reasons to remove this "hack:"

  1. It contradicted FF, IE, and the ECMA spec.
  1. It incurred a performance penalty, since merely parsing a function required parsing its body for nested functions (and so on).
  1. SVN history contains no explanation for why it was added. It was just legacy code in a large merge a long, long time ago.

[ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]

  • kjs/nodes.cpp: (FuncDeclNode::processFuncDecl):

LayoutTests:

Reviewed by Darin Adler.


Removed surprising self-named "hack" that made nested functions
available as named properties of their containing functions, and placed
containing function objects in the scope chains of nested functions.


[ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]

Changed this test to reflect correct behavior:

  • fast/js/kde/function-expected.txt:
  • fast/js/kde/resources/function.js: (Also removed tab characters.)

Added this test to flesh out the behavior more:

  • fast/js/nested-function-scope-expected.txt: Added.
  • fast/js/nested-function-scope.html: Added.
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26620 r26621  
     12007-10-15  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Darin Adler.
     4       
     5        Removed surprising self-named "hack" that made nested functions
     6        available as named properties of their containing functions, and placed
     7        containing function objects in the scope chains of nested functions.
     8       
     9        There were a few reasons to remove this "hack:"
     10
     11        1. It contradicted FF, IE, and the ECMA spec.
     12
     13        2. It incurred a performance penalty, since merely parsing a function
     14        required parsing its body for nested functions (and so on).
     15
     16        3. SVN history contains no explanation for why it was added. It was just
     17        legacy code in a large merge a long, long time ago.
     18
     19        [ Patch broken off from http://bugs.webkit.org/show_bug.cgi?id=14868 ]
     20
     21        * kjs/nodes.cpp:
     22        (FuncDeclNode::processFuncDecl):
     23
    1242007-10-15  Geoffrey Garen  <[email protected]>
    225
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r26620 r26621  
    24872487  // ECMA 10.2.2
    24882488  context->variableObject()->put(exec, ident, func, Internal | (context->codeType() == EvalCode ? 0 : DontDelete));
    2489 
    2490   if (body) {
    2491     // hack the scope so that the function gets put as a property of func, and it's scope
    2492     // contains the func as well as our current scope
    2493     JSObject *oldVar = context->variableObject();
    2494     context->setVariableObject(func);
    2495     context->pushScope(func);
    2496     body->processFuncDecl(exec);
    2497     context->popScope();
    2498     context->setVariableObject(oldVar);
    2499   }
    25002489}
    25012490
Note: See TracChangeset for help on using the changeset viewer.