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 java.util.HashMap;
016 import org.jikesrvm.compilers.opt.ir.Register;
017
018 /**
019 * This class holds the results of a flow-insensitive escape analysis
020 * for a method.
021 */
022 class FI_EscapeSummary {
023
024 /**
025 * Returns true iff ANY object pointed to by symbolic register r
026 * MUST be thread local
027 */
028 boolean isThreadLocal(Register r) {
029 Object result = hash.get(r);
030 return result != null && result == THREAD_LOCAL;
031 }
032
033 /**
034 * Returns true iff ANY object pointed to by symbolic register r
035 * MUST be method local
036 */
037 boolean isMethodLocal(Register r) {
038 Object result = hash2.get(r);
039 return result != null && result == METHOD_LOCAL;
040 }
041
042 /**
043 * record the fact that ALL object pointed to by symbolic register r
044 * MUST (or may) escape this thread
045 */
046 void setThreadLocal(Register r, boolean b) {
047 if (b) {
048 hash.put(r, THREAD_LOCAL);
049 } else {
050 hash.put(r, MAY_ESCAPE_THREAD);
051 }
052 }
053
054 /**
055 * Record the fact that ALL object pointed to by symbolic register r
056 * MUST (or may) escape this method
057 */
058 void setMethodLocal(Register r, boolean b) {
059 if (b) {
060 hash2.put(r, METHOD_LOCAL);
061 } else {
062 hash2.put(r, MAY_ESCAPE_METHOD);
063 }
064 }
065
066 /* Implementation */
067 /**
068 * A mapping that holds the analysis result for thread-locality for each
069 * Register.
070 */
071 private final HashMap<Register, Object> hash = new HashMap<Register, Object>();
072
073 /**
074 * A mapping that holds the analysis result for method-locality for each
075 * Register.
076 */
077 private final HashMap<Register, Object> hash2 = new HashMap<Register, Object>();
078
079 /**
080 * Static object used to represent analysis result
081 */
082 static final Object THREAD_LOCAL = new Object();
083 /**
084 * Static object used to represent analysis result
085 */
086 static final Object MAY_ESCAPE_THREAD = new Object();
087 /**
088 * Static object used to represent analysis result
089 */
090 static final Object METHOD_LOCAL = new Object();
091 /**
092 * Static object used to represent analysis result
093 */
094 static final Object MAY_ESCAPE_METHOD = new Object();
095 }
096
097
098