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

Unified Diff: src/zone.h

Issue 2493002: - Remove [static] from methods in Zone and associated helpers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 7 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.h
===================================================================
--- src/zone.h (revision 4781)
+++ src/zone.h (working copy)
@@ -57,22 +57,23 @@
public:
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
// allocating new segments of memory on demand using malloc().
- static inline void* New(int size);
+ inline void* New(int size);
template <typename T>
- static inline T* NewArray(int length);
+ inline T* NewArray(int length);
// Delete all objects and free all memory allocated in the Zone.
- static void DeleteAll();
+ void DeleteAll();
// Returns true if more memory has been allocated in zones than
// the limit allows.
- static inline bool excess_allocation();
+ inline bool excess_allocation();
- static inline void adjust_segment_bytes_allocated(int delta);
+ inline void adjust_segment_bytes_allocated(int delta);
private:
-
+ friend class Isolate;
+
// All pointers returned from New() have this alignment.
static const int kAlignment = kPointerSize;
@@ -86,30 +87,28 @@
static const int kMaximumKeptSegmentSize = 64 * KB;
// Report zone excess when allocation exceeds this limit.
- static int zone_excess_limit_;
+ int zone_excess_limit_;
// The number of bytes allocated in segments. Note that this number
// includes memory allocated from the OS but not yet allocated from
// the zone.
- static int segment_bytes_allocated_;
+ int segment_bytes_allocated_;
- // The Zone is intentionally a singleton; you should not try to
- // allocate instances of the class.
- Zone() { UNREACHABLE(); }
+ // Each isolate gets its own zone.
+ Zone();
-
// Expand the Zone to hold at least 'size' more bytes and allocate
// the bytes. Returns the address of the newly allocated chunk of
// memory in the Zone. Should only be called if there isn't enough
// room in the Zone already.
- static Address NewExpand(int size);
+ Address NewExpand(int 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.
- static Address position_;
- static Address limit_;
+ Address position_;
+ Address limit_;
};
@@ -118,7 +117,7 @@
class ZoneObject {
public:
// Allocate a new ZoneObject of 'size' bytes in the Zone.
- void* operator new(size_t size) { return Zone::New(static_cast<int>(size)); }
+ inline void* operator new(size_t size);
// Ideally, the delete operator should be private instead of
// public, but unfortunately the compiler sometimes synthesizes
@@ -134,14 +133,10 @@
class AssertNoZoneAllocation {
public:
- AssertNoZoneAllocation() : prev_(allow_allocation_) {
- allow_allocation_ = false;
- }
- ~AssertNoZoneAllocation() { allow_allocation_ = prev_; }
- static bool allow_allocation() { return allow_allocation_; }
+ inline AssertNoZoneAllocation();
+ inline ~AssertNoZoneAllocation();
private:
bool prev_;
- static bool allow_allocation_;
};
@@ -151,7 +146,7 @@
class ZoneListAllocationPolicy {
public:
// Allocate 'size' bytes of memory in the zone.
- static void* New(int size) { return Zone::New(size); }
+ static inline void* New(int size);
// De-allocation attempts are silently ignored.
static void Delete(void* p) { }
@@ -181,10 +176,7 @@
nesting_++;
}
- virtual ~ZoneScope() {
- if (ShouldDeleteOnExit()) Zone::DeleteAll();
- --nesting_;
- }
+ virtual ~ZoneScope();
bool ShouldDeleteOnExit() {
return nesting_ == 1 && mode_ == DELETE_ON_EXIT;

Powered by Google App Engine
This is Rietveld 408576698