Implement a bit more of GC object interface
This commit is contained in:
committed by
Space
parent
a3105da32e
commit
94076300ec
@@ -47,9 +47,13 @@ public:
|
|||||||
void SetAllocationThresholdBytes(size_t value) noexcept { allocationThresholdBytes_ = value; }
|
void SetAllocationThresholdBytes(size_t value) noexcept { allocationThresholdBytes_ = value; }
|
||||||
size_t GetAllocationThresholdBytes() noexcept { return allocationThresholdBytes_; }
|
size_t GetAllocationThresholdBytes() noexcept { return allocationThresholdBytes_; }
|
||||||
|
|
||||||
|
void SetAutoTune(bool value) noexcept { autoTune_ = value; }
|
||||||
|
bool GetAutoTune() noexcept { return autoTune_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t threshold_ = 0;
|
size_t threshold_ = 0;
|
||||||
size_t allocationThresholdBytes_ = 0;
|
size_t allocationThresholdBytes_ = 0;
|
||||||
|
bool autoTune_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gc
|
} // namespace gc
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ public:
|
|||||||
void SetAllocationThresholdBytes(size_t value) noexcept { allocationThresholdBytes_ = value; }
|
void SetAllocationThresholdBytes(size_t value) noexcept { allocationThresholdBytes_ = value; }
|
||||||
size_t GetAllocationThresholdBytes() noexcept { return allocationThresholdBytes_; }
|
size_t GetAllocationThresholdBytes() noexcept { return allocationThresholdBytes_; }
|
||||||
|
|
||||||
|
void SetAutoTune(bool value) noexcept { autoTune_ = value; }
|
||||||
|
bool GetAutoTune() noexcept { return autoTune_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PerformFullGC() noexcept;
|
void PerformFullGC() noexcept;
|
||||||
|
|
||||||
@@ -70,6 +73,7 @@ private:
|
|||||||
|
|
||||||
size_t threshold_ = 1000;
|
size_t threshold_ = 1000;
|
||||||
size_t allocationThresholdBytes_ = 10000;
|
size_t allocationThresholdBytes_ = 10000;
|
||||||
|
bool autoTune_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gc
|
} // namespace gc
|
||||||
|
|||||||
@@ -3537,7 +3537,7 @@ KLong Kotlin_native_internal_GC_getThresholdAllocations(KRef) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_setTuneThreshold(KRef, KInt value) {
|
void Kotlin_native_internal_GC_setTuneThreshold(KRef, KBoolean value) {
|
||||||
#if USE_GC
|
#if USE_GC
|
||||||
setTuneGCThreshold(value);
|
setTuneGCThreshold(value);
|
||||||
#endif
|
#endif
|
||||||
@@ -3736,4 +3736,4 @@ MemoryState* kotlin::mm::GetMemoryState() {
|
|||||||
kotlin::ThreadState kotlin::GetThreadState(MemoryState* thread) noexcept {
|
kotlin::ThreadState kotlin::GetThreadState(MemoryState* thread) noexcept {
|
||||||
// Assume that we are always in the Runnable thread state.
|
// Assume that we are always in the Runnable thread state.
|
||||||
return ThreadState::kRunnable;
|
return ThreadState::kRunnable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ void Kotlin_native_internal_GC_setCollectCyclesThreshold(ObjHeader*, int64_t val
|
|||||||
int64_t Kotlin_native_internal_GC_getCollectCyclesThreshold(ObjHeader*);
|
int64_t Kotlin_native_internal_GC_getCollectCyclesThreshold(ObjHeader*);
|
||||||
void Kotlin_native_internal_GC_setThresholdAllocations(ObjHeader*, int64_t value);
|
void Kotlin_native_internal_GC_setThresholdAllocations(ObjHeader*, int64_t value);
|
||||||
int64_t Kotlin_native_internal_GC_getThresholdAllocations(ObjHeader*);
|
int64_t Kotlin_native_internal_GC_getThresholdAllocations(ObjHeader*);
|
||||||
void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, int32_t value);
|
void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, bool value);
|
||||||
bool Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*);
|
bool Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*);
|
||||||
OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*);
|
OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*);
|
||||||
OBJ_GETTER(Kotlin_native_internal_GC_findCycle, ObjHeader*, ObjHeader* root);
|
OBJ_GETTER(Kotlin_native_internal_GC_findCycle, ObjHeader*, ObjHeader* root);
|
||||||
|
|||||||
@@ -264,6 +264,25 @@ extern "C" void Kotlin_native_internal_GC_collectCyclic(ObjHeader*) {
|
|||||||
ThrowIllegalArgumentException();
|
ThrowIllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Maybe a pair of suspend/resume or start/stop may be useful in the future?
|
||||||
|
// The other pair is likely to be removed.
|
||||||
|
|
||||||
|
extern "C" void Kotlin_native_internal_GC_suspend(ObjHeader*) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void Kotlin_native_internal_GC_resume(ObjHeader*) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void Kotlin_native_internal_GC_stop(ObjHeader*) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void Kotlin_native_internal_GC_start(ObjHeader*) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void Kotlin_native_internal_GC_setThreshold(ObjHeader*, int32_t value) {
|
extern "C" void Kotlin_native_internal_GC_setThreshold(ObjHeader*, int32_t value) {
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
ThrowIllegalArgumentException();
|
ThrowIllegalArgumentException();
|
||||||
@@ -306,6 +325,14 @@ extern "C" int64_t Kotlin_native_internal_GC_getThresholdAllocations(ObjHeader*)
|
|||||||
return static_cast<int64_t>(maxValue);
|
return static_cast<int64_t>(maxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, KBoolean value) {
|
||||||
|
mm::GlobalData::Instance().gc().SetAutoTune(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" KBoolean Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*) {
|
||||||
|
return mm::GlobalData::Instance().gc().GetAutoTune();
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*) {
|
extern "C" OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*) {
|
||||||
// TODO: Remove when legacy MM is gone.
|
// TODO: Remove when legacy MM is gone.
|
||||||
RETURN_OBJ(nullptr);
|
RETURN_OBJ(nullptr);
|
||||||
|
|||||||
@@ -9,30 +9,6 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_suspend(ObjHeader*) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_resume(ObjHeader*) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_stop(ObjHeader*) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_start(ObjHeader*) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, int32_t value) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*) {
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TryAddHeapRef(const ObjHeader* object) {
|
bool TryAddHeapRef(const ObjHeader* object) {
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user