Title: [173541] trunk/Source
Revision
173541
Author
msab...@apple.com
Date
2014-09-11 14:52:33 -0700 (Thu, 11 Sep 2014)

Log Message

Move JSScope out of JSFunction into separate JSCallee class
https://bugs.webkit.org/show_bug.cgi?id=136725

Reviewed by Oliver Hunt.

Created new JSCallee class that contains a JSScope*.  Changed JSFunction to inherit from
JSCallee.

Source/_javascript_Core:

* CMakeLists.txt:
* _javascript_Core.vcxproj/_javascript_Core.vcxproj:
* _javascript_Core.vcxproj/_javascript_Core.vcxproj.filters:
* _javascript_Core.xcodeproj/project.pbxproj:
Build changes.  Added JSCallee.cpp and JSCallee.h.

* runtime/JSCallee.cpp: Added.
(JSC::JSCallee::create):
(JSC::JSCallee::destroy):
(JSC::JSCallee::JSCallee):
(JSC::JSCallee::finishCreation):
(JSC::JSCallee::visitChildren):
(JSC::JSCallee::getOwnPropertySlot): Pass through wrapper function.
(JSC::JSCallee::getOwnNonIndexPropertyNames): Pass through wrapper function.
(JSC::JSCallee::put): Pass through wrapper function.
(JSC::JSCallee::deleteProperty): Pass through wrapper function.
(JSC::JSCallee::defineOwnProperty): Pass through wrapper function.

* runtime/JSCallee.h: Added.
(JSC::JSCallee::scope):
(JSC::JSCallee::scopeUnchecked):
(JSC::JSCallee::setScope):
(JSC::JSCallee::createStructure):
(JSC::JSCallee::offsetOfScopeChain):

* runtime/JSFunction.cpp:
(JSC::JSFunction::JSFunction):
(JSC::JSFunction::addNameScopeIfNeeded):
(JSC::JSFunction::visitChildren):
* runtime/JSFunction.h:
(JSC::JSFunction::scope): Deleted.
(JSC::JSFunction::scopeUnchecked): Deleted.
(JSC::JSFunction::setScope): Deleted.
(JSC::JSFunction::offsetOfScopeChain): Deleted.
* runtime/JSFunctionInlines.h:
(JSC::JSFunction::JSFunction):
Changed to reference JSCallee and its methods.

* runtime/JSType.h: Added JSCallee as a TypeEnum.

Source/WebCore:

* ForwardingHeaders/runtime/JSCallee.h: New forwarding header.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (173540 => 173541)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2014-09-11 21:52:33 UTC (rev 173541)
@@ -438,11 +438,13 @@
     runtime/JSBoundFunction.cpp
     runtime/JSGlobalObjectDebuggable.cpp
     runtime/JSCJSValue.cpp
+    runtime/JSCallee.cpp
     runtime/JSCell.cpp
     runtime/JSConsole.cpp
     runtime/JSDataView.cpp
     runtime/JSDataViewPrototype.cpp
     runtime/JSDateMath.cpp
+    runtime/JSEnvironmentRecord.cpp
     runtime/JSFunction.cpp
     runtime/JSGlobalObject.cpp
     runtime/JSGlobalObjectFunctions.cpp
@@ -471,7 +473,6 @@
     runtime/JSTypedArrayConstructors.cpp
     runtime/JSTypedArrayPrototypes.cpp
     runtime/JSTypedArrays.cpp
-    runtime/JSEnvironmentRecord.cpp
     runtime/JSWeakMap.cpp
     runtime/JSWithScope.cpp
     runtime/JSWrapperObject.cpp

Modified: trunk/Source/_javascript_Core/ChangeLog (173540 => 173541)


