From a3629daa2ce797cc170e12192119c690a9c59a77 Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Wed, 11 Apr 2012 09:23:57 +0000 Subject: [PATCH] Fix external allocated memory accounting to use 64 bit values on 64 bit architectures. Review URL: https://chromiumcodereview.appspot.com/10020032 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11265 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- include/v8.h | 6 +++--- src/api.cc | 2 +- src/heap-inl.h | 7 ++++--- src/heap.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/v8.h b/include/v8.h index 33179f5..e360f7e 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1236,8 +1236,7 @@ class String : public Primitive { * this function should not otherwise delete or modify the resource. Neither * should the underlying buffer be deallocated or modified except through the * destructor of the external string resource. - */ - V8EXPORT static Local NewExternal( + */ V8EXPORT static Local NewExternal( ExternalAsciiStringResource* resource); /** @@ -3153,7 +3152,8 @@ class V8EXPORT V8 { * that is kept alive by JavaScript objects. * \returns the adjusted value. */ - static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes); + static intptr_t AdjustAmountOfExternalAllocatedMemory( + intptr_t change_in_bytes); /** * Suspends recording of tick samples in the profiler. diff --git a/src/api.cc b/src/api.cc index bb9ba23..960e7a4 100644 --- a/src/api.cc +++ b/src/api.cc @@ -5208,7 +5208,7 @@ void V8::AddImplicitReferences(Persistent parent, } -int V8::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { +intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { i::Isolate* isolate = i::Isolate::Current(); if (IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) { return 0; diff --git a/src/heap-inl.h b/src/heap-inl.h index 706d288..e12895a 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -460,15 +460,16 @@ MaybeObject* Heap::PrepareForCompare(String* str) { } -int Heap::AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) { +intptr_t Heap::AdjustAmountOfExternalAllocatedMemory( + intptr_t change_in_bytes) { ASSERT(HasBeenSetUp()); - int amount = amount_of_external_allocated_memory_ + change_in_bytes; + intptr_t amount = amount_of_external_allocated_memory_ + change_in_bytes; if (change_in_bytes >= 0) { // Avoid overflow. if (amount > amount_of_external_allocated_memory_) { amount_of_external_allocated_memory_ = amount; } - int amount_since_last_global_gc = + intptr_t amount_since_last_global_gc = amount_of_external_allocated_memory_ - amount_of_external_allocated_memory_at_last_global_gc_; if (amount_since_last_global_gc > external_allocation_limit_) { diff --git a/src/heap.h b/src/heap.h index 0391e0e..ee6f2bc 100644 --- a/src/heap.h +++ b/src/heap.h @@ -1711,7 +1711,7 @@ class Heap { // The amount of external memory registered through the API kept alive // by global handles - int amount_of_external_allocated_memory_; + intptr_t amount_of_external_allocated_memory_; // Caches the amount of external memory registered at the last global gc. int amount_of_external_allocated_memory_at_last_global_gc_; -- 2.7.4