Mercurial > hg > graal-compiler
comparison graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiCodePos.java @ 4199:aaac4894175c
Renamed cri packages from sun to oracle.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 03 Jan 2012 16:29:28 +0100 |
parents | graal/com.oracle.max.cri/src/com/sun/cri/ci/CiCodePos.java@bc8527f3071c |
children | 51111665eda6 |
comparison
equal
deleted
inserted
replaced
4198:8c9c0e1eaab1 | 4199:aaac4894175c |
---|---|
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.oracle.max.cri.ci; | |
24 | |
25 import java.io.*; | |
26 | |
27 import com.oracle.max.cri.ri.*; | |
28 | |
29 /** | |
30 * Represents a code position, that is, a chain of inlined methods with bytecode | |
31 * locations, that is communicated from the compiler to the runtime system. A code position | |
32 * can be used by the runtime system to reconstruct a source-level stack trace | |
33 * for exceptions and to create {@linkplain CiFrame frames} for deoptimization. | |
34 */ | |
35 public class CiCodePos implements Serializable { | |
36 /** | |
37 * | |
38 */ | |
39 private static final long serialVersionUID = 8633885274526033515L; | |
40 | |
41 /** | |
42 * The position where this position has been called, {@code null} if none. | |
43 */ | |
44 public final CiCodePos caller; | |
45 | |
46 /** | |
47 * The runtime interface method for this position. | |
48 */ | |
49 public final RiResolvedMethod method; | |
50 | |
51 /** | |
52 * The location within the method, as a bytecode index. The constant | |
53 * {@code -1} may be used to indicate the location is unknown, for example | |
54 * within code synthesized by the compiler. | |
55 */ | |
56 public final int bci; | |
57 | |
58 /** | |
59 * Constructs a new object representing a given parent/caller, a given method, and a given BCI. | |
60 * | |
61 * @param caller the parent position | |
62 * @param method the method | |
63 * @param bci a BCI within the method | |
64 */ | |
65 public CiCodePos(CiCodePos caller, RiResolvedMethod method, int bci) { | |
66 assert method != null; | |
67 this.caller = caller; | |
68 this.method = method; | |
69 this.bci = bci; | |
70 } | |
71 | |
72 /** | |
73 * Converts this code position to a string representation. | |
74 * @return a string representation of this code position | |
75 */ | |
76 @Override | |
77 public String toString() { | |
78 return CiUtil.append(new StringBuilder(100), this).toString(); | |
79 } | |
80 | |
81 /** | |
82 * Deep equality test. | |
83 */ | |
84 @Override | |
85 public boolean equals(Object obj) { | |
86 if (obj == this) { | |
87 return true; | |
88 } | |
89 if (obj instanceof CiCodePos) { | |
90 CiCodePos other = (CiCodePos) obj; | |
91 if (other.method.equals(method) && other.bci == bci) { | |
92 if (caller == null) { | |
93 return other.caller == null; | |
94 } | |
95 return caller.equals(other.caller); | |
96 } | |
97 } | |
98 return false; | |
99 } | |
100 | |
101 @Override | |
102 public int hashCode() { | |
103 return bci; | |
104 } | |
105 } |