--- trunk/Source/_javascript_Core/ChangeLog	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-09-11 21:52:33 UTC (rev 173541)
@@ -1,3 +1,53 @@
+2014-09-10  Michael Saboff  <msab...@apple.com>
+
+        Move JSScope out of JSFunction into separate JSCallee class
+        https://bugs.webkit.org/show_bug.cgi?id=136725
+
+        Reviewed by Oliver Hunt.
+
+        Created new JSCallee class that contains a JSScope*.  Changed JSFunction to inherit from
+        JSCallee.
+
+        * CMakeLists.txt:
+        * _javascript_Core.vcxproj/_javascript_Core.vcxproj:
+        * _javascript_Core.vcxproj/_javascript_Core.vcxproj.filters:
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        Build changes.  Added JSCallee.cpp and JSCallee.h.
+
+        * runtime/JSCallee.cpp: Added.
+        (JSC::JSCallee::create):
+        (JSC::JSCallee::destroy):
+        (JSC::JSCallee::JSCallee):
+        (JSC::JSCallee::finishCreation):
+        (JSC::JSCallee::visitChildren):
+        (JSC::JSCallee::getOwnPropertySlot): Pass through wrapper function.
+        (JSC::JSCallee::getOwnNonIndexPropertyNames): Pass through wrapper function.
+        (JSC::JSCallee::put): Pass through wrapper function.
+        (JSC::JSCallee::deleteProperty): Pass through wrapper function.
+        (JSC::JSCallee::defineOwnProperty): Pass through wrapper function.
+
+        * runtime/JSCallee.h: Added.
+        (JSC::JSCallee::scope):
+        (JSC::JSCallee::scopeUnchecked):
+        (JSC::JSCallee::setScope):
+        (JSC::JSCallee::createStructure):
+        (JSC::JSCallee::offsetOfScopeChain):
+
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::JSFunction):
+        (JSC::JSFunction::addNameScopeIfNeeded):
+        (JSC::JSFunction::visitChildren):
+        * runtime/JSFunction.h:
+        (JSC::JSFunction::scope): Deleted.
+        (JSC::JSFunction::scopeUnchecked): Deleted.
+        (JSC::JSFunction::setScope): Deleted.
+        (JSC::JSFunction::offsetOfScopeChain): Deleted.
+        * runtime/JSFunctionInlines.h:
+        (JSC::JSFunction::JSFunction):
+        Changed to reference JSCallee and its methods.
+
+        * runtime/JSType.h: Added JSCallee as a TypeEnum.
+
 2014-09-11  Filip Pizlo  <fpi...@apple.com>
 
         REGRESSION (r172129): Vine pages load as blank

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj (173540 => 173541)


--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj	2014-09-11 21:52:33 UTC (rev 173541)
@@ -711,6 +711,7 @@
     <ClCompile Include="..\runtime\JSArrayBufferView.cpp" />
     <ClCompile Include="..\runtime\JSBoundFunction.cpp" />
     <ClCompile Include="..\runtime\JSCJSValue.cpp" />
+    <ClCompile Include="..\runtime\JSCallee.cpp" />
     <ClCompile Include="..\runtime\JSCell.cpp" />
     <ClCompile Include="..\runtime\JSConsole.cpp" />
     <ClCompile Include="..\runtime\JSDataView.cpp" />
@@ -1467,6 +1468,7 @@
     <ClInclude Include="..\runtime\JSCInlines.h" />
     <ClInclude Include="..\runtime\JSCJSValue.h" />
     <ClInclude Include="..\runtime\JSCJSValueInlines.h" />
+    <ClInclude Include="..\runtime\JSCallee.h" />
     <ClInclude Include="..\runtime\JSCell.h" />
     <ClInclude Include="..\runtime\JSConsole.h" />
     <ClInclude Include="..\runtime\JSDataView.h" />

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters (173540 => 173541)


--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj.filters	2014-09-11 21:52:33 UTC (rev 173541)
@@ -633,6 +633,9 @@
     <ClCompile Include="..\runtime\JSBoundFunction.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
+    <ClCompile Include="..\runtime\JSCallee.cpp">
+      <Filter>runtime</Filter>
+    </ClCompile>
     <ClCompile Include="..\runtime\JSCell.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
@@ -2588,6 +2591,9 @@
     <ClInclude Include="..\runtime\JSBoundFunction.h">
       <Filter>runtime</Filter>
     </ClInclude>
