001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.compilers.opt.escape;
014    
015    import org.jikesrvm.classloader.RVMMethod;
016    import org.jikesrvm.util.ImmutableEntryHashMapRVM;
017    
018    /**
019     * Class that holds method summary information.
020     * This class is a Singleton.
021     *
022     * <p> This database holds summaries:
023     *  <ul>
024     *   <li>MethodSummary, indexed by RVMMethod
025     *  </ul>
026     */
027    class SummaryDatabase {
028      /**
029       * Lookup a given method in the database
030       *
031       * @return MethodSummary instance representing method
032       */
033      public static synchronized MethodSummary findMethodSummary(RVMMethod m) {
034        return hash.get(m);
035      }
036    
037      public static synchronized MethodSummary findOrCreateMethodSummary(RVMMethod m) {
038        MethodSummary result = findMethodSummary(m);
039        if (result == null) {
040          result = new MethodSummary(m);
041          hash.put(m, result);
042        }
043        return result;
044      }
045    
046      /* Implementation */
047      private static final ImmutableEntryHashMapRVM<RVMMethod, MethodSummary> hash =
048        new ImmutableEntryHashMapRVM<RVMMethod, MethodSummary>();
049    }