Skip to content
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

Better Bitwuzla solver support #71

Merged
merged 72 commits into from
Feb 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2a26cd9
Fp 16 fixes && eval for fp.add
Saloed Jan 25, 2023
f348bea
Fix fp 16
Saloed Jan 27, 2023
878ba3e
KAst structural equality methods
Saloed Jan 17, 2023
28708b9
tmp
Saloed Jan 17, 2023
642d517
KInternedObject
Saloed Jan 18, 2023
1961d8a
Optimizations
Saloed Jan 18, 2023
e328f36
ConcurrentWeakHashMap
Saloed Jan 18, 2023
84806be
Ast interner
Saloed Jan 18, 2023
88cd4eb
remove caffeine
Saloed Jan 18, 2023
d5d3120
Faster cache
Saloed Jan 19, 2023
e39833f
Parametrize ast management modes
Saloed Jan 19, 2023
4c093d9
Single thread weak caches
Saloed Jan 19, 2023
d472ffd
Bv compare
Saloed Jan 31, 2023
80c6f7e
Fix after rebase
Saloed Feb 2, 2023
2517bd8
Comment empty arith add simplified args
Saloed Feb 17, 2023
e723c10
JNA to JNI migration (#69)
DKARAGODIN Feb 6, 2023
3f6d231
Initial native part fix
Saloed Feb 6, 2023
69d26f4
Timeouts
Saloed Feb 6, 2023
006b789
check exception handling
Saloed Feb 7, 2023
f9d5c18
better timeout handling
Saloed Feb 7, 2023
b66c9d4
enable ipo
Saloed Feb 7, 2023
0b29768
Fix default array value handling
Saloed Feb 7, 2023
f54375d
Jni bindings
Saloed Feb 7, 2023
8ee97cc
Fix Native documentation
Saloed Feb 7, 2023
fbd04c3
Enum wrappers
Saloed Feb 7, 2023
4d68757
Cleanup
Saloed Feb 7, 2023
825f3fc
Remove dummy test
Saloed Feb 7, 2023
7361b30
Fix timeout test
Saloed Feb 7, 2023
be4759d
Fix detekt issues
Saloed Feb 7, 2023
bc30f08
Rework unsupported theories for Bitwuzla
Saloed Feb 7, 2023
8ffea7a
Support quantifiers in bitwuzla
Saloed Feb 7, 2023
34f93d2
Fix nested quantifiers conversion
Saloed Feb 7, 2023
8f2c173
Small fixes
Saloed Feb 7, 2023
e0240c1
Better Bitwuzla bv bits api
Saloed Feb 7, 2023
f068d93
New API based converter
Saloed Feb 7, 2023
8c0550d
New API based internalizer
Saloed Feb 7, 2023
df32c30
Update docs
Saloed Feb 7, 2023
8ed1ea2
axioms
Saloed Feb 7, 2023
304feae
Minor
Saloed Feb 8, 2023
8979662
fix bigInt to bits
Saloed Feb 8, 2023
c844f24
fix bigInt to bits
Saloed Feb 8, 2023
bba6a02
Fix fp64 conversion
Saloed Feb 8, 2023
1dc5633
Use KSMT based model evaluation
Saloed Feb 8, 2023
9a5671c
Better model evaluator for partial functions
Saloed Feb 8, 2023
aede677
Fix bv bit utils
Saloed Feb 8, 2023
96cf82b
Better handling of as-array expressions in model evaluator
Saloed Feb 8, 2023
8fbcedf
Fix bit utils
Saloed Feb 8, 2023
1ce7211
Better doc for bits
Saloed Feb 8, 2023
affaf0b
m
Saloed Feb 8, 2023
e8d5c0e
Fix as-array rewrite loops
Saloed Feb 8, 2023
67708ba
Special test data-source for Bitwuzla model conversion
Saloed Feb 8, 2023
f04efda
Fix detekt issues
Saloed Feb 8, 2023
103267f
Ensure bitwuzla ctx is active
Saloed Feb 8, 2023
825dc43
Rebase
Saloed Feb 10, 2023
5aa72de
Skip Z3 fma failures
Saloed Feb 10, 2023
ebec86d
Skip fp max/min with +/- 0
Saloed Feb 10, 2023
a39692e
Fix Z3 fma test issues
Saloed Feb 10, 2023
fc2a859
minor change
Saloed Feb 10, 2023
0118ddc
fix vars management
Saloed Feb 10, 2023
3637e72
Move comment
Saloed Feb 13, 2023
ec7a9dd
Use unsat assumptions instead of core
Saloed Feb 13, 2023
82f0e34
Support for uninterpreted sorts
Saloed Feb 13, 2023
8b2e66e
Rework declaration scoping
Saloed Feb 13, 2023
525574c
Better tests parametrization
Saloed Feb 13, 2023
2854d7d
Fix model detach
Saloed Feb 13, 2023
14f5976
Fix detekt issues
Saloed Feb 13, 2023
a855f76
Minor fix
Saloed Feb 14, 2023
284eda3
Use adapter for uninterpreted sort conversion
Saloed Feb 14, 2023
c83e78f
rebase
Saloed Feb 14, 2023
3597679
Fix pointer formatting
Saloed Feb 17, 2023
e8c95dc
Fixes
Saloed Feb 17, 2023
e73a487
Rebase
Saloed Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Faster cache
  • Loading branch information
Saloed committed Feb 17, 2023
commit d5d3120d1bb88ec021faff5f0cebeaf451f34260
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
private val keyReferenceQueue = ReferenceQueue<K>()
private val cleanupLock = ReentrantLock()
private val cleanupStatus = AtomicInteger(IDLE)
private val modificationsSinceLastCleanup = AtomicInteger(0)
private var removeHandler: CacheRemoveHandler<K, V>? = null

abstract fun lookupKey(key: K): Any
Expand All @@ -26,35 +27,22 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {

fun getKey(): K? = keyReference.get()


abstract fun getValue(): V
abstract fun setValue(value: V)

fun isAlive(): Boolean {
val keyRef = keyReference
return keyRef !== deadRef && keyRef !== retiredRef
}
fun isAlive(): Boolean = keyReference !== deadRef

fun isDead(): Boolean = keyReference === deadRef

fun retire() {
val keyRef = keyReference
keyReference = deadRef
keyRef.clear()
}

fun die() {
val keyRef = keyReference
keyReference = retiredRef
keyReference = deadRef
keyRef.clear()
}

companion object {
@JvmStatic
private val deadRef: Reference<Nothing> = WeakReference(null)

@JvmStatic
private val retiredRef: Reference<Nothing> = WeakReference(null)
}
}

Expand Down Expand Up @@ -158,7 +146,7 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
if (currentKey != null) return currentKey

// Previously interned object was removed. Try cleanup and retry interning
afterWrite()
scheduleCleanup()
}

} else {
Expand All @@ -167,7 +155,7 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
if (currentKey != null) return currentKey

// Previously interned object was removed. Try cleanup and retry interning
afterWrite()
scheduleCleanup()
}
}
}
Expand All @@ -184,35 +172,49 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
}

