• No results found

10.1

Future Work

The Mu project is in active development. Much work can be done to improved Mu, and bring more languages onto the Mu platform.

10.1.1 Refining the Design of Mu

As we explore the clients and the real-world language implementations, we frequently find deficiencies in our existing design. We have already made changes to Mu several times to adapt to the new ideas, but there is still much room for improvement. Removing the type parameter of references and pointers

One example is the removal of the type parameter from pointer and reference types, such as the ‘<T>’ inref<T>,iref<T>anduptr<T>. In conventional languages such as C, C++ and Java, the referent type is a part of the pointer or reference type, and the pointers and references to one type can becastto that of another type. Mu already supports check-less type casting between reference types or pointer types with the

REFCASTorPTRCASTinstructions, assuming the client has already inserted proper checks for validity. However, during our work on a Java client, our fellow researcher reported that it is impossible to construct a Mu-level reference type ref<Foo> to class Foo without actually loading the class Foo, because the Mu-level structure type Foo must encode the layout of the class. If lazy loading is to be supported, references from one class to another must be encoded asref<void>, and cast to the appropriateref<Foo>when accessing the fields ofFoo. Colleagues working on the PyPy client also reported that it is often required to compare the equality between two references to two different static types, as the concrete values may refer to objects of derived types. AlthoughREFCASTis essentially a no-op at the machine level, the type parameter for thereftype appears to be redundant, as the concrete Mu instructions, such asEQ,NE,LOADandSTORE, are already annotated with the operand type for the convenience of the Mu backend compiler. Eventually, we realised that only ‘storage types’ (i.e. the types that determines therepresentationorlayoutof values) matter at the micro virtual machine level, and the enforcement of high-level type consistency (such as what objects aref may refer to) could be off-loaded to the client, too. However, since this change implies a major redesign of the type system, we have postponed this change to the future as other research projects, such as the PyPy client, depend on a relatively stable Mu at this moment.

Factored Control Flow Graph

Another alternative design choice we have considered is to loosen the single-exit requirement of basic blocks and allow side-exits (including branches and potential excepting instructions such asCALL with ‘exception clauses’) in the middle of basic blocks. In principle, this is similar to the ‘factored control flow graphs’ (FCFG) intro- duced by Choi et al. [1999] and used in JikesRVM. FCFGs will have fewer but longer

122 Conclusion

basic blocks than the single-exit counterpart, while still permitting efficient forward and backward intra-procedural analysis with minor changes to the algorithms. The compactness of FCFG allows more efficient communication between the client and Mu, and the benefit could be more significant since the Mu IR needs to pass parame- ters between basic blocks. The tracing JIT compilers can also benefit from this form since the trace usually has many ‘guard’ operations which could be simply translated to comparison operations and side exits without having to break the trace into many tiny basic blocks just for binary branching. This change would also result in a major Mu IR redesign, thus we postponed this idea as a future work.

Transactional Memory

Transactional memory provides a scalable, composable alternative to the lock-based synchronisation mechanisms on parallel hardware. Software transactional memory (STM) is able to run general transactional programs, but with significant performance overhead. Meanwhile, recent commodity processors, such as Intel’s Haswell microar- chitecture, also started to offer best-effort hardware transactional memory (HTM) of limited transaction sizes. As an abstraction layer over execution and concurrency, Mu should consider providing primitives for transactional memory, allowing a hybrid STM/HTM system to be implemented, and the optimal STM or HTM strategy to be chosen dynamically at run time, similar to the work by Chapman et al. [2016].

10.1.2 Client-side Development Clients with JIT-compiling Capability

Although Mu is designed from the very beginning as a platform for JIT compilation, the mechanisms provided by Mu IR and the API need to be tested with real-world language clients. So far, the only working Mu client capable of JIT-compiling the high-level language and performing feedback-directed optimisation is the proof-of- concept JS-Mu project which only implements a subset of JavaScript, as described in Section 7.4. The meta-tracing JIT compiler in PyPy is a good candidate to evaluate such JIT-compiling capabilities in a real-world language client.

Supporting Additional Languages

The more language we test on Mu, the better we can demonstrate and improve the generality of Mu. Some languages may potentially benefit from what Mu offers. For example, Erlang and Go may use the Swapstackoperation to implement their massive multi-threading model. Java and C#, as conventional static managed languages, may not see immediate performance improvement when ported on Mu as their original VMs, namely the JVM and the .NET CLR, are already highly optimised. However, supporting such languages on Mu will allow us to compare against state-of-the-art VMs on a common ground. Such static languages may also play the role of ‘high-level