[codegen] added konan.internal.NoReorderFields to disable field reordering
This commit is contained in:
+3
@@ -135,6 +135,9 @@ private fun Context.getDeclaredFields(classDescriptor: ClassDescriptor): List<Ir
|
||||
// TODO: hack over missed parents in deserialized fields/property declarations.
|
||||
fields.forEach{it.parent = irClass}
|
||||
|
||||
if (classDescriptor.hasAnnotation(FqName.fromSegments(listOf("konan", "internal", "NoReorderFields"))))
|
||||
return fields
|
||||
|
||||
return fields.sortedBy {
|
||||
it.fqNameSafe.localHash.value
|
||||
}
|
||||
|
||||
@@ -65,3 +65,10 @@ annotation class InlineConstructor
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class Frozen
|
||||
|
||||
/**
|
||||
* Fields of annotated class won't be sorted.
|
||||
*/
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class NoReorderFields
|
||||
@@ -18,6 +18,7 @@ package konan.ref
|
||||
|
||||
import kotlinx.cinterop.COpaquePointer
|
||||
import konan.internal.ExportForCppRuntime
|
||||
import konan.internal.NoReorderFields
|
||||
|
||||
/**
|
||||
* Theory of operations:
|
||||
@@ -42,6 +43,7 @@ import konan.internal.ExportForCppRuntime
|
||||
*/
|
||||
|
||||
// Clear holding the counter object, which refers to the actual object.
|
||||
@NoReorderFields
|
||||
internal class WeakReferenceCounter(var referred: COpaquePointer?) : WeakReferenceImpl() {
|
||||
// Spinlock, potentially taken when materializing or removing 'referred' object.
|
||||
var lock: Int = 0
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package konan.worker
|
||||
|
||||
import konan.internal.Frozen
|
||||
import konan.internal.NoReorderFields
|
||||
import konan.SymbolName
|
||||
import kotlinx.cinterop.NativePtr
|
||||
|
||||
@@ -123,6 +124,7 @@ external private fun checkIfFrozen(ref: Any?)
|
||||
* Otherwise memory leak could happen.
|
||||
*/
|
||||
@Frozen
|
||||
@NoReorderFields
|
||||
class AtomicReference<T>(private var value: T? = null) {
|
||||
// A spinlock to fix potential ARC race. Not an AtomicInt just for the effeciency sake.
|
||||
private var lock: Int = 0
|
||||
|
||||
Reference in New Issue
Block a user