OSUIF: A Closer Look - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

OSUIF: A Closer Look

Description:

j2s Caveats. compiles class files. has its own runtime system (SPARC only! ... j2s Caveats (cont'd) restrictions: exception-handling. threads and synchronization ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 32
Provided by: holger3
Category:

less

Transcript and Presenter's Notes

Title: OSUIF: A Closer Look


1
OSUIF A Closer Look
  • Holger KienleUCSBhttp//www.cs.ucsb.edu/osuif

2
OSUIF The Basic Idea
  • thin layer on top of SUIF for OO languages -gt
    extension of SUIF IR nodes
  • lowering OSUIF -gt SUIF
  • set of basic passes
  • client (e.g., C/Java front end/extension) has
    to extend OSUIF skeleton

3
Language Independence
  • three extension points for language-specific
    functionality
  • front-end(e.g., subclass ClassSymbolTable for
    lookup)
  • lowering passes(e.g., dispatch table
    construction)
  • IR(language-specific nodes)

4
Language Independence (cont.)
  • design goalput only language-independent parts
    in OSUIF rest in front end / lowering
  • exampleOSUIF has inheritance links but leaves
    semantics to be implemented by front end
    (abstract lookup() method)

5
OSUIF IR Extensions (1)
  • new constructs
  • classes and inheritance
  • methods and fields (static and instance)
  • method calls(dispatching and non-dispatching)
  • (exception-handling)

6
OSUIF IR Extensions (2)
  • DataType
  • GroupType
  • StructType
  • ClassType
  • SingleInheritanceClassType
  • encapsulates methods and fields
  • symbol table interface

7
OSUIF IR Extensions (3)
  • SuifObject
  • AnnotableObject
  • InheritanceLink
  • models relationships between classes
  • first-class entity

8
OSUIF IR Extensions (4)
  • ProcedureSymbol VariableSymbol
  • InstanceMethodSymbol FieldSymbol
  • StaticMethodSymbol InstanceFieldSymbol
  • StaticFieldSymbol
  • reference to owning class
  • LString attributes(e.g., to model access
    modifiers)

9
OSUIF IR Extensions (5)
  • Statement
  • CallStatement
  • InstanceMethodCallStatement
  • StaticMethodCallStatement
  • static and instance methods(this-ref vs. no
    this-ref)
  • dispatching vs. non-dispatching calls

10
InstanceMethodCallStatement
  • concrete InstanceMethodSymbol ProcedureSymbol
  • ClassType reference owning_class omitted
  • bool is_dispatched default true
  • ...
  • concrete InstanceMethodCallStatement
    CallStatement InstanceMethodSymbol reference
    target_method
  • bool is_dispatched default true
  • single receiver (i.e., no multiple dispatch)
  • dispatching and non-dispatching call

11
Lowering (and Raising)
  • symbols
  • moved in higher symbol table(reversible)
  • name mangling
  • InstanceMethodCallStatement
  • dispatching code
  • toggle is_dispatched flag and set callee_address
  • Note OSUIF classes are not replaced by
  • SUIF classes!

12
Lowering Passes (1)
  • lower_osuif_symbols-lower-instance-methods-lower
    -static-fields-lower-static-methods-lower-per-cl
    ass-symbol-table-symtab externalfile_setfile_b
    lockone-up-mangle-name lthowgt-ignore-lowering-na
    me-annote
  • lower_static_method_call_expressions

13
Lowering Passes (2)
  • layout_single_inheritance_instance_fields-mangle-
    name lthowgt-ignore-lowering-name-annote
  • build_single_inheritance_vtbl-construct-vtbls-at
    tach-vtbl-slot-number-annotes-ignore-no-vtbl-anno
    te

14
OSUIF passes
  • use "as is" (default behavior)-gt command line
    switches
  • front-end controls behavior of pass with SUIF
    annotations
  • customize pass via C subclassing

15
OSUIF front-ends
  • Java (j2s)
  • alpha-version
  • several bigger applications compile
  • C
  • back-end reasonably stable
  • front-end does not implement completelanguage
    yet
  • lowering to SUIF in place

16
j2s Goals
  • full Java support for off-line compilation
  • provide a good platform forOO/Java-related
    compiler research

17
j2s Caveats
  • compiles class files
  • has its own runtime system (SPARC only!)
  • JNI
  • reflection
  • class initialization
  • ...
  • requires Java 1.2beta2

18
j2s Caveats (cont'd)
  • restrictions
  • exception-handling
  • threads and synchronization
  • dynamic loading of classes
  • accurate GC
  • floating-point computations

19
j2s Environment
Java .class file
j2s
OSUIF
Transformations (OSUIF and j2s)
OSUIF
OSUIF Lowering
SUIF
SUIF Compiler System
20
j2s Compilation
Helloworld.class
j2s-fe
j2s-glue
j2s-main
HelloWorld.osuif
o2s
HelloWorld.suif
HelloWorld_glue.suif
HelloWorld_main.suif
s2c
s2c
s2c
HelloWorld_main.c
HelloWorld.c
HelloWorld_glue.c
21
j2s Compilation Link-Step
(360 classes)
HelloWorld'stransitive closure
java_math_BigInteger.o
...
HelloWorld.o
libc.so
java_lang_String.o
ld
hw
libj2s_runtime.so
HelloWorld_glue.o
libjvm.so libjava.so ...
HelloWorld_main.o
22
j2s OSUIF extensions
  • ClassType
  • SingleInheritanceClassType
  • JavaAbstractClassType
  • JavaClass
  • JavaInterface
  • JavaArray
  • distinguished Java constructs
  • tiny layer on top of OSUIF

23
j2s Status
  • generates C code (s2c)
  • running applications
  • javac (538 classes)
  • SPECjvm98 benchmarks
  • _201_compress
  • _202_db
  • _202_jess

24
How to get started...
  • "The j2s User Manual"
  • restrictions
  • modified class files
  • setup
  • J2SHOME and PATH
  • JAVAHOME and JVMCLASSPATH
  • LD_LIBRARY_PATH

25
How to get started... (2)
  • compilation process (jmake)gtjmake
    Helloworldbuilds Makefile.deps (dependencies)
  • user-customized MakefileTARGETNAME hwCCFLAGS
    -o2...include J2SHOME/Makefile.driver.confin
    clude Makefile.deps

26
HelloWorld.java
  • public class HelloWorld
  • public static void main(String args)
  • System.out.println("Hello world!")

27
hw Stats
  • loop size ./hw
  • text data bss dec hex filename
  • 3033666 436664 196 3470526 34f4be ./hw

28
hw Libs
  • loop ldd ./hw
  • libthread.so.1 gt
    /usr/lib/libthread.so.1
  • libj2s_runtime.so gt ...prj/suif2b/j2s/sol
    ib/libj2s_runtime.so
  • libjvm.so gt /fs/oo1/local/src/jdk1.2/
    lib/sparc/green_threads/libjvm.so
  • libjava.so gt /fs/oo1/local/src/jdk1.2/
    lib/sparc/libjava.so
  • libdl.so.1 gt /usr/lib/libdl.so.1
  • libnet.so gt /fs/oo1/local/src/jdk1.2/
    lib/sparc/libnet.so
  • libzip.so gt /fs/oo1/local/src/jdk1.2/
    lib/sparc/libzip.so
  • libmath.so gt /fs/oo1/local/src/jdk1.2/
    lib/sparc/libmath.so
  • libc.so.1 gt /usr/lib/libc.so.1
  • libw.so.1 gt /usr/lib/libw.so.1
  • libm.so.1 gt /usr/lib/libm.so.1
  • libsocket.so.1 gt
    /usr/lib/libsocket.so.1
  • libnsl.so.1 gt /usr/lib/libnsl.so.1
  • libmp.so.2 gt /usr/lib/libmp.so.2
  • /usr/platform/SUNW,Ultra-5_10/lib/libc_psr
    .so.1

29
hw Run (finally -))
  • loop ./hw
  • RTS ltclinitgt executed java/lang/System
  • RTS ltclinitgt executed java/util/Properties
  • RTS ltclinitgt executed java/io/FileInputStream
  • RTS ltclinitgt executed java/io/FileDescriptor
  • RTS ltclinitgt executed java/io/FileOutputStream
  • ...
  • RTS ltclinitgt executed java/lang/Integer
  • RTS ltclinitgt executed java/lang/ref/CachedRefere
    nce
  • RTS ltclinitgt executed java/lang/Runtime
  • RTS ltclinitgt executed java/io/BufferedWriter
  • Hello world!

30
hw Run (Stats)
  • rt_type_test_cnt 746
    checkcast_cnt 0
  • rt_checkcast_class_cnt 0
    rt_checkcast_iface_cnt 0
  • rt_checkcast_array_cnt 0
    instanceof_cnt 14
  • rt_instanceof_class_cnt 14
    rt_instanceof_iface_cnt 0
  • rt_instanceof_array_cnt 0
    rt_aastore_cnt 732
  • ci_check_cnt 1408
    rt_init_class_cnt 1382
  • Constructor_newInstance 0
    Class_newInstance_cnt 2
  • Class_forName_cnt 2
    Method_invoke_cnt 0
  • GetStaticMethodID_cnt 0
    GetMethodID_cnt 0
  • GetStaticFieldID_cnt 0
    GetFieldID_cnt 0
  • Field_set_static_cnt 0
    Field_get_static_cnt 0
  • static_field_acc_rts_cn 8
    ci_check_succeeded_cnt 14
  • rt_new_cnt 519
    rt_new_array_cnt 161
  • obj_alloc_cnt 680
    Class_bcNew_cnt 3371
  • rt_intf_lookup_cnt 0

31
Resources http//www.cs.ucsb.edu/osuif
  • The j2s User Manual
  • IL docu(osuif, osuifextension, j2s)
  • A SUIF Java Compiler, UCSB, TRCS98-18(inner
    workings of j2s partly outdated)
  • Runtime Support for a Static Java
    Compiler,Master's Thesis by Andy Rutz
Write a Comment
User Comments (0)
About PowerShow.com