Commit 7746b2ed authored by ggaren@apple.com's avatar ggaren@apple.com

Removed redundant helper functions for allocating Strong handles

https://bugs.webkit.org/show_bug.cgi?id=69218

Reviewed by Sam Weinig.

../JavaScriptCore: 

* heap/Heap.h:
(JSC::Heap::handleHeap):
* runtime/JSGlobalData.h: Removed these helper functions, since they
just created indirection.

* heap/StrongInlines.h: Added. Broke out a header for inline functions
to resolve circular dependencies created by inlining. I'm told this is
the future for JavaScriptCore.

* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj: Go forth and build.

* API/JSCallbackObjectFunctions.h:
(JSC::::init):
* runtime/WeakGCMap.h:
(JSC::WeakGCMap::add):
(JSC::WeakGCMap::set):
* runtime/StructureTransitionTable.h:
(JSC::StructureTransitionTable::setSingleTransition):
* heap/Local.h:
(JSC::::Local):
* heap/Strong.h:
(JSC::::Strong):
(JSC::::set):
* heap/Weak.h:
(JSC::Weak::Weak):
(JSC::Weak::set): Allocate handles directly instead of going through a
chain of forwarding functions.

* bytecompiler/BytecodeGenerator.cpp:
* runtime/JSGlobalData.cpp:
* runtime/LiteralParser.cpp:
* runtime/RegExpCache.cpp: Updated for header changes.

../JavaScriptGlue: 

* JSRun.cpp:
* JSValueWrapper.cpp:

../WebCore: 

* ForwardingHeaders/heap/StrongInlines.h: Added.
* bindings/js/JSCallbackData.h:
* bindings/js/JSDOMWindowShell.cpp:
* bindings/js/ScheduledAction.h:
* bindings/js/ScriptCachedFrameData.cpp:
* bindings/js/ScriptController.cpp:
* bindings/js/ScriptState.cpp:
* bindings/js/ScriptValue.h:
* bindings/js/WorkerScriptController.cpp:
* bridge/runtime_root.cpp:

../WebKit2: 