+    <ClInclude Include="..\runtime\JSCallee.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
     <ClInclude Include="..\runtime\JSCell.h">
       <Filter>runtime</Filter>
     </ClInclude>

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (173540 => 173541)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2014-09-11 21:52:33 UTC (rev 173541)
@@ -1169,6 +1169,9 @@
 		6553A33117A1F1EE008CF6F3 /* CommonSlowPathsExceptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6553A32F17A1F1EE008CF6F3 /* CommonSlowPathsExceptions.cpp */; };
 		6553A33217A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6553A33017A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h */; };
 		655EB29B10CE2581001A990E /* NodesCodegen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 655EB29A10CE2581001A990E /* NodesCodegen.cpp */; };
+		657CF45819BF6662004ACBF2 /* JSCallee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 657CF45619BF6662004ACBF2 /* JSCallee.cpp */; };
+		657CF45919BF6662004ACBF2 /* JSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = 657CF45719BF6662004ACBF2 /* JSCallee.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		657CF45A19C11390004ACBF2 /* JSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = 657CF45719BF6662004ACBF2 /* JSCallee.h */; };
 		658D3A5619638268003C45D6 /* VMEntryRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 658D3A5519638268003C45D6 /* VMEntryRecord.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		65C02850171795E200351E35 /* ARMv7Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65C0284F171795E200351E35 /* ARMv7Disassembler.cpp */; };
 		65C0285C1717966800351E35 /* ARMv7DOpcode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65C0285A1717966800351E35 /* ARMv7DOpcode.cpp */; };
@@ -2798,6 +2801,8 @@
 		6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
 		65621E6B089E859700760F35 /* PropertySlot.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertySlot.cpp; sourceTree = "<group>"; tabWidth = 8; };
 		65621E6C089E859700760F35 /* PropertySlot.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = PropertySlot.h; sourceTree = "<group>"; tabWidth = 8; };
+		657CF45619BF6662004ACBF2 /* JSCallee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallee.cpp; sourceTree = "<group>"; };
+		657CF45719BF6662004ACBF2 /* JSCallee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallee.h; sourceTree = "<group>"; };
 		65860177185A8F5E00030EEE /* MaxFrameExtentForSlowPathCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaxFrameExtentForSlowPathCall.h; sourceTree = "<group>"; };
 		658D3A5519638268003C45D6 /* VMEntryRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = VMEntryRecord.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		65987F2C167FE84B003C2F8D /* DFGOSRExitCompilationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSRExitCompilationInfo.h; path = dfg/DFGOSRExitCompilationInfo.h; sourceTree = "<group>"; };
@@ -4498,6 +4503,8 @@
 				A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */,
 				86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */,
 				86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */,
+				657CF45619BF6662004ACBF2 /* JSCallee.cpp */,
+				657CF45719BF6662004ACBF2 /* JSCallee.h */,
 				BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */,
 				BC1167D80E19BCC9008066DD /* JSCell.h */,
 				0F97496F1687ADE200A4FF6A /* JSCellInlines.h */,
@@ -5528,6 +5535,7 @@
 				5540771818DA58AD00EFF7F2 /* JSLexicalEnvironment.h in Headers */,
 				5540771B18DA58AD00EFF7F2 /* JSArgumentsIterator.h in Headers */,
 				5540772218DA58AD00EFF7F2 /* JSArrayIterator.h in Headers */,
+				657CF45A19C11390004ACBF2 /* JSCallee.h in Headers */,
 				5540774818DA58AD00EFF7F2 /* JSGlobalObjectDebuggable.h in Headers */,
 				5540774A18DA58AD00EFF7F2 /* JSGlobalObjectFunctions.h in Headers */,
 				5540775918DA58AD00EFF7F2 /* JSMapIterator.h in Headers */,
@@ -6221,6 +6229,7 @@
 				0F2D4DE919832DAC007D4B19 /* ToThisStatus.h in Headers */,
 				140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */,
 				86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */,
+				657CF45919BF6662004ACBF2 /* JSCallee.h in Headers */,
 				BC18C4190E16F5CD00B34460 /* JSCallbackConstructor.h in Headers */,
 				BC18C41A0E16F5CD00B34460 /* JSCallbackFunction.h in Headers */,
 				BC18C41B0E16F5CD00B34460 /* JSCallbackObject.h in Headers */,
