Introduced JSWithScope, making all scope objects subclasses of JSScope
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 17:13:50 +0000 (17:13 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2012 17:13:50 +0000 (17:13 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@127010 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Target.pri
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/runtime/JSGlobalData.cpp
Source/JavaScriptCore/runtime/JSGlobalData.h
Source/JavaScriptCore/runtime/JSScope.cpp
Source/JavaScriptCore/runtime/JSScope.h
Source/JavaScriptCore/runtime/JSType.h
Source/JavaScriptCore/runtime/JSWithScope.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSWithScope.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/StrictEvalActivation.cpp
Source/JavaScriptCore/runtime/StrictEvalActivation.h

index a458dcf..72f4213 100644 (file)
@@ -208,6 +208,7 @@ SET(JavaScriptCore_SOURCES
     runtime/JSPropertyNameIterator.cpp
     runtime/JSSegmentedVariableObject.cpp
     runtime/JSNameScope.cpp
+    runtime/JSWithScope.cpp
     runtime/JSScope.cpp
     runtime/JSString.cpp
     runtime/JSStringJoiner.cpp
index fa25c31..8774538 100644 (file)
@@ -1,3 +1,57 @@
+2012-08-28  Geoffrey Garen  <ggaren@apple.com>
+
+        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.
+
 2012-08-29  Patrick Gansterer  <paroga@webkit.org>
 
         Unreviewed. Build fix for !ENABLE(JIT) after r126962.
index 63ccf39..0363fd6 100644 (file)
@@ -547,6 +547,7 @@ javascriptcore_sources += \
        Source/JavaScriptCore/runtime/JSPropertyNameIterator.h \
        Source/JavaScriptCore/runtime/JSSegmentedVariableObject.cpp \
        Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h \
+       Source/JavaScriptCore/runtime/JSWithScope.cpp \
        Source/JavaScriptCore/runtime/JSNameScope.cpp \
        Source/JavaScriptCore/runtime/JSNameScope.h \
        Source/JavaScriptCore/runtime/JSScope.cpp \
index c78cefb..32b17a8 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\..\runtime\JSWithScope.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\runtime\JSWithScope.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\runtime\JSNameScope.cpp"
                                >
                        </File>
index cb3b86b..00859b8 100644 (file)
                0F63944015C75F1D006A597C /* DFGStructureCheckHoistingPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63943C15C75F14006A597C /* DFGStructureCheckHoistingPhase.cpp */; };
                0F63945415D07055006A597C /* ArrayProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63945115D07051006A597C /* ArrayProfile.cpp */; };
                0F63945515D07057006A597C /* ArrayProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63945215D07051006A597C /* ArrayProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63948115E48114006A597C /* DFGArrayMode.cpp */; };
                0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63948215E48114006A597C /* DFGArrayMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F66E16B14DF3F1600B7B2E4 /* DFGAdjacencyList.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F66E16C14DF3F1600B7B2E4 /* DFGEdge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F766D2815A8CC1E008F363E /* JITStubRoutine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F766D2615A8CC1B008F363E /* JITStubRoutine.cpp */; };
                1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440F8900A508B100005F061 /* JSCallbackFunction.cpp */; };
                1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */; };
                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440FCE20A51E46B0005F061 /* JSClassRef.cpp */; };
+               1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1442565F15EDE98D0066A49B /* JSWithScope.cpp */; };
+               1442566215EDE98D0066A49B /* JSWithScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 1442566015EDE98D0066A49B /* JSWithScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                14469DDE107EC7E700650446 /* Lookup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8680255597D01FF60F7 /* Lookup.cpp */; };
                14469DDF107EC7E700650446 /* MathObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A86A0255597D01FF60F7 /* MathObject.cpp */; };
                14469DE0107EC7E700650446 /* NativeErrorConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC02E9080E1839DB000F9297 /* NativeErrorConstructor.cpp */; };
                E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; };
                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; };