* WebProcess/Plugins/Netscape/NPJSObject.cpp:
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96465 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 27f3902a
......@@ -106,7 +106,7 @@ void JSCallbackObject<Parent>::init(ExecState* exec)
for (JSClassRef jsClassPtr = classRef(); jsClassPtr && !needsFinalizer; jsClassPtr = jsClassPtr->parentClass)
needsFinalizer = jsClassPtr->finalize;
if (needsFinalizer) {
HandleSlot slot = exec->globalData().allocateGlobalHandle();
HandleSlot slot = exec->globalData().heap.handleHeap()->allocate();
HandleHeap::heapFor(slot)->makeWeak(slot, m_callbackObjectData.get(), classRef());
HandleHeap::heapFor(slot)->writeBarrier(slot, this);
*slot = this;
......
2011-10-01 Geoffrey Garen <ggaren@apple.com>
Removed redundant helper functions for allocating Strong handles
https://bugs.webkit.org/show_bug.cgi?id=69218
Reviewed by Sam Weinig.
* heap/Heap.h:
(JSC::Heap::handleHeap):
* runtime/JSGlobalData.h: Removed these helper functions, since they
just created indirection.
* heap/StrongInlines.h: Added. Broke out a header for inline functions
to resolve circular dependencies created by inlining. I'm told this is
the future for JavaScriptCore.
* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj: Go forth and build.
* API/JSCallbackObjectFunctions.h:
(JSC::::init):
* runtime/WeakGCMap.h:
(JSC::WeakGCMap::add):
(JSC::WeakGCMap::set):
* runtime/StructureTransitionTable.h:
(JSC::StructureTransitionTable::setSingleTransition):
* heap/Local.h:
(JSC::::Local):
* heap/Strong.h:
(JSC::::Strong):
(JSC::::set):
* heap/Weak.h:
(JSC::Weak::Weak):
(JSC::Weak::set): Allocate handles directly instead of going through a
chain of forwarding functions.
* bytecompiler/BytecodeGenerator.cpp:
* runtime/JSGlobalData.cpp:
* runtime/LiteralParser.cpp:
* runtime/RegExpCache.cpp: Updated for header changes.
2011-09-30 Filip Pizlo <fpizlo@apple.com>
All of JSC's heuristics should be in one place for easier tuning
......@@ -162,6 +162,7 @@ javascriptcore_sources += \
Source/JavaScriptCore/heap/MarkedSpace.cpp \
Source/JavaScriptCore/heap/MarkedSpace.h \
Source/JavaScriptCore/heap/Strong.h \
Source/JavaScriptCore/heap/StrongInlines.h \
Source/JavaScriptCore/heap/VTableSpectrum.cpp \
Source/JavaScriptCore/heap/VTableSpectrum.h \
Source/JavaScriptCore/heap/Weak.h \
......
......@@ -38,6 +38,7 @@
'heap/Local.h',
'heap/LocalScope.h',
'heap/Strong.h',
'heap/StrongInlines.h',
'heap/Weak.h',
'config.h',
'debugger/Debugger.h',
......
......@@ -1973,6 +1973,10 @@
RelativePath="..\..\heap\Strong.h"
>
</File>
<File
RelativePath="..\..\heap\StrongInlines.h"
>
</File>
<File
RelativePath="..\..\heap\Handle.h"
>
......
......@@ -166,6 +166,7 @@
14469DED107EC7E700650446 /* StringPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C50E16EE3300B34460 /* StringPrototype.cpp */; };
14469DEE107EC7E700650446 /* UString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8850255597D01FF60F7 /* UString.cpp */; };
144836E7132DA7BE005BE785 /* ConservativeRoots.h in Headers */ = {isa = PBXBuildFile; fileRef = 149DAAF212EB559D0083B12B /* ConservativeRoots.h */; settings = {ATTRIBUTES = (Private, ); }; };
145722861437E140005FDE26 /* StrongInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 145722851437E140005FDE26 /* StrongInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
146AAB380B66A94400E55F16 /* JSStringRefCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */; };
146B16D812EB5B59001BEC1B /* ConservativeRoots.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146B14DB12EB5B12001BEC1B /* ConservativeRoots.cpp */; };
146FE51211A710430087AE66 /* JITCall32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146FE51111A710430087AE66 /* JITCall32_64.cpp */; };
......@@ -891,6 +892,7 @@
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>"; };
14456A311314657800212CA3 /* DoublyLinkedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoublyLinkedList.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>"; };
146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringRefCF.cpp; sourceTree = "<group>"; };
......@@ -1693,6 +1695,7 @@
0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */,
0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */,
0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */,
145722851437E140005FDE26 /* StrongInlines.h */,
);
path = heap;
sourceTree = "<group>";
......@@ -2477,6 +2480,7 @@
BC257DE80E1F51C50016B6C9 /* Arguments.h in Headers */,
86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
145722861437E140005FDE26 /* StrongInlines.h in Headers */,
0FD82F4B142806A100179C94 /* BitVector.h in Headers */,
0FD82F2B1426CA6D00179C94 /* JettisonedCodeBlocks.h in Headers */,
0FD82EF51423075B00179C94 /* DFGIntrinsic.h in Headers */,
......
......@@ -34,6 +34,7 @@
#include "JSFunction.h"
#include "Interpreter.h"
#include "ScopeChain.h"
#include "StrongInlines.h"
#include "UString.h"
using namespace std;
......
......@@ -118,11 +118,10 @@ namespace JSC {
template<typename Functor> typename Functor::ReturnType forEachProtectedCell(Functor&);
template<typename Functor> typename Functor::ReturnType forEachProtectedCell();
HandleSlot allocateGlobalHandle() { return m_handleHeap.allocate(); }
HandleSlot allocateLocalHandle() { return m_handleStack.push(); }
HandleHeap* handleHeap() { return &m_handleHeap; }
HandleStack* handleStack() { return &m_handleStack; }
void getConservativeRegisterRoots(HashSet<JSCell*>& roots);
private:
......
......@@ -57,13 +57,13 @@ private:
};
template <typename T> inline Local<T>::Local(JSGlobalData& globalData, ExternalType value)
: Handle<T>(globalData.allocateLocalHandle())
: Handle<T>(globalData.heap.handleStack()->push())
{
set(value);
}
template <typename T> inline Local<T>::Local(JSGlobalData& globalData, Handle<T> other)
: Handle<T>(globalData.allocateLocalHandle())
: Handle<T>(globalData.heap.handleStack()->push())
{
set(other.get());
}
......
......@@ -33,7 +33,6 @@
namespace JSC {
class JSGlobalData;
HandleSlot allocateGlobalHandle(JSGlobalData&);
// A strongly referenced handle that prevents the object it points to from being garbage collected.
template <typename T> class Strong : public Handle<T> {
......@@ -48,17 +47,9 @@ public:
{
}
Strong(JSGlobalData& globalData, ExternalType value = ExternalType())
: Handle<T>(allocateGlobalHandle(globalData))
{
set(value);
}
Strong(JSGlobalData&, ExternalType = ExternalType());
Strong(JSGlobalData& globalData, Handle<T> handle)
: Handle<T>(allocateGlobalHandle(globalData))
{
set(handle.get());
}
Strong(JSGlobalData&, Handle<T>);
Strong(const Strong& other)
: Handle<T>()
......@@ -95,12 +86,7 @@ public:
Handle<T>::swap(other);
}
void set(JSGlobalData& globalData, ExternalType value)
{
if (!slot())
setSlot(allocateGlobalHandle(globalData));
set(value);
}
void set(JSGlobalData&, ExternalType);
template <typename U> Strong& operator=(const Strong<U>& other)
{
......
/*
* Copyright (C) 2011 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. AND ITS CONTRIBUTORS ``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 ITS 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 StrongInlines_h
#define StrongInlines_h
namespace JSC {
template <typename T>
inline Strong<T>::Strong(JSGlobalData& globalData, ExternalType value)
: Handle<T>(globalData.heap.handleHeap()->allocate())
{
set(value);
}
template <typename T>
inline Strong<T>::Strong(JSGlobalData& globalData, Handle<T> handle)
: Handle<T>(globalData.heap.handleHeap()->allocate())
{
set(handle.get());
}
template <typename T>
inline void Strong<T>::set(JSGlobalData& globalData, ExternalType value)
{
if (!slot())
setSlot(globalData.heap.handleHeap()->allocate());
set(value);
}
} // namespace JSC
#endif // StrongInlines_h
......@@ -47,7 +47,7 @@ public:
}
Weak(JSGlobalData& globalData, ExternalType value = ExternalType(), WeakHandleOwner* weakOwner = 0, void* context = 0)
: Handle<T>(globalData.allocateGlobalHandle())
: Handle<T>(globalData.heap.handleHeap()->allocate())
{
HandleHeap::heapFor(slot())->makeWeak(slot(), weakOwner, context);
set(value);
......@@ -106,7 +106,7 @@ public:
void set(JSGlobalData& globalData, ExternalType value, WeakHandleOwner* weakOwner = 0, void* context = 0)
{
if (!slot()) {
setSlot(globalData.allocateGlobalHandle());
setSlot(globalData.heap.handleHeap()->allocate());
HandleHeap::heapFor(slot())->makeWeak(slot(), weakOwner, context);
}
ASSERT(HandleHeap::heapFor(slot())->hasWeakOwner(slot(), weakOwner));
......
......@@ -56,6 +56,7 @@
#include "RegExpCache.h"
#include "RegExpObject.h"
#include "StrictEvalActivation.h"
#include "StrongInlines.h"
#include <wtf/Threading.h>
#include <wtf/WTFThreadData.h>
#if PLATFORM(MAC)
......
......@@ -295,8 +295,6 @@ namespace JSC {
void addRegExpToTrace(PassRefPtr<RegExp> regExp);
#endif
void dumpRegExpTrace();
HandleSlot allocateGlobalHandle() { return heap.allocateGlobalHandle(); }
HandleSlot allocateLocalHandle() { return heap.allocateLocalHandle(); }
void clearBuiltinStructures();
bool isCollectorBusy() { return heap.isBusy(); }
......@@ -320,11 +318,6 @@ namespace JSC {
#endif
};
inline HandleSlot allocateGlobalHandle(JSGlobalData& globalData)
{
return globalData.allocateGlobalHandle();
}
#if ENABLE(GC_VALIDATION)
inline bool JSGlobalData::isInitializingObject() const
{
......
......@@ -29,6 +29,7 @@
#include "JSArray.h"
#include "JSString.h"
#include "Lexer.h"
#include "StrongInlines.h"
#include "UStringBuilder.h"
#include <wtf/ASCIICType.h>
#include <wtf/dtoa.h>
......
......@@ -29,6 +29,7 @@
#include "RegExpCache.h"
#include "RegExpObject.h"
#include "StrongInlines.h"
namespace JSC {
......
......@@ -156,7 +156,7 @@ private:
ASSERT(isUsingSingleSlot());
HandleSlot slot = this->slot();
if (!slot) {
slot = globalData.allocateGlobalHandle();
slot = globalData.heap.handleHeap()->allocate();
HandleHeap::heapFor(slot)->makeWeak(slot, 0, 0);
m_data = reinterpret_cast<intptr_t>(slot) | UsingSingleSlotFlag;
}
......
......@@ -125,7 +125,7 @@ public:
{
pair<typename MapType::iterator, bool> iter = m_map.add(key, 0);
if (iter.second) {
HandleSlot slot = globalData.allocateGlobalHandle();
HandleSlot slot = globalData.heap.handleHeap()->allocate();
iter.first->second = slot;
HandleHeap::heapFor(slot)->makeWeak(slot, this, FinalizerCallback::finalizerContextFor(key));
HandleHeap::heapFor(slot)->writeBarrier(slot, value);
......@@ -147,7 +147,7 @@ public:
pair<typename MapType::iterator, bool> iter = m_map.add(key, 0);
HandleSlot slot = iter.first->second;
if (iter.second) {
slot = globalData.allocateGlobalHandle();
slot = globalData.heap.handleHeap()->allocate();
HandleHeap::heapFor(slot)->makeWeak(slot, this, key);
iter.first->second = slot;
}
......
2011-10-01 Geoffrey Garen <ggaren@apple.com>
Removed redundant helper functions for allocating Strong handles
https://bugs.webkit.org/show_bug.cgi?id=69218
Reviewed by Sam Weinig.
* JSRun.cpp:
* JSValueWrapper.cpp:
2011-09-29 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize JSCell::visitChildrenVirtual and remove all other visitChildrenVirtual methods
......
......@@ -32,6 +32,7 @@
#include "UserObjectImp.h"
#include <JavaScriptCore/Completion.h>
#include <JavaScriptCore/SourceCode.h>
#include <JavaScriptCore/StrongInlines.h>
JSGlueGlobalObject::JSGlueGlobalObject(JSGlobalData& globalData, Structure* structure, Structure* userObjectStructure, JSFlags flags)
: JSGlobalObject(globalData, structure)
......
......@@ -31,6 +31,7 @@
#include "JSRun.h"
#include <JavaScriptCore/JSArray.h>
#include <JavaScriptCore/PropertyNameArray.h>
#include <JavaScriptCore/StrongInlines.h>
#include <pthread.h>
JSValueWrapper::JSValueWrapper(JSValue inValue)
......
2011-10-01 Geoffrey Garen <ggaren@apple.com>
Removed redundant helper functions for allocating Strong handles
https://bugs.webkit.org/show_bug.cgi?id=69218
Reviewed by Sam Weinig.
* ForwardingHeaders/heap/StrongInlines.h: Added.
* bindings/js/JSCallbackData.h:
* bindings/js/JSDOMWindowShell.cpp:
* bindings/js/ScheduledAction.h:
* bindings/js/ScriptCachedFrameData.cpp:
* bindings/js/ScriptController.cpp:
* bindings/js/ScriptState.cpp:
* bindings/js/ScriptValue.h:
* bindings/js/WorkerScriptController.cpp:
* bridge/runtime_root.cpp:
2011-10-01 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r96421.
#ifndef WebCore_FWD_StrongInlines_h
#define WebCore_FWD_StrongInlines_h
#include <JavaScriptCore/StrongInlines.h>
#endif
......@@ -33,6 +33,7 @@
#include "JSDOMGlobalObject.h"
#include "ScriptExecutionContext.h"
#include <heap/Strong.h>
#include <heap/StrongInlines.h>
#include <runtime/JSObject.h>
#include <wtf/Threading.h>
......
......@@ -33,6 +33,7 @@
#include "JSDOMWindow.h"
#include "DOMWindow.h"
#include "ScriptController.h"
#include <heap/StrongInlines.h>
#include <runtime/JSObject.h>
using namespace JSC;
......
......@@ -23,6 +23,7 @@
#include "JSDOMBinding.h"
#include "PlatformString.h"
#include <heap/Strong.h>
#include <heap/StrongInlines.h>
#include <runtime/JSCell.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
......
......@@ -36,6 +36,7 @@
#include "GCController.h"
#include "Page.h"
#include "PageGroup.h"
#include <heap/StrongInlines.h>
#include <runtime/JSLock.h>
#include "ScriptController.h"
......
......@@ -44,6 +44,7 @@
#include "npruntime_impl.h"
#include "runtime_root.h"
#include <debugger/Debugger.h>
#include <heap/StrongInlines.h>
#include <runtime/InitializeThreading.h>
#include <runtime/JSLock.h>
#include <wtf/Threading.h>
......
......@@ -37,6 +37,7 @@
#include "Page.h"
#include "WorkerContext.h"
#include "WorkerScriptController.h"
#include <heap/StrongInlines.h>
#include <interpreter/CallFrame.h>
#include <runtime/JSGlobalObject.h>
......
......@@ -36,6 +36,7 @@
#include "SerializedScriptValue.h"
#include "ScriptState.h"
#include <heap/Strong.h>
#include <heap/StrongInlines.h>
#include <runtime/JSValue.h>
#include <wtf/PassRefPtr.h>
......
......@@ -38,6 +38,7 @@
#include "WorkerContext.h"
#include "WorkerObjectProxy.h"
#include "WorkerThread.h"
#include <heap/StrongInlines.h>
#include <interpreter/Interpreter.h>
#include <runtime/Completion.h>
#include <runtime/ExceptionHelpers.h>
......
......@@ -28,6 +28,7 @@
#include "BridgeJSC.h"
#include "runtime_object.h"
#include <heap/StrongInlines.h>
#include <heap/Weak.h>
#include <runtime/JSGlobalObject.h>
#include <wtf/HashCountedSet.h>
......
2011-10-01 Geoffrey Garen <ggaren@apple.com>
Removed redundant helper functions for allocating Strong handles
https://bugs.webkit.org/show_bug.cgi?id=69218
Reviewed by Sam Weinig.
* WebProcess/Plugins/Netscape/NPJSObject.cpp:
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
2011-09-30 Sam Weinig <sam@webkit.org>
Add support for eventSender.mouseScrollBy in WTR
......
......@@ -31,6 +31,7 @@
#include "NPRuntimeUtilities.h"
#include <JavaScriptCore/JSLock.h>
#include <JavaScriptCore/JSObject.h>
#include <JavaScriptCore/StrongInlines.h>
#include <WebCore/Frame.h>
#include <WebCore/IdentifierRep.h>
#include <wtf/text/WTFString.h>
......
......@@ -36,6 +36,7 @@
#include <JavaScriptCore/JSLock.h>
#include <JavaScriptCore/SourceCode.h>
#include <JavaScriptCore/Strong.h>
#include <JavaScriptCore/StrongInlines.h>
#include <WebCore/Frame.h>
using namespace JSC;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment