This repository contains a javascript-based BP library.
- BPjs is open sourced under the MIT license. If you use it in a system, please provide a link to this page somewhere in the documentation/system about section.
- BPjs uses the Mozilla Rhino Javascript engine. Project page and source code can be found here.
- For Maven projects: Add BPjs as dependency. Note that the version number changes.
<dependencies>
...
<dependency>
<groupId>com.github.bthink-bgu</groupId>
<artifactId>BPjs</artifactId>
<version>0.8.6</version>
</dependency>
...
</dependencies>
- Clone, fork, or download the starting project.
- Download the
.jar
files directly from Maven Central. - The project's Google group
- Presentations: Introduction Deeper dive
- Tutorial and Reference
- API Javadocs
- ⬆️
VisitedStateStore
Adds aclear()
method. - 🐛
DfsBProgramVerifier
instances can now be re-used.
- ⬆️ Improved hashing algorithm on
BThreadStateVisitedNodeStore
. - ✨ Transient caching of thread state in
BThreadSyncSnapshot
s. This improves verification performance, with low memory cost. - 🐛 Removed visited state stores that took incoming state into consideration.
- 🔄 More mazes in the Mazes example.
- 🐛 Fixed a crash where program with failed assertions were intermittently crashing.
- 🐛 Verifier now correctly identifies deadlock as a state where there are requested events, but they are all blocked (formerly it just looked for the existence of b-threads).
- 🐛 ✨ Refactored analysis code, removing the invalid (easy to understand, but invalid)
PathRequirement
based analysis, and using only b-thread now. This design is much cleaner, as it uses less concepts. Also moves us towards "everything is a b-thread" world. - ✨ Added tests to demonstrate the various states a verification can end in.
- 🐛 Verifiers and runners terminate their threadpools when they are done using them.
- ✨ During forward execution, b-threads can halt execution using
bp.ASSERT(boolean, text)
. - ⬆️ Refactored the engine tasks to support raising assertions. Reduced some code duplication in the way.
- ⬆️ Thread pools executing b-threads are now allocated per-executor/verifier (as opposed to using a single static pool).
- ⬆️ Re-arranged package structure, duplicate and ambiguous packages merged. We now have a clean
model
/execution
/analysis
division. - 🐛 Fixed an equality bug in
OrderedSet
.
- 🐛
BSyncStatement
s now retain information about the b-thread that created them. - ⬆️ Now using a single
ExecutorService
for the entire JVM (OK, per class-loader). This makes runtime more efficient, resource-wise. - 🔄 Using cached thread execution pool instead of the fork-join one (the former seems to make more sense in a BP context).
- ⬆️ The Java threads executing the b-threads now have specific names:
bpjs-executor-N
(whereN
is a number starting at 1). - ✨ New method:
bp.getJavaThreadName
: Returns the name of the Java thread executing the b-thread while this method was called. - 🎉 Some changes in this version were requested by actual users. 🎉
- ✨ Documentation updated to mention verification (full-length text to be added post-paper).
- 🐛
BThreadJSProxy.get/setBthread
updated to use capitalT
, like the resp fo the code. - 🔄 Test clean-up
- 🔄 Documentation clean-up
- ✨
BProgram
allows appending and prepending source code programmatically, usingappendSource
andprependSource
. These can be used to add environment simulation without touching the simulated model. Or just to act as includes, e.g. for common set-ups. - ✨ Added new class:
PathRequirements
, to hold path requirements that do not require state (e.g. "no deadlock"). - ✨
DfsBProgramVerifier
now has a "debug mode" (set/get viaget/isDebugMode
). On debug mode, it prints verbose information toSystem.out
. - ✨ Added new class:
BThreadStateVisitedNodeStore
, looks only into the states of the b-threads when deciding whether a search node was already visited or not. - 🐛
InMemoryEventLoggingListener
cleans its event log when a run begins, so it can be reused for multiple runs. - 🔄 Reduced method accessibility in
BProgram
, so subclassers have harder time getting into trouble. - :put_trash_in_its_place:
BProgramListener
renamed toBProgramRunnerListener
, since that is the object it listens to. - :put_trash_in_its_place:
NoDeadlock
class deleted. UsePathRequirements.NO_DEADLOCK
instead. - ✨
PathRequirements.ACCEPT_ALL
, is a new requirement that's always true. Useful for scanning a program state space.
- ⬆️
DfsProgramVerifier
usesFullVisitedNodeStore
by default (preferring correctness over speed in the default case). - ⬆️ Updated the Dining Philosopher example to use advanced features. Also added it as a unit test.
- 🚮 Removed
validation
package. - ✨
ContinuationProgramState
correctly captures updated variable values. 🎉
- ✨ the
DfsBProgramVerifier
is now accepting requirement objects over execution paths, instead of the hard-coded deadlock check. - ✨ new
PathRequirement
class. Requirements are passed to the verifiers for making sure the program conforms to them. Two implementation already present:NoDeadlock
Breakes when there's a deadlockEventNotPresent
Breaks when the last event in the ongoing path is a member of a given event set.
- ✨ the
DfsBProgramVerifier
is now using listener architecture for reporting progress. - ✨ new event set from bp:
bp.allExcept(es)
. - ⬆️ Efficient path stack implementation for
BfsBProgramVerifier
(no copying, reversal, etc.) - ⬆️
Mazes.java
Updates to fully use the new verifier features
- ⬆️ Re-created program state cloning based on code from @szegedi. Cloning is now faster, more efficient, and can handle storage of events.
- ✨ New base class for implementing event selection strategies.
- ✨
OrderedEventSelectionStrategy
- A new event selection strategy that honors the order in which events are requested by a given b-thread. - ✨
PrioritizedBThreadsEventSelectionStrategy
- A new event selection strategy that can assign priorities to b-threads. - ✨
PrioritizedBSyncEventSelectionStrategy
- A new event selection strategy that allows b-threads to add priority to theirbsync
s. - ⬆️
LoggingEventSelectionStrategyDecorator
also logs selectable events - ⬆️
BProgram
acts nicer when it has anull
event selection strategy.
- ✨ Updated to Rhino 1.7.7.2.
- ✨ Initial verification added.
DfsBProgramVerifier
scans the states of aBProgram
using DFS, and can return traces where there are no selectable events.
- ✨ Added a class to compare continuations (base for comparing snapshots).
- ✨
bsync
now has an extra parameter, allowing b-threads to pass hinting data to customEventSelectionStrategy
s. - 🔄 Moved event selection strategy to
BProgram
. - ✨ Added a mechanism to log the
BProgramState
at sync points.
- ✨ Added documentation for embedding BPjs programs in larger Java apps.
- ✨ README includes a more prominent reference to the documentation.
- ✨ Added an adapter class for
BProgramListener
. - 🐛 Fixed issues with adding objects to the program's scope.
- 🚮 Cleaned up the
BProgramRunner
-BProgram
-BProgramSyncSnapshot
trio such that listeners don't have to be passed around between them. - ✨ Cloning of
BProgramSyncSnapshot
ready. This is the basis for search.
- ✨ New architecture: Running logic moved from
BProgram
toBProgramRunner
- ongoing. - ✨
BProgramListener
s notified before BPrograms are started. - 🐛 Fixed a bug where dynamically added b-threads that were added by other dynamically added b-threads would run one cycle too late.
- 🐛 Fixed a bug where external events enqueued from top-level JS code where ignored.
- ✨ New architecture: Running logic moved from
BProgram
toBProgramRunner
. This will help implementing search. - ✨
BProgramListener
s notified when a b-thread runs to completion. - ✨
bp.getTime()
added. - ✨ Updated tutorial now includes the
bp
object.
- 🚮 Simplified the
examples
test package. - 🚮
all
andnone
are now only available viabp
. - 🔄 cleaner scope structure..
- 🔄 Internal method name clean-ups.
- 🚮 Removed unneeded initializations.
- 🐛 Program and bthread scopes are treated as scopes rather than prototypes.
- ✨ B-Thread scope games eliminated 🎉. Dynamic b-thread addition is now possible from within loops etc. Tutorial updated.
- ✨ More tests.
- ✨
bp.random
added. - 🔄 Documentation updates
- ✨ Added java accessors for putting and getting variables in the JS program
- 🔄
fat.jar
is nowuber.jar
.
- ✨ the standard
.jar
file now contains only BPjs, and no dependencies. Fat jar (the jar that includes dependencies) is available via the releases tab.
- 🔄
Events
class renamed toEventSets
. Some cleanup. - 🔄
emptySet
is nownone
. - 🔄
all
andemptySet
are now available to BPjs code viabp.all
andbp.none
. This is to prevent name collisions with client code. - 🐛 Fixed an issue with the logger, where logging levels were ignored.
- ✨ Log level can be set by BPjs code, using
bp.log.setLevel(l)
.l
is one ofWarn
,Info
,Fine
.
- ✨ Updated documentation to refer to Maven Central
- 🐛
RunFile
re-reads files from file system again. - 🔄 More dead code removal.
This release in focused on better BPjs-programmer experience and getting the code into a maven-central quality grade.
- 🐛 Fixing Javadoc references.
- 🚮 Positional
bsync
removed. - ✨ Better error reporting on event sets defined in JavaScript.
- ✨ Better error reports for generic JS errors.
- ✨ Added
StringBProgram
: a new class for running BPjs code from a String (rather than a resource or a file).
- ✨ Adding a BThread is idempotent. Previously, if a BThread was added twice, it would run twice with unexpected results.
- ✨ Basic engine exceptions, plus a friendlier error message when calling
bsync
outside of a BThread. - 🔄 More Javadocs and code cleanup (mostly dead code removal).
- ✨ License (MIT)
- ✨ Preparations for Maven Central
- 🔄 More Javadocs and code cleanup.
- ✨
RunFile
can now accept multiple BPjs files for input, and runs them as a single BProgram. It also has improved help text.
- ✨ Added continuous code coverage with Coveralls.io (Thanks guys!).
- ✨ Improved test coverage.
- ✨ Added continuous testing with Travis-CI (Thanks guys!).
- 🎉 Moved from native NetBeans to maven project 🎉 🎉 ✨
- 🐛 Various small issues fixed thanks to static analysis (and NetBeans' Code Inspection tool).
- 🔄 Moved to canonical package structure (
il.ac.bgu.cs.bp.*
).
- ✨ Re-arranged code to minimize amount of
Context.enter
-Context.exit
pairs (~x5 performance factor!) - ✨ Simplified mechanism for handling event selection in
BProgram
. Replaced a complex Visitor pattern with Java8'sOptional
. - 🔄 Improved efficiency for external events handling.
- ✨ More tests for
SimpleEventSelectionStrategy
. - ✨ More documentation.
- ✨ Better error messages.
- 🚮 Removed unused code from
BProgram
. - 🚮 Removed non-serializable
Optional
from fields.
- 🚮 Removed
bpjs
from JS scope. Programs must usebp
now. - 🚮 Polished the interface for adding BThreads to a program: 1 method instead of 3.
- 🐛 Fixed an issue where external events were re-ordered while checking for daemon mode termination.
- 🐛 A BProgram now quits when there are no more BThreads, even if there are enqueued external events.
- 🐛 Fixed typos in error messages.
- 🔄 Reduces method accessibility to minimum (nothing is
public
unless it has to be). - ✨ More documentation.
- ✨ A class for running bpjs files.
- 👍 Efficient use of
Context
, so that we don't open and exit it all the time. - 🚮 More removal of more unused code. We now have less unused code. Less is more, especially with unused code.
- 🔄
breakUpon
is nowinterrupt
. This leavesbreakUpon
to be later used as a language construct rather than absync
parameter.
- 🚮 ✨ 🐘 Big refactoring and clean-up towards enabling search.
BThread
s removed from engine - main new concept is that an execution of a BThread is a series ofBThreadSyncSnapshot
, advanced/connected byBPEngineTask
s. A BProgram is an execution environment for multiple BThreads (plus some state and management code).
- 🐛
breakUpon
handlers are evaluated in theBThread
's context, rather than in theBProgram
one.
- ✨ Updated the logging mechanism from global, single level to 3-level. Code change required:
bplog("hello") -> bp.log.info("hello)
. Also supportswarn
andfine
. - 🚮
bpjs
is deprecated (but still works). Please usebp
now. - 🚮 positional bsync deprecated (but still works). Please use the named-argument variant
bsync({request:....})
. - 🚮 BThread is not exposed in Javascript via
bt
(that was never used). - ✨ BThreads can now enqueue external events using
bp.enqueueExternalEvent()
. - ✨ BThreads can now specify a function that will be executed if they are removed because an event in their
breakUpon
event set was selected. UsesetBreakUponHandler( function(event){...} )
.
- ✨ Restructured the engine with JS proxies - javascript code has no direct interaction with the Java engine parts!
- 👍 More unit tests and examples
- Restructured the engine with JS proxies - javascript code has no direct interaction with the Java engine parts!
- More unit tests and examples
-
✨ BEvents now have an associated
data
object. See example here -
✨ New way of creating
BEvent
s: a static method namednamed
:new BEvent("1stEvent") // old BEvent.named("1stEvent") // new and English-like.
Future usaged include the ability to reuse event instances, but we're not there yet.
-
✨ Added support for Javascript definition of event sets:
var sampleSet = bpjs.EventSet( function(e){ return e.getName().startsWith("1st"); } );
-
✨ Support for
breakUpon
inbsync
s:bsync( {request:A, waitFor:B, block:C, breakUpon:D})
-
✨
SingleResourceBProgram
- a convenience class for the common case of having a BProgram that consists of a single file.
- 🔄 BProgram's
setupProgramScope
gets a scope as parameter. So no need to callgetGlobalScope
, and it's clearer what to do. - ✨
RWBStatement
now knows which BThread instantiated it - ✨ When a program deadlock,
StreamLoggerListener
would print theRWBStatement
s of allBThreads
.
Legend:
- 🔄 Change
- ✨New feature
- 🚮 Deprecation
- ⬆️ Upgrade
- 🐛 Bug fix