@@ -7490,6 +7499,7 @@
 				1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */,
 				14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */,
 				A7D801A81880D6A80026C39B /* JSCBuiltins.cpp in Sources */,
+				657CF45819BF6662004ACBF2 /* JSCallee.cpp in Sources */,
 				147F39D1107EC37600427A48 /* JSCell.cpp in Sources */,
 				147F39D6107EC37600427A48 /* JSCJSValue.cpp in Sources */,
 				1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,

Added: trunk/Source/_javascript_Core/runtime/JSCallee.cpp (0 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSCallee.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/JSCallee.cpp	2014-09-11 21:52:33 UTC (rev 173541)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014 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 "JSCallee.h"
+
+#include "GetterSetter.h"
+#include "JSCJSValueInlines.h"
+#include "JSCell.h"
+#include "JSCellInlines.h"
+#include "JSGlobalObject.h"
+#include "SlotVisitorInlines.h"
+#include "StackVisitor.h"
+#include "StructureInlines.h"
+
+namespace JSC {
+
+const ClassInfo JSCallee::s_info = { "Callee", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCallee) };
+
+JSCallee* JSCallee::create(VM& vm, JSGlobalObject* globalObject)
+{
+    JSCallee* function = new (NotNull, allocateCell<JSCallee>(vm.heap)) JSCallee(vm, globalObject, globalObject->functionStructure());
+    function->finishCreation(vm);
+    return function;
+}
+
+void JSCallee::destroy(JSCell* cell)
+{
+    static_cast<JSCallee*>(cell)->JSCallee::~JSCallee();
+}
+
+JSCallee::JSCallee(VM& vm, JSGlobalObject* globalObject, Structure* structure)
+    : Base(vm, structure)
+    , m_scope(vm, this, globalObject)
+{
+}
+
+JSCallee::JSCallee(VM& vm, JSScope* scope, Structure* structure)
+    : Base(vm, structure)
+{
+    setScope(vm, scope);
+}
+
+void JSCallee::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+}
+
+void JSCallee::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+    JSCallee* thisObject = jsCast<JSCallee*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    Base::visitChildren(thisObject, visitor);
+
+    visitor.append(&thisObject->m_scope);
+}
+
+bool JSCallee::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
+{
+    return Base::getOwnPropertySlot(object, exec, propertyName, slot);
+}
+
+void JSCallee::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
+{
+    Base::getOwnNonIndexPropertyNames(object, exec, propertyNames, mode);
+}
+
+void JSCallee::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
+{
+    Base::put(cell, exec, propertyName, value, slot);
+}
+
+bool JSCallee::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
+{
+    return Base::deleteProperty(cell, exec, propertyName);
+}
+
+bool JSCallee::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool throwException)
+{
+    return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
+}
+
+} // namespace JSC