private fun afterRead() {
runCleanupIfRequired()
}

private fun afterWrite() {
if (modificationsSinceLastCleanup.incrementAndGet() >= MODIFICATIONS_TO_CLEANUP) {
modificationsSinceLastCleanup.set(0)
scheduleCleanup()
} else {
runCleanupIfRequired()
}
}

private fun runCleanupIfRequired() {
if (cleanupStatus.get() == REQUIRED) {
runCleanup()
}
}

private fun afterWrite() {
var status = cleanupStatus.get()
private fun scheduleCleanup() {
while (true) {
when (status) {
when (cleanupStatus.get()) {
// No ongoing cleanup -> schedule and run
IDLE -> {
cleanupStatus.compareAndSet(IDLE, REQUIRED)
runCleanup()
return
}

// No ongoing cleanup and cleanup is already scheduled -> run
REQUIRED -> {
runCleanup()
return
}

// Cleanup is running. Try to reschedule cleanup after completion.
PROCESSING_TO_IDLE -> {
if (cleanupStatus.compareAndSet(PROCESSING_TO_IDLE, PROCESSING_TO_REQUIRED)) {
return
}
status = cleanupStatus.get()
continue
// Cleanup status changed. Retry
}
// Cleanup is running and will be rescheduled right after completion.
PROCESSING_TO_REQUIRED -> {
return
}

PROCESSING_TO_REQUIRED -> return
}
}
}
Expand All @@ -237,7 +239,6 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
}
}


private fun cleanup() {
cleanupStatus.set(PROCESSING_TO_IDLE)
try {
Expand Down Expand Up @@ -266,48 +267,54 @@ abstract class ConcurrentWeakHashMapCache<K : Any, V : Any> {
var removed = false

data.computeIfPresent(keyRef) { _, newNode ->
// We have a new node associated with the key. Our node was already removed.
if (newNode != node) return@computeIfPresent newNode

synchronized(newNode) {
// Key is reachable for some reason. Don't remove node
if (key != null) {
nodeResurrected = true
return@computeIfPresent newNode
}

// Mark node as removed
node.die()
removed = true
node.retire()
}

// Remove node from data
null
}

if (nodeResurrected) {
return
}

makeDead(node)
synchronized(node) {
// Mark node as removed
if (!node.isDead()) {
node.die()
}
}

if (removed) {
notifyRemove(key, node.getValue())
}
}

private fun makeDead(node: KeyRefNode<K, V>) = synchronized(node) {
if (node.isDead()) return
node.die()
}

companion object {
/** A cleanup is not taking place. */
private const val MODIFICATIONS_TO_CLEANUP = 16

//A cleanup is not taking place.
private const val IDLE = 0

/** A cleanup is required due to write modification. */
// A cleanup is required due to write modification.
private const val REQUIRED = 1

/** A cleanup is in progress and will transition to idle. */
// A cleanup is in progress and will transition to idle.
private const val PROCESSING_TO_IDLE = 2

/** A cleanup is in progress and will transition to required. */
// A cleanup is in progress and will transition to required.
private const val PROCESSING_TO_REQUIRED = 3
}
}