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

Unified Diff: src/allocation.cc

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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
« no previous file with comments | « src/allocation.h ('k') | src/api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/allocation.cc
===================================================================
--- src/allocation.cc (revision 3427)
+++ src/allocation.cc (working copy)
@@ -53,7 +53,7 @@
#ifdef DEBUG
-static void* invalid = static_cast<void*>(NULL);
+static void* const invalid = static_cast<void*>(NULL);
void* Embedded::operator new(size_t size) {
UNREACHABLE();
@@ -97,16 +97,20 @@
return result;
}
+StorageData::StorageData()
+ :in_use_list_(0),
+ free_list_(0),
+ preallocated_(false),
+ #ifdef DEBUG
+ rset_used_(true),
+ #endif
+ allocation_disallowed_(0) {
+}
-int NativeAllocationChecker::allocation_disallowed_ = 0;
-
-PreallocatedStorage PreallocatedStorage::in_use_list_(0);
-PreallocatedStorage PreallocatedStorage::free_list_(0);
-bool PreallocatedStorage::preallocated_ = false;
-
-
void PreallocatedStorage::Init(size_t size) {
+ StorageData& storage_data = v8_context()->storage_data_;
+ PreallocatedStorage & free_list_ = storage_data.free_list_;
ASSERT(free_list_.next_ == &free_list_);
ASSERT(free_list_.previous_ == &free_list_);
PreallocatedStorage* free_chunk =
@@ -114,14 +118,20 @@
free_list_.next_ = free_list_.previous_ = free_chunk;
free_chunk->next_ = free_chunk->previous_ = &free_list_;
free_chunk->size_ = size - sizeof(PreallocatedStorage);
- preallocated_ = true;
+ storage_data.preallocated_ = true;
}
void* PreallocatedStorage::New(size_t size) {
- if (!preallocated_) {
+ StorageData& storage_data = v8_context()->storage_data_;
+
+ if (!storage_data.preallocated_) {
return FreeStoreAllocationPolicy::New(size);
}
+
+ PreallocatedStorage & free_list_ = storage_data.free_list_;
+ PreallocatedStorage & in_use_list_ = storage_data.in_use_list_;
+
ASSERT(free_list_.next_ != &free_list_);
ASSERT(free_list_.previous_ != &free_list_);
size = (size + kPointerSize - 1) & ~(kPointerSize - 1);
@@ -164,7 +174,8 @@
if (p == NULL) {
return;
}
- if (!preallocated_) {
+ StorageData& storage_data = v8_context()->storage_data_;
+ if (!storage_data.preallocated_) {
FreeStoreAllocationPolicy::Delete(p);
return;
}
@@ -172,7 +183,7 @@
ASSERT(storage->next_->previous_ == storage);
ASSERT(storage->previous_->next_ == storage);
storage->Unlink();
- storage->LinkTo(&free_list_);
+ storage->LinkTo(&storage_data.free_list_);
}
« no previous file with comments | « src/allocation.h ('k') | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698