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.2. Virtual Machine Support<br />

to the domain object. 5 This provi<strong>de</strong>s part of the support for controlled<br />

enforcement.<br />

The initial ownership of newly created objects is <strong>de</strong>duced from a special<br />

field in each domain object. During initialization of a domain, the domain<br />

can pre<strong>de</strong>termine the owner domain for objects newly created during execution<br />

in the domain’s context. The standard owner domain is the domain the<br />

Process is currently executing in. However, it can be useful to create objects<br />

with a domain different from their initial owner. For example, objects created<br />

by an update function in the context of a Clojure agent should be owned<br />

by the immutable domain (cf. Sec. 2.4.3). The RoarVM+OMOP represents the<br />

initial owner via a field in the domain because it avoids executing another<br />

Smalltalk method on every object creation, while giving some flexibility with<br />

regard to the initial owner. For more complex use cases, it is always possible<br />

to change the owner of an object during the course of the execution. Furthermore,<br />

setting the owner during object initialization avoids race conditions on<br />

the object owner as compared to when it is set afterwards.<br />

Changed Byteco<strong>de</strong> Semantics and Customization Constant To expose the<br />

OMOP’s intercession points, i. e., to support managed state and managed<br />

execution, the RoarVM+OMOP adapts most byteco<strong>de</strong>s and primitives.<br />

The general i<strong>de</strong>a is to check first, whether currently an enforced execution<br />

is required, and if that is the case, the target object’s domain is inspected<br />

to <strong>de</strong>termine whether a relevant intercession handler has been customized<br />

based on the customization constant. If this is the case, the intercession handler<br />

is invoked instead of executing the byteco<strong>de</strong>’s or primitive’s operation.<br />

During enforced execution, byteco<strong>de</strong>s reify their operations and <strong>de</strong>legate<br />

them to the intercession handlers. Most of the byteco<strong>de</strong>s have trivial semantics,<br />

in terms of the stack operations they perform. Thus, a Smalltalk<br />

method, such as the intercession handlers can stand in for the actual byteco<strong>de</strong><br />

operation without loss of flexibility. During enforced execution, the byteco<strong>de</strong><br />

implementations can t<strong>here</strong>fore perform message sends, similarly to the standard<br />

behavior of the send byteco<strong>de</strong>, instead of performing their operations<br />

directly. This approach corresponds directly to the one <strong>de</strong>scribing the overall<br />

semantics of the OMOP in Sec. 5.4.<br />

5 On a 32-bit architecture with 4 byte alignment, the first bit of an Oop is used to indicate<br />

whether an Oop is an immediate integer, or a references. The second bit remains unused,<br />

and is used to enco<strong>de</strong> the enforcement.<br />

191

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

Saved successfully!

Ooh no, something went wrong!