Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The general idea is that all accesses to objects and arrays are mediated via `Change` objects. These keep a copy of the initial state, and a working copy on which the transactions perform their accesses. On commit, we simply compare the initial state with the publicly visible objects, if any change (conflict) is seen the transaction retries. If no conflict was determined, the new state is copied into the publicly visible object. Transactions always succeed, this implementation automatically retries. The initial creation of a `Change` object accesses the public object while holding its lock. Similarly, on writing back changes, the lock is acquired. Transaction commits are globally sequentialized on a single lock. Method and blocks executed inside a transaction execute an `atomic` variant of their method body. All invocable used in the transactional context, i.e., within a `atomic: [...]` execution are split from the normal methods, and marked as `isAtomic`. This flag allows to insert the necessary nodes to ensure that a transaction works on working copies private to the transaction. To avoid issues with class identity, the slots storing lazily allocated class objects are ignored when comparing and updating objects. Inspired by: Transactional Memory for Smalltalk L. Renggli, and O. Nierstrasz. In Proc. of ICDL, 2007. DOI: 10.1145/1352678.1352692 Signed-off-by: Stefan Marr <git@stefan-marr.de>
- Loading branch information
Showing
22 changed files
with
707 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package som.interpreter.transactions; | ||
|
||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.nodes.InvalidAssumptionException; | ||
|
||
import som.interpreter.nodes.dispatch.AbstractDispatchNode; | ||
import som.interpreter.nodes.dispatch.CachedSlotAccessNode.CachedSlotRead; | ||
import som.interpreter.nodes.dispatch.DispatchGuard; | ||
import som.interpreter.objectstorage.FieldReadNode; | ||
import som.vmobjects.SObject.SMutableObject; | ||
|
||
|
||
public final class CachedTxSlotRead extends CachedSlotRead { | ||
public CachedTxSlotRead(final SlotAccess type, | ||
final FieldReadNode read, | ||
final DispatchGuard guard, final AbstractDispatchNode nextInCache) { | ||
super(type, read, guard, nextInCache); | ||
assert type == SlotAccess.FIELD_READ; | ||
} | ||
|
||
@Override | ||
protected Object read(final VirtualFrame frame, final Object rcvr) throws InvalidAssumptionException { | ||
SMutableObject workingCopy = Transactions.workingCopy((SMutableObject) rcvr); | ||
return read.read(frame, workingCopy); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package som.interpreter.transactions; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.nodes.InvalidAssumptionException; | ||
|
||
import som.interpreter.nodes.dispatch.AbstractDispatchNode; | ||
import som.interpreter.nodes.dispatch.CachedSlotAccessNode.CachedSlotWrite; | ||
import som.interpreter.nodes.dispatch.DispatchGuard; | ||
import som.interpreter.objectstorage.FieldWriteNode.AbstractFieldWriteNode; | ||
import som.vmobjects.SObject.SMutableObject; | ||
|
||
|
||
public final class CachedTxSlotWrite extends CachedSlotWrite { | ||
public CachedTxSlotWrite(final AbstractFieldWriteNode write, | ||
final DispatchGuard guard, | ||
final AbstractDispatchNode nextInCache) { | ||
super(write, guard, nextInCache); | ||
|
||
} | ||
|
||
@Override | ||
public Object executeDispatch(final VirtualFrame frame, | ||
final Object[] arguments) { | ||
Object rcvr = arguments[0]; | ||
try { | ||
if (guard.entryMatches(rcvr)) { | ||
SMutableObject workingCopy = Transactions.workingCopy((SMutableObject) rcvr); | ||
return write.write(workingCopy, arguments[1]); | ||
} else { | ||
return nextInCache.executeDispatch(frame, arguments); | ||
} | ||
} catch (InvalidAssumptionException e) { | ||
CompilerDirectives.transferToInterpreterAndInvalidate(); | ||
return replace(nextInCache).executeDispatch(frame, arguments); | ||
} | ||
} | ||
} |
Oops, something went wrong.