Changeset 127010 in webkit


Ignore:
Timestamp:
Aug 29, 2012 10:13:50 AM (12 years ago)
Author:
ggaren@apple.com
Message:

Introduced JSWithScope, making all scope objects subclasses of JSScope
https://bugs.webkit.org/show_bug.cgi?id=95295

Reviewed by Filip Pizlo.

This is a step toward removing ScopeChainNode. With a uniform representation
for objects in the scope chain, we can move data from ScopeChainNode
into JSScope.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri: Build!
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL): Use an explicit JSWithScope object
for 'with' statements. Since 'with' can put any object in the scope
chain, we'll need an adapter object to hold the data ScopeChainNode
currently holds.

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:

(JSGlobalData): Support for JSWithScope.

  • runtime/JSScope.cpp:

(JSC::JSScope::objectAtScope):

  • runtime/JSScope.h: Check for and unwrap JSWithScope.
  • runtime/JSType.h: Support for JSWithScope.
  • runtime/StrictEvalActivation.cpp:

(JSC::StrictEvalActivation::StrictEvalActivation):

  • runtime/StrictEvalActivation.h:

(StrictEvalActivation): Inherit from JSScope, to make the scope chain uniform.

  • runtime/JSWithScope.cpp: Added.

(JSC::JSWithScope::visitChildren):

  • runtime/JSWithScope.h: Added.

(JSWithScope):
(JSC::JSWithScope::create):
(JSC::JSWithScope::object):
(JSC::JSWithScope::createStructure):
(JSC::JSWithScope::JSWithScope): New adapter object. Since this object
is never exposed to scripts, it doesn't need any meaningful implementation
of property access or other callbacks.

