| Index: src/zone.h
|
| diff --git a/src/zone.h b/src/zone.h
|
| index 864846553a234d82cfd88c3e527f1f5c7416e654..3f8e5b244b626766260ae043286a54100d2c1429 100644
|
| --- a/src/zone.h
|
| +++ b/src/zone.h
|
| @@ -164,16 +164,16 @@ class ZoneObject {
|
| };
|
|
|
|
|
| -// The ZoneListAllocationPolicy is used to specialize the GenericList
|
| -// implementation to allocate ZoneLists and their elements in the
|
| -// Zone.
|
| -class ZoneListAllocationPolicy {
|
| +// The ZoneAllocationPolicy is used to specialize the generic data
|
| +// structures to allocate themselves and their elements in the Zone.
|
| +struct ZoneAllocationPolicy {
|
| public:
|
| - // Allocate 'size' bytes of memory in the zone.
|
| - static void* New(int size);
|
| + explicit ZoneAllocationPolicy(Zone* zone = NULL) : zone_(zone) { }
|
| + INLINE(void* New(size_t size));
|
| + INLINE(static void Delete(void *pointer)) { }
|
|
|
| - // De-allocation attempts are silently ignored.
|
| - static void Delete(void* p) { }
|
| + private:
|
| + Zone* zone_;
|
| };
|
|
|
|
|
| @@ -182,20 +182,49 @@ class ZoneListAllocationPolicy {
|
| // Zone. ZoneLists cannot be deleted individually; you can delete all
|
| // objects in the Zone by calling Zone::DeleteAll().
|
| template<typename T>
|
| -class ZoneList: public List<T, ZoneListAllocationPolicy> {
|
| +class ZoneList: public List<T, ZoneAllocationPolicy> {
|
| public:
|
| - INLINE(void* operator new(size_t size));
|
| - INLINE(void* operator new(size_t size, Zone* zone));
|
| -
|
| // Construct a new ZoneList with the given capacity; the length is
|
| // always zero. The capacity must be non-negative.
|
| - explicit ZoneList(int capacity)
|
| - : List<T, ZoneListAllocationPolicy>(capacity) { }
|
| + explicit ZoneList(int capacity, Zone* zone = NULL)
|
| + : List<T, ZoneAllocationPolicy>(capacity, ZoneAllocationPolicy(zone)) { }
|
| +
|
| + INLINE(void* operator new(size_t size, Zone* zone));
|
| + INLINE(void* operator new(size_t size));
|
|
|
| // Construct a new ZoneList by copying the elements of the given ZoneList.
|
| - explicit ZoneList(const ZoneList<T>& other)
|
| - : List<T, ZoneListAllocationPolicy>(other.length()) {
|
| - AddAll(other);
|
| + explicit ZoneList(const ZoneList<T>& other, Zone* zone = NULL)
|
| + : List<T, ZoneAllocationPolicy>(other.length(),
|
| + ZoneAllocationPolicy(zone)) {
|
| + AddAll(other, ZoneAllocationPolicy(zone));
|
| + }
|
| +
|
| + // We add some convenience wrappers where so that we can pass in a
|
| + // Zone instead of a (less convenient) ZoneAllocationPolicy.
|
| + INLINE(void Add(const T& element, Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::Add(element, ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(void AddAll(const List<T, ZoneAllocationPolicy>& other,
|
| + Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(void AddAll(const Vector<T>& other, Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(void InsertAt(int index, const T& element, Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::InsertAt(index, element,
|
| + ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(Vector<T> AddBlock(T value, int count, Zone* zone = NULL)) {
|
| + return List<T, ZoneAllocationPolicy>::AddBlock(value, count,
|
| + ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(void Allocate(int length, Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::Allocate(length, ZoneAllocationPolicy(zone));
|
| + }
|
| + INLINE(void Initialize(int capacity, Zone* zone = NULL)) {
|
| + List<T, ZoneAllocationPolicy>::Initialize(capacity,
|
| + ZoneAllocationPolicy(zone));
|
| }
|
|
|
| void operator delete(void* pointer) { UNREACHABLE(); }
|
| @@ -232,15 +261,15 @@ class ZoneScope BASE_EMBEDDED {
|
| // different configurations of a concrete splay tree (see splay-tree.h).
|
| // The tree itself and all its elements are allocated in the Zone.
|
| template <typename Config>
|
| -class ZoneSplayTree: public SplayTree<Config, ZoneListAllocationPolicy> {
|
| +class ZoneSplayTree: public SplayTree<Config, ZoneAllocationPolicy> {
|
| public:
|
| ZoneSplayTree()
|
| - : SplayTree<Config, ZoneListAllocationPolicy>() {}
|
| + : SplayTree<Config, ZoneAllocationPolicy>() {}
|
| ~ZoneSplayTree();
|
| };
|
|
|
|
|
| -typedef TemplateHashMapImpl<ZoneListAllocationPolicy> ZoneHashMap;
|
| +typedef TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
|
|
|
| } } // namespace v8::internal
|
|
|
|
|