Ignore:
Timestamp:
Aug 30, 2012, 3:50:00 PM (13 years ago)
Author:
[email protected]
Message:

Use one object instead of two for closures, eliminating ScopeChainNode
https://bugs.webkit.org/show_bug.cgi?id=95501

Reviewed by Filip Pizlo.

../JavaScriptCore:

This patch removes ScopeChainNode, and moves all the data and related
functions that used to be in ScopeChainNode into JSScope.

Most of this patch is mechanical changes to use a JSScope* where we used
to use a ScopeChainNode*. I've only specifically commented about items
that were non-mechanical.

  • runtime/Completion.cpp:

(JSC::evaluate):

  • runtime/Completion.h: Don't require an explicit scope chain argument

when evaluating code. Clients never wanted anything other than the
global scope, and other arbitrary scopes probably wouldn't work
correctly, anyway.

  • runtime/JSScope.cpp:
  • runtime/JSScope.h:

(JSC::JSScope::JSScope): JSScope now requires the data we used to pass to
ScopeChainNode, so it can link itself into the scope chain correctly.

  • runtime/JSWithScope.h:

(JSC::JSWithScope::create):
(JSC::JSWithScope::JSWithScope): JSWithScope gets an extra constructor
for specifically supplying your own scope chain. The DOM needs this
interface for setting up the scope chain for certain event handlers.
Other clients always just push the JSWithScope to the head of the current
scope chain.

../WebCore:

Mechanical changes to update for JSC interface changes.

../WebKit/mac:

Mechanical change to update for JSC interface change.

../WebKit/qt:

Mechanical change to update for JSC interface change.

  • Api/qwebelement.cpp:

(QWebElement::evaluateJavaScript):

../WebKit2:

Mechanical changes to update for JSC interface change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSFunction.h

    r127191 r127202  
    2626
    2727#include "InternalFunction.h"
    28 #include "JSObject.h"
     28#include "JSScope.h"
    2929
    3030namespace JSC {
     
    5858        JS_EXPORT_PRIVATE static JSFunction* create(ExecState*, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
    5959
    60         static JSFunction* create(ExecState* exec, FunctionExecutable* executable, ScopeChainNode* scopeChain)
     60        static JSFunction* create(ExecState* exec, FunctionExecutable* executable, JSScope* scope)
    6161        {
    62             JSFunction* function = new (NotNull, allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, executable, scopeChain);
     62            JSFunction* function = new (NotNull, allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, executable, scope);
    6363            ASSERT(function->structure()->globalObject());
    64             function->finishCreation(exec, executable, scopeChain);
     64            function->finishCreation(exec, executable, scope);
    6565            return function;
    6666        }
     
    7070        const String calculatedDisplayName(ExecState*);
    7171
    72         ScopeChainNode* scope()
     72        JSScope* scope()
    7373        {
    7474            ASSERT(!isHostFunctionNonInline());
    75             return m_scopeChain.get();
     75            return m_scope.get();
    7676        }
    7777        // This method may be called for host functins, in which case it
     
    8080        // host functions, and checking whether the function is a host
    8181        // function is deemed too expensive.
    82         ScopeChainNode* scopeUnchecked()
     82        JSScope* scopeUnchecked()
    8383        {
    84             return m_scopeChain.get();
     84            return m_scope.get();
    8585        }
    86         void setScope(JSGlobalData& globalData, ScopeChainNode* scopeChain)
     86        void setScope(JSGlobalData& globalData, JSScope* scope)
    8787        {
    8888            ASSERT(!isHostFunctionNonInline());
    89             m_scopeChain.set(globalData, this, scopeChain);
     89            m_scope.set(globalData, this, scope);
    9090        }
    9191
     
    114114        static inline size_t offsetOfScopeChain()
    115115        {
    116             return OBJECT_OFFSETOF(JSFunction, m_scopeChain);
     116            return OBJECT_OFFSETOF(JSFunction, m_scope);
    117117        }
    118118
     
    138138
    139139        JS_EXPORT_PRIVATE JSFunction(ExecState*, JSGlobalObject*, Structure*);
    140         JSFunction(ExecState*, FunctionExecutable*, ScopeChainNode*);
     140        JSFunction(ExecState*, FunctionExecutable*, JSScope*);
    141141       
    142142        void finishCreation(ExecState*, NativeExecutable*, int length, const String& name);
    143         void finishCreation(ExecState*, FunctionExecutable*, ScopeChainNode*);
     143        void finishCreation(ExecState*, FunctionExecutable*, JSScope*);
    144144
    145145        Structure* cacheInheritorID(ExecState*);
     
    166166
    167167        WriteBarrier<ExecutableBase> m_executable;
    168         WriteBarrier<ScopeChainNode> m_scopeChain;
     168        WriteBarrier<JSScope> m_scope;
    169169        WriteBarrier<Structure> m_cachedInheritorID;
    170170    };
Note: See TracChangeset for help on using the changeset viewer.