MPSCR-14: Correctly trace incrementally reactivated occurrences. Fixes the bug.

This commit is contained in:
Grigorii Kirgizov 2019-11-07 15:38:32 +03:00
parent ea309d05e7
commit f80371e148
2 changed files with 21 additions and 10 deletions

View File

@ -45,6 +45,8 @@ internal class ControllerImpl (
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V>? = null
})
traceActivated(occ)
val status = state.processActivated(this, active, NORMAL())
if (status is FAILED) {
throw status.failure.failureCause()
@ -91,8 +93,13 @@ internal class ControllerImpl (
solver.tell(invocation)
}
override fun reactivate(occ: Occurrence): FeedbackStatus =
state.processActivated(this, occ, NORMAL())
override fun reactivate(occ: Occurrence): FeedbackStatus {
// fixme: leave one of these, ensure impl is present on both reactor & mps levels
trace.activate(occ)
trace.reactivateIncremental(occ)
return state.processActivated(this, occ, NORMAL())
}
override fun offerMatch(match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus =
profiler.profile<FeedbackStatus>("offerMatch") {
@ -212,10 +219,20 @@ internal class ControllerImpl (
val args = supervisor.instantiateArguments(constraint.arguments(), context.logicalContext, context)
return context.eval { status ->
state.processActivated(this, constraint.occurrence(this, args, justsCopy(justs), context.logicalContext, context.ruleUniqueTag), status)
constraint.occurrence(this, args, justsCopy(justs), context.logicalContext, context.ruleUniqueTag).let { occ ->
traceActivated(occ)
state.processActivated(this, occ, status)
}
}
}
private fun traceActivated(occ: Occurrence) =
if (!occ.stored)
trace.activate(occ)
else
trace.reactivate(occ)
private fun askPredicate(predicate: Predicate, context: Context) : Boolean =
profiler.profile<Boolean>("ask_${predicate.symbol()}") {

View File

@ -65,7 +65,7 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp
// processed as with reactivation through observers.
// Incremental reactivation should proceed more like usual activation.
this.dispatchingFront = dispatchingFront.forgetExpanded(activeOcc)
trace.reactivateIncremental(activeOcc)
return controller.reactivate(activeOcc)
}
@ -216,16 +216,10 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp
if (!active.stored) {
active.stored = true
trace.activate(active)
logActivation(active)
active.revive(controller)
} else {
trace.reactivate(active)
}
profiler.profile("dispatch_${active.constraint().symbol()}") {
this.dispatchingFront = dispatchingFront.expand(active)