[KT-42275] Eliminate recursive GC calls (#4412)

This commit is contained in:
LepilkinaElena
2020-09-30 19:23:27 +03:00
committed by GitHub
parent 9c4831ee45
commit ccb6927e05
+3 -2
View File
@@ -2115,7 +2115,7 @@ void updateHeapRefIfNull(ObjHeader** location, const ObjHeader* object) {
}
inline void checkIfGcNeeded(MemoryState* state) {
if (state != nullptr && state->allocSinceLastGc > state->allocSinceLastGcThreshold) {
if (state != nullptr && state->allocSinceLastGc > state->allocSinceLastGcThreshold && state->gcSuspendCount == 0) {
// To avoid GC trashing check that at least 10ms passed since last GC.
if (konan::getTimeMicros() - state->lastGcTimestamp > 10 * 1000) {
GC_LOG("Calling GC from checkIfGcNeeded: %d\n", state->toRelease->size())
@@ -2125,7 +2125,8 @@ inline void checkIfGcNeeded(MemoryState* state) {
}
inline void checkIfForceCyclicGcNeeded(MemoryState* state) {
if (state != nullptr && state->toFree != nullptr && state->toFree->size() > kMaxToFreeSizeThreshold) {
if (state != nullptr && state->toFree != nullptr && state->toFree->size() > kMaxToFreeSizeThreshold
&& state->gcSuspendCount == 0) {
// To avoid GC trashing check that at least 10ms passed since last GC.
if (konan::getTimeMicros() - state->lastGcTimestamp > 10 * 1000) {
GC_LOG("Calling GC from checkIfForceCyclicGcNeeded: %d\n", state->toFree->size())