De-virtualize JSVariableObject::isDynamicScope
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2011 23:21:56 +0000 (23:21 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2011 23:21:56 +0000 (23:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71933

Reviewed by Geoffrey Garen.

* runtime/JSActivation.cpp:
* runtime/JSActivation.h: Inlined and de-virtualized isDynamicScope
(JSC::JSActivation::isDynamicScope):
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h: Inlined and de-virtualized isDynamicScope
(JSC::JSGlobalObject::isDynamicScope):
* runtime/JSStaticScopeObject.cpp:
* runtime/JSStaticScopeObject.h: Inlined and de-virtualized isDynamicScope
(JSC::JSStaticScopeObject::createStructure): Changed createStructure to use new JSType
(JSC::JSStaticScopeObject::isDynamicScope):
* runtime/JSType.h: Added new type for JSStaticScopeObject
* runtime/JSVariableObject.cpp: De-virtualized and added an implementation that checks the
object's type and calls the corresponding implementation.
(JSC::JSVariableObject::isDynamicScope):
* runtime/JSVariableObject.h:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSActivation.cpp
Source/JavaScriptCore/runtime/JSActivation.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/JSStaticScopeObject.cpp
Source/JavaScriptCore/runtime/JSStaticScopeObject.h
Source/JavaScriptCore/runtime/JSType.h
Source/JavaScriptCore/runtime/JSVariableObject.cpp
Source/JavaScriptCore/runtime/JSVariableObject.h

index 1aa2224..d4ded67 100644 (file)
@@ -1,5 +1,28 @@
 2011-11-09  Mark Hahnenberg  <mhahnenberg@apple.com>
 
+        De-virtualize JSVariableObject::isDynamicScope
+        https://bugs.webkit.org/show_bug.cgi?id=71933
+
+        Reviewed by Geoffrey Garen.
+
+        * runtime/JSActivation.cpp:
+        * runtime/JSActivation.h: Inlined and de-virtualized isDynamicScope
+        (JSC::JSActivation::isDynamicScope):
+        * runtime/JSGlobalObject.cpp:
+        * runtime/JSGlobalObject.h: Inlined and de-virtualized isDynamicScope
+        (JSC::JSGlobalObject::isDynamicScope):
+        * runtime/JSStaticScopeObject.cpp:
+        * runtime/JSStaticScopeObject.h: Inlined and de-virtualized isDynamicScope
+        (JSC::JSStaticScopeObject::createStructure): Changed createStructure to use new JSType
+        (JSC::JSStaticScopeObject::isDynamicScope):
+        * runtime/JSType.h: Added new type for JSStaticScopeObject
+        * runtime/JSVariableObject.cpp: De-virtualized and added an implementation that checks the 
+        object's type and calls the corresponding implementation.
+        (JSC::JSVariableObject::isDynamicScope):
+        * runtime/JSVariableObject.h:
+
+2011-11-09  Mark Hahnenberg  <mhahnenberg@apple.com>
+
         De-virtualize JSGlobalObject::hasOwnPropertyForWrite
         https://bugs.webkit.org/show_bug.cgi?id=71934
 
index 075d8db..ffe13d4 100644 (file)
@@ -209,12 +209,6 @@ JSObject* JSActivation::toThisObject(JSCell*, ExecState* exec)
     return exec->globalThisValue();
 }
 
-bool JSActivation::isDynamicScope(bool& requiresDynamicChecks) const
-{
-    requiresDynamicChecks = m_requiresDynamicChecks;
-    return false;
-}
-
 JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identifier&)
 {
     JSActivation* activation = asActivation(slotBase);
index 9589262..a5e14a1 100644 (file)
@@ -108,6 +108,12 @@ namespace JSC {
         return asActivation(jsValue());
     }
 
+    inline bool JSActivation::isDynamicScope(bool& requiresDynamicChecks) const
+    {
+        requiresDynamicChecks = m_requiresDynamicChecks;
+        return false;
+    }
+
 } // namespace JSC
 
 #endif // JSActivation_h
