-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static memory snapshot: add support for Unsafe, VarHandle, AFU, kotlinx.atomicfu #429
base: develop
Are you sure you want to change the base?
Conversation
src/jvm/main/org/jetbrains/kotlinx/lincheck/strategy/managed/ManagedStrategy.kt
Outdated
Show resolved
Hide resolved
881a74a
to
fb813ab
Compare
Please note that you don't need to have special support for atomicfu -- it compiles to either AFU or VarHandle |
…ity methods of Arrays and Collections classes
d95fd4d
to
2fd1a05
Compare
@@ -25,6 +25,57 @@ import java.util.* | |||
import kotlin.coroutines.* | |||
import kotlin.coroutines.intrinsics.* | |||
|
|||
fun shouldTransformClass(className: String): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the code was moved from somewhere, but I do not see it removed in the original location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would suggest keeping the transformation-related logic in the corresponding package.
@@ -37,11 +37,22 @@ internal object AtomicFieldUpdaterNames { | |||
val offsetField = updater.javaClass.getDeclaredField("offset") | |||
val offset = UNSAFE.getLong(updater, UNSAFE.objectFieldOffset(offsetField)) | |||
|
|||
return findFieldNameByOffsetViaUnsafe(targetType, offset) | |||
return findFieldNameByOffsetViaUnsafe(targetType, offset).let { fieldName -> | |||
if (fieldName != null) AtomicFieldUpdaterDescriptor(targetType, fieldName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please always add { .. }
when the else
branch is present.
|
||
runInIgnoredSection { | ||
// process method effect on the static memory snapshot | ||
processMethodEffectOnStaticSnapshot(owner, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the name of the method or what it does?
This method checks what kind of function was called (Unsafe API, VarHandle API, Java AFU) and updates static snapshot accordingly
Partly resolves issue #389.
This PR is aimed to add support for lazy tracking fields, that are accessed via:
System.arraycopy
- right now some tests fail for this functionality. I have an assumption that this could be caused by jit compilation, when the same test (same scenario basically) succeeds forN
iterations and fails onN+1
th. I am investigating into that. Support for this call will be done via separate PR.kotlinx.atomicfu