Added: trunk/Source/_javascript_Core/runtime/JSCallee.h (0 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSCallee.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/JSCallee.h	2014-09-11 21:52:33 UTC (rev 173541)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2014 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 JSCallee_h
+#define JSCallee_h
+
+#include "JSDestructibleObject.h"
+#include "JSScope.h"
+
+namespace JSC {
+
+class JSGlobalObject;
+class LLIntOffsetsExtractor;
+
+
+class JSCallee : public JSDestructibleObject {
+    friend class JIT;
+    friend class DFG::SpeculativeJIT;
+    friend class DFG::JITCompiler;
+    friend class VM;
+
+public:
+    typedef JSDestructibleObject Base;
+
+    JS_EXPORT_PRIVATE static JSCallee* create(VM&, JSGlobalObject*);
+
+    static void destroy(JSCell*);
+
+    JS_EXPORT_PRIVATE String name(ExecState*);
+    JS_EXPORT_PRIVATE String displayName(ExecState*);
+    const String calculatedDisplayName(ExecState*);
+
+    JSScope* scope()
+    {
+        return m_scope.get();
+    }
+
+    // This method may be called for host functions, in which case it
+    // will return an arbitrary value. This should only be used for
+    // optimized paths in which the return value does not matter for
+    // host functions, and checking whether the function is a host
+    // function is deemed too expensive.
+    JSScope* scopeUnchecked()
+    {
+        return m_scope.get();
+    }
+
+    void setScope(VM& vm, JSScope* scope)
+    {
+        m_scope.set(vm, this, scope);
+    }
+
+    DECLARE_EXPORT_INFO;
+
+    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 
+    {
+        ASSERT(globalObject);
+        return Structure::create(vm, globalObject, prototype, TypeInfo(JSCalleeType, StructureFlags), info());
+    }
+
+    static inline ptrdiff_t offsetOfScopeChain()
+    {
+        return OBJECT_OFFSETOF(JSCallee, m_scope);
+    }
+
+protected:
+    const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesGetPropertyNames | JSObject::StructureFlags;
+
+    JS_EXPORT_PRIVATE JSCallee(VM&, JSGlobalObject*, Structure*);
+    JSCallee(VM&, JSScope*, Structure*);
+
+    void finishCreation(VM&);
+    using Base::finishCreation;
+
+    static void visitChildren(JSCell*, SlotVisitor&);
+
+    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
+    static void getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode = ExcludeDontEnumProperties);
+    static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
+    static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
+    static bool deleteProperty(JSCell*, ExecState*, PropertyName);
+
+private:
+    friend class LLIntOffsetsExtractor;
+
+    WriteBarrier<JSScope> m_scope;
+};
+
+} // namespace JSC
+
+#endif // JSCallee_h

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (173540 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp	2014-09-11 21:52:33 UTC (rev 173541)
@@ -85,9 +85,8 @@
 }
 
 JSFunction::JSFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure)
-    : Base(vm, structure)
+    : Base(vm, globalObject, structure)
     , m_executable()
-    , m_scope(vm, this, globalObject)
     // We initialize blind so that changes to the prototype after function creation but before
     // the optimizer kicks in don't disable optimizations. Once the optimizer kicks in, the
     // watchpoint will start watching and any changes will both force deoptimization and disable
@@ -117,7 +116,7 @@
         return;
     if (!functionNameScopeIsDynamic(executable->usesEval(), executable->isStrictMode()))
         return;
-    m_scope.set(vm, this, JSNameScope::create(vm, m_scope->globalObject(), executable->name(), this, ReadOnly | DontDelete, m_scope.get()));
+    setScope(vm, JSNameScope::create(vm, scope()->globalObject(), executable->name(), this, ReadOnly | DontDelete, scope()));
 }
 
 JSFunction* JSFunction::createBuiltinFunction(VM& vm, FunctionExecutable* executable, JSGlobalObject* globalObject)
@@ -180,7 +179,6 @@
     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
     Base::visitChildren(thisObject, visitor);
 
-    visitor.append(&thisObject->m_scope);
     visitor.append(&thisObject->m_executable);
     thisObject->m_allocationProfile.visitAggregate(visitor);
 }

