J e a n n i e granting java native interface developers their wishes
This presentation is the property of its rightful owner.
Sponsored Links
1 / 19

J e a n n i e : Granting Java Native Interface Developers their Wishes PowerPoint PPT Presentation


  • 145 Views
  • Uploaded on
  • Presentation posted in: General

J e a n n i e : Granting Java Native Interface Developers their Wishes. FFI: Foreign Function Interface. User Program — nqueens. Brown: Java. Stan dard Libra ries — ja va. io. Cus tom Libra ries — Java BDD. Motivation: OS Services Legacy Code Performance Convenience.

Download Presentation

J e a n n i e : Granting Java Native Interface Developers their Wishes

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


J e a n n i e granting java native interface developers their wishes

Jeannie: Granting Java Native Interface Developers their Wishes


Ffi foreign function interface

FFI: Foreign Function Interface

UserProgram

nqueens

Brown:Java

StandardLibraries—java.io

CustomLibraries—JavaBDD

  • Motivation:

  • OS Services

  • Legacy Code

  • Performance

  • Convenience

Virtual Execution Environment —JVM

Operating System —Linux

Blue:C


Jni java native interface

JNI = Java Native Interface

Java

Native method:no body in Java

C function with mangled nameimplements Java method

C

Read Javafield from C

Throw Javaexception from C


Ffi design goals

FFI Design Goals

Productivity

  • Writing & maintaining code

    Safety

  • Preventing & detecting bugs

    Efficiency

  • At transition & elsewhere

    Portability

  • Different OS, HW, virtual execution environment


J e a n n i e example

JeannieExample

Support fullC syntax

Can useshort names

Native methods have a body

Nestedblock

Nestedexpression

Can nest toany depth

Exception handling in C


J e a n n i e build process

Jeannie Build Process

Socket.jni

Preprocessor

Socket.jni.i

Jeannie Compiler

C sources

Java sources

Socket.i

Socket.java

C Compiler

Java Compiler

Network.dll

Network.jar


Translation scheme

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 y};Java_C_m1(JEnv)

Java_C_m3(JEnv,CEnv)

1

2

3

4

“1”

“2”


Typing

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


Java garbage collection

Java Garbage Collection


Compiler stages

Compiler Stages

Jeannie code

Jeannie grammar

Jeannie Parser

Jeannie AST

Jeannie Analyzer

Jeannie AST+SymTab

Code generator

C code

Java code


Scalable composition syntax

Scalable Composition: Syntax

Jeannie code

C grammar

Rats!parsergenerator

Jeannie Parser

Jeannie grammar

Java grammar

Jeannie AST

Jeannie Analyzer

Jeannie AST+SymTab

Code generator

C code

Java code


Scalable composition analyzers

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 AST+SymTab

Code generator

C code

Java code


Scalable composition codegen

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 AST+SymTab

xtc ASTgenerator

Code generator

Java stencils

C stencils

C AST

Java AST

C pretty printer

Java pretty printer

C code

Java code


Ffi design goals revisited

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


Efficiency jni vs jeannie

Efficiency: JNI vs. Jeannie

1


Array access

Array Access

  • Nested expression is simple:

    for (i = 0, n = `ja.length; i < n; i++)

    s += `ja[`i];

  • But bulk access is faster:

    with (jint* ca = `ja) {

    jint n = `ja.length;

    for (jint i=0; i<n; i++)

    s += ca[i];

    }


Efficiency bulk vs simple array access

Efficiency:Bulk vs. Simple Array Access

1


Related work

Related Work

  • Improving JNI

    • Productivity: Bubak+Kurzyniec (Janet)

    • Safety: Tan et al. (Ccured, ILEA),Furr+Foster (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


Conclusions

Conclusions

  • Have:

    • Language: Jeannie = FFI(Java+C)

    • Open source compiler contributed to xtc http://cs.nyu.edu/rgrimm/xtc

  • Next:

    • Debugging

    • Fault isolation

    • Optimization


  • Login