170 likes | 255 Views
OSUIF: SUIF For Objects Urs H ölzle Holger Kienle UCSB. OSUIF In A Nutshell. extends SUIF IL to better support OO languages provides standard OO optimization passes tests SUIF2 extensibility model. Extending SUIF2 For OOPLS. symbol table support for classes, inheritance, methods
E N D
OSUIF In A Nutshell • extends SUIF IL to better support OO languages • provides standard OO optimization passes • tests SUIF2 extensibility model
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, ...
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
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
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)
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 extensibleSUIF --> OSUIF --> Java_OSUIF
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; };
Compilation of Hoof specs osuif.hoof osuif.h (Interface) smgn osuif.cc (Implementation) osuif_factory.h (Node Creation) osuif_forwarders.h
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; };
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 );
Three Forms Of Extensibility • example: add Java access control (public / protected / private) • SUIF Annotation • string-attributes in InstanceMethodSymbol • subclassing from InstanceMethodSymbol
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 );
Extensibility: String-attributes concrete InstanceMethodSymbol : ProcedureSymbol { searchable_list<LString> attributes; ... }; InstanceMethodSymbol* ims = create_instance_method_symbol( ... ), ims->append_attribute( "protected" ):
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 );
OSUIF Components • New IR Nodesosuifosuifextensions (single inheritance)j2s (Java)cpp_osuif (C++)
OSUIF Components (cont'd) • passes • OSUIF -> SUIF ("lowering") • SUIF -> OSUIF ("raising") • v-table construction (single inheritance) • layout of instance fields (single inheritance) • miscellaneous: • typebuilder for MethodType • utilities for convenient IR node creation/manipulation