April 8 Lecture Outline Notes Characteristics of modern OO languages, e.g., Java. - Two kinds of types Primitive types (boolean; signed integers (8,16,32,64 bits); char (16 bit unicode); float (32, 64 bits)) - correspond to machine hardware (mostly; floating point can be problematic) Object types (Java: "reference" types) classes arrays strings interfaces - Review of objects (in Java) Fields Methods Inheritance via extension and overriding Virtual functions Interfaces: a limited form of multiple inheritance 'final' modifier instanceof operator reflection - Consequences of Object-orientation (in general) many small functions & indirect function calls calls are inherently expensive unknown calls are more so inability to inline unknown calls inhibits many more optimizations so, can we inline? lots of heap allocation; can it be avoided via object inlining, stack allocation? late binding of methods: can multiple inheritance be made efficient? - Consequences of Java's safety and portability properties No dangling pointers => garbage collection: how cheap can it be? Bad things (from compiler's perspective!): - array bounds checks (expensive) - instanceof checks (expensive) Good things - memory layout completely hidden from user; allows lots of flexibility! - local variables and object fields can't be modified except by direct assignment Some compromises remain - e.g., can still get null pointer violations (quite common) - Exceptions require runtime system support 'precise' property inhibit optimization - Multi-threaded (thread creation, synchronization) requires runtime system support can we avoid synchonization overhead? precise memory model introduces portability issues, inhibits optimization - Dynamic class loading requires runtime validation inhibits optimization