[+] v8::DisableHeapGC

[+] v8::EnableHeapGC
(high level heap gc request filters, not safepoint assertions)

Last aurora commit: 65aae12e
*amended to include commit link*
This commit is contained in:
Reece Wilson 2023-03-25 23:49:14 +00:00
parent 65aae12e09
commit e9f848d445
3 changed files with 31 additions and 0 deletions

View File

@ -1164,6 +1164,16 @@ V8_EXPORT void SafepointUnparkIsolate(v8::Isolate* pIsolate) {
reinterpret_cast<i::Isolate*>(pIsolate)->heap()->safepoint()->NotifyUnpark(); reinterpret_cast<i::Isolate*>(pIsolate)->heap()->safepoint()->NotifyUnpark();
} }
// Reece:
V8_EXPORT void DisableHeapGC(v8::Isolate* pIsolate) {
reinterpret_cast<i::Isolate*>(pIsolate)->heap()->is_forcing_no_gc = true;
}
// Reece:
V8_EXPORT void EnableHeapGC(v8::Isolate* pIsolate) {
reinterpret_cast<i::Isolate*>(pIsolate)->heap()->is_forcing_no_gc = false;
}
void Context::Enter() { void Context::Enter() {
i::DisallowGarbageCollection no_gc; i::DisallowGarbageCollection no_gc;
i::Context env = *Utils::OpenHandle(this); i::Context env = *Utils::OpenHandle(this);

View File

@ -1652,6 +1652,22 @@ void Heap::CollectGarbage(AllocationSpace space,
FatalProcessOutOfMemory("GC during deserialization"); FatalProcessOutOfMemory("GC during deserialization");
} }
if (V8_UNLIKELY(is_forcing_no_gc)) {
if (!(((int)gc_callback_flags &
((int)v8::GCCallbackFlags::kGCCallbackFlagForced) |
0))) {
if (gc_reason != GarbageCollectionReason::kLastResort &&
gc_reason != GarbageCollectionReason::kFinalizeMarkingViaTask &&
gc_reason != GarbageCollectionReason::kFinalizeMarkingViaStackGuard &&
gc_reason != GarbageCollectionReason::kFinalizeMinorMC &&
gc_reason != GarbageCollectionReason::kExternalFinalize &&
gc_reason != GarbageCollectionReason::kAllocationFailure &&
gc_reason != GarbageCollectionReason::kAllocationLimit) {
return;
}
}
}
// CollectGarbage consists of three parts: // CollectGarbage consists of three parts:
// 1. The prologue part which may execute callbacks. These callbacks may // 1. The prologue part which may execute callbacks. These callbacks may
// allocate and trigger another garbage collection. // allocate and trigger another garbage collection.

View File

@ -2413,6 +2413,11 @@ class Heap {
// This field is used only when not running with MinorMC. // This field is used only when not running with MinorMC.
ResizeNewSpaceMode resize_new_space_mode_ = ResizeNewSpaceMode::kNone; ResizeNewSpaceMode resize_new_space_mode_ = ResizeNewSpaceMode::kNone;
// Reece: (another hack)
public:
bool is_forcing_no_gc = false;
private:
// Classes in "heap" can be friends. // Classes in "heap" can be friends.
friend class AlwaysAllocateScope; friend class AlwaysAllocateScope;
friend class ArrayBufferCollector; friend class ArrayBufferCollector;