Location:
trunk/Source/JavaScriptCore
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r126893 r127010  
    209209    runtime/JSSegmentedVariableObject.cpp
    210210    runtime/JSNameScope.cpp
     211    runtime/JSWithScope.cpp
    211212    runtime/JSScope.cpp
    212213    runtime/JSString.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r126990 r127010  
     12012-08-28  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Introduced JSWithScope, making all scope objects subclasses of JSScope
     4        https://bugs.webkit.org/show_bug.cgi?id=95295
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This is a step toward removing ScopeChainNode. With a uniform representation
     9        for objects in the scope chain, we can move data from ScopeChainNode
     10        into JSScope.
     11
     12        * CMakeLists.txt:
     13        * GNUmakefile.list.am:
     14        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     15        * JavaScriptCore.xcodeproj/project.pbxproj:
     16        * Target.pri: Build!
     17
     18        * interpreter/Interpreter.cpp:
     19        (JSC::Interpreter::privateExecute):
     20        * jit/JITStubs.cpp:
     21        (JSC::DEFINE_STUB_FUNCTION):
     22        * llint/LLIntSlowPaths.cpp:
     23        (JSC::LLInt::LLINT_SLOW_PATH_DECL): Use an explicit JSWithScope object
     24        for 'with' statements. Since 'with' can put any object in the scope
     25        chain, we'll need an adapter object to hold the data ScopeChainNode
     26        currently holds.
     27
     28        * runtime/JSGlobalData.cpp:
     29        (JSC::JSGlobalData::JSGlobalData):
     30        * runtime/JSGlobalData.h:
     31        (JSGlobalData): Support for JSWithScope.
     32
     33        * runtime/JSScope.cpp:
     34        (JSC::JSScope::objectAtScope):
     35        * runtime/JSScope.h: Check for and unwrap JSWithScope.
     36
     37        * runtime/JSType.h: Support for JSWithScope.
     38
     39        * runtime/StrictEvalActivation.cpp:
     40        (JSC::StrictEvalActivation::StrictEvalActivation):
     41        * runtime/StrictEvalActivation.h:
     42        (StrictEvalActivation): Inherit from JSScope, to make the scope chain uniform.
     43
     44        * runtime/JSWithScope.cpp: Added.
     45        (JSC::JSWithScope::visitChildren):
     46        * runtime/JSWithScope.h: Added.
     47        (JSWithScope):
     48        (JSC::JSWithScope::create):
     49        (JSC::JSWithScope::object):
     50        (JSC::JSWithScope::createStructure):
     51        (JSC::JSWithScope::JSWithScope): New adapter object. Since this object
     52        is never exposed to scripts, it doesn't need any meaningful implementation
     53        of property access or other callbacks.
     54
    1552012-08-29  Patrick Gansterer  <paroga@webkit.org>
    256
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r126893 r127010  
    548548        Source/JavaScriptCore/runtime/JSSegmentedVariableObject.cpp \
    549549        Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h \
     550        Source/JavaScriptCore/runtime/JSWithScope.cpp \
    550551        Source/JavaScriptCore/runtime/JSNameScope.cpp \
    551552        Source/JavaScriptCore/runtime/JSNameScope.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r126893 r127010  
    883883                        </File>
    884884                        <File
     885                                RelativePath="..\..\runtime\JSWithScope.cpp"
     886                                >
     887                        </File>
     888                        <File
     889                                RelativePath="..\..\runtime\JSWithScope.h"
     890                                >
     891                        </File>
     892                        <File
    885893                                RelativePath="..\..\runtime\JSNameScope.cpp"
    886894                                >
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r126955 r127010  
    141141                0F63945415D07055006A597C /* ArrayProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63945115D07051006A597C /* ArrayProfile.cpp */; };
    142142                0F63945515D07057006A597C /* ArrayProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63945215D07051006A597C /* ArrayProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
     143                0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    143144                0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63948115E48114006A597C /* DFGArrayMode.cpp */; };
    144145                0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63948215E48114006A597C /* DFGArrayMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    145                 0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    146146                0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */; settings = {ATTRIBUTES = (Private, ); }; };
    147147                0F66E16C14DF3F1600B7B2E4 /* DFGEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    315315                1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */; };
    316316                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440FCE20A51E46B0005F061 /* JSClassRef.cpp */; };
     317                1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1442565F15EDE98D0066A49B /* JSWithScope.cpp */; };
     318                1442566215EDE98D0066A49B /* JSWithScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1442566015EDE98D0066A49B /* JSWithScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
    317319                14469DDE107EC7E700650446 /* Lookup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8680255597D01FF60F7 /* Lookup.cpp */; };
    318320                14469DDF107EC7E700650446 /* MathObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A86A0255597D01FF60F7 /* MathObject.cpp */; };
     
    721723                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; };
    722724                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; };
    723                 FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */;  settings = {ATTRIBUTES = (Private, ); }; };
     725                FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    724726/* End PBXBuildFile section */
    725727
     
    902904                0F63945115D07051006A597C /* ArrayProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayProfile.cpp; sourceTree = "<group>"; };
    903905                0F63945215D07051006A597C /* ArrayProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayProfile.h; sourceTree = "<group>"; };
     906                0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
    904907                0F63948115E48114006A597C /* DFGArrayMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGArrayMode.cpp; path = dfg/DFGArrayMode.cpp; sourceTree = "<group>"; };
    905908                0F63948215E48114006A597C /* DFGArrayMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGArrayMode.h; path = dfg/DFGArrayMode.h; sourceTree = "<group>"; };
    906                 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
    907909                0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdjacencyList.h; path = dfg/DFGAdjacencyList.h; sourceTree = "<group>"; };
    908910                0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGEdge.h; path = dfg/DFGEdge.h; sourceTree = "<group>"; };
     
    10631065                1440FCE10A51E46B0005F061 /* JSClassRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSClassRef.h; sourceTree = "<group>"; };
    10641066                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSClassRef.cpp; sourceTree = "<group>"; };
     1067                1442565F15EDE98D0066A49B /* JSWithScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWithScope.cpp; sourceTree = "<group>"; };
     1068                1442566015EDE98D0066A49B /* JSWithScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWithScope.h; sourceTree = "<group>"; };
    10651069                145722851437E140005FDE26 /* StrongInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StrongInlines.h; sourceTree = "<group>"; };
    10661070                145C507F0D9DF63B0088F6B9 /* CallData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallData.h; sourceTree = "<group>"; };
     
    21362140                                BC22A39A0E16E14800AF21C8 /* JSVariableObject.cpp */,
    21372141                                14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
     2142                                1442565F15EDE98D0066A49B /* JSWithScope.cpp */,
     2143                                1442566015EDE98D0066A49B /* JSWithScope.h */,
    21382144                                65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
    21392145                                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
     
    29102916                                14874AE615EBDE4A002E3587 /* JSScope.h in Headers */,
    29112917                                FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */,
     2918                                1442566215EDE98D0066A49B /* JSWithScope.h in Headers */,
    29122919                        );
    29132920                        runOnlyForDeploymentPostprocessing = 0;
     
    35123519                                14874AE315EBDE4A002E3587 /* JSNameScope.cpp in Sources */,
    35133520                                14874AE515EBDE4A002E3587 /* JSScope.cpp in Sources */,
     3521                                1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */,
    35143522                        );
    35153523                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/Target.pri

    r126893 r127010  
    210210    runtime/JSPropertyNameIterator.cpp \
    211211    runtime/JSSegmentedVariableObject.cpp \
     212    runtime/JSWithScope.cpp \
    212213    runtime/JSNameScope.cpp \
    213214    runtime/JSScope.cpp \
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r126990 r127010  
    47974797
    47984798        callFrame->uncheckedR(scope) = JSValue(o);
    4799         callFrame->setScopeChain(callFrame->scopeChain()->push(o));
     4799        callFrame->setScopeChain(callFrame->scopeChain()->push(JSWithScope(callFrame, o)));
    48004800
    48014801        vPC += OPCODE_LENGTH(op_push_scope);
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r126926 r127010  
    5555#include "JSPropertyNameIterator.h"
    5656#include "JSString.h"
     57#include "JSWithScope.h"
    5758#include "NameInstance.h"
    5859#include "ObjectPrototype.h"
     
    31473148    JSObject* o = stackFrame.args[0].jsValue().toObject(stackFrame.callFrame);
    31483149    CHECK_FOR_EXCEPTION();
    3149     stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(o));
     3150    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(JSWithScope::create(stackFrame.callFrame, o)));
    31503151    return o;
    31513152}
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r126893 r127010  
    4343#include "JSString.h"
    4444#include "JSValue.h"
     45#include "JSWithScope.h"
    4546#include "LLIntCommon.h"
    4647#include "LLIntExceptions.h"
     
    15361537   
    15371538    LLINT_OP(1) = o;
    1538     exec->setScopeChain(exec->scopeChain()->push(o));
     1539    exec->setScopeChain(exec->scopeChain()->push(JSWithScope::create(exec, o)));
    15391540   
    15401541    LLINT_END();
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r126893 r127010  
    4949#include "JSNotAnObject.h"
    5050#include "JSPropertyNameIterator.h"
     51#include "JSWithScope.h"
    5152#include "Lexer.h"
    5253#include "Lookup.h"
     
    206207    sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull()));
    207208    structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
     209    withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull()));
    208210
    209211    wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r126893 r127010  
    241241        Strong<Structure> sharedSymbolTableStructure;
    242242        Strong<Structure> structureChainStructure;
     243        Strong<Structure> withScopeStructure;
    243244
    244245        IdentifierTable* identifierTable;
  • trunk/Source/JavaScriptCore/runtime/JSScope.cpp

    r126962 r127010  
    3030#include "JSGlobalObject.h"
    3131#include "JSNameScope.h"
     32#include "JSWithScope.h"
    3233
    3334namespace JSC {
     
    5253}
    5354
     55JSObject* JSScope::objectAtScope(ScopeChainNode* scopeChain)
     56{
     57    JSObject* object = scopeChain->object.get();
     58    if (object->structure()->typeInfo().type() == WithScopeType)
     59        return jsCast<JSWithScope*>(object)->object();
     60
     61    return object;
     62}
     63
    5464JSValue JSScope::resolve(CallFrame* callFrame, const Identifier& identifier)
    5565{
  • trunk/Source/JavaScriptCore/runtime/JSScope.h

    r126962 r127010  
    3535    typedef JSNonFinalObject Base;
    3636
    37     static JSObject* objectAtScope(ScopeChainNode*);
     37    JS_EXPORT_PRIVATE static JSObject* objectAtScope(ScopeChainNode*);
    3838
    3939    static JSValue resolve(CallFrame*, const Identifier&);
     
    6666    : Base(globalData, structure)
    6767{
    68 }
    69 
    70 inline JSObject* JSScope::objectAtScope(ScopeChainNode* scopeChain)
    71 {
    72     return scopeChain->object.get();
    7368}
    7469
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r126893 r127010  
    5050    ErrorInstanceType,
    5151    GlobalThisType,
     52    WithScopeType,
    5253
    5354    NameScopeObjectType,
  • trunk/Source/JavaScriptCore/runtime/StrictEvalActivation.cpp

    r116828 r127010  
    3434
    3535StrictEvalActivation::StrictEvalActivation(ExecState* exec)
    36     : JSNonFinalObject(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
     36    : Base(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
    3737{
    3838}
  • trunk/Source/JavaScriptCore/runtime/StrictEvalActivation.h

    r116828 r127010  
    2727#define StrictEvalActivation_h
    2828
    29 #include "JSObject.h"
     29#include "JSScope.h"
    3030
    3131namespace JSC {
    3232
    33 class StrictEvalActivation : public JSNonFinalObject {
     33class StrictEvalActivation : public JSScope {
    3434public:
    35     typedef JSNonFinalObject Base;
     35    typedef JSScope Base;
    3636
    3737    static StrictEvalActivation* create(ExecState* exec)
     
    5353
    5454protected:
    55     static const unsigned StructureFlags = IsEnvironmentRecord | JSNonFinalObject::StructureFlags;
     55    static const unsigned StructureFlags = IsEnvironmentRecord | Base::StructureFlags;
    5656
    5757private:
Note: See TracChangeset for help on using the changeset viewer.