Add a bunch of symbols required by Kotlin runtime part (#4655)

This commit is contained in:
Alexander Shabalin
2021-01-29 10:50:25 +03:00
committed by Vasily Levchenko
parent 51f70254f7
commit e2280ce855
4 changed files with 115 additions and 2 deletions
@@ -220,6 +220,7 @@ void SetHeapRefLocked(ObjHeader** location, ObjHeader* newValue, int32_t* spinlo
int32_t* cookie) RUNTIME_NOTHROW;
// Reads reference with taken lock.
OBJ_GETTER(ReadHeapRefLocked, ObjHeader** location, int32_t* spinlock, int32_t* cookie) RUNTIME_NOTHROW;
OBJ_GETTER(ReadHeapRefNoLock, ObjHeader* object, int32_t index);
// Called on frame enter, if it has object slots.
void EnterFrame(ObjHeader** start, int parameters, int count) RUNTIME_NOTHROW;
// Called on frame leave, if it has object slots.
@@ -257,7 +258,27 @@ void GC_RegisterWorker(void* worker) RUNTIME_NOTHROW;
void GC_UnregisterWorker(void* worker) RUNTIME_NOTHROW;
void GC_CollectorCallback(void* worker) RUNTIME_NOTHROW;
void Kotlin_native_internal_GC_collect(ObjHeader*);
void Kotlin_native_internal_GC_collectCyclic(ObjHeader*);
void Kotlin_native_internal_GC_suspend(ObjHeader*);
void Kotlin_native_internal_GC_resume(ObjHeader*);
void Kotlin_native_internal_GC_stop(ObjHeader*);
void Kotlin_native_internal_GC_start(ObjHeader*);
void Kotlin_native_internal_GC_setThreshold(ObjHeader*, int32_t value);
int32_t Kotlin_native_internal_GC_getThreshold(ObjHeader*);
void Kotlin_native_internal_GC_setCollectCyclesThreshold(ObjHeader*, int64_t value);
int64_t Kotlin_native_internal_GC_getCollectCyclesThreshold(ObjHeader*);
void Kotlin_native_internal_GC_setThresholdAllocations(ObjHeader*, int64_t value);
int64_t Kotlin_native_internal_GC_getThresholdAllocations(ObjHeader*);
void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, int32_t value);
bool Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*);
OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*);
OBJ_GETTER(Kotlin_native_internal_GC_findCycle, ObjHeader*, ObjHeader* root);
bool Kotlin_native_internal_GC_getCyclicCollector(ObjHeader* gc);
void Kotlin_native_internal_GC_setCyclicCollector(ObjHeader* gc, bool value);
bool Kotlin_Any_isShareable(ObjHeader* thiz);
void Kotlin_Any_share(ObjHeader* thiz);
void PerformFullGC(MemoryState* memory) RUNTIME_NOTHROW;
bool TryAddHeapRef(const ObjHeader* object);
@@ -31,7 +31,11 @@ public class MutableData constructor(capacity: Int = 16) {
private var buffer_ = ByteArray(capacity).apply { share() }
private var buffer: ByteArray
get() = readHeapRefNoLock(this, 0) as ByteArray
get() =
when (kotlin.native.Platform.memoryModel) {
kotlin.native.MemoryModel.EXPERIMENTAL -> buffer_
else -> readHeapRefNoLock(this, 0) as ByteArray
}
set(value) { buffer_ = value}
private var size_ = 0
private val lock = Lock()
@@ -130,4 +134,4 @@ public class MutableData constructor(capacity: Int = 16) {
public fun <R> withBufferLocked(block: (array: ByteArray, dataSize: Int) -> R) = locked(lock) {
block(buffer, size)
}
}
}
@@ -142,6 +142,11 @@ extern "C" RUNTIME_NOTHROW void InitAndRegisterGlobal(ObjHeader** location, cons
extern "C" const MemoryModel CurrentMemoryModel = MemoryModel::kExperimental;
extern "C" OBJ_GETTER(ReadHeapRefNoLock, ObjHeader* object, int32_t index) {
// TODO: Remove when legacy MM is gone.
ThrowNotImplementedError();
}
extern "C" RUNTIME_NOTHROW void EnterFrame(ObjHeader** start, int parameters, int count) {
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
threadData->shadowStack().EnterFrame(start, parameters, count);
@@ -183,11 +188,42 @@ extern "C" RUNTIME_NOTHROW void GC_CollectorCallback(void* worker) {
// Nothing to do
}
extern "C" void Kotlin_native_internal_GC_collectCyclic(ObjHeader*) {
// TODO: Remove when legacy MM is gone.
ThrowIllegalArgumentException();
}
extern "C" OBJ_GETTER(Kotlin_native_internal_GC_detectCycles, ObjHeader*) {
// TODO: Remove when legacy MM is gone.
RETURN_OBJ(nullptr);
}
extern "C" OBJ_GETTER(Kotlin_native_internal_GC_findCycle, ObjHeader*, ObjHeader* root) {
// TODO: Remove when legacy MM is gone.
RETURN_OBJ(nullptr);
}
extern "C" bool Kotlin_native_internal_GC_getCyclicCollector(ObjHeader* gc) {
// TODO: Remove when legacy MM is gone.
return false;
}
extern "C" void Kotlin_native_internal_GC_setCyclicCollector(ObjHeader* gc, bool value) {
// TODO: Remove when legacy MM is gone.
if (value)
ThrowIllegalArgumentException();
}
extern "C" bool Kotlin_Any_isShareable(ObjHeader* thiz) {
// TODO: Remove when legacy MM is gone.
return true;
}
extern "C" void Kotlin_Any_share(ObjHeader* thiz) {
// TODO: Remove when legacy MM is gone.
// Nothing to do
}
extern "C" RUNTIME_NOTHROW bool ClearSubgraphReferences(ObjHeader* root, bool checked) {
// TODO: Remove when legacy MM is gone.
return true;
@@ -82,6 +82,58 @@ void EnsureNeverFrozen(ObjHeader* obj) {
TODO();
}
void Kotlin_native_internal_GC_collect(ObjHeader*) {
TODO();
}
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_setThreshold(ObjHeader*, int32_t value) {
TODO();
}
int32_t Kotlin_native_internal_GC_getThreshold(ObjHeader*) {
TODO();
}
void Kotlin_native_internal_GC_setCollectCyclesThreshold(ObjHeader*, int64_t value) {
TODO();
}
int64_t Kotlin_native_internal_GC_getCollectCyclesThreshold(ObjHeader*) {
TODO();
}
void Kotlin_native_internal_GC_setThresholdAllocations(ObjHeader*, int64_t value) {
TODO();
}
int64_t Kotlin_native_internal_GC_getThresholdAllocations(ObjHeader*) {
TODO();
}
void Kotlin_native_internal_GC_setTuneThreshold(ObjHeader*, int32_t value) {
TODO();
}
bool Kotlin_native_internal_GC_getTuneThreshold(ObjHeader*) {
TODO();
}
RUNTIME_NOTHROW void PerformFullGC(MemoryState* memory) {
TODO();
}