org.jikesrvm.compilers.opt.inlining
Class InvalidationDatabase

java.lang.Object
  extended by org.jikesrvm.compilers.opt.inlining.InvalidationDatabase

public final class InvalidationDatabase
extends Object

This class holds the dependencies that define invalidation requirements for the opt compiled methods.

Currently we only support 2 kinds of dependencies: The set of compiled method id's that depend on a RVMMethod not being overridden. The set of compiled method id's that depend on a RVMClass having no subclasses

Note we track by compiled method ids instead of pointers to compiled methods because we don't have weak pointers. We don't want the invalidaton database to keep code alive! This would be an ideal use of weak references if we had them.

TODO: In the future, we should think about implementing a general dependency mechanism. See Chambers, Dean, Grove in ICSE-17 (1995) for one possible design and pointers to related work.


Nested Class Summary
(package private) static class InvalidationDatabase.MethodSet
          The following defines a set of methods that share a common "key"
 
Field Summary
private  HashMapRVM<RVMMethod,InvalidationDatabase.MethodSet> nonOverriddenHash
          A mapping from RVMMethod to MethodSet: holds the set of methods which depend on a particular method being "final"
private  HashMapRVM<RVMClass,InvalidationDatabase.MethodSet> noSubclassHash
          A mapping from RVMClass to MethodSet: holds the set of methods which depend on a particular class being "final"
 
Constructor Summary
InvalidationDatabase()
           
 
Method Summary
 void addNoSubclassDependency(RVMClass source, int dependent_cmid)
          Record that if a particular RVMClass ever has a subclass, then the CompiledMethod encoded by the cmid must be invalidated.
 void addNotOverriddenDependency(RVMMethod source, int dependent_cmid)
          Record that if a particular RVMMethod method is ever overridden, then the CompiledMethod encoded by the cmid must be invalidated.
private
<T> InvalidationDatabase.MethodSet
findOrCreateMethodSet(HashMapRVM<T,InvalidationDatabase.MethodSet> hash, T key)
          Look up the MethodSet corresponding to a given key in the database.
 Iterator<Integer> invalidatedByOverriddenMethod(RVMMethod m)
          Returns an iteration of CMID's (compiled method ids) that are dependent on the argument RVMMethod not being overridden.
 Iterator<Integer> invalidatedBySubclass(RVMClass m)
          Returns an iteration of CMID's (compiled method ids) that are dependent on the argument RVMMethod not having any subclasses.
 void removeNoSubclassDependency(RVMClass source)
          Delete all NoSubclass dependencies on the argument RVMClass
 void removeNoSubclassDependency(RVMClass source, int dependent_cmid)
          Delete a NoSubclassDependency.
 void removeNotOverriddenDependency(RVMMethod source)
          Delete all NotOverridden dependencies on the argument RVMMethod
 void removeNotOverriddenDependency(RVMMethod source, int dependent_cmid)
          Delete a NotOverriddenDependency.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nonOverriddenHash

private final HashMapRVM<RVMMethod,InvalidationDatabase.MethodSet> nonOverriddenHash
A mapping from RVMMethod to MethodSet: holds the set of methods which depend on a particular method being "final"


noSubclassHash

private final HashMapRVM<RVMClass,InvalidationDatabase.MethodSet> noSubclassHash
A mapping from RVMClass to MethodSet: holds the set of methods which depend on a particular class being "final"

Constructor Detail

InvalidationDatabase

public InvalidationDatabase()
Method Detail

invalidatedByOverriddenMethod

public Iterator<Integer> invalidatedByOverriddenMethod(RVMMethod m)
Returns an iteration of CMID's (compiled method ids) that are dependent on the argument RVMMethod not being overridden. If there are no dependent methods, null will be returned.

NOTE: null is used instead of EmptyIterator.getInstance as part of delicate dance to avoid recursive classloading.

Parameters:
m - a method that can be overridden
Returns:
an iterator of CMIDs or null

addNotOverriddenDependency

public void addNotOverriddenDependency(RVMMethod source,
                                       int dependent_cmid)
Record that if a particular RVMMethod method is ever overridden, then the CompiledMethod encoded by the cmid must be invalidated.


removeNotOverriddenDependency

public void removeNotOverriddenDependency(RVMMethod source,
                                          int dependent_cmid)
Delete a NotOverriddenDependency. No effect if the dependency doesn't exist..


removeNotOverriddenDependency

public void removeNotOverriddenDependency(RVMMethod source)
Delete all NotOverridden dependencies on the argument RVMMethod


invalidatedBySubclass

public Iterator<Integer> invalidatedBySubclass(RVMClass m)
Returns an iteration of CMID's (compiled method ids) that are dependent on the argument RVMMethod not having any subclasses. If there are no dependent methods, null will be returned.

NOTE: null is used instead of EmptyIterator.getInstance as part of delicate dance to avoid recursive classloading.

Parameters:
m - a method that can be overridden
Returns:
an iterator of CMIDs or null

addNoSubclassDependency

public void addNoSubclassDependency(RVMClass source,
                                    int dependent_cmid)
Record that if a particular RVMClass ever has a subclass, then the CompiledMethod encoded by the cmid must be invalidated.


removeNoSubclassDependency

public void removeNoSubclassDependency(RVMClass source,
                                       int dependent_cmid)
Delete a NoSubclassDependency. No effect if the dependency doesn't exist..


removeNoSubclassDependency

public void removeNoSubclassDependency(RVMClass source)
Delete all NoSubclass dependencies on the argument RVMClass


findOrCreateMethodSet

private <T> InvalidationDatabase.MethodSet findOrCreateMethodSet(HashMapRVM<T,InvalidationDatabase.MethodSet> hash,
                                                                 T key)
Look up the MethodSet corresponding to a given key in the database. If none found, create one.