-               FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */;  settings = {ATTRIBUTES = (Private, ); }; };
+               FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                0F63943D15C75F14006A597C /* DFGStructureCheckHoistingPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureCheckHoistingPhase.h; path = dfg/DFGStructureCheckHoistingPhase.h; sourceTree = "<group>"; };
                0F63945115D07051006A597C /* ArrayProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayProfile.cpp; sourceTree = "<group>"; };
                0F63945215D07051006A597C /* ArrayProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayProfile.h; sourceTree = "<group>"; };
+               0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
                0F63948115E48114006A597C /* DFGArrayMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGArrayMode.cpp; path = dfg/DFGArrayMode.cpp; sourceTree = "<group>"; };
                0F63948215E48114006A597C /* DFGArrayMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGArrayMode.h; path = dfg/DFGArrayMode.h; sourceTree = "<group>"; };
-               0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
                0F66E16814DF3F1300B7B2E4 /* DFGAdjacencyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGAdjacencyList.h; path = dfg/DFGAdjacencyList.h; sourceTree = "<group>"; };
                0F66E16914DF3F1300B7B2E4 /* DFGEdge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGEdge.h; path = dfg/DFGEdge.h; sourceTree = "<group>"; };
                0F766D1C15A5028D008F363E /* JITStubRoutine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubRoutine.h; sourceTree = "<group>"; };
                1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackConstructor.cpp; sourceTree = "<group>"; };
                1440FCE10A51E46B0005F061 /* JSClassRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSClassRef.h; sourceTree = "<group>"; };
                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSClassRef.cpp; sourceTree = "<group>"; };
+               1442565F15EDE98D0066A49B /* JSWithScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWithScope.cpp; sourceTree = "<group>"; };
+               1442566015EDE98D0066A49B /* JSWithScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWithScope.h; sourceTree = "<group>"; };
                145722851437E140005FDE26 /* StrongInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StrongInlines.h; sourceTree = "<group>"; };
                145C507F0D9DF63B0088F6B9 /* CallData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallData.h; sourceTree = "<group>"; };
                146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStringRefCF.h; sourceTree = "<group>"; };
                                865A30F0135007E100CDB49E /* JSValueInlineMethods.h */,
                                BC22A39A0E16E14800AF21C8 /* JSVariableObject.cpp */,
                                14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
+                               1442565F15EDE98D0066A49B /* JSWithScope.cpp */,
+                               1442566015EDE98D0066A49B /* JSWithScope.h */,
                                65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
                                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
                                A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */,
                                14874AE415EBDE4A002E3587 /* JSNameScope.h in Headers */,
                                14874AE615EBDE4A002E3587 /* JSScope.h in Headers */,
                                FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */,
+                               1442566215EDE98D0066A49B /* JSWithScope.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */,
                                14874AE315EBDE4A002E3587 /* JSNameScope.cpp in Sources */,
                                14874AE515EBDE4A002E3587 /* JSScope.cpp in Sources */,
+                               1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index ed8d278..e5af1f7 100644 (file)
@@ -209,6 +209,7 @@ SOURCES += \
     runtime/JSONObject.cpp \
     runtime/JSPropertyNameIterator.cpp \
     runtime/JSSegmentedVariableObject.cpp \
+    runtime/JSWithScope.cpp \
     runtime/JSNameScope.cpp \
     runtime/JSScope.cpp \
     runtime/JSString.cpp \
index 8a4d643..884569e 100644 (file)
@@ -4796,7 +4796,7 @@ skip_id_custom_self:
         CHECK_FOR_EXCEPTION();
 
         callFrame->uncheckedR(scope) = JSValue(o);
-        callFrame->setScopeChain(callFrame->scopeChain()->push(o));
+        callFrame->setScopeChain(callFrame->scopeChain()->push(JSWithScope(callFrame, o)));
 
         vPC += OPCODE_LENGTH(op_push_scope);
         NEXT_INSTRUCTION();
