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

Unified Diff: include/v8.h

Issue 2917853004: [heap] Activate memory reducer on external memory activity. (Closed)
Patch Set: check for memory_reducer_ Created 3 years, 7 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 | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 30445457c20638b5cd2512e29649ae370ab7f97f..112fe4c9f07a2f829c1fac1d22111f81266d0bc5 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -7589,6 +7589,7 @@ class V8_EXPORT Isolate {
friend class PersistentValueMapBase;
void ReportExternalAllocationLimitReached();
+ void CheckMemoryPressure();
};
class V8_EXPORT StartupData {
@@ -8816,6 +8817,8 @@ class Internals {
static const int kExternalMemoryOffset = 4 * kApiPointerSize;
static const int kExternalMemoryLimitOffset =
kExternalMemoryOffset + kApiInt64Size;
+ static const int kExternalMemoryAtLastMarkCompactOffset =
+ kExternalMemoryLimitOffset + kApiInt64Size;
static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
kApiInt64Size + kApiInt64Size +
kApiPointerSize + kApiPointerSize;
@@ -10033,13 +10036,28 @@ uint32_t Isolate::GetNumberOfDataSlots() {
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes) {
+ const int64_t kMemoryReducerActivationLimit = 1024 * 1024;
typedef internal::Internals I;
int64_t* external_memory = reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
const int64_t external_memory_limit = *reinterpret_cast<int64_t*>(
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
+ int64_t* external_memory_at_last_mc =
+ reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
+ I::kExternalMemoryAtLastMarkCompactOffset);
const int64_t amount = *external_memory + change_in_bytes;
+
*external_memory = amount;
+
+ int64_t allocation_diff_since_last_mc =
+ *external_memory_at_last_mc - *external_memory;
+ allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
+ ? -allocation_diff_since_last_mc
+ : allocation_diff_since_last_mc;
+ if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
+ CheckMemoryPressure();
+ }
+
if (change_in_bytes > 0 && amount > external_memory_limit) {
ReportExternalAllocationLimitReached();
}
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698