diff options
| author | Steve Block <steveblock@google.com> | 2011-05-26 01:26:41 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-06-02 15:09:56 +0100 |
| commit | 44f0eee88ff00398ff7f715fab053374d808c90d (patch) | |
| tree | addd100e906cd43f843f3aaf64b445f17f46fe0f /src/allocation.h | |
| parent | 1b63b9ad386abd62f61af0e29246a687f5311b53 (diff) | |
| download | android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.tar.gz android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.tar.bz2 android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.zip | |
Update V8 to r7427: Initial merge by git
As required by WebKit r82507
Change-Id: I7ae83ef3f689356043b4929255b7c1dd31d8c5df
Diffstat (limited to 'src/allocation.h')
| -rw-r--r-- | src/allocation.h | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/src/allocation.h b/src/allocation.h index 394366ea..75aba35d 100644 --- a/src/allocation.h +++ b/src/allocation.h @@ -39,38 +39,6 @@ namespace internal { // processing. void FatalProcessOutOfMemory(const char* message); -// A class that controls whether allocation is allowed. This is for -// the C++ heap only! -class NativeAllocationChecker { - public: - typedef enum { ALLOW, DISALLOW } NativeAllocationAllowed; - explicit inline NativeAllocationChecker(NativeAllocationAllowed allowed) - : allowed_(allowed) { -#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; - } - private: - // This static counter ensures that NativeAllocationCheckers can be nested. - static int allocation_disallowed_; - // This flag applies to this particular instance. - NativeAllocationAllowed allowed_; -}; - - // Superclass for classes managed with new & delete. class Malloced { public: @@ -114,7 +82,6 @@ class AllStatic { template <typename T> static T* NewArray(int size) { - ASSERT(NativeAllocationChecker::allocation_allowed()); T* result = new T[size]; if (result == NULL) Malloced::FatalProcessOutOfMemory(); return result; @@ -146,27 +113,27 @@ class FreeStoreAllocationPolicy { // 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); }; |
