Jeannie: Granting Java Native Interface Developers their Wishes - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Jeannie: Granting Java Native Interface Developers their Wishes

Description:

1. Jeannie: Granting Java Native Interface Developers their Wishes ... Operating systems: Mac OS X, Linux, Cygwin. 15. Efficiency: JNI vs. Jeannie. 1. 16 ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 20
Provided by: martin356
Category:

less

Transcript and Presenter's Notes

Title: Jeannie: Granting Java Native Interface Developers their Wishes


1
Jeannie Granting Java Native Interface
Developers their Wishes
2
FFI Foreign Function Interface
UserProgram nqueens
BrownJava
StandardLibraries java.io
CustomLibraries JavaBDD
  • Motivation
  • OS Services
  • Legacy Code
  • Performance
  • Convenience

Virtual Execution Environment JVM
Operating System Linux
BlueC
3
JNI Java Native Interface
Java
Native methodno body in Java
C function with mangled nameimplements Java
method
C
Read Javafield from C
Throw Javaexception from C
4
FFI Design Goals
  • Productivity
  • Writing maintaining code
  • Safety
  • Preventing detecting bugs
  • Efficiency
  • At transition elsewhere
  • Portability
  • Different OS, HW, virtual execution environment

5
Jeannie Example
Support fullC syntax
Can useshort names
Native methods have a body
Nestedblock
Nestedexpression
Can nest toany depth
Exception handling in C
6
Jeannie Build Process
Socket.jni
Preprocessor
Socket.jni.i
Jeannie Compiler
Java sources
C sources
Socket.i
Socket.java
Java Compiler
C Compiler
Network.jar
Network.dll
7
Translation Scheme
Jeannie source code
Generated code
class JavaEnv int x int z native m1()
m2(CEnv) native m3(CEnv) m4(CEnv) struct
CEnv jint yJava_C_m1(JEnv) Java_C_m3(JEnv,
CEnv)
1
2
3
4
1
2
8
Typing
  • Nested expressions have equivalent types
  • if (((jboolean)feof(stdin))) ..
  • Java references are opaque in C
  • Use in nested Java expression
  • Assign to variable
  • Pass as parameter
  • Return as result
  • C can widen Java references
  • List lst new ArrayList(10)
  • C pointers/structs/unions are illegal in Java

9
Java Garbage Collection
10
Compiler Stages
Jeannie code
Jeannie grammar
Jeannie Parser
Jeannie AST
Jeannie Analyzer
Jeannie ASTSymTab
Code generator
C code
Java code
11
Scalable Composition Syntax
Jeannie code
C grammar
Rats!parsergenerator
Jeannie Parser
Jeannie grammar
Java grammar
Jeannie AST
Jeannie Analyzer
Jeannie ASTSymTab
Code generator
C code
Java code
12
Scalable Composition Analyzers
Jeannie code
C grammar
Rats!parsergenerator
Jeannie Parser
Jeannie grammar
Java grammar
Jeannie AST
xtc visitors,commontype rep.
C Jeannie Java Analyzer
Jeannie ASTSymTab
Code generator
C code
Java code
13
Scalable Composition CodeGen
Jeannie code
C grammar
Rats!parsergenerator
Jeannie Parser
Jeannie grammar
Java grammar
Jeannie AST
xtc visitors,commontype rep.
C Jeannie Java Analyzer
Jeannie ASTSymTab
xtc ASTgenerator
Code generator
Java stencils
C stencils
C AST
Java AST
C pretty printer
Java pretty printer
C code
Java code
14
FFI Design Goals Revisited
  • Productivity
  • Concise syntax
  • Safety
  • Static error checking
  • Efficiency
  • See next slide
  • Portability
  • Java virtual machines HotSpot, J9, Jikes RVM
  • Operating systems Mac OS X, Linux, Cygwin

15
Efficiency JNI vs. Jeannie
1
16
Array Access
  • Nested expression is simple
  • for (i 0, n ja.length i lt n i)
  • s jai
  • But bulk access is faster
  • with (jint ca ja)
  • jint n ja.length
  • for (jint i0 iltn i)
  • s cai

17
EfficiencyBulk vs. Simple Array Access
1
18
Related Work
  • Improving JNI
  • Productivity BubakKurzyniec (Janet)
  • Safety Tan et al. (Ccured, ILEA),FurrFoster
    (type inference)
  • Efficiency Stepanian et al. (JIT native code)
  • Portability Chen et al. (dynamic binary
    translator)
  • Deep language interoperability
  • XJ, XTATIC, C?, Linq, DALI
  • Scalable composition
  • Polyglot, JastAdd, Silver, Stratego/XT, Safari

19
Conclusions
  • Have
  • Language Jeannie FFI(JavaC)
  • Open source compiler contributed to xtc
    http//cs.nyu.edu/rgrimm/xtc
  • Next
  • Debugging
  • Fault isolation
  • Optimization
Write a Comment
User Comments (0)
About PowerShow.com