index e64e38d..485adfc 100644 (file)
@@ -395,11 +395,6 @@ ExecState* JSGlobalObject::globalExec()
     return CallFrame::create(m_globalCallFrame + RegisterFile::CallFrameHeaderSize);
 }
 
-bool JSGlobalObject::isDynamicScope(bool&) const
-{
-    return true;
-}
-
 void JSGlobalObject::resizeRegisters(size_t newSize)
 {
     // Previous duplicate symbols may have created spare capacity in m_registerArray.
index 09e08f9..b8cbd16 100644 (file)
@@ -273,7 +273,7 @@ namespace JSC {
 
         virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; }
 
-        virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
+        bool isDynamicScope(bool& requiresDynamicChecks) const;
 
         void setEvalEnabled(bool enabled) { m_evalEnabled = enabled; }
         bool evalEnabled() { return m_evalEnabled; }
@@ -473,6 +473,11 @@ namespace JSC {
         JSGlobalObject* m_savedDynamicGlobalObject;
     };
 
+    inline bool JSGlobalObject::isDynamicScope(bool&) const
+    {
+        return true;
+    }
+
 } // namespace JSC
 
 #endif // JSGlobalObject_h
index be01d4e..4591f5b 100644 (file)
@@ -82,11 +82,6 @@ void JSStaticScopeObject::putWithAttributes(JSObject* object, ExecState* exec, c
     ASSERT_NOT_REACHED();
 }
 
-bool JSStaticScopeObject::isDynamicScope(bool&) const
-{
-    return false;
-}
-
 bool JSStaticScopeObject::getOwnPropertySlot(JSCell* cell, ExecState*, const Identifier& propertyName, PropertySlot& slot)
 {
     return static_cast<JSStaticScopeObject*>(cell)->symbolTableGet(propertyName, slot);
index b59bb03..23a3aca 100644 (file)
@@ -49,7 +49,7 @@ namespace JSC{
 
         static void putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
 
-        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info); }
+        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(StaticScopeObjectType, StructureFlags), &s_info); }
 
         static const ClassInfo s_info;
 
@@ -72,6 +72,11 @@ namespace JSC{
         WriteBarrier<Unknown> m_registerStore;
     };
 
+    inline bool JSStaticScopeObject::isDynamicScope(bool&) const
+    {
+        return false;
+    }
+
 }
 
 #endif // JSStaticScopeObject_h
index 3046a8c..772a899 100644 (file)
@@ -49,6 +49,7 @@ enum JSType {
     VariableObjectType  = 16,
     GlobalObjectType    = 17,
     ActivationObjectType = 18,
+    StaticScopeObjectType = 19,
 };
 
 } // namespace JSC
index 5d1d238..edc41b5 100644 (file)
@@ -29,6 +29,9 @@
 #include "config.h"
 #include "JSVariableObject.h"
 
+#include "JSActivation.h"
+#include "JSGlobalObject.h"
+#include "JSStaticScopeObject.h"
 #include "PropertyNameArray.h"
 #include "PropertyDescriptor.h"
 
@@ -74,4 +77,21 @@ void JSVariableObject::putWithAttributes(JSObject*, ExecState*, const Identifier
     ASSERT_NOT_REACHED();
 }
 
+bool JSVariableObject::isDynamicScope(bool& requiresDynamicChecks) const
+{
+    switch (structure()->typeInfo().type()) {
+    case GlobalObjectType:
+        return static_cast<const JSGlobalObject*>(this)->isDynamicScope(requiresDynamicChecks);
+    case ActivationObjectType:
+        return static_cast<const JSActivation*>(this)->isDynamicScope(requiresDynamicChecks);
+    case StaticScopeObjectType:
+        return static_cast<const JSStaticScopeObject*>(this)->isDynamicScope(requiresDynamicChecks);
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    return false;
+}
+
 } // namespace JSC
index 9a3f597..e49fb71 100644 (file)
@@ -55,7 +55,7 @@ namespace JSC {
         static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
         static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
         
-        virtual bool isDynamicScope(bool& requiresDynamicChecks) const = 0;
+        bool isDynamicScope(bool& requiresDynamicChecks) const;
 
         WriteBarrier<Unknown>& registerAt(int index) const { return m_registers[index]; }