@@ -8879,6 +8879,40 @@ void Isolate::GetStackSample(const RegisterState& state, void** frames,
88798879 sample_info->external_callback_entry = nullptr ;
88808880}
88818881
8882+ int64_t Isolate::AdjustAmountOfExternalAllocatedMemoryCustom (
8883+ int64_t change_in_bytes) {
8884+ const int64_t kMemoryReducerActivationLimit = 1024 * 1024 ;
8885+ typedef internal::Internals I;
8886+ int64_t * external_memory = reinterpret_cast <int64_t *>(
8887+ reinterpret_cast <uint8_t *>(this ) + I::kExternalMemoryOffset );
8888+ int64_t * external_memory_limit = reinterpret_cast <int64_t *>(
8889+ reinterpret_cast <uint8_t *>(this ) + I::kExternalMemoryLimitOffset );
8890+ int64_t * external_memory_at_last_mc =
8891+ reinterpret_cast <int64_t *>(reinterpret_cast <uint8_t *>(this ) +
8892+ I::kExternalMemoryAtLastMarkCompactOffset );
8893+ const int64_t amount = *external_memory + change_in_bytes;
8894+
8895+ *external_memory = amount;
8896+
8897+ int64_t allocation_diff_since_last_mc =
8898+ *external_memory_at_last_mc - *external_memory;
8899+ allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
8900+ ? -allocation_diff_since_last_mc
8901+ : allocation_diff_since_last_mc;
8902+ if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit ) {
8903+ CheckMemoryPressure ();
8904+ }
8905+
8906+ if (change_in_bytes < 0 ) {
8907+ *external_memory_limit += change_in_bytes;
8908+ }
8909+
8910+ if (change_in_bytes > 0 && amount > *external_memory_limit) {
8911+ ReportExternalAllocationLimitReached ();
8912+ }
8913+ return *external_memory;
8914+ }
8915+
88828916size_t Isolate::NumberOfPhantomHandleResetsSinceLastCall () {
88838917 i::Isolate* isolate = reinterpret_cast <i::Isolate*>(this );
88848918 size_t result = isolate->global_handles ()->NumberOfPhantomHandleResets ();
0 commit comments