We implemented a translator from a subset of C to Java that guarantees safety. For such translation, we need to emulate C's pointer arithmetics in Java. We thus defined Java classes to represent C's pointers and memory blocks. Next, we defined translation rules which use these classes, and implemented a translator following the rules. We also need to translate integers as pointers, because they can be cast to each other in C. However, representing all integers as pointers incurs too much overhead. We therefore implemented optimizations, including a data flow analysis for translating C's integer variables (to which no pointers are assigned) to Java's integer variables. We conducted experiments with 9 benchmark programs. Without optimizations, the translated programs were 3.3-585 times slower than the original C programs. After the optimizations, those numbers improved to 1.3-5.9.
|Number of pages||16|
|Publication status||Published - 2009 Jun 19|
ASJC Scopus subject areas