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 017 /** 018 * Hold semantic information about a method that is not defined in 019 * RVMMethod. 020 */ 021 class MethodSummary { 022 023 /** 024 * Is this method currently being analyzed? Used for recursive 025 * invocations of the optimizing compiler. 026 */ 027 private static boolean inProgress = false; 028 029 /** 030 * Default escape result, that the result escapes but that no parameter is 031 * escaping. 032 */ 033 private static final long RES_ESCAPE = 0x80000000; 034 035 /** 036 * Escape result, top bit is result of the method bits 0..63 are for 037 * parameters 0..63 respectively 038 */ 039 private long escapeInfo = RES_ESCAPE; 040 041 /** 042 * @param m RVMMethod representing this method. 043 */ 044 MethodSummary(RVMMethod m) { } 045 046 /** 047 * Record that a parameter may or may not escape from a thread. 048 * 049 * @param p the number of the parameter 050 * @param b may it escape? 051 */ 052 public void setParameterMayEscapeThread(int p, boolean b) { 053 if (p > 62) return; // all params past 62 escape! 054 long mask = 1L << p; 055 if (b) { 056 escapeInfo |= mask; 057 } else { 058 escapeInfo &= (~mask); 059 } 060 } 061 062 /** 063 * Query whether a parameter may escape from a thread. 064 * @param p the number of the parameter 065 * @return false iff the parameter <em> must not </em> escape from the 066 * thread. true otherwise. 067 */ 068 public boolean parameterMayEscapeThread(int p) { 069 if (p > 62) return true; // all params past 62 escape! 070 long mask = 1L << p; 071 return (escapeInfo & mask) != 0; 072 } 073 074 /** 075 * Record that a result of this method may or may not escape from a thread. 076 * 077 * @param b may it escape? 078 */ 079 public void setResultMayEscapeThread(boolean b) { 080 if (b) { 081 escapeInfo |= RES_ESCAPE; 082 } else { 083 escapeInfo &= ~RES_ESCAPE; 084 } 085 } 086 087 /** 088 * Query whether the result of this method may escape from a thread. 089 * @return {@code false} iff the parameter <em> must not </em> escape from the 090 * thread. true otherwise. 091 */ 092 public boolean resultMayEscapeThread() { 093 return (escapeInfo & RES_ESCAPE) != 0L; 094 } 095 096 /** 097 * Is analysis of this method in progress? 098 */ 099 public boolean inProgress() { 100 return inProgress; 101 } 102 103 /** 104 * Mark that analysis of this method is or is not in progress. 105 * @param b 106 */ 107 public void setInProgress(boolean b) { 108 inProgress = b; 109 } 110 }