OSUIF (morning talk)

Download Report

Transcript OSUIF (morning talk)

OSUIF: SUIF For Objects
Urs Hölzle
Holger Kienle
UCSB
1
OSUIF In A Nutshell
• extends SUIF IL to better support OO
languages
• provides standard OO optimization passes
• tests SUIF2 extensibility model
2
Extending SUIF2 For OOPLS
• symbol table
– support for classes, inheritance, methods
– support for incomplete types (transitive closure
problem)
• method calls
– hide exact dispatch sequence
• future: exceptions, garbage collection, ...
3
Utility Passes
• OSUIF -> SUIF
–
–
–
–
build-vtables: virtual tables
lower-instance-variables: layout of class-types
lower-methods: method dispatch
lower-static-fields, lower-static-methods: put
static in global scope
4
Example Front-End: Java
• Java byte code -> OSUIF (Solaris)
– class loading, resolution of the constant pool
– control flow analysis (normal and exception
handling)
– data flow analysis (construct type information)
– OSUIF code generation
• no threads, exception handling
• run-time system: optimized for clarity
5
Current Status
• included in SUIF release
• more at http://www.cs.ucsb.edu/~osuif
• tested on SPARC/Solaris
– works with Sun JDK
– successfully ran most SPECjvm98 programs in
the past (currently less stable)
6
OSUIF Extensions To SUIF
• test of how easy it is to extend SUIF
• no “privileged access”: what we did for
OSUIF, any SUIF user can do
• OSUIF itself is designed to be similarly
extensible
SUIF --> OSUIF --> Java_OSUIF
7
Example: Methods, Not
Procedures
Hoof specification:
concrete InstanceMethodSymbol : ProcedureSymbol {
searchable_list<LString> attributes;
ClassType * reference owning_class omitted;
bool is_dispatched default {true};
InstanceMethodSymbol * reference
overridden_method omitted;
};
8
Compilation of Hoof specs
osuif.hoof
osuif.h
smgn
osuif.cc
(Interface)
(Implementation)
osuif_factory.h
(Node Creation)
osuif_forwarders.h
9
smgn-Generated Code: osuif.h
class InstanceMethodSymbol : public ProcedureSymbol {
public:
// searchable_list<LString> attributes;
void append_attribute(const LString & key);
Iter<LString > get_attribute_iterator() const;
void remove_attribute(const LString & key);
bool has_attribute_member(const LString & key);
int get_attribute_count() const;
virtual void insert_attribute(int pos,const LString & x);
// ClassType * reference owning_class omitted;
virtual ClassType* get_owning_class () const;
virtual void set_owning_class(ClassType* the_value);
...
private:
searchable_list<LString> _attributes;
ClassType* _owning_class;
bool _is_dispatched;
InstanceMethodSymbol* _overridden_method;
};
10
smgn-Generated Code:
osuif_factory.h
InstanceMethodSymbol*
create_instance_method_symbol (
SuifEnv * env,
ProcedureType* type,
const LString & name = emptyLString,
bool is_address_taken = false,
ProcedureDefinition* definition = 0,
bool is_dispatched = true );
11
Three Forms Of Extensibility
• example: add Java access control
(public / protected / private)
• SUIF Annotation
• string-attributes in
InstanceMethodSymbol
• subclassing from InstanceMethodSymbol
12
Extensibility: SUIF Annotations
concrete AccessAnnote : GeneralAnnote {
bool is_public default {false};
bool is_protected default {false};
bool is_private default {false};
};
InstanceMethodSymbol* ims =
create_instance_method_symbol ( ... ),
AccessAnnote* annote =
create_access_annote( ..., false, true, false );
ims -> append_annote( annote );
13
Extensibility: String-attributes
concrete InstanceMethodSymbol : ProcedureSymbol {
searchable_list<LString> attributes;
...
};
InstanceMethodSymbol* ims =
create_instance_method_symbol( ... ),
ims->append_attribute( "protected" ):
14
Extensibility: Subclassing
concrete JavaInstanceMethodSymbol :
InstanceMethodSymbol {
bool is_public default {false};
bool is_protected default {false};
bool is_private default {false};
};
JavaInstanceMethodSymbol* jims =
create_java_instance_method_symbol
( ..., false, true, false );
15
OSUIF Components
• New IR Nodes
osuif
osuifextensions (single inheritance)
j2s
(Java)
cpp_osuif
(C++)
16
OSUIF Components (cont'd)
• passes
–
–
–
–
OSUIF -> SUIF
SUIF -> OSUIF
v-table construction
layout of instance fields
("lowering")
("raising")
(single inheritance)
(single inheritance)
• miscellaneous:
– typebuilder for MethodType
– utilities for convenient IR node
creation/manipulation
17