05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7. Implementation Approaches<br />

Customization Constant In addition to showing the implementation of the<br />

store and pop byteco<strong>de</strong>, Lst. 7.3 also contains the specifics of the customization<br />

constant implementation. On line 2, the byteco<strong>de</strong> implementation calls the<br />

method requires_<strong>de</strong>legation(..) with the receiver (rcvr) object and a bit<br />

mask, which indicates a write operation. Line 18 <strong>de</strong>fines the called method.<br />

It first looks up the domain owning the given receiver. Then, it looks up the<br />

customization constant in the domain object and uses another helper method<br />

that checks whether the constant has the corresponding bits of the bit mask<br />

set. If that is not the case, the byteco<strong>de</strong> implementation will continue executing<br />

at line 11 and directly perform the operation, as if the co<strong>de</strong> was executed<br />

in the unenforced execution mo<strong>de</strong>. This avoids the overhead of reifying the<br />

operation and performing it later reflectively. In case a <strong>de</strong>legation is required,<br />

the byteco<strong>de</strong> implementation will call redirect_write_field(..) instead of<br />

performing the write directly.<br />

Handling of Primitives Primitives are handled similarly to byteco<strong>de</strong>s. Once<br />

the primitive co<strong>de</strong> is reached it is already clear that the message send that<br />

led to it succee<strong>de</strong>d and does not need to be consi<strong>de</strong>red anymore. However,<br />

the primitive itself might still need to be intercepted by the domain. Thus,<br />

it needs to check whether the domain customizes the corresponding intercession<br />

handler. Lst. 7.4 provi<strong>de</strong>s an example of the adapted primitive for<br />

shallow copying of objects. As <strong>de</strong>scribed, the receiver is first checked whether<br />

it customizes the corresponding handler, and if this is the case, the handler is<br />

invoked instead. As request_primitive_clone() <strong>de</strong>monstrates, we rely for<br />

that operation on the standard method invocation, i. e., commonSend().<br />

Strategy for Controlled Enforcement As mentioned before, each context object<br />

keeps track of whether the VM is supposed to execute the corresponding<br />

co<strong>de</strong> in enforced or unenforced mo<strong>de</strong>.<br />

The VM offers two ways to switch to enforced execution. The first one is<br />

the #evaluateEnforced: primitive, which takes a block that is going to be<br />

evaluated with enforcement enabled. The second way is enabled by the variants<br />

of the #performEnforced: primitives, which take a selector, arguments,<br />

and optionally a lookup class for super sends. Both approaches cause either<br />

blocks or methods to be executed in enforced mo<strong>de</strong>.<br />

To leave enforced execution, methods are marked similarly to the solution<br />

for SOM and the AST-OMOP. The RoarVM+OMOP implementation uses bit<br />

30 (UN) in the method hea<strong>de</strong>r (cf. Tab. 7.1) to indicate to the VM that the<br />

194

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

Saved successfully!

Ooh no, something went wrong!