Always adjust amount of external memory when change is reported.
authorhpayer <hpayer@chromium.org>
Fri, 23 Jan 2015 11:37:33 +0000 (03:37 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 23 Jan 2015 11:37:49 +0000 (11:37 +0000)
BUG=

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

Cr-Commit-Position: refs/heads/master@{#26247}

include/v8.h
test/cctest/test-api.cc

index 5dbf9933ece0666cedc81e8fe4f698aa8ddc6d10..1df17bbaf5107619ca6245610c32a8e9cda9322e 100644 (file)
@@ -7289,9 +7289,8 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
       amount - *amount_of_external_allocated_memory_at_last_global_gc >
           I::kExternalAllocationLimit) {
     CollectAllGarbage("external memory allocation limit reached.");
-  } else {
-    *amount_of_external_allocated_memory = amount;
   }
+  *amount_of_external_allocated_memory = amount;
   return *amount_of_external_allocated_memory;
 }
 
index 63edb01de0404792e4da1f8d5c21c68b97595b6f..410c2e13540ddfecedbda7495b47095170cced4b 100644 (file)
@@ -15199,6 +15199,12 @@ THREADED_TEST(ExternalAllocatedMemory) {
            isolate->AdjustAmountOfExternalAllocatedMemory(kSize));
   CHECK_EQ(baseline,
            isolate->AdjustAmountOfExternalAllocatedMemory(-kSize));
+  const int64_t kTriggerGCSize =
+      v8::internal::Internals::kExternalAllocationLimit + 1;
+  CHECK_EQ(baseline + kTriggerGCSize,
+           isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize));
+  CHECK_EQ(baseline,
+           isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize));
 }