Compiling Java for Real-Time Systems
Anders Nilsson
andersn@cs.lth.se
Department of Computer Science, Lund University, Sweden
Compiling Java for Real-Time Systems – p.1
Compiling Java for Real-Time Systems Anders Nilsson - - PowerPoint PPT Presentation
Compiling Java for Real-Time Systems Anders Nilsson andersn@cs.lth.se Department of Computer Science, Lund University, Sweden Compiling Java for Real-Time Systems p.1 Outline Introduction Approach Real-Time Execution Platform
Anders Nilsson
andersn@cs.lth.se
Department of Computer Science, Lund University, Sweden
Compiling Java for Real-Time Systems – p.1
Compiling Java for Real-Time Systems – p.2
Compiling Java for Real-Time Systems – p.3
Compiling Java for Real-Time Systems – p.4
Compiling Java for Real-Time Systems – p.5
Compiling Java for Real-Time Systems – p.6
Compiling Java for Real-Time Systems – p.7
Compiling Java for Real-Time Systems – p.8
Compiling Java for Real-Time Systems – p.9
Compiling Java for Real-Time Systems – p.10
Compiling Java for Real-Time Systems – p.11
Compiling Java for Real-Time Systems – p.12
Compiling Java for Real-Time Systems – p.13
Compiling Java for Real-Time Systems – p.14
Compiling Java for Real-Time Systems – p.15
Compiling Java for Real-Time Systems – p.16
Compiling Java for Real-Time Systems – p.17
class MyClass { void foo() { String foo = new String("Hello World!"); System.out.println(foo); } } GC_PROC_BEGIN(_MyClass_foo, GC_PARAM(MyClass,this)) GC_PARAM_REF(MyClass,this); GC_PUSH_PARAM(this); GC_ENTER GC_REF(String,foo); GC_PUSH_ROOT(foo) GC_NEW(String,foo,"Hello World!"); GC_PROC_CALL(System_out_println,foo); GC_POP_ROOT(foo); GC_LEAVE GC_POP_PARAM(this); GC_PROC_END(_MyClass_foo)
Compiling Java for Real-Time Systems – p.18
Compiling Java for Real-Time Systems – p.19
Compiling Java for Real-Time Systems – p.20
= b a c d = tmp_1 d c = b a tmp_1
Compiling Java for Real-Time Systems – p.21
Compiling Java for Real-Time Systems – p.22
Lines of code Parser and AST Abstract Grammar 181 Concrete Grammar 1044 Semantic Analysis Name- and Type Analysis 1458 Transformations and Optimizations Simplifications 901 Dead Code Optimization 154 Code Generation C code generation 5745 TOTAL 9473
Compiling Java for Real-Time Systems – p.23
Compiling Java for Real-Time Systems – p.24
Compiling Java for Real-Time Systems – p.25
Compiling Java for Real-Time Systems – p.26
6 MHz ⇒ 6 MIPS
4KB RAM
Clock, UART, Timers, 8-channel 10-bit ADC
Compiling Java for Real-Time Systems – p.27
T1 T2 T3 GC1 Period (µs) 100 300 500 NA Workload (µs) 30 50 90 NA
50 100 150 200 250 300 350 20 40 60 Latency and response times for three periodic threads High priority number of samples (10 KHz) us 20 40 60 80 100 120 50 100 150 200 Medium priority number of samples (3.3 KHz) us 10 20 30 40 50 60 70 100 200 300 Low priority number of samples (2 KHz) us
Compiling Java for Real-Time Systems – p.28
fibonacci (virtual) fibonacci (static) scalar Our compiler (ms) mark-compact GC 10050 7012 146400 mark-sweep GC 7002 6904 7760 no GC 753 586 5402 Other (ms) Sun JVM 271 251 5085 Sun JVM -server 270 245 3910 Sun JVM -Xint 3302 3120 52500 GCJ 360 567 10098 GCJ -O3 328 504 2249 Hand-written C GCC NA 280 6810 GCC -O3 NA 293 761
Compiling Java for Real-Time Systems – p.29
Compiling Java for Real-Time Systems – p.30
Compiling Java for Real-Time Systems – p.31
Compiling Java for Real-Time Systems – p.32
Non-moving GC + Can link with external binary code that can use Java objects + Latency as good as C++
Compacting GC
quired (no ext. code)
+ Hard RT Java!
Compiling Java for Real-Time Systems – p.33
Compiling Java for Real-Time Systems – p.34
Compiling Java for Real-Time Systems – p.35
Compiling Java for Real-Time Systems – p.36
Compiling Java for Real-Time Systems – p.37
Compiling Java for Real-Time Systems – p.38