Osuif a closer look
Download
1 / 31

OSUIF: A Closer Look - PowerPoint PPT Presentation


  • 144 Views
  • Uploaded on

OSUIF: A Closer Look. Holger Kienle UCSB http://www.cs.ucsb.edu/~osuif. OSUIF: The Basic Idea. thin layer on top of SUIF for OO languages -> extension of SUIF IR nodes lowering OSUIF -> SUIF set of basic passes client (e.g., C++/Java front end/extension) has to extend OSUIF skeleton.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'OSUIF: A Closer Look' - dunne


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
Osuif a closer look l.jpg

OSUIF: A Closer Look

Holger KienleUCSBhttp://www.cs.ucsb.edu/~osuif


Osuif the basic idea l.jpg
OSUIF: The Basic Idea

  • thin layer on top of SUIF for OO languages -> extension of SUIF IR nodes

  • lowering OSUIF -> SUIF

  • set of basic passes

  • client (e.g., C++/Java front end/extension) has to extend OSUIF skeleton


Language independence l.jpg
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)


Language independence cont l.jpg
Language Independence (cont.)

  • design goal:put only language-independent parts in OSUIF; rest in front end / lowering

  • example:OSUIF has inheritance links but leaves semantics to be implemented by front end (abstract lookup() method)


Osuif ir extensions 1 l.jpg
OSUIF IR Extensions (1)

new constructs:

  • classes and inheritance

  • methods and fields (static and instance)

  • method calls(dispatching and non-dispatching)

  • (exception-handling)


Osuif ir extensions 2 l.jpg
OSUIF IR Extensions (2)

DataType

GroupType

StructType

ClassType

SingleInheritanceClassType

  • encapsulates methods and fields

  • symbol table interface


Osuif ir extensions 3 l.jpg
OSUIF IR Extensions (3)

SuifObject

AnnotableObject

InheritanceLink

  • models relationships between classes

  • first-class entity


Osuif ir extensions 4 l.jpg
OSUIF IR Extensions (4)

ProcedureSymbol VariableSymbol

InstanceMethodSymbol FieldSymbol

StaticMethodSymbolInstanceFieldSymbol

StaticFieldSymbol

  • reference to owning class

  • LString attributes(e.g., to model access modifiers)


Osuif ir extensions 5 l.jpg
OSUIF IR Extensions (5)

Statement

CallStatement

InstanceMethodCallStatement

StaticMethodCallStatement

  • static and instance methods(this-ref vs. no this-ref)

  • dispatching vs. non-dispatching calls


Instancemethodcallstatement l.jpg
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


Lowering and raising l.jpg
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!


Lowering passes 1 l.jpg
Lowering Passes (1)

  • lower_osuif_symbols-lower-instance-methods-lower-static-fields-lower-static-methods-lower-per-class-symbol-table-symtab external|file_set|file_block|one-up-mangle-name <how>-ignore-lowering-name-annote

  • lower_static_method_call_expressions


Lowering passes 2 l.jpg
Lowering Passes (2)

  • layout_single_inheritance_instance_fields-mangle-name <how>-ignore-lowering-name-annote

  • build_single_inheritance_vtbl-construct-vtbls-attach-vtbl-slot-number-annotes-ignore-no-vtbl-annote


Osuif passes l.jpg
OSUIF passes

  • use "as is" (default behavior)-> command line switches

  • front-end controls behavior of pass with SUIF annotations

  • customize pass via C++ subclassing


Osuif front ends l.jpg
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


J2s goals l.jpg
j2s Goals

  • full Java support for off-line compilation

  • provide a good platform forOO/Java-related compiler research


J2s caveats l.jpg
j2s Caveats

  • compiles class files

  • has its own runtime system (SPARC only!)

    • JNI

    • reflection

    • class initialization

    • ...

  • requires Java 1.2beta2


J2s caveats cont d l.jpg
j2s Caveats (cont'd)

restrictions:

  • exception-handling

  • threads and synchronization

  • dynamic loading of classes

  • accurate GC

  • floating-point computations


J2s environment l.jpg
j2s Environment

Java .class file

j2s

OSUIF

Transformations

(OSUIF and j2s)

OSUIF

OSUIF Lowering

SUIF

SUIF

Compiler System


J2s compilation l.jpg
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


J2s compilation link step l.jpg
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


J2s osuif extensions l.jpg
j2s OSUIF extensions

ClassType

SingleInheritanceClassType

JavaAbstractClassType

JavaClass

JavaInterface

JavaArray

  • distinguished Java constructs

  • tiny layer on top of OSUIF


J2s status l.jpg
j2s Status

  • generates C code (s2c)

  • running applications:

    • javac (538 classes)

    • SPECjvm98 benchmarks:

      • _201_compress

      • _202_db

      • _202_jess


How to get started l.jpg
How to get started...

  • "The j2s User Manual"

    • restrictions

    • modified class files

    • setup

      • $J2SHOME and $PATH

      • $JAVAHOME and $JVMCLASSPATH

      • $LD_LIBRARY_PATH


How to get started 2 l.jpg
How to get started... (2)

  • compilation process (jmake)>jmake Helloworldbuilds Makefile.deps (dependencies)

  • user-customized MakefileTARGETNAME = hwCCFLAGS = -o2...include $J2SHOME/Makefile.driver.confinclude Makefile.deps


Helloworld java l.jpg
HelloWorld.java

public class HelloWorld

{

public static void main(String[] args)

{

System.out.println("Hello world!");

}

}


Hw stats l.jpg
hw Stats

loop% size ./hw

text data bss dec hex filename

3033666 436664 196 3470526 34f4be ./hw


Hw libs l.jpg
hw Libs

loop% ldd ./hw

libthread.so.1 => /usr/lib/libthread.so.1

libj2s_runtime.so => ...prj/suif2b/j2s/solib/libj2s_runtime.so

libjvm.so => /fs/oo1/local/src/jdk1.2/lib/sparc/green_threads/libjvm.so

libjava.so => /fs/oo1/local/src/jdk1.2/lib/sparc/libjava.so

libdl.so.1 => /usr/lib/libdl.so.1

libnet.so => /fs/oo1/local/src/jdk1.2/lib/sparc/libnet.so

libzip.so => /fs/oo1/local/src/jdk1.2/lib/sparc/libzip.so

libmath.so => /fs/oo1/local/src/jdk1.2/lib/sparc/libmath.so

libc.so.1 => /usr/lib/libc.so.1

libw.so.1 => /usr/lib/libw.so.1

libm.so.1 => /usr/lib/libm.so.1

libsocket.so.1 => /usr/lib/libsocket.so.1

libnsl.so.1 => /usr/lib/libnsl.so.1

libmp.so.2 => /usr/lib/libmp.so.2

/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1


Hw run finally l.jpg
hw Run (finally ;-))

loop% ./hw

RTS: <clinit> executed: java/lang/System

RTS: <clinit> executed: java/util/Properties

RTS: <clinit> executed: java/io/FileInputStream

RTS: <clinit> executed: java/io/FileDescriptor

RTS: <clinit> executed: java/io/FileOutputStream

...

RTS: <clinit> executed: java/lang/Integer

RTS: <clinit> executed: java/lang/ref/CachedReference

RTS: <clinit> executed: java/lang/Runtime

RTS: <clinit> executed: java/io/BufferedWriter

Hello world!


Hw run stats l.jpg
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: 680Class_bcNew_cnt: 3371

rt_intf_lookup_cnt: 0


Resources http www cs ucsb edu osuif l.jpg
Resourceshttp://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


ad