Skip to content

Commit 5555111

Browse files
committed
synchronised stmt
1 parent 409fc4c commit 5555111

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/common/stmt-syntax.k

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,8 @@ syntax BreakStmt ::= "break" K ";" [klabel('Break)]
6363
syntax ReturnStmt ::= "return" K ";" [klabel('Return)]
6464

6565
syntax SynchronizedStmt ::= "synchronized" "(" Exp ")" Block [strict(1),klabel('Synchronized)]
66-
//todo
66+
//todo: replace Exp with StmtExp
6767
syntax ExprStmt ::= Exp ";" [strict, klabel('ExprStm)]
68-
//syntax InternalUse ::= TypedVal ";"
69-
70-
71-
7268

7369
endmodule
7470

src/exec/api-threads.k

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,13 @@ when
4343
Class ==K class String2Id("java.lang.Thread") andBool Id2String(MethodName) ==String "startImpl"
4444

4545
//@ \subsection{Synchronized statement}
46-
// 'Synchronized(objectRef(...)::_,, Block)
47-
//syntax KLabel ::= "'Synchronized"
48-
//evaluate the expression
49-
//context 'Synchronized(HOLE,, _)
5046

5147
rule [Synchronized-first-time]:
5248
<k>
53-
'Synchronized(objectRef(OId:Int,_)::_,, Block:K)
54-
=> 'Try(Block,, [.KList],, releaseLock(OId))
55-
...
49+
synchronized (objectRef(OId:Int,_)::_) Block:Block
50+
=> try Block [.KList] finally releaseLock(OId)
51+
...
5652
</k>
57-
// <k>
58-
// synchronized (objectRef(OId:Int,_)::_) Block:Block
59-
// => 'Try(Block,, [.KList],, releaseLock(OId))
60-
// ...
61-
// </k>
6253
<holds>... (. => OId |-> 1) ...</holds>
6354
<busy> Busy:Set (. => SetItem(OId)) </busy>
6455
when
@@ -67,15 +58,15 @@ when
6758

6859
rule [Synchronized-nested]:
6960
<k>
70-
'Synchronized(objectRef(OId:Int,_)::_,, Block:K)
71-
=> 'Try(Block,, [.KList],, releaseLock(OId))
61+
synchronized (objectRef(OId:Int,_)::_) Block:Block
62+
=> try Block [.KList] finally releaseLock(OId)
7263
...
7364
</k>
7465
<holds>... OId |-> (Level:Int => Level +Int 1) ...</holds>
7566
[transition-threading, transition-sync]
7667

7768
rule [Synchronized-on-null]:
78-
'Synchronized(null::_,,_) => throw new classNullPointerException(null::classString);
69+
synchronized (null::_) _ => throw new classNullPointerException(null::classString);
7970

8071
/*@Release one level of lock for the given object.*/
8172
syntax KItem ::= releaseLock ( Int )

0 commit comments

Comments
 (0)