05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5. An Ownership-based MOP for Expressing Concurrency Abstractions<br />

1 SOMInterpreter = (<br />

2 | frame universe currentByteco<strong>de</strong> |<br />

3<br />

4 doPopField = (<br />

5 | omopWriteField args oldFrame value |<br />

6 value := frame pop .<br />

7 frame enforced ifFalse : [<br />

8 ^ self currentObject<br />

9 fieldAtIn<strong>de</strong>x : currentByteco<strong>de</strong> fieldIn<strong>de</strong>x<br />

10 put : value ].<br />

11<br />

12 omopWriteField := self currentObject domain class<br />

13 lookupInvokable : # write : toField :of :.<br />

14 oldFrame := frame .<br />

15 oldFrame pushAll : { self currentObject domain .<br />

16 value .<br />

17 currentByteco<strong>de</strong> fieldIn<strong>de</strong>x .<br />

18 self currentObject }.<br />

19 frame := interpreter pushNewFrameWithMethod : omopWriteField .<br />

20 frame copyArgumentsFrom : oldFrame )<br />

21<br />

22 pushNewFrameWithMethod : method = (<br />

23 ^ frame := SOMFrame new<br />

24 method : method ;<br />

25 previousFrame : frame ;<br />

26 resetStackPointerAndByteco<strong>de</strong>In<strong>de</strong>x ;<br />

27 domain : frame domain ;<br />

28 enforced : ( frame enforced and : [ method unenforced not ]);<br />

29 yourself )<br />

30 " ... " )<br />

Listing 5.5: Reifying mutation of object fields<br />

and PUSH_FIELD byteco<strong>de</strong> is that the latter uses its own OMOP intercession<br />

handler #readField:of:.<br />

The byteco<strong>de</strong>s for sends and super sends themselves remain unchanged<br />

(cf. Sec. 4.2.2, Lst. 4.5). However, both byteco<strong>de</strong>s rely on adaptation of the actual<br />

send in the #performSend:to:lookupCls: method. Lst. 5.7 shows that<br />

#performSend:to:lookupCls: will send the message directly during unenforced<br />

execution, and it will rearrange the operand stack during enforced<br />

execution to be able to trigger the #requestExecOf:with:on:lookup: intercession<br />

handler on the receiver’s domain instead.<br />

While handling message sends implicitly covers the methods that represent<br />

the VM’s primitives, they still need to be treated explicitly to re<strong>de</strong>fine them<br />

126

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!