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

Unified Diff: include/v8.h

Issue 2085893002: [heap] Internalize kExternalAllocationLimit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Initialize limit Created 4 years, 6 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/extensions/statistics-extension.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 20583c852ca83d686b31099cc562359d99714289..86db38799b103fc9b61fa9b7bbd993a6bd71186f 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -7493,13 +7493,12 @@ class Internals {
static const int kExternalOneByteRepresentationTag = 0x06;
static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize;
- static const int kAmountOfExternalAllocatedMemoryOffset =
- 4 * kApiPointerSize;
- static const int kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset =
- kAmountOfExternalAllocatedMemoryOffset + kApiInt64Size;
- static const int kIsolateRootsOffset =
- kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset + kApiInt64Size +
- kApiPointerSize + kApiPointerSize;
+ static const int kExternalMemoryOffset = 4 * kApiPointerSize;
+ static const int kExternalMemoryLimitOffset =
+ kExternalMemoryOffset + kApiInt64Size;
+ static const int kIsolateRootsOffset = kExternalMemoryLimitOffset +
+ kApiInt64Size + kApiInt64Size +
+ kApiPointerSize + kApiPointerSize;
static const int kUndefinedValueRootIndex = 4;
static const int kTheHoleValueRootIndex = 5;
static const int kNullValueRootIndex = 6;
@@ -7507,10 +7506,6 @@ class Internals {
static const int kFalseValueRootIndex = 8;
static const int kEmptyStringRootIndex = 9;
- // The external allocation limit should be below 256 MB on all architectures
- // to avoid that resource-constrained embedders run low on memory.
- static const int kExternalAllocationLimit = 192 * 1024 * 1024;
-
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
static const int kNodeStateMask = 0x7;
@@ -8705,21 +8700,16 @@ uint32_t Isolate::GetNumberOfDataSlots() {
int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t change_in_bytes) {
typedef internal::Internals I;
- int64_t* amount_of_external_allocated_memory =
- reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
- I::kAmountOfExternalAllocatedMemoryOffset);
- int64_t* amount_of_external_allocated_memory_at_last_global_gc =
- reinterpret_cast<int64_t*>(
- reinterpret_cast<uint8_t*>(this) +
- I::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset);
- int64_t amount = *amount_of_external_allocated_memory + change_in_bytes;
- if (change_in_bytes > 0 &&
- amount - *amount_of_external_allocated_memory_at_last_global_gc >
- I::kExternalAllocationLimit) {
+ 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);
+ const int64_t amount = *external_memory + change_in_bytes;
+ *external_memory = amount;
+ if (change_in_bytes > 0 && amount > external_memory_limit) {
ReportExternalAllocationLimitReached();
}
- *amount_of_external_allocated_memory = amount;
- return *amount_of_external_allocated_memory;
+ return *external_memory;
}
« no previous file with comments | « no previous file | src/extensions/statistics-extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698