|
|
MACE - Mobile Agent Code Environment
OverviewMACE (Mobile Agent Code Environment) is an interpretative execution environment for mobile agents programmed in C/C++ which is based upon the model of an abstract machine. The MACE compiler generates byte code derived from the internal representation of RTL (Register Transfer Language) code produced by the GNU C compiler from C/C++ source. This byte code consists of pseudo machine language operations of an abstract microprocessor within a virtual memory image, which is interpreted by the MACE interpreter. This allows a safe and efficient execution and the simple migration of agent code.MACE is used with the Ara platform for mobile agents.
MACE byte codeMACE uses its own language - MACE byte code - to represent programs written in C or C++, generated from their internal representation in the GNU compiler. This compiler uses the language RTL (Register Transfer Language) to describe the steps necessary for the execution of these programs as elementary operations of an abstract microprocessor. This RTL code is used throughout almost all of the internal compiler stages, including code optimization. The MACE compiler translates the text representation of the (optimized) RTL code into an efficiently interpretable byte code format, which can later be interpreted by the MACE interpreter.The usage of the common abstraction layer RTL in the GNU compiler system allows the MACE interpreter to operate almost independently from the actual language used (currently C or C++). An extension of the MACE system to support additional languages (e.g. Pascal) should be achievable in an relatively easy way. The RTL representation of a program is not totally independent of the target architecture it is compiled for. The MACE compiler requires RTL code generated for the Motorola 680x0 processor, which can easily be produced on almost any platform using a GNU compiler configured as a Motorola 680x0 crosscompiler. The rather complex instruction set of the Motorola processor allows the generation of more powerful byte code instructions than it would have been possible for other architectures.
The interpreterIn comparison to high level programming languages, the MACE byte code has a rather low level of abstraction, resulting in a compact and easily portable interpreter. Due to the simplicity of the underlying model, the migration process can be reduced to a simple transfer of the processor registers and the virtual memory image. Memory accesses are limited to the virtual memory image by incorporating address-checking code into the relevant parts of the interpreter core. This leads to a portable and safe way of interpretation without depending on hardware-based protection schemes (MMU). The interpreter assigns a virtual memory image to every virtual processor, serving as the only adressable memory for the processor. The real size of this virtual memory image is determined according to the current memory usage or an optional size limitation, whereas the virtual size is only limited by the adressable range.In the MACE system the common practice of linking C/C++ code against libraries is replaced by a dynamic linking mechanism against user-defined, compiled functions which are part of the execution environment. This linking mechanism happens both at the time of initial loading of agent code and after each successful migration. These external functions are called by stub routines and are executed outside the interpreter context. The main purpose of these stub routines is the format conversion of their arguments, e.g. byte order conversion and conversion between real and virtual addresses. For testing purposes a simple interpreter for ANSI C programs has been developed, which incorporates stub routines for functions of the ANSI C library. Using that interpreter, it was possible to measure the efficiency and functionality of the MACE system in direct comparison to conventionally compiled programs.
PerformanceLike every interpretative system MACE is subject to an inherent performance penalty compared to compilative systems. Due to the fine granularity of the called byte code routines (typically only a few machine instructions), the inevitable overhead of the byte code dispatcher sums up to a significant amount. By the means of a precompilation mechanism which performs the opcode-routine mapping already at load time, the performance of the system was raised considerably. Even better performance is expected using a projected mechanism to dynamically compile loop bodies of the program into native machine code at runtime.A detailed description of the MACE system (dated 08/17/95) in german language is available (gzip'd PostScript - 92413 bytes)
copyright © 1997 The University of Kaiserslautern. Torsten Stolpmann |