Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Unified Diff: src/zone/zone.h

Issue 2344143003: Moved zones and zone related stuff in its own directory. (Closed)
Patch Set: Renamed defines to match new file locations Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/zone/zone.h
diff --git a/src/zone.h b/src/zone/zone.h
similarity index 91%
rename from src/zone.h
rename to src/zone/zone.h
index 29055cb70d053547d44091cdfaf420e0f6736e2d..f9a861a459320c633b1ebcc3cd6509d015130ae5 100644
--- a/src/zone.h
+++ b/src/zone/zone.h
@@ -2,25 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef V8_ZONE_H_
-#define V8_ZONE_H_
+#ifndef V8_SRC_ZONE_ZONE_H_
marja 2016/09/19 08:05:11 Ditto
heimbuef 2016/09/19 10:47:52 Done.
+#define V8_SRC_ZONE_ZONE_H_
#include <limits>
-#include "src/base/accounting-allocator.h"
#include "src/base/hashmap.h"
#include "src/base/logging.h"
#include "src/globals.h"
#include "src/list.h"
#include "src/splay-tree.h"
+#include "src/zone/accounting-allocator.h"
namespace v8 {
namespace internal {
-// Forward declarations.
-class Segment;
-
-
// The Zone supports very fast allocation of small chunks of
// memory. The chunks cannot be deallocated individually, but instead
// the Zone supports deallocating all chunks in one fast
@@ -35,7 +31,7 @@ class Segment;
// from multi-threaded code.
class Zone final {
public:
- explicit Zone(base::AccountingAllocator* allocator);
+ explicit Zone(AccountingAllocator* allocator);
~Zone();
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
@@ -64,12 +60,13 @@ class Zone final {
size_t allocation_size() const { return allocation_size_; }
- base::AccountingAllocator* allocator() const { return allocator_; }
+ AccountingAllocator* allocator() const { return allocator_; }
private:
- // All pointers returned from New() have this alignment. In addition, if the
- // object being allocated has a size that is divisible by 8 then its alignment
- // will be 8. ASan requires 8-byte alignment.
+ friend class SegmentPool;
marja 2016/09/19 08:05:11 Hmm, what? Is this CL based on some other CL and c
heimbuef 2016/09/19 10:47:52 Removed.
+// All pointers returned from New() have this alignment. In addition, if the
+// object being allocated has a size that is divisible by 8 then its alignment
+// will be 8. ASan requires 8-byte alignment.
#ifdef V8_USE_ADDRESS_SANITIZER
static const size_t kAlignment = 8;
STATIC_ASSERT(kPointerSize <= 8);
@@ -107,21 +104,17 @@ class Zone final {
// of the segment chain. Returns the new segment.
inline Segment* NewSegment(size_t size);
- // Deletes the given segment. Does not touch the segment chain.
- inline void DeleteSegment(Segment* segment, size_t size);
-
// The free region in the current (front) segment is represented as
// the half-open interval [position, limit). The 'position' variable
// is guaranteed to be aligned as dictated by kAlignment.
Address position_;
Address limit_;
- base::AccountingAllocator* allocator_;
+ AccountingAllocator* allocator_;
Segment* segment_head_;
};
-
// ZoneObject is an abstraction that helps define classes of objects
// allocated in the Zone. Use it as a base class; see ast.h.
class ZoneObject {
@@ -141,12 +134,11 @@ class ZoneObject {
void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
};
-
// The ZoneScope is used to automatically call DeleteAll() on a
// Zone when the ZoneScope is destroyed (i.e. goes out of scope)
class ZoneScope final {
public:
- explicit ZoneScope(Zone* zone) : zone_(zone) { }
+ explicit ZoneScope(Zone* zone) : zone_(zone) {}
~ZoneScope() { zone_->DeleteAll(); }
Zone* zone() const { return zone_; }
@@ -155,12 +147,11 @@ class ZoneScope final {
Zone* zone_;
};
-
// The ZoneAllocationPolicy is used to specialize generic data
// structures to allocate themselves and their elements in the Zone.
class ZoneAllocationPolicy final {
public:
- explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { }
+ explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) {}
void* New(size_t size) { return zone()->New(size); }
static void Delete(void* pointer) {}
Zone* zone() const { return zone_; }
@@ -169,7 +160,6 @@ class ZoneAllocationPolicy final {
Zone* zone_;
};
-
// ZoneLists are growable lists with constant-time access to the
// elements. The list itself and all its elements are allocated in the
// Zone. ZoneLists cannot be deleted individually; you can delete all
@@ -180,7 +170,7 @@ class ZoneList final : public List<T, ZoneAllocationPolicy> {
// Construct a new ZoneList with the given capacity; the length is
// always zero. The capacity must be non-negative.
ZoneList(int capacity, Zone* zone)
- : List<T, ZoneAllocationPolicy>(capacity, ZoneAllocationPolicy(zone)) { }
+ : List<T, ZoneAllocationPolicy>(capacity, ZoneAllocationPolicy(zone)) {}
void* operator new(size_t size, Zone* zone) { return zone->New(size); }
@@ -222,7 +212,6 @@ class ZoneList final : public List<T, ZoneAllocationPolicy> {
void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
};
-
// A zone splay tree. The config type parameter encapsulates the
// different configurations of a concrete splay tree (see splay-tree.h).
// The tree itself and all its elements are allocated in the Zone.

Powered by Google App Engine
This is Rietveld 408576698