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/runtime/Executable.h

    r127774 r127810  
    540540        typedef ScriptExecutable Base;
    541541
    542         static FunctionExecutable* create(ExecState* exec, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    543         {
    544             FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, inferredName, source, forceUsesArguments, parameters, isInStrictContext);
    545             executable->finishCreation(exec->globalData(), name, firstLine, lastLine);
     542        static FunctionExecutable* create(JSGlobalData& globalData, FunctionBodyNode* node)
     543        {
     544            FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, node);
     545            executable->finishCreation(globalData);
    546546            return executable;
    547547        }
    548 
    549         static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const Identifier& inferredName, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    550         {
    551             FunctionExecutable* executable = new (NotNull, allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, inferredName, source, forceUsesArguments, parameters, isInStrictContext);
    552             executable->finishCreation(globalData, name, firstLine, lastLine);
    553             return executable;
    554         }
     548        static FunctionExecutable* fromGlobalCode(const Identifier& name, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
    555549
    556550        static void destroy(JSCell*);
    557551
    558         JSFunction* make(ExecState* exec, JSScope* scope)
    559         {
    560             return JSFunction::create(exec, this, scope);
    561         }
    562        
    563552        // Returns either call or construct bytecode. This can be appropriate
    564553        // for answering questions that that don't vary between call and construct --
     
    709698        void clearCodeIfNotCompiling();
    710699        static void visitChildren(JSCell*, SlotVisitor&);
    711         static FunctionExecutable* fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
    712700        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
    713701        {
     
    722710
    723711    protected:
    724         void finishCreation(JSGlobalData& globalData, const Identifier& name, int firstLine, int lastLine)
     712        void finishCreation(JSGlobalData& globalData)
    725713        {
    726714            Base::finishCreation(globalData);
    727             m_firstLine = firstLine;
    728             m_lastLine = lastLine;
    729             m_nameValue.set(globalData, this, jsString(&globalData, name.ustring()));
     715            m_nameValue.set(globalData, this, jsString(&globalData, name().ustring()));
    730716        }
    731717
    732718    private:
    733         FunctionExecutable(JSGlobalData&, const Identifier& name, const Identifier& inferredName, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool);
    734         FunctionExecutable(ExecState*, const Identifier& name, const Identifier& inferredName, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool);
     719        FunctionExecutable(JSGlobalData&, FunctionBodyNode*);
    735720
    736721        JSObject* compileForCallInternal(ExecState*, JSScope*, JITCode::JITType, unsigned bytecodeIndex = UINT_MAX);
     
    765750        Identifier m_name;
    766751        Identifier m_inferredName;
     752        FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle;
    767753        WriteBarrier<JSString> m_nameValue;
    768754        WriteBarrier<SharedSymbolTable> m_symbolTable;
Note: See TracChangeset for help on using the changeset viewer.