Commit 918a2f97 authored by dcarney@chromium.org's avatar dcarney@chromium.org

revert thread isolate in PreallocatedStorageAllocationPolicy

This reverts 16467 for breaking windows build

TBR=svenpanne@chromium.org

BUG=

Review URL: https://codereview.chromium.org/23824005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16468 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9ee80162
...@@ -35,12 +35,12 @@ namespace internal { ...@@ -35,12 +35,12 @@ namespace internal {
void* PreallocatedStorageAllocationPolicy::New(size_t size) { void* PreallocatedStorageAllocationPolicy::New(size_t size) {
return isolate_->PreallocatedStorageNew(size); return Isolate::Current()->PreallocatedStorageNew(size);
} }
void PreallocatedStorageAllocationPolicy::Delete(void* p) { void PreallocatedStorageAllocationPolicy::Delete(void* p) {
return isolate_->PreallocatedStorageDelete(p); return Isolate::Current()->PreallocatedStorageDelete(p);
} }
......
...@@ -104,7 +104,6 @@ char* StrNDup(const char* str, int n); ...@@ -104,7 +104,6 @@ char* StrNDup(const char* str, int n);
// and free. Used as the default policy for lists. // and free. Used as the default policy for lists.
class FreeStoreAllocationPolicy { class FreeStoreAllocationPolicy {
public: public:
typedef FreeStoreAllocationPolicy Deleter;
INLINE(void* New(size_t size)) { return Malloced::New(size); } INLINE(void* New(size_t size)) { return Malloced::New(size); }
INLINE(static void Delete(void* p)) { Malloced::Delete(p); } INLINE(static void Delete(void* p)) { Malloced::Delete(p); }
}; };
...@@ -132,21 +131,9 @@ class PreallocatedStorage { ...@@ -132,21 +131,9 @@ class PreallocatedStorage {
}; };
class Isolate; struct PreallocatedStorageAllocationPolicy {
class PreallocatedStorageAllocationPolicy {
public:
typedef PreallocatedStorageAllocationPolicy Deleter;
INLINE(explicit PreallocatedStorageAllocationPolicy(Isolate* isolate))
: isolate_(isolate) { }
INLINE(PreallocatedStorageAllocationPolicy(
const PreallocatedStorageAllocationPolicy& policy))
: isolate_(policy.isolate_) { }
INLINE(void* New(size_t size)); INLINE(void* New(size_t size));
INLINE(void Delete(void* ptr)); INLINE(static void Delete(void* ptr));
private:
Isolate* isolate_;
}; };
......
...@@ -2059,7 +2059,7 @@ Isolate::~Isolate() { ...@@ -2059,7 +2059,7 @@ Isolate::~Isolate() {
delete eternal_handles_; delete eternal_handles_;
eternal_handles_ = NULL; eternal_handles_ = NULL;
DebugObjectCache::Delete(string_stream_debug_object_cache_); delete string_stream_debug_object_cache_;
string_stream_debug_object_cache_ = NULL; string_stream_debug_object_cache_ = NULL;
delete external_reference_table_; delete external_reference_table_;
......
...@@ -48,15 +48,13 @@ namespace internal { ...@@ -48,15 +48,13 @@ namespace internal {
// template <typename T, // template <typename T,
// class AllocationPolicy = FreeStoreAllocationPolicy> class List; // class AllocationPolicy = FreeStoreAllocationPolicy> class List;
template <typename T, class AllocationPolicy> template <typename T, class AllocationPolicy>
class List : private AllocationPolicy::Deleter { class List {
public: public:
explicit List(AllocationPolicy allocator = AllocationPolicy()) explicit List(AllocationPolicy allocator = AllocationPolicy()) {
: AllocationPolicy::Deleter(allocator) {
Initialize(0, allocator); Initialize(0, allocator);
} }
INLINE(explicit List(int capacity, INLINE(explicit List(int capacity,
AllocationPolicy allocator = AllocationPolicy())) AllocationPolicy allocator = AllocationPolicy())) {
: AllocationPolicy::Deleter(allocator) {
Initialize(capacity, allocator); Initialize(capacity, allocator);
} }
INLINE(~List()) { DeleteData(data_); } INLINE(~List()) { DeleteData(data_); }
...@@ -73,7 +71,7 @@ class List : private AllocationPolicy::Deleter { ...@@ -73,7 +71,7 @@ class List : private AllocationPolicy::Deleter {
return allocator.New(static_cast<int>(size)); return allocator.New(static_cast<int>(size));
} }
INLINE(void operator delete(void* p)) { INLINE(void operator delete(void* p)) {
AllocationPolicy::Deleter::Delete(p); AllocationPolicy::Delete(p);
} }
// Please the MSVC compiler. We should never have to execute this. // Please the MSVC compiler. We should never have to execute this.
...@@ -81,13 +79,6 @@ class List : private AllocationPolicy::Deleter { ...@@ -81,13 +79,6 @@ class List : private AllocationPolicy::Deleter {
UNREACHABLE(); UNREACHABLE();
} }
// Delete via the instance Deleter
static void Delete(List* p) {
if (p == NULL) return;
p->~List();
p->AllocationPolicy::Deleter::Delete(p);
}
// Returns a reference to the element at index i. This reference is // Returns a reference to the element at index i. This reference is
// not safe to use after operations that can change the list's // not safe to use after operations that can change the list's
// backing store (e.g. Add). // backing store (e.g. Add).
...@@ -188,7 +179,7 @@ class List : private AllocationPolicy::Deleter { ...@@ -188,7 +179,7 @@ class List : private AllocationPolicy::Deleter {
return static_cast<T*>(allocator.New(n * sizeof(T))); return static_cast<T*>(allocator.New(n * sizeof(T)));
} }
INLINE(void DeleteData(T* data)) { INLINE(void DeleteData(T* data)) {
this->AllocationPolicy::Deleter::Delete(data); AllocationPolicy::Delete(data);
} }
// Increase the capacity of a full list, and add an element. // Increase the capacity of a full list, and add an element.
......
...@@ -204,9 +204,7 @@ void StringStream::PrintObject(Object* o) { ...@@ -204,9 +204,7 @@ void StringStream::PrintObject(Object* o) {
} }
if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) { if (debug_object_cache->length() < kMentionedObjectCacheMaxSize) {
Add("#%d#", debug_object_cache->length()); Add("#%d#", debug_object_cache->length());
HeapObject* ho = HeapObject::cast(o); debug_object_cache->Add(HeapObject::cast(o));
PreallocatedStorageAllocationPolicy policy(ho->GetIsolate());
debug_object_cache->Add(ho, policy);
} else { } else {
Add("@%p", o); Add("@%p", o);
} }
...@@ -301,9 +299,8 @@ void StringStream::ClearMentionedObjectCache() { ...@@ -301,9 +299,8 @@ void StringStream::ClearMentionedObjectCache() {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
isolate->set_string_stream_current_security_token(NULL); isolate->set_string_stream_current_security_token(NULL);
if (isolate->string_stream_debug_object_cache() == NULL) { if (isolate->string_stream_debug_object_cache() == NULL) {
PreallocatedStorageAllocationPolicy policy(isolate);
isolate->set_string_stream_debug_object_cache( isolate->set_string_stream_debug_object_cache(
new(policy) DebugObjectCache(policy)); new List<HeapObject*, PreallocatedStorageAllocationPolicy>(0));
} }
isolate->string_stream_debug_object_cache()->Clear(); isolate->string_stream_debug_object_cache()->Clear();
} }
......
...@@ -174,11 +174,6 @@ struct ZoneScope { ...@@ -174,11 +174,6 @@ struct ZoneScope {
// structures to allocate themselves and their elements in the Zone. // structures to allocate themselves and their elements in the Zone.
struct ZoneAllocationPolicy { struct ZoneAllocationPolicy {
public: public:
class Deleter {
public:
INLINE(explicit Deleter(const ZoneAllocationPolicy&)) {}
INLINE(static void Delete(void *pointer)) { }
};
explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { } explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { }
INLINE(void* New(size_t size)); INLINE(void* New(size_t size));
INLINE(static void Delete(void *pointer)) { } INLINE(static void Delete(void *pointer)) { }
......
...@@ -35,8 +35,6 @@ using namespace v8::internal; ...@@ -35,8 +35,6 @@ using namespace v8::internal;
// Use a testing allocator that clears memory before deletion. // Use a testing allocator that clears memory before deletion.
class ZeroingAllocationPolicy { class ZeroingAllocationPolicy {
public: public:
typedef ZeroingAllocationPolicy Deleter;
void* New(size_t size) { void* New(size_t size) {
// Stash the size in the first word to use for Delete. // Stash the size in the first word to use for Delete.
size_t true_size = size + sizeof(size_t); size_t true_size = size + sizeof(size_t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment