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 5dbf993..1df17bb 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 63edb01..410c2e1 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));
 }