Index: src/allocation.h |
=================================================================== |
--- src/allocation.h (revision 7267) |
+++ src/allocation.h (working copy) |
@@ -43,31 +43,18 @@ |
// the C++ heap only! |
class NativeAllocationChecker { |
public: |
- typedef enum { ALLOW, DISALLOW } NativeAllocationAllowed; |
- explicit inline NativeAllocationChecker(NativeAllocationAllowed allowed) |
- : allowed_(allowed) { |
+ enum NativeAllocationAllowed { ALLOW, DISALLOW }; |
#ifdef DEBUG |
- if (allowed == DISALLOW) { |
- allocation_disallowed_++; |
- } |
-#endif |
- } |
- ~NativeAllocationChecker() { |
-#ifdef DEBUG |
- if (allowed_ == DISALLOW) { |
- allocation_disallowed_--; |
- } |
-#endif |
- ASSERT(allocation_disallowed_ >= 0); |
- } |
- static inline bool allocation_allowed() { |
- return allocation_disallowed_ == 0; |
- } |
+ explicit NativeAllocationChecker(NativeAllocationAllowed allowed); |
+ ~NativeAllocationChecker(); |
+ static bool allocation_allowed(); |
private: |
- // This static counter ensures that NativeAllocationCheckers can be nested. |
- static int allocation_disallowed_; |
// This flag applies to this particular instance. |
NativeAllocationAllowed allowed_; |
+#else |
+ explicit inline NativeAllocationChecker(NativeAllocationAllowed allowed) {} |
+ static inline bool allocation_allowed() { return true; } |
+#endif |
}; |
@@ -146,27 +133,27 @@ |
// Allocation policy for allocating in preallocated space. |
// Used as an allocation policy for ScopeInfo when generating |
// stack traces. |
-class PreallocatedStorage : public AllStatic { |
+class PreallocatedStorage { |
public: |
explicit PreallocatedStorage(size_t size); |
size_t size() { return size_; } |
- static void* New(size_t size); |
- static void Delete(void* p); |
- // Preallocate a set number of bytes. |
- static void Init(size_t size); |
+ // TODO(isolates): Get rid of these-- we'll have to change the allocator |
+ // interface to include a pointer to an isolate to do this |
+ // efficiently. |
+ static inline void* New(size_t size); |
+ static inline void Delete(void* p); |
private: |
size_t size_; |
PreallocatedStorage* previous_; |
PreallocatedStorage* next_; |
- static bool preallocated_; |
- static PreallocatedStorage in_use_list_; |
- static PreallocatedStorage free_list_; |
- |
void LinkTo(PreallocatedStorage* other); |
void Unlink(); |
+ |
+ friend class Isolate; |
+ |
DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); |
}; |