comparison jvmci/com.oracle.jvmci.code/src/com/oracle/jvmci/code/DebugInfo.java @ 21798:395ac43a8578

moved JVMCI sources from graal/ to jvmci/ directory
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 00:22:49 +0200
parents graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/DebugInfo.java@f5b549811bac
children
comparison
equal deleted inserted replaced
21797:42452d2dfbec 21798:395ac43a8578
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.jvmci.code;
24
25 import com.oracle.jvmci.meta.Value;
26 import java.util.*;
27
28 /**
29 * Represents the debugging information for a particular point of execution. This information
30 * includes:
31 * <ul>
32 * <li>a {@linkplain #getBytecodePosition() bytecode position}</li>
33 * <li>a reference map for registers and stack slots in the current frame</li>
34 * <li>a map from bytecode locals and operand stack slots to their values or locations from which
35 * their values can be read</li>
36 * <li>a map from the registers (in the caller's frame) to the slots where they are saved in the
37 * current frame</li>
38 * </ul>
39 */
40 public final class DebugInfo {
41
42 private final BytecodePosition bytecodePosition;
43 private final ReferenceMap referenceMap;
44 @SuppressWarnings("unused") private final Value[] virtualObjectMapping;
45 private RegisterSaveLayout calleeSaveInfo;
46
47 /**
48 * Creates a new {@link DebugInfo} from the given values.
49 *
50 * @param codePos the {@linkplain BytecodePosition code position} or {@linkplain BytecodeFrame
51 * frame} info
52 * @param referenceMap the reference map
53 * @param virtualObjectMapping the mapping of {@link VirtualObject}s to their real values
54 */
55 public DebugInfo(BytecodePosition codePos, ReferenceMap referenceMap, Value[] virtualObjectMapping) {
56 this.bytecodePosition = codePos;
57 this.referenceMap = referenceMap;
58 this.virtualObjectMapping = virtualObjectMapping;
59 }
60
61 public DebugInfo(BytecodePosition codePos) {
62 this(codePos, null, null);
63 }
64
65 /**
66 * @return {@code true} if this debug information has a frame
67 */
68 public boolean hasFrame() {
69 return getBytecodePosition() instanceof BytecodeFrame;
70 }
71
72 /**
73 * Gets the deoptimization information for each inlined frame (if available).
74 *
75 * @return {@code null} if no frame de-opt info is {@linkplain #hasFrame() available}
76 */
77 public BytecodeFrame frame() {
78 if (hasFrame()) {
79 return (BytecodeFrame) getBytecodePosition();
80 }
81 return null;
82 }
83
84 @Override
85 public String toString() {
86 return CodeUtil.append(new StringBuilder(100), this, null).toString();
87 }
88
89 /**
90 * @return The code position (including all inlined methods) of this debug info. If this is a
91 * {@link BytecodeFrame} instance, then it is also the deoptimization information for
92 * each inlined frame.
93 */
94 public BytecodePosition getBytecodePosition() {
95 return bytecodePosition;
96 }
97
98 public ReferenceMap getReferenceMap() {
99 return referenceMap;
100 }
101
102 /**
103 * Sets the map from the registers (in the caller's frame) to the slots where they are saved in
104 * the current frame.
105 */
106 public void setCalleeSaveInfo(RegisterSaveLayout calleeSaveInfo) {
107 this.calleeSaveInfo = calleeSaveInfo;
108 }
109
110 /**
111 * Gets the map from the registers (in the caller's frame) to the slots where they are saved in
112 * the current frame. If no such information is available, {@code null} is returned.
113 */
114 public RegisterSaveLayout getCalleeSaveInfo() {
115 return calleeSaveInfo;
116 }
117
118 @Override
119 public int hashCode() {
120 throw new UnsupportedOperationException("hashCode");
121 }
122
123 @Override
124 public boolean equals(Object obj) {
125 if (this == obj) {
126 return true;
127 }
128 if (obj instanceof DebugInfo) {
129 DebugInfo that = (DebugInfo) obj;
130 if (Objects.equals(this.bytecodePosition, that.bytecodePosition) && Objects.equals(this.calleeSaveInfo, that.calleeSaveInfo) && Objects.equals(this.referenceMap, that.referenceMap)) {
131 return true;
132 }
133 }
134 return false;
135 }
136 }