summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/collector
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-06-02 12:07:03 +0100
committerBen Murdoch <benm@google.com>2011-06-10 10:47:21 +0100
commit2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch)
treee4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/JavaScriptCore/collector
parent87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff)
downloadexternal_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/JavaScriptCore/collector')
-rw-r--r--Source/JavaScriptCore/collector/handles/Global.h159
-rw-r--r--Source/JavaScriptCore/collector/handles/Handle.h203
-rw-r--r--Source/JavaScriptCore/collector/handles/HandleHeap.cpp140
-rw-r--r--Source/JavaScriptCore/collector/handles/HandleHeap.h273
-rw-r--r--Source/JavaScriptCore/collector/handles/HandleStack.cpp63
-rw-r--r--Source/JavaScriptCore/collector/handles/HandleStack.h129
-rw-r--r--Source/JavaScriptCore/collector/handles/Local.h157
-rw-r--r--Source/JavaScriptCore/collector/handles/LocalScope.h78
8 files changed, 0 insertions, 1202 deletions
diff --git a/Source/JavaScriptCore/collector/handles/Global.h b/Source/JavaScriptCore/collector/handles/Global.h
deleted file mode 100644
index 571fe31..0000000
--- a/Source/JavaScriptCore/collector/handles/Global.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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 Global_h
-#define Global_h
-
-#include "Assertions.h"
-#include "Handle.h"
-#include "HandleHeap.h"
-#include "JSGlobalData.h"
-
-namespace JSC {
-
-/*
- A Global is a persistent handle whose lifetime is not limited to any given
- scope. Use Globals for data members and global variables.
-*/
-
-template <typename T> class Global : public Handle<T> {
-public:
- typedef typename Handle<T>::ExternalType ExternalType;
- Global(JSGlobalData& globalData, ExternalType ptr = ExternalType())
- : Handle<T>(globalData.allocateGlobalHandle())
- {
- internalSet(ptr);
- }
-
- Global(JSGlobalData& globalData, Handle<T> handle)
- : Handle<T>(globalData.allocateGlobalHandle())
- {
- internalSet(handle.get());
- }
-
- enum EmptyValueTag { EmptyValue };
- Global(EmptyValueTag)
- : Handle<T>(0, HandleBase::DontNullCheckSlot)
- {
- }
-
- ~Global()
- {
- HandleSlot slot = this->slot();
- if (slot)
- HandleHeap::heapFor(slot)->deallocate(slot);
- }
-
- void set(JSGlobalData& globalData, ExternalType value)
- {
- if (!value) {
- clear();
- return;
- }
- if (!this->slot())
- this->setSlot(globalData.allocateGlobalHandle());
- internalSet(value);
- }
-
- template <typename U> Global& operator=(const Global<U>& handle)
- {
- if (handle.slot()) {
- if (!this->slot())
- this->setSlot(HandleHeap::heapFor(handle.slot())->allocate());
- internalSet(handle.get());
- } else
- clear();
-
- return *this;
- }
-
- Global& operator=(const Global& handle)
- {
- if (handle.slot()) {
- if (!this->slot())
- this->setSlot(HandleHeap::heapFor(handle.slot())->allocate());
- internalSet(handle.get());
- } else
- clear();
-
- return *this;
- }
-
- void clear()
- {
- if (this->slot())
- internalSet(ExternalType());
- }
-
- enum HashTableDeletedValueType { HashTableDeletedValue };
- const static intptr_t HashTableDeletedValueTag = 0x1;
- Global(HashTableDeletedValueType)
- : Handle<T>(reinterpret_cast<HandleSlot>(HashTableDeletedValueTag))
- {
- }
- bool isHashTableDeletedValue() const { return slot() == reinterpret_cast<HandleSlot>(HashTableDeletedValueTag); }
-
- template <typename U> Global(const Global<U>& other)
- : Handle<T>(other.slot() ? HandleHeap::heapFor(other.slot())->allocate() : 0, Handle<T>::DontNullCheckSlot)
- {
- if (other.slot())
- internalSet(other.get());
- }
-
- Global(const Global& other)
- : Handle<T>(other.slot() ? HandleHeap::heapFor(other.slot())->allocate() : 0, Handle<T>::DontNullCheckSlot)
- {
- if (other.slot())
- internalSet(other.get());
- }
-
-protected:
- void internalSet(ExternalType value)
- {
- JSValue newValue(HandleTypes<T>::toJSValue(value));
- HandleSlot slot = this->slot();
- ASSERT(slot);
- HandleHeap::heapFor(slot)->writeBarrier(slot, newValue);
- *slot = newValue;
- }
-
- using Handle<T>::slot;
-
-};
-
-}
-
-namespace WTF {
-
-template<typename P> struct HashTraits<JSC::Global<P> > : GenericHashTraits<JSC::Global<P> > {
- static const bool emptyValueIsZero = true;
- static JSC::Global<P> emptyValue() { return JSC::Global<P>(JSC::Global<P>::EmptyValue); }
- static void constructDeletedValue(JSC::Global<P>& slot) { new (&slot) JSC::Global<P>(JSC::Global<P>::HashTableDeletedValue); }
- static bool isDeletedValue(const JSC::Global<P>& value) { return value.isHashTableDeletedValue(); }
-};
-
-}
-
-#endif // Global_h
diff --git a/Source/JavaScriptCore/collector/handles/Handle.h b/Source/JavaScriptCore/collector/handles/Handle.h
deleted file mode 100644
index d4e38c0..0000000
--- a/Source/JavaScriptCore/collector/handles/Handle.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * 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 Handle_h
-#define Handle_h
-
-#include "WriteBarrier.h"
-
-#include <wtf/Assertions.h>
-
-namespace JSC {
-
-/*
- A Handle is a smart pointer that updates automatically when the garbage
- collector moves the object to which it points.
-
- The base Handle class represents a temporary reference to a pointer whose
- lifetime is guaranteed by something else.
-*/
-
-template <class T> class Handle;
-
-// Creating a JSValue Handle is invalid
-template <> class Handle<JSValue>;
-
-class HandleBase {
- friend class HandleHeap;
-
-public:
- bool operator!() const { return isEmpty(); }
-
- // This conversion operator allows implicit conversion to bool but not to other integer types.
- typedef JSValue (HandleBase::*UnspecifiedBoolType);
- operator UnspecifiedBoolType*() const { return (m_slot && *m_slot) ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; }
-
- bool isEmpty() const { return !m_slot || !*m_slot; }
-
-protected:
- HandleBase(HandleSlot slot)
- : m_slot(slot)
- {
- ASSERT(slot);
- }
-
- enum DontNullCheckSlotTag { DontNullCheckSlot };
- HandleBase(HandleSlot slot, DontNullCheckSlotTag)
- : m_slot(slot)
- {
- }
-
- HandleSlot slot() const { return m_slot; }
- void invalidate()
- {
- // It is unsafe to use a handle after invalidating it.
- m_slot = 0;
- }
-
- // needed by Global<>::operator= and Global<>::set if it's an empty handle
- void setSlot(HandleSlot slot)
- {
- ASSERT(!m_slot);
- ASSERT(slot);
- m_slot = slot;
- }
-
-private:
- HandleSlot m_slot;
-};
-
-template <typename T> struct HandleTypes {
- typedef T* ExternalType;
- static ExternalType getFromSlot(HandleSlot slot) { return (slot && *slot) ? reinterpret_cast<ExternalType>(slot->asCell()) : 0; }
- static JSValue toJSValue(T* cell) { return reinterpret_cast<JSCell*>(cell); }
- template <typename U> static void validateUpcast() { T* temp; temp = (U*)0; }
-};
-
-template <> struct HandleTypes<Unknown> {
- typedef JSValue ExternalType;
- static ExternalType getFromSlot(HandleSlot slot) { return slot ? *slot : JSValue(); }
- static JSValue toJSValue(const JSValue& v) { return v; }
- template <typename U> static void validateUpcast() {}
-};
-
-template <typename Base, typename T> struct HandleConverter {
- T* operator->() { return static_cast<Base*>(this)->get(); }
- const T* operator->() const { return static_cast<const Base*>(this)->get(); }
- T* operator*() { return static_cast<Base*>(this)->get(); }
- const T* operator*() const { return static_cast<const Base*>(this)->get(); }
-};
-
-template <typename Base> struct HandleConverter<Base, Unknown> {
- Handle<JSObject> asObject() const;
- bool isObject() const { return jsValue().isObject(); }
- bool getNumber(double number) const { return jsValue().getNumber(number); }
- UString getString(ExecState*) const;
- bool isUndefinedOrNull() const { return jsValue().isUndefinedOrNull(); }
-
-private:
- JSValue jsValue() const { return static_cast<const Base*>(this)->get(); }
-};
-
-template <typename T> class Handle : public HandleBase, public HandleConverter<Handle<T>, T> {
-public:
- template <typename A, typename B> friend class HandleConverter;
- typedef typename HandleTypes<T>::ExternalType ExternalType;
- template <typename U> Handle(Handle<U> o)
- {
- typename HandleTypes<T>::template validateUpcast<U>();
- m_slot = o.slot();
- }
-
- ExternalType get() const { return HandleTypes<T>::getFromSlot(this->slot()); }
-
-protected:
-
- Handle(HandleSlot slot)
- : HandleBase(slot)
- {
- }
- Handle(HandleSlot slot, HandleBase::DontNullCheckSlotTag)
- : HandleBase(slot, HandleBase::DontNullCheckSlot)
- {
- }
-
-private:
- friend class HandleHeap;
-
- static Handle<T> wrapSlot(HandleSlot slot)
- {
- return Handle<T>(slot);
- }
-};
-
-template <typename Base> Handle<JSObject> HandleConverter<Base, Unknown>::asObject() const
-{
- return Handle<JSObject>::wrapSlot(static_cast<const Base*>(this)->slot());
-}
-
-template <typename T, typename U> inline bool operator==(const Handle<T>& a, const Handle<U>& b)
-{
- return a.get() == b.get();
-}
-
-template <typename T, typename U> inline bool operator==(const Handle<T>& a, U* b)
-{
- return a.get() == b;
-}
-
-template <typename T, typename U> inline bool operator==(T* a, const Handle<U>& b)
-{
- return a == b.get();
-}
-
-template <typename T, typename U> inline bool operator!=(const Handle<T>& a, const Handle<U>& b)
-{
- return a.get() != b.get();
-}
-
-template <typename T, typename U> inline bool operator!=(const Handle<T>& a, U* b)
-{
- return a.get() != b;
-}
-
-template <typename T, typename U> inline bool operator!=(T* a, const Handle<U>& b)
-{
- return a != b.get();
-}
-
-template <typename T, typename U> inline bool operator!=(const Handle<T>& a, JSValue b)
-{
- return a.get() != b;
-}
-
-template <typename T, typename U> inline bool operator!=(JSValue a, const Handle<U>& b)
-{
- return a != b.get();
-}
-
-}
-
-#endif
diff --git a/Source/JavaScriptCore/collector/handles/HandleHeap.cpp b/Source/JavaScriptCore/collector/handles/HandleHeap.cpp
deleted file mode 100644
index 1beb407..0000000
--- a/Source/JavaScriptCore/collector/handles/HandleHeap.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-
-#include "HandleHeap.h"
-
-#include "JSObject.h"
-
-namespace JSC {
-
-HandleHeap::HandleHeap(JSGlobalData* globalData)
- : m_globalData(globalData)
- , m_nextToFinalize(0)
-#if !ASSERT_DISABLED
- , m_handlingFinalizers(false)
-#endif
-{
- grow();
-}
-
-void HandleHeap::grow()
-{
- Node* block = m_blockStack.grow();
- for (int i = m_blockStack.blockLength - 1; i >= 0; --i) {
- Node* node = &block[i];
- new (node) Node(this);
- m_freeList.push(node);
- }
-}
-
-void HandleHeap::markStrongHandles(HeapRootMarker& heapRootMarker)
-{
- Node* end = m_strongList.end();
- for (Node* node = m_strongList.begin(); node != end; node = node->next())
- heapRootMarker.mark(node->slot());
-}
-
-void HandleHeap::updateAfterMark()
-{
- clearWeakPointers();
-}
-
-void HandleHeap::clearWeakPointers()
-{
-#if !ASSERT_DISABLED
- m_handlingFinalizers = true;
-#endif
- Node* end = m_weakList.end();
- for (Node* node = m_weakList.begin(); node != end;) {
- Node* current = node;
- node = current->next();
-
- JSValue value = *current->slot();
- if (!value || !value.isCell())
- continue;
-
- JSCell* cell = value.asCell();
- ASSERT(!cell || cell->structure());
-
-#if ENABLE(JSC_ZOMBIES)
- ASSERT(!cell->isZombie());
-#endif
- if (Heap::isMarked(cell))
- continue;
-
- if (Finalizer* finalizer = current->finalizer()) {
- m_nextToFinalize = node;
- finalizer->finalize(Handle<Unknown>::wrapSlot(current->slot()), current->finalizerContext());
- node = m_nextToFinalize;
- m_nextToFinalize = 0;
- }
-
- if (current->isSelfDestroying()) {
- ASSERT(node != current);
- ASSERT(current->next() == node);
- deallocate(toHandle(current));
- } else if (current->next() == node) { // if current->next() != node, then current has been deallocated
- SentinelLinkedList<Node>::remove(current);
- *current->slot() = JSValue();
- m_immediateList.push(current);
- }
- }
-#if !ASSERT_DISABLED
- m_handlingFinalizers = false;
-#endif
-}
-
-void HandleHeap::writeBarrier(HandleSlot slot, const JSValue& value)
-{
- ASSERT(!m_handlingFinalizers);
- if (slot->isCell() == value.isCell() && !value == !*slot)
- return;
- Node* node = toNode(slot);
- SentinelLinkedList<Node>::remove(node);
- if (!value.isCell() || !value) {
- m_immediateList.push(node);
- return;
- }
- if (node->isWeak())
- m_weakList.push(node);
- else
- m_strongList.push(node);
-}
-
-unsigned HandleHeap::protectedGlobalObjectCount()
-{
- unsigned count = 0;
- Node* end = m_strongList.end();
- for (Node* node = m_strongList.begin(); node != end; node = node->next()) {
- JSValue value = *node->slot();
- if (value.isObject() && asObject(value.asCell())->isGlobalObject())
- count++;
- }
- return count;
-}
-
-}
diff --git a/Source/JavaScriptCore/collector/handles/HandleHeap.h b/Source/JavaScriptCore/collector/handles/HandleHeap.h
deleted file mode 100644
index ed462d4..0000000
--- a/Source/JavaScriptCore/collector/handles/HandleHeap.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * 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 HandleHeap_h
-#define HandleHeap_h
-
-#include "BlockStack.h"
-#include "Handle.h"
-#include "SentinelLinkedList.h"
-#include "SinglyLinkedList.h"
-
-namespace JSC {
-
-class HandleHeap;
-class JSGlobalData;
-class JSValue;
-class HeapRootMarker;
-
-class Finalizer {
-public:
- virtual void finalize(Handle<Unknown>, void*) = 0;
- virtual ~Finalizer() {}
-};
-
-class HandleHeap {
-public:
- static HandleHeap* heapFor(HandleSlot);
-
- HandleHeap(JSGlobalData*);
-
- HandleSlot allocate();
- void deallocate(HandleSlot);
-
- void makeWeak(HandleSlot, Finalizer*, void* context);
- void makeSelfDestroying(HandleSlot, Finalizer*, void* context);
-
- void markStrongHandles(HeapRootMarker&);
- void updateAfterMark();
-
- // Should only be called during teardown.
- void clearWeakPointers();
-
- void writeBarrier(HandleSlot, const JSValue&);
-
-#if !ASSERT_DISABLED
- Finalizer* getFinalizer(HandleSlot handle)
- {
- return toNode(handle)->finalizer();
- }
-#endif
-
- unsigned protectedGlobalObjectCount();
-
-private:
- typedef uintptr_t HandleHeapWithFlags;
- enum { FlagsMask = 3, WeakFlag = 1, SelfDestroyingFlag = 2 };
- class Node {
- public:
- Node(WTF::SentinelTag);
- Node(HandleHeap*);
-
- HandleSlot slot();
- HandleHeap* handleHeap();
-
- void setFinalizer(Finalizer*, void* context);
- Finalizer* finalizer();
- void* finalizerContext();
-
- void setPrev(Node*);
- Node* prev();
-
- void setNext(Node*);
- Node* next();
-
- bool isWeak();
- void makeWeak();
-
- bool isSelfDestroying();
- void makeSelfDestroying();
-
- private:
- JSValue m_value;
- HandleHeapWithFlags m_handleHeapWithFlags;
- Finalizer* m_finalizer;
- void* m_finalizerContext;
- Node* m_prev;
- Node* m_next;
- };
-
- static HandleSlot toHandle(Node*);
- static Node* toNode(HandleSlot);
-
- void grow();
-
- JSGlobalData* m_globalData;
- BlockStack<Node> m_blockStack;
-
- SentinelLinkedList<Node> m_strongList;
- SentinelLinkedList<Node> m_weakList;
- SentinelLinkedList<Node> m_immediateList;
- SinglyLinkedList<Node> m_freeList;
- Node* m_nextToFinalize;
-
-#if !ASSERT_DISABLED
- bool m_handlingFinalizers;
-#endif
-};
-
-inline HandleHeap* HandleHeap::heapFor(HandleSlot handle)
-{
- return toNode(handle)->handleHeap();
-}
-
-inline HandleSlot HandleHeap::toHandle(Node* node)
-{
- return reinterpret_cast<HandleSlot>(node);
-}
-
-inline HandleHeap::Node* HandleHeap::toNode(HandleSlot handle)
-{
- return reinterpret_cast<Node*>(handle);
-}
-
-inline HandleSlot HandleHeap::allocate()
-{
- if (m_freeList.isEmpty())
- grow();
-
- Node* node = m_freeList.pop();
- new (node) Node(this);
- m_immediateList.push(node);
- return toHandle(node);
-}
-
-inline void HandleHeap::deallocate(HandleSlot handle)
-{
- Node* node = toNode(handle);
- if (m_nextToFinalize == node) {
- m_nextToFinalize = node->next();
- ASSERT(m_nextToFinalize->next());
- }
- SentinelLinkedList<Node>::remove(node);
- m_freeList.push(node);
-}
-
-inline void HandleHeap::makeWeak(HandleSlot handle, Finalizer* finalizer, void* context)
-{
- Node* node = toNode(handle);
- SentinelLinkedList<Node>::remove(node);
- node->setFinalizer(finalizer, context);
- node->makeWeak();
- if (handle->isCell() && *handle)
- m_weakList.push(node);
- else
- m_immediateList.push(node);
-}
-
-inline void HandleHeap::makeSelfDestroying(HandleSlot handle, Finalizer* finalizer, void* context)
-{
- makeWeak(handle, finalizer, context);
- Node* node = toNode(handle);
- node->makeSelfDestroying();
-}
-
-inline HandleHeap::Node::Node(HandleHeap* handleHeap)
- : m_handleHeapWithFlags(reinterpret_cast<uintptr_t>(handleHeap))
- , m_finalizer(0)
- , m_finalizerContext(0)
-{
-}
-
-inline HandleHeap::Node::Node(WTF::SentinelTag)
- : m_handleHeapWithFlags(0)
- , m_finalizer(0)
- , m_finalizerContext(0)
-{
-}
-
-inline HandleSlot HandleHeap::Node::slot()
-{
- return &m_value;
-}
-
-inline HandleHeap* HandleHeap::Node::handleHeap()
-{
- return reinterpret_cast<HandleHeap*>(m_handleHeapWithFlags & ~FlagsMask);
-}
-
-inline void HandleHeap::Node::setFinalizer(Finalizer* finalizer, void* context)
-{
- m_finalizer = finalizer;
- m_finalizerContext = context;
-}
-
-inline void HandleHeap::Node::makeWeak()
-{
- ASSERT(!(m_handleHeapWithFlags & WeakFlag));
- m_handleHeapWithFlags |= WeakFlag;
-}
-
-inline bool HandleHeap::Node::isWeak()
-{
- return !!(m_handleHeapWithFlags & WeakFlag);
-}
-
-inline void HandleHeap::Node::makeSelfDestroying()
-{
- ASSERT(m_handleHeapWithFlags & WeakFlag);
- ASSERT(!(m_handleHeapWithFlags & SelfDestroyingFlag));
- m_handleHeapWithFlags |= SelfDestroyingFlag;
-}
-
-inline bool HandleHeap::Node::isSelfDestroying()
-{
- return !!(m_handleHeapWithFlags & SelfDestroyingFlag);
-}
-
-inline Finalizer* HandleHeap::Node::finalizer()
-{
- return m_finalizer;
-}
-
-inline void* HandleHeap::Node::finalizerContext()
-{
- ASSERT(m_finalizer);
- return m_finalizerContext;
-}
-
-inline void HandleHeap::Node::setPrev(Node* prev)
-{
- m_prev = prev;
-}
-
-inline HandleHeap::Node* HandleHeap::Node::prev()
-{
- return m_prev;
-}
-
-inline void HandleHeap::Node::setNext(Node* next)
-{
- m_next = next;
-}
-
-inline HandleHeap::Node* HandleHeap::Node::next()
-{
- return m_next;
-}
-
-}
-
-#endif
diff --git a/Source/JavaScriptCore/collector/handles/HandleStack.cpp b/Source/JavaScriptCore/collector/handles/HandleStack.cpp
deleted file mode 100644
index 1c151af..0000000
--- a/Source/JavaScriptCore/collector/handles/HandleStack.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#include "config.h"
-
-#include "HandleStack.h"
-
-#include "MarkStack.h"
-
-namespace JSC {
-
-HandleStack::HandleStack()
-#ifndef NDEBUG
- : m_scopeDepth(0)
-#endif
-{
- grow();
-}
-
-void HandleStack::mark(HeapRootMarker& heapRootMarker)
-{
- const Vector<HandleSlot>& blocks = m_blockStack.blocks();
- size_t blockLength = m_blockStack.blockLength;
-
- int end = blocks.size() - 1;
- for (int i = 0; i < end; ++i) {
- HandleSlot block = blocks[i];
- heapRootMarker.mark(block, blockLength);
- }
- HandleSlot block = blocks[end];
- heapRootMarker.mark(block, m_frame.m_next - block);
-}
-
-void HandleStack::grow()
-{
- HandleSlot block = m_blockStack.grow();
- m_frame.m_next = block;
- m_frame.m_end = block + m_blockStack.blockLength;
-}
-
-}
diff --git a/Source/JavaScriptCore/collector/handles/HandleStack.h b/Source/JavaScriptCore/collector/handles/HandleStack.h
deleted file mode 100644
index 54e6c60..0000000
--- a/Source/JavaScriptCore/collector/handles/HandleStack.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2010 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 HandleStack_h
-#define HandleStack_h
-
-#include "Assertions.h"
-#include "BlockStack.h"
-#include "Handle.h"
-
-#include <wtf/UnusedParam.h>
-
-namespace JSC {
-
-class LocalScope;
-class HeapRootMarker;
-
-class HandleStack {
-public:
- class Frame {
- public:
- HandleSlot m_next;
- HandleSlot m_end;
- };
-
- HandleStack();
-
- void enterScope(Frame&);
- void leaveScope(Frame&);
-
- HandleSlot push();
-
- void mark(HeapRootMarker&);
-
-private:
- void grow();
- void zapTo(Frame&);
- HandleSlot findFirstAfter(HandleSlot);
-
-#ifndef NDEBUG
- size_t m_scopeDepth;
-#endif
- BlockStack<JSValue> m_blockStack;
- Frame m_frame;
-};
-
-inline void HandleStack::enterScope(Frame& lastFrame)
-{
-#ifndef NDEBUG
- ++m_scopeDepth;
-#endif
-
- lastFrame = m_frame;
-}
-
-
-
-inline void HandleStack::zapTo(Frame& lastFrame)
-{
-#ifdef NDEBUG
- UNUSED_PARAM(lastFrame);
-#else
- const Vector<HandleSlot>& blocks = m_blockStack.blocks();
-
- if (lastFrame.m_end != m_frame.m_end) { // Zapping to a frame in a different block.
- int i = blocks.size() - 1;
- for ( ; blocks[i] + m_blockStack.blockLength != lastFrame.m_end; --i) {
- for (int j = m_blockStack.blockLength - 1; j >= 0; --j)
- blocks[i][j] = JSValue();
- }
-
- for (HandleSlot it = blocks[i] + m_blockStack.blockLength - 1; it != lastFrame.m_next - 1; --it)
- *it = JSValue();
-
- return;
- }
-
- for (HandleSlot it = m_frame.m_next - 1; it != lastFrame.m_next - 1; --it)
- *it = JSValue();
-#endif
-}
-
-inline void HandleStack::leaveScope(Frame& lastFrame)
-{
-#ifndef NDEBUG
- --m_scopeDepth;
-#endif
-
- zapTo(lastFrame);
-
- if (lastFrame.m_end != m_frame.m_end) // Popping to a frame in a different block.
- m_blockStack.shrink(lastFrame.m_end);
-
- m_frame = lastFrame;
-}
-
-inline HandleSlot HandleStack::push()
-{
- ASSERT(m_scopeDepth); // Creating a Local outside of a LocalScope is a memory leak.
- if (m_frame.m_next == m_frame.m_end)
- grow();
- return m_frame.m_next++;
-}
-
-}
-
-#endif
diff --git a/Source/JavaScriptCore/collector/handles/Local.h b/Source/JavaScriptCore/collector/handles/Local.h
deleted file mode 100644
index 035e9e9..0000000
--- a/Source/JavaScriptCore/collector/handles/Local.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 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 Local_h
-#define Local_h
-
-#include "Handle.h"
-#include "JSGlobalData.h"
-
-/*
- A Local is a temporary handle whose lifetime is tied to a given LocalScope.
- Use Locals for local values on the stack. It is an error to create a Local
- outside of any LocalScope.
-*/
-
-namespace JSC {
-template <typename T> class Local;
-}
-
-namespace WTF {
-
-template<typename T> struct VectorTraits<JSC::Local<T> > {
- static const bool needsDestruction = false;
- static const bool needsInitialization = true;
- static const bool canInitializeWithMemset = false;
- static const bool canMoveWithMemcpy = true;
- static const bool canCopyWithMemcpy = false;
- static const bool canFillWithMemset = false;
- static const bool canCompareWithMemcmp = true;
-};
-
-}
-
-namespace JSC {
-
-template <typename T> class Local : public Handle<T> {
- friend class LocalScope;
-public:
- typedef typename Handle<T>::ExternalType ExternalType;
- Local(JSGlobalData&, ExternalType = ExternalType());
- Local(JSGlobalData&, Handle<T>);
- Local(const Local<T>&); // Adopting constructor. Used to return a Local to a calling function.
-
- Local& operator=(ExternalType);
- Local& operator=(Handle<T>);
-
- using Handle<T>::slot;
-
-private:
- Local(HandleSlot, ExternalType); // Used by LocalScope::release() to move a Local to a containing scope.
- void internalSet(ExternalType value)
- {
- JSValue newValue(HandleTypes<T>::toJSValue(value));
- HandleSlot slot = this->slot();
- *slot = newValue;
- }
-};
-
-template <typename T> inline Local<T>::Local(JSGlobalData& globalData, ExternalType value)
- : Handle<T>(globalData.allocateLocalHandle())
-{
- internalSet(value);
-}
-
-template <typename T> inline Local<T>::Local(JSGlobalData& globalData, Handle<T> handle)
- : Handle<T>(globalData.allocateLocalHandle())
-{
- internalSet(handle.get());
-}
-
-template <typename T> inline Local<T>::Local(const Local<T>& o)
- : Handle<T>(o.slot())
-{
- const_cast<Local<T>&>(o).invalidate(); // Prevent accidental sharing.
-}
-
-template <typename T> inline Local<T>::Local(HandleSlot slot, ExternalType value)
- : Handle<T>(slot, value)
-{
-}
-
-template <typename T> inline Local<T>& Local<T>::operator=(ExternalType value)
-{
- internalSet(value);
- return *this;
-}
-
-template <typename T> inline Local<T>& Local<T>::operator=(Handle<T> handle)
-{
- internalSet(handle.get());
- return *this;
-}
-
-template <typename T, unsigned inlineCapacity = 0> class LocalStack {
- typedef typename Handle<T>::ExternalType ExternalType;
-public:
- LocalStack(JSGlobalData& globalData)
- : m_globalData(&globalData)
- , m_count(0)
- {
- }
-
- ExternalType peek() const
- {
- ASSERT(m_count > 0);
- return m_stack[m_count - 1].get();
- }
-
- ExternalType pop()
- {
- ASSERT(m_count > 0);
- return m_stack[--m_count].get();
- }
-
- void push(ExternalType value)
- {
- if (m_count == m_stack.size())
- m_stack.append(Local<T>(*m_globalData, value));
- else
- m_stack[m_count] = value;
- m_count++;
- }
-
- bool isEmpty() const { return !m_count; }
- unsigned size() const { return m_count; }
-
-private:
- RefPtr<JSGlobalData> m_globalData;
- Vector<Local<T>, inlineCapacity> m_stack;
- unsigned m_count;
-};
-
-}
-
-#endif
diff --git a/Source/JavaScriptCore/collector/handles/LocalScope.h b/Source/JavaScriptCore/collector/handles/LocalScope.h
deleted file mode 100644
index cd27b32..0000000
--- a/Source/JavaScriptCore/collector/handles/LocalScope.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2010 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 LocalScope_h
-#define LocalScope_h
-
-#include "HandleStack.h"
-#include "Local.h"
-
-namespace JSC {
-/*
- A LocalScope is a temporary scope in which Locals are allocated. When a
- LocalScope goes out of scope, all the Locals created in it are destroyed.
-
- LocalScope is similar in concept to NSAutoreleasePool.
-*/
-
-class JSGlobalData;
-
-class LocalScope {
-public:
- explicit LocalScope(JSGlobalData&);
- ~LocalScope();
-
- template <typename T> Local<T> release(Local<T>); // Destroys all other locals in the scope.
-
-private:
- HandleStack* m_handleStack;
- HandleStack::Frame m_lastFrame;
-};
-
-inline LocalScope::LocalScope(JSGlobalData& globalData)
- : m_handleStack(globalData.heap.handleStack())
-{
- m_handleStack->enterScope(m_lastFrame);
-}
-
-inline LocalScope::~LocalScope()
-{
- m_handleStack->leaveScope(m_lastFrame);
-}
-
-template <typename T> Local<T> LocalScope::release(Local<T> local)
-{
- typename Local<T>::ExternalType ptr = local.get();
-
- m_handleStack->leaveScope(m_lastFrame);
- HandleSlot slot = m_handleStack->push();
- m_handleStack->enterScope(m_lastFrame);
-
- return Local<T>(slot, ptr);
-}
-
-}
-
-#endif