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

Unified Diff: src/allocation.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « src/allocation.h ('k') | src/allocation-inl.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 7267)
+++ src/allocation.cc (working copy)
@@ -25,17 +25,56 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
+#include "v8.h"
+#include "isolate.h"
+#include "allocation.h"
+/* TODO(isolates): this is what's included in bleeding_edge
+ including of v8.h was replaced with these in
+ http://codereview.chromium.org/5005001/
+ we need Isolate and Isolate needs a lot more so I'm including v8.h back.
#include "../include/v8stdint.h"
#include "globals.h"
#include "checks.h"
#include "allocation.h"
#include "utils.h"
+*/
namespace v8 {
namespace internal {
+#ifdef DEBUG
+
+NativeAllocationChecker::NativeAllocationChecker(
+ NativeAllocationChecker::NativeAllocationAllowed allowed)
+ : allowed_(allowed) {
+ if (allowed == DISALLOW) {
+ Isolate* isolate = Isolate::Current();
+ isolate->set_allocation_disallowed(isolate->allocation_disallowed() + 1);
+ }
+}
+
+
+NativeAllocationChecker::~NativeAllocationChecker() {
+ Isolate* isolate = Isolate::Current();
+ if (allowed_ == DISALLOW) {
+ isolate->set_allocation_disallowed(isolate->allocation_disallowed() - 1);
+ }
+ ASSERT(isolate->allocation_disallowed() >= 0);
+}
+
+
+bool NativeAllocationChecker::allocation_allowed() {
+ // TODO(isolates): either find a way to make this work that doesn't
+ // require initializing an isolate before we can use malloc or drop
+ // it completely.
+ return true;
+ // return Isolate::Current()->allocation_disallowed() == 0;
+}
+
+#endif // DEBUG
+
+
void* Malloced::New(size_t size) {
ASSERT(NativeAllocationChecker::allocation_allowed());
void* result = malloc(size);
@@ -103,15 +142,7 @@
}
-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) {
+void Isolate::PreallocatedStorageInit(size_t size) {
ASSERT(free_list_.next_ == &free_list_);
ASSERT(free_list_.previous_ == &free_list_);
PreallocatedStorage* free_chunk =
@@ -119,12 +150,12 @@
free_list_.next_ = free_list_.previous_ = free_chunk;
free_chunk->next_ = free_chunk->previous_ = &free_list_;
free_chunk->size_ = size - sizeof(PreallocatedStorage);
- preallocated_ = true;
+ preallocated_storage_preallocated_ = true;
}
-void* PreallocatedStorage::New(size_t size) {
- if (!preallocated_) {
+void* Isolate::PreallocatedStorageNew(size_t size) {
+ if (!preallocated_storage_preallocated_) {
return FreeStoreAllocationPolicy::New(size);
}
ASSERT(free_list_.next_ != &free_list_);
@@ -166,11 +197,11 @@
// We don't attempt to coalesce.
-void PreallocatedStorage::Delete(void* p) {
+void Isolate::PreallocatedStorageDelete(void* p) {
if (p == NULL) {
return;
}
- if (!preallocated_) {
+ if (!preallocated_storage_preallocated_) {
FreeStoreAllocationPolicy::Delete(p);
return;
}
« no previous file with comments | « src/allocation.h ('k') | src/allocation-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698