Mercurial > hg > truffle
comparison graal/Compiler/src/com/sun/c1x/ir/IRScope.java @ 2507:9ec15d6914ca
Pull over of compiler from maxine repository.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:43:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2506:4a3bf8a5bf41 | 2507:9ec15d6914ca |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.c1x.ir; | |
24 | |
25 import com.sun.c1x.value.*; | |
26 import com.sun.cri.ci.*; | |
27 import com.sun.cri.ri.*; | |
28 | |
29 /** | |
30 * The {@code IRScope} class represents an inlining context in the compilation | |
31 * of a method. | |
32 * | |
33 * @author Ben L. Titzer | |
34 */ | |
35 public class IRScope { | |
36 | |
37 public final IRScope caller; | |
38 public final RiMethod method; | |
39 public final int level; | |
40 CiCodePos callerCodePos; | |
41 | |
42 /** | |
43 * The frame state at the call site of this scope's caller or {@code null} | |
44 * if this is not a nested scope. | |
45 */ | |
46 public final FrameState callerState; | |
47 | |
48 /** | |
49 * The maximum number of locks held in this scope at any one time | |
50 * (c.f. maxStack and maxLocals of the Code attribute in a class file). | |
51 */ | |
52 int maxLocks; | |
53 | |
54 CiBitMap storesInLoops; | |
55 | |
56 public IRScope(IRScope caller, FrameState callerState, RiMethod method, int osrBCI) { | |
57 this.caller = caller; | |
58 this.callerState = callerState; | |
59 this.method = method; | |
60 this.level = caller == null ? 0 : 1 + caller.level; | |
61 } | |
62 | |
63 /** | |
64 * Updates the maximum number of locks held in this scope at any one time. | |
65 * | |
66 * @param locks a lock count that will replace the current {@linkplain #maxLocks() max locks} for this scope if it is greater | |
67 */ | |
68 public void updateMaxLocks(int locks) { | |
69 if (locks > maxLocks) { | |
70 maxLocks = locks; | |
71 } | |
72 } | |
73 | |
74 /** | |
75 * Gets the number of locks in this IR scope. | |
76 * @return the number of locks | |
77 */ | |
78 public final int maxLocks() { | |
79 return maxLocks; | |
80 } | |
81 | |
82 /** | |
83 * Gets the bytecode index of the call site that called this method. | |
84 * @return the call site's bytecode index | |
85 */ | |
86 public final int callerBCI() { | |
87 return callerState == null ? -1 : callerState.bci; | |
88 } | |
89 | |
90 /** | |
91 * Returns whether this IR scope is the top scope (i.e. has no caller). | |
92 * @return {@code true} if this inlining scope has no parent | |
93 */ | |
94 public final boolean isTopScope() { | |
95 return caller == null; | |
96 } | |
97 | |
98 /** | |
99 * Gets the phi bitmap for this IR scope. The phi bitmap stores | |
100 * whether a phi instruction is required for each local variable. | |
101 * @return the phi bitmap for this IR scope | |
102 */ | |
103 public final CiBitMap getStoresInLoops() { | |
104 return storesInLoops; | |
105 } | |
106 | |
107 public final void setStoresInLoops(CiBitMap storesInLoops) { | |
108 this.storesInLoops = storesInLoops; | |
109 } | |
110 | |
111 @Override | |
112 public String toString() { | |
113 if (caller == null) { | |
114 return "root-scope: " + method; | |
115 } else { | |
116 return "inlined-scope: " + method + " [caller bci: " + callerState.bci + "]"; | |
117 } | |
118 } | |
119 | |
120 public CiCodePos callerCodePos() { | |
121 if (caller != null && callerCodePos == null) { | |
122 callerCodePos = caller.toCodePos(callerBCI()); | |
123 } | |
124 return callerCodePos; | |
125 } | |
126 | |
127 public CiCodePos toCodePos(int bci) { | |
128 return new CiCodePos(callerCodePos(), method, bci); | |
129 } | |
130 } |