Title: [127010] trunk/Source/_javascript_Core
Revision
127010
Author
gga...@apple.com
Date
2012-08-29 10:13:50 -0700 (Wed, 29 Aug 2012)

Log 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:
* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
* _javascript_Core.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.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (127009 => 127010)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2012-08-29 17:13:50 UTC (rev 127010)
@@ -208,6 +208,7 @@
     runtime/JSPropertyNameIterator.cpp
     runtime/JSSegmentedVariableObject.cpp
     runtime/JSNameScope.cpp
+    runtime/JSWithScope.cpp
     runtime/JSScope.cpp
     runtime/JSString.cpp
     runtime/JSStringJoiner.cpp

Modified: trunk/Source/_javascript_Core/ChangeLog (127009 => 127010)


--- trunk/Source/_javascript_Core/ChangeLog	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-08-29 17:13:50 UTC (rev 127010)
@@ -1,3 +1,57 @@
+2012-08-28  Geoffrey Garen  <gga...@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:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj:
+        * _javascript_Core.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  <par...@webkit.org>
 
         Unreviewed. Build fix for !ENABLE(JIT) after r126962.

Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (127009 => 127010)


--- trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am	2012-08-29 17:13:50 UTC (rev 127010)
@@ -547,6 +547,7 @@
 	Source/_javascript_Core/runtime/JSPropertyNameIterator.h \
 	Source/_javascript_Core/runtime/JSSegmentedVariableObject.cpp \
 	Source/_javascript_Core/runtime/JSSegmentedVariableObject.h \
+	Source/_javascript_Core/runtime/JSWithScope.cpp \
 	Source/_javascript_Core/runtime/JSNameScope.cpp \
 	Source/_javascript_Core/runtime/JSNameScope.h \
 	Source/_javascript_Core/runtime/JSScope.cpp \

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj (127009 => 127010)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.vcproj	2012-08-29 17:13:50 UTC (rev 127010)
@@ -882,6 +882,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\runtime\JSWithScope.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\runtime\JSWithScope.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\runtime\JSNameScope.cpp"
 				>
 			</File>

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (127009 => 127010)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2012-08-29 17:13:50 UTC (rev 127010)
@@ -140,9 +140,9 @@
 		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 */; };
@@ -314,6 +314,8 @@
 		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 */; };
@@ -720,7 +722,7 @@
 		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 */
@@ -901,9 +903,9 @@
 		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>"; };
@@ -1062,6 +1064,8 @@
 		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>"; };
@@ -2135,6 +2139,8 @@
 				865A30F0135007E100CDB49E /* JSValueInlineMethods.h */,
 				BC22A39A0E16E14800AF21C8 /* JSVariableObject.cpp */,
 				14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
+				1442565F15EDE98D0066A49B /* JSWithScope.cpp */,
+				1442566015EDE98D0066A49B /* JSWithScope.h */,
 				65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
 				65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
 				A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */,
@@ -2909,6 +2915,7 @@
 				14874AE415EBDE4A002E3587 /* JSNameScope.h in Headers */,
 				14874AE615EBDE4A002E3587 /* JSScope.h in Headers */,
 				FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */,
+				1442566215EDE98D0066A49B /* JSWithScope.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -3511,6 +3518,7 @@
 				C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */,
 				14874AE315EBDE4A002E3587 /* JSNameScope.cpp in Sources */,
 				14874AE515EBDE4A002E3587 /* JSScope.cpp in Sources */,
+				1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/_javascript_Core/Target.pri (127009 => 127010)


--- trunk/Source/_javascript_Core/Target.pri	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/Target.pri	2012-08-29 17:13:50 UTC (rev 127010)
@@ -209,6 +209,7 @@
     runtime/JSONObject.cpp \
     runtime/JSPropertyNameIterator.cpp \
     runtime/JSSegmentedVariableObject.cpp \
+    runtime/JSWithScope.cpp \
     runtime/JSNameScope.cpp \
     runtime/JSScope.cpp \
     runtime/JSString.cpp \

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -4796,7 +4796,7 @@
         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();

Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/jit/JITStubs.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -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 @@
 
     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;
 }
 

Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -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_CHECK_EXCEPTION();
     
     LLINT_OP(1) = o;
-    exec->setScopeChain(exec->scopeChain()->push(o));
+    exec->setScopeChain(exec->scopeChain()->push(JSWithScope::create(exec, o)));
     
     LLINT_END();
 }

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -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 @@
     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);
 

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.h (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2012-08-29 17:13:50 UTC (rev 127010)
@@ -240,6 +240,7 @@
         Strong<Structure> regExpStructure;
         Strong<Structure> sharedSymbolTableStructure;
         Strong<Structure> structureChainStructure;
+        Strong<Structure> withScopeStructure;
 
         IdentifierTable* identifierTable;
         CommonIdentifiers* propertyNames;

Modified: trunk/Source/_javascript_Core/runtime/JSScope.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSScope.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/JSScope.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -29,6 +29,7 @@
 #include "JSActivation.h"
 #include "JSGlobalObject.h"
 #include "JSNameScope.h"
+#include "JSWithScope.h"
 
 namespace JSC {
 
@@ -51,6 +52,15 @@
     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();

Modified: trunk/Source/_javascript_Core/runtime/JSScope.h (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSScope.h	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/JSScope.h	2012-08-29 17:13:50 UTC (rev 127010)
@@ -34,7 +34,7 @@
 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 JSObject* JSScope::objectAtScope(ScopeChainNode* scopeChain)
-{
-    return scopeChain->object.get();
-}
-
 class ScopeChainIterator {
 public:
     ScopeChainIterator(ScopeChainNode* node)

Modified: trunk/Source/_javascript_Core/runtime/JSType.h (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSType.h	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/JSType.h	2012-08-29 17:13:50 UTC (rev 127010)
@@ -49,6 +49,7 @@
     NumberObjectType,
     ErrorInstanceType,
     GlobalThisType,
+    WithScopeType,
 
     NameScopeObjectType,
     // VariableObjectType must be less than MOST of the types of its subclasses and only its subclasses.

Added: trunk/Source/_javascript_Core/runtime/JSWithScope.cpp (0 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSWithScope.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/JSWithScope.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -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

Added: trunk/Source/_javascript_Core/runtime/JSWithScope.h (0 => 127010)


--- trunk/Source/_javascript_Core/runtime/JSWithScope.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/JSWithScope.h	2012-08-29 17:13:50 UTC (rev 127010)
@@ -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

Modified: trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/StrictEvalActivation.cpp	2012-08-29 17:13:50 UTC (rev 127010)
@@ -33,7 +33,7 @@
 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())
 {
 }
 

Modified: trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h (127009 => 127010)


--- trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h	2012-08-29 17:12:28 UTC (rev 127009)
+++ trunk/Source/_javascript_Core/runtime/StrictEvalActivation.h	2012-08-29 17:13:50 UTC (rev 127010)
@@ -26,13 +26,13 @@
 #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 @@
     static const ClassInfo s_info;
 
 protected:
-    static const unsigned StructureFlags = IsEnvironmentRecord | JSNonFinalObject::StructureFlags;
+    static const unsigned StructureFlags = IsEnvironmentRecord | Base::StructureFlags;
 
 private:
     StrictEvalActivation(ExecState*);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to