Modified: trunk/Source/_javascript_Core/runtime/JSFunction.h (173540 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSFunction.h	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.h	2014-09-11 21:52:33 UTC (rev 173541)
@@ -25,7 +25,7 @@
 #define JSFunction_h
 
 #include "InternalFunction.h"
-#include "JSDestructibleObject.h"
+#include "JSCallee.h"
 #include "JSScope.h"
 #include "ObjectAllocationProfile.h"
 #include "Watchpoint.h"
@@ -49,14 +49,14 @@
 
 JS_EXPORT_PRIVATE String getCalculatedDisplayName(CallFrame*, JSObject*);
     
-class JSFunction : public JSDestructibleObject {
+class JSFunction : public JSCallee {
     friend class JIT;
     friend class DFG::SpeculativeJIT;
     friend class DFG::JITCompiler;
     friend class VM;
 
 public:
-    typedef JSDestructibleObject Base;
+    typedef JSCallee Base;
 
     JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
 
@@ -76,25 +76,6 @@
     JS_EXPORT_PRIVATE String displayName(ExecState*);
     const String calculatedDisplayName(ExecState*);
 
-    JSScope* scope()
-    {
-        ASSERT(!isHostFunctionNonInline());
-        return m_scope.get();
-    }
-    // This method may be called for host functins, in which case it
-    // will return an arbitrary value. This should only be used for
-    // optimized paths in which the return value does not matter for
-    // host functions, and checking whether the function is a host
-    // function is deemed too expensive.
-    JSScope* scopeUnchecked()
-    {
-        return m_scope.get();
-    }
-    void setScope(VM& vm, JSScope* scope)
-    {
-        ASSERT(!isHostFunctionNonInline());
-        m_scope.set(vm, this, scope);
-    }
     void addNameScopeIfNeeded(VM&);
 
     ExecutableBase* executable() const { return m_executable.get(); }
@@ -119,11 +100,6 @@
     static ConstructType getConstructData(JSCell*, ConstructData&);
     static CallType getCallData(JSCell*, CallData&);
 
-    static inline ptrdiff_t offsetOfScopeChain()
-    {
-        return OBJECT_OFFSETOF(JSFunction, m_scope);
-    }
-
     static inline ptrdiff_t offsetOfExecutable()
     {
         return OBJECT_OFFSETOF(JSFunction, m_executable);
@@ -182,7 +158,6 @@
     static EncodedJSValue nameGetter(ExecState*, JSObject*, EncodedJSValue, PropertyName);
 
     WriteBarrier<ExecutableBase> m_executable;
-    WriteBarrier<JSScope> m_scope;
     ObjectAllocationProfile m_allocationProfile;
     InlineWatchpointSet m_allocationProfileWatchpoint;
 };

Modified: trunk/Source/_javascript_Core/runtime/JSFunctionInlines.h (173540 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSFunctionInlines.h	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/runtime/JSFunctionInlines.h	2014-09-11 21:52:33 UTC (rev 173541)
@@ -32,9 +32,8 @@
 namespace JSC {
 
 inline JSFunction::JSFunction(VM& vm, FunctionExecutable* executable, JSScope* scope)
-    : Base(vm, scope->globalObject()->functionStructure())
+    : Base(vm, scope, scope->globalObject()->functionStructure())
     , m_executable(vm, this, executable)
-    , m_scope(vm, this, scope)
     , m_allocationProfileWatchpoint(ClearWatchpoint) // See comment in JSFunction.cpp concerning the reason for using ClearWatchpoint as opposed to IsWatched.
 {
 }

Modified: trunk/Source/_javascript_Core/runtime/JSType.h (173540 => 173541)


--- trunk/Source/_javascript_Core/runtime/JSType.h	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/_javascript_Core/runtime/JSType.h	2014-09-11 21:52:33 UTC (rev 173541)
@@ -50,6 +50,7 @@
     // The ObjectType value must come before any JSType that is a subclass of JSObject.
     ObjectType,
     FinalObjectType,
+    JSCalleeType,
     JSFunctionType,
     NameInstanceType,
     NumberObjectType,

Modified: trunk/Source/WebCore/ChangeLog (173540 => 173541)


--- trunk/Source/WebCore/ChangeLog	2014-09-11 21:45:45 UTC (rev 173540)
+++ trunk/Source/WebCore/ChangeLog	2014-09-11 21:52:33 UTC (rev 173541)
@@ -1,3 +1,15 @@
+2014-09-10  Michael Saboff  <msab...@apple.com>
+
+        Move JSScope out of JSFunction into separate JSCallee class
+        https://bugs.webkit.org/show_bug.cgi?id=136725
+
+        Reviewed by Oliver Hunt.
+
+        Created new JSCallee class that contains a JSScope*.  Changed JSFunction to inherit from
+        JSCallee.
+
+        * ForwardingHeaders/runtime/JSCallee.h: New forwarding header.
+
 2014-09-11  Roger Fong  <roger_f...@apple.com>
 
         Unreviewed build fix iOS.

Added: trunk/Source/WebCore/ForwardingHeaders/runtime/JSCallee.h (0 => 173541)


--- trunk/Source/WebCore/ForwardingHeaders/runtime/JSCallee.h	                        (rev 0)
+++ trunk/Source/WebCore/ForwardingHeaders/runtime/JSCallee.h	2014-09-11 21:52:33 UTC (rev 173541)
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_JSCallee_h
+#define WebCore_FWD_JSCallee_h
+#include <_javascript_Core/JSCallee.h>
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to