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.

7.1. AST Transformation<br />

all have the same receiver object, which might be the result of an expression.<br />

However, the object may change its owner. This indirection, to <strong>de</strong>termine the<br />

domain for every execution request directly, avoids a complete restructuring<br />

of the co<strong>de</strong> as part of the transformation. With that, it also avoids the need of<br />

complex transformations and the use of additional temporary variables. The<br />

latter is a problem when a naive 1 transformation is used. The transformed<br />

method could require more temporary variables than what is supported by<br />

the byteco<strong>de</strong> set and VM. Furthermore, besi<strong>de</strong>s keeping the transformation<br />

simple, the approach has another benefit. It preserves the structure of the<br />

original co<strong>de</strong>, which is beneficial while <strong>de</strong>bugging the transformed co<strong>de</strong>.<br />

In Squeak/Pharo, globals such as classes and class variables are realized by<br />

mutable associations of a symbol with a value. These accesses are rewritten by<br />

sending either #readGlobal: or #write:toGlobal: to the current execution<br />

domain. Note that the current execution domain does not need to be the<br />

receiver’s owner domain. Certain shared memory concurrency mo<strong>de</strong>ls might<br />

want to enable access from processes from multiple domains on the same<br />

object.<br />

Strategy for Controlled Enforcement The AST-OMOP realizes the notion of<br />

controlled enforcement by applying the approach Renggli and Nierstrasz<br />

utilized to differentiate between normal and transactional execution.<br />

As illustrated in Lst. 7.2, every method implementation needs to be available<br />

in two versions: the normal unchanged version, which corresponds to unenforced<br />

execution, and the transformed method. Enforced, i. e., transformed<br />

methods are ma<strong>de</strong> available with a name prefixed with __enforced__. The<br />

prefix is used to have the enforced methods si<strong>de</strong> by si<strong>de</strong> with the unenforced<br />

ones in the same Smalltalk method dictionary.<br />

Switching to enforced execution is done by sending the #enter: message to<br />

a block. The parameter to #enter: is the domain which #evaluateEnforced:<br />

is going to be sent to with the block as argument. This double dispatch is<br />

used for idiomatic/esthetic reasons. However, it also simplifies the correct<br />

implementation of enforced execution. The example block given in line 25<br />

needs to be transformed in the same way normal methods are transformed<br />

into their enforced equivalents. The current restriction of this implementation<br />

is that only blocks that directly receive the #enter: message statically in the<br />

1 Other approaches would require analysis of the transformed co<strong>de</strong> to minimize the number<br />

of temporary variables required.<br />

185

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

Saved successfully!

Ooh no, something went wrong!