Skip to content

Commit

Permalink
added end of thread execution as default sync event
Browse files Browse the repository at this point in the history
changed rs for Example1 accordingly
  • Loading branch information
kheradmand committed Feb 7, 2015
1 parent 22f6227 commit 82aae9c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/Example1/Example1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ after_sync:
default
;

schedule: 1 x 7 , 10 x 5 , 1 x 1 , 10 x 1 ;
schedule: 1 x 7 , 10 x 5 , 1 x 2 , 10 x 2 ;

4 changes: 4 additions & 0 deletions src/main/java/replaymop/output/AspectJGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void generateBeforeSyncPointCut() {
StringJoiner pointcuts = new StringJoiner(" ||\n\t\t\t");
if (spec.beforeMonitorEnter)
pointcuts.add("lock()");
if (spec.afterThreadBegin) //trick: before run execution = after thread begin
pointcuts.add("execution(* Thread+.run())");
for (String sync : spec.beforeSync){
pointcuts.add(String.format("call(%s)", sync));
}
Expand All @@ -51,6 +53,8 @@ void generateAfterSyncPointCut() {
StringJoiner pointcuts = new StringJoiner(" ||\n\t\t\t");
if (spec.afterMonitorExit)
pointcuts.add("unlock()");
if (spec.beforeThreadEnd) //trick: after run execution = before thread end
pointcuts.add("execution(* Thread+.run())");
for (String sync : spec.afterSync){
pointcuts.add(String.format("call(%s)", sync));
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/replaymop/parser/RSParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ void handleBeforeSync() throws ReplayMOPException {
spec.addBeforeSyncDefault();
else if (func.equals("synchronized"))
spec.beforeMonitorEnter = true;
else if (func.equals("begin"))
spec.beforeThreadEnd = true;
else if (func.equals(";"))
return;
else
Expand All @@ -100,7 +102,9 @@ void handleAfterSync() throws ReplayMOPException {
if (func.equals("default"))
spec.addAfterSyncDefault();
else if (func.equals("synchronized"))
spec.afterMonitorExit = false;
spec.afterMonitorExit = true;
else if (func.equals("begin"))
spec.afterThreadBegin = true;
else if (func.equals(";"))
return;
else
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/replaymop/parser/rs/ReplaySpecification.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class ReplaySpecification {
public Set<Variable> shared;
public Set<String> beforeSync;
public boolean beforeMonitorEnter = false;
public boolean beforeThreadEnd = false;
public Set<String> afterSync;
public boolean afterMonitorExit = false;
public boolean afterThreadBegin = false;
public List<ScheduleUnit> schedule;
public String input;

Expand All @@ -40,11 +42,13 @@ public ReplaySpecification() {

public void addBeforeSyncDefault(){
beforeMonitorEnter = true;
beforeThreadEnd = true;
beforeSync.addAll(Arrays.asList(beforeSyncDefault));
}

public void addAfterSyncDefault(){
afterMonitorExit = true;
//afterThreadBegin = true;
afterSync.addAll(Arrays.asList(afterSyncDefault));

}
Expand Down

0 comments on commit 82aae9c

Please sign in to comment.