8
OPTIMIZATION OPTIMIZATION FRAMEWORK METHODS OF OPTIMIZATION 1. Code Relay out 2. Method In lining 3. Optimizing Virtual Method Calls 4. Multiversioning and Specialization 5. On Stack Replacement 6. Optimization of Heap Allocated Objects 7. Low Level Optimizations 8. Optimizing Garbage Collection 1

Optimization

Embed Size (px)

Citation preview

Page 1: Optimization

1

OPTIMIZATIONOPTIMIZATION FRAMEWORKMETHODS OF OPTIMIZATION

1. Code Relay out2. Method In lining3. Optimizing Virtual Method Calls4. Multiversioning and Specialization5. On Stack Replacement 6. Optimization of Heap Allocated Objects7. Low Level Optimizations8. Optimizing Garbage Collection

Page 2: Optimization

2

1. OPTIMIZATION FRAMEWORK The Framework for optimization is universal Any step in the framework can be skipped

Page 3: Optimization

3

2. METHODS OF OPTIMIZATIONCODE RELAY OUT This method straightens the code The code of basic blocks and most commonly followed control paths are in contiguous locations in memory

METHOD IN LINING All HLLs supports method inlining Large sized methods threatens inlining resulting in poor cache performance Profiling is incorporated Methods with high profile value are often inlined Profile value is found by 2 ways,

» Call graph» Stack frame

Page 4: Optimization

4

OPTIMIZING VIRTUAL METHOD CALLS Usually all HLLs supports virtual methods VMs enhances runtime polymorphism invokevirtual method in JVM and PIC helps in optimizing virtual method calls VMs having high profile values are inlined

Page 5: Optimization

5

MULTIVERSIONING AND SPECIALIZATION This method includes two versions of code to achieve optimization One version is inlined by method inlining Another version is dealt with invokevirtual instruction Specialized code is one used instead of more complex code In the below example B[i] is specialized code.

Page 6: Optimization

6

ON-STACK REPLACEMENTTwo types of Stacks are maintained namely,

– Architected Stack (Traditional Stack)– Implementation Stack (Optimized)

Methods in Architected Stack are replaced and inlined in implementation stack

Page 7: Optimization

7

OPTIMIZATION OF HEAP ALLOCATED OBJECTS Objects in the program are stored in Heap Memory Only way of optimization of Objects is to decide to whether the object to be created or not Reducing the number of objects created increases optimization Objects in the program can be replaced by scalar values

In the below example object is replaced by scalars….

Page 8: Optimization

8

LOW LEVEL OPTIMIZATION It includes optimizations in Arrays and Pointers In arrays range violation is great problem and it can be reduced by periodic checking or array index Uninitialized pointers are also monitored periodically

OPTIMIZING GARBAGE COLLECTION Yield Point