Static Analyser Design

Michael Hope <michaelh@juju.net.nz>

April 28, 2002

Abstract: This document describes the Static Analyser in Jaune, a ahead of time compiler for Java class files. The purpose of the Static Analyser is to optimise the output for code size and speed by computing what methods and classes can be created and by computing which virtual calls can be made statically instead. As a side effect, the Static Analyser also provides the support methods required for Jaune such as absolute method numbers.

This document is incomplete. The static analyser was deemed too complicated for a 1.0 release.

1  Rules

It is hard to detect and inhibit the class field initialisation code for fields that are initialised but not used.

2  Algorithim

The interface and overrides rules above require the interface implementors list and overriders list to be computed ahead of time or the algorithm to be run iteratively. Choose a tree based scan, so we need to compute the lists first.

2.1  Setup

Compute the implementors list. The implementors list is the list of all classes that implement a given interface. Compute the overriders list. The overriders list is the list of all methods that override a given method.

2.2  Scan

2.3  Method scan

2.4  Class scan

This set of rules describes how to scan a new class.

2.5  Invoke Virtual

This set of rules describes how to scan a normal virtual method that is invoked.

2.6  Invoke Static

2.7  Invoke Interface


1
A static method can be obscured but cannot be overridden.

This document was translated from LATEX by HEVEA.