Reviewers: Vyacheslav Egorov,

Description:
Fix external allocated memory accounting to use 64 bit values on
64 bit architectures.

Please review this at https://chromiumcodereview.appspot.com/10020032/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     include/v8.h
  M     src/api.cc
  M     src/heap-inl.h
  M     src/heap.h


Index: include/v8.h
===================================================================
--- include/v8.h        (revision 11259)
+++ include/v8.h        (working copy)
@@ -1236,8 +1236,7 @@
* 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<String> NewExternal(
+   */ V8EXPORT static Local<String> NewExternal(
       ExternalAsciiStringResource* resource);

   /**
@@ -3153,7 +3152,8 @@
    *   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.
Index: src/api.cc
===================================================================
--- src/api.cc  (revision 11259)
+++ src/api.cc  (working copy)
@@ -5208,7 +5208,7 @@
 }


-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;
Index: src/heap-inl.h
===================================================================
--- src/heap-inl.h      (revision 11259)
+++ src/heap-inl.h      (working copy)
@@ -460,15 +460,16 @@
 }


-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_) {
Index: src/heap.h
===================================================================
--- src/heap.h  (revision 11259)
+++ src/heap.h  (working copy)
@@ -1711,7 +1711,7 @@

   // 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_;


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to