index e0faa0f..d51a740 100644 (file)
@@ -54,6 +54,7 @@
 #include "JSNotAnObject.h"
 #include "JSPropertyNameIterator.h"
 #include "JSString.h"
+#include "JSWithScope.h"
 #include "NameInstance.h"
 #include "ObjectPrototype.h"
 #include "Operations.h"
@@ -3146,7 +3147,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_push_scope)
 
     JSObject* o = stackFrame.args[0].jsValue().toObject(stackFrame.callFrame);
     CHECK_FOR_EXCEPTION();
-    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(o));
+    stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(JSWithScope::create(stackFrame.callFrame, o)));
     return o;
 }
 
index 3480560..b370c21 100644 (file)
@@ -42,6 +42,7 @@
 #include "JSPropertyNameIterator.h"
 #include "JSString.h"
 #include "JSValue.h"
+#include "JSWithScope.h"
 #include "LLIntCommon.h"
 #include "LLIntExceptions.h"
 #include "LowLevelInterpreter.h"
@@ -1535,7 +1536,7 @@ LLINT_SLOW_PATH_DECL(slow_path_push_scope)
     LLINT_CHECK_EXCEPTION();
     
     LLINT_OP(1) = o;
-    exec->setScopeChain(exec->scopeChain()->push(o));
+    exec->setScopeChain(exec->scopeChain()->push(JSWithScope::create(exec, o)));
     
     LLINT_END();
 }
index 64d4749..cdc44ca 100644 (file)
@@ -48,6 +48,7 @@
 #include "JSNameScope.h"
 #include "JSNotAnObject.h"
 #include "JSPropertyNameIterator.h"
+#include "JSWithScope.h"
 #include "Lexer.h"
 #include "Lookup.h"
 #include "Nodes.h"
@@ -205,6 +206,7 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
     regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull()));
     sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull()));
     structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull()));
+    withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull()));
 
     wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable);
 
index ed764a3..75c5f37 100644 (file)
@@ -240,6 +240,7 @@ namespace JSC {
         Strong<Structure> regExpStructure;
         Strong<Structure> sharedSymbolTableStructure;
         Strong<Structure> structureChainStructure;
+        Strong<Structure> withScopeStructure;
 
         IdentifierTable* identifierTable;
         CommonIdentifiers* propertyNames;
index aba56e8..0669137 100644 (file)
@@ -29,6 +29,7 @@
 #include "JSActivation.h"
 #include "JSGlobalObject.h"
 #include "JSNameScope.h"
+#include "JSWithScope.h"
 
 namespace JSC {
 
@@ -51,6 +52,15 @@ bool JSScope::isDynamicScope(bool& requiresDynamicChecks) const
     return false;
 }
 
+JSObject* JSScope::objectAtScope(ScopeChainNode* scopeChain)
+{
+    JSObject* object = scopeChain->object.get();
+    if (object->structure()->typeInfo().type() == WithScopeType)
+        return jsCast<JSWithScope*>(object)->object();
+
+    return object;
+}
+
 JSValue JSScope::resolve(CallFrame* callFrame, const Identifier& identifier)
 {
     ScopeChainNode* scopeChain = callFrame->scopeChain();
index 73be4a9..dabf437 100644 (file)
@@ -34,7 +34,7 @@ class JSScope : public JSNonFinalObject {
 public:
     typedef JSNonFinalObject Base;
 
-    static JSObject* objectAtScope(ScopeChainNode*);
+    JS_EXPORT_PRIVATE static JSObject* objectAtScope(ScopeChainNode*);
 
     static JSValue resolve(CallFrame*, const Identifier&);
     static JSValue resolveSkip(CallFrame*, const Identifier&, int skip);
@@ -67,11 +67,6 @@ inline JSScope::JSScope(JSGlobalData& globalData, Structure* structure)
 {
 }
 
-inline JSObject* JSScope::objectAtScope(ScopeChainNode* scopeChain)
-{
-    return scopeChain->object.get();
-}
-
 class ScopeChainIterator {
 public:
     ScopeChainIterator(ScopeChainNode* node)
index 3d44dd7..b8ab330 100644 (file)
@@ -49,6 +49,7 @@ enum JSType {
     NumberObjectType,
     ErrorInstanceType,
     GlobalThisType,
+    WithScopeType,
 
     NameScopeObjectType,
     // VariableObjectType must be less than MOST of the types of its subclasses and only its subclasses.
diff --git a/Source/JavaScriptCore/runtime/JSWithScope.cpp b/Source/JavaScriptCore/runtime/JSWithScope.cpp
new file mode 100644 (file)
index 0000000..0c4b6e2
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "JSWithScope.h"
+
+namespace JSC {
+
+ASSERT_CLASS_FITS_IN_CELL(JSWithScope);
+
+const ClassInfo JSWithScope::s_info = { "WithScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSWithScope) };
+
+void JSWithScope::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+    JSWithScope* thisObject = jsCast<JSWithScope*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
+    COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+    ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
+
+    Base::visitChildren(thisObject, visitor);
+    visitor.append(&thisObject->m_object);
+}
+
+} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/JSWithScope.h b/Source/JavaScriptCore/runtime/JSWithScope.h
new file mode 100644 (file)
index 0000000..f1e0272
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JSWithScope_h
+#define JSWithScope_h
+
+#include "JSScope.h"
+
+namespace JSC {
+
+class JSWithScope : public JSScope {
+public:
+    typedef JSScope Base;
+
+    static JSWithScope* create(ExecState* exec, JSObject* object)
+    {
+        JSWithScope* withScope = new (NotNull, allocateCell<JSWithScope>(*exec->heap())) JSWithScope(exec, object);
+        withScope->finishCreation(exec->globalData());
+        return withScope;
+    }
+
+    JSObject* object() { return m_object.get(); }
+
+    static void visitChildren(JSCell*, SlotVisitor&);
+
+    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
+    {
+        return Structure::create(globalData, globalObject, proto, TypeInfo(WithScopeType, StructureFlags), &s_info);
+    }
+
+    static const ClassInfo s_info;
+
+protected:
+    static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
+
+private:
+    JSWithScope(ExecState* exec, JSObject* object)
+        : Base(exec->globalData(), exec->globalData().withScopeStructure.get())
+        , m_object(exec->globalData(), this, object)
+    {
+    }
+
+    WriteBarrier<JSObject> m_object;
+};
+
+} // namespace JSC
+
+#endif // JSWithScope_h
index 8b47a5d..0a89b43 100644 (file)
@@ -33,7 +33,7 @@ ASSERT_HAS_TRIVIAL_DESTRUCTOR(StrictEvalActivation);
 const ClassInfo StrictEvalActivation::s_info = { "Object", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictEvalActivation) };
 
 StrictEvalActivation::StrictEvalActivation(ExecState* exec)
-    : JSNonFinalObject(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
+    : Base(exec->globalData(), exec->globalData().strictEvalActivationStructure.get())
 {
 }
 
index d73eedf..9f64feb 100644 (file)
 #ifndef StrictEvalActivation_h
 #define StrictEvalActivation_h
 
-#include "JSObject.h"
+#include "JSScope.h"
 
 namespace JSC {
 
-class StrictEvalActivation : public JSNonFinalObject {
+class StrictEvalActivation : public JSScope {
 public:
-    typedef JSNonFinalObject Base;
+    typedef JSScope Base;
 
     static StrictEvalActivation* create(ExecState* exec)
     {
@@ -52,7 +52,7 @@ public:
     static const ClassInfo s_info;
 
 protected:
-    static const unsigned StructureFlags = IsEnvironmentRecord | JSNonFinalObject::StructureFlags;
+    static const unsigned StructureFlags = IsEnvironmentRecord | Base::StructureFlags;
 
 private:
     StrictEvalActivation(ExecState*);