Mercurial > hg > graal-compiler
comparison graal/com.oracle.max.cri/src/com/sun/cri/ci/CiCodePos.java @ 3733:e233f5660da4
Added Java files from Maxine project.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 19:59:18 +0100 |
parents | |
children | bc8527f3071c |
comparison
equal
deleted
inserted
replaced
3732:3e2e8b8abdaf | 3733:e233f5660da4 |
---|---|
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.cri.ci; | |
24 | |
25 import java.io.*; | |
26 | |
27 import com.sun.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 * The position where this position has been called, {@code null} if none. | |
38 */ | |
39 public final CiCodePos caller; | |
40 | |
41 /** | |
42 * The runtime interface method for this position. | |
43 */ | |
44 public final RiResolvedMethod method; | |
45 | |
46 /** | |
47 * The location within the method, as a bytecode index. The constant | |
48 * {@code -1} may be used to indicate the location is unknown, for example | |
49 * within code synthesized by the compiler. | |
50 */ | |
51 public final int bci; | |
52 | |
53 /** | |
54 * Constructs a new object representing a given parent/caller, a given method, and a given BCI. | |
55 * | |
56 * @param caller the parent position | |
57 * @param method the method | |
58 * @param bci a BCI within the method | |
59 */ | |
60 public CiCodePos(CiCodePos caller, RiResolvedMethod method, int bci) { | |
61 assert method != null; | |
62 this.caller = caller; | |
63 this.method = method; | |
64 this.bci = bci; | |
65 } | |
66 | |
67 /** | |
68 * Converts this code position to a string representation. | |
69 * @return a string representation of this code position | |
70 */ | |
71 @Override | |
72 public String toString() { | |
73 return CiUtil.append(new StringBuilder(100), this).toString(); | |
74 } | |
75 | |
76 /** | |
77 * Deep equality test. | |
78 */ | |
79 @Override | |
80 public boolean equals(Object obj) { | |
81 if (obj == this) { | |
82 return true; | |
83 } | |
84 if (obj instanceof CiCodePos) { | |
85 CiCodePos other = (CiCodePos) obj; | |
86 if (other.method.equals(method) && other.bci == bci) { | |
87 if (caller == null) { | |
88 return other.caller == null; | |
89 } | |
90 return caller.equals(other.caller); | |
91 } | |
92 } | |
93 return false; | |
94 } | |
95 | |
96 @Override | |
97 public int hashCode() { | |
98 return bci; | |
99 } | |
100 } |