comparison graal/Compiler/src/com/sun/c1x/lir/LIRDebugInfo.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, 2010, 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.lir;
24
25 import java.util.*;
26
27 import com.sun.c1x.*;
28 import com.sun.c1x.ir.*;
29 import com.sun.c1x.value.*;
30 import com.sun.cri.ci.*;
31
32 /**
33 * This class represents debugging and deoptimization information attached to a LIR instruction.
34 *
35 * @author Marcelo Cintra
36 * @author Thomas Wuerthinger
37 * @author Ben L. Titzer
38 */
39 public class LIRDebugInfo {
40
41 public abstract static class ValueLocator {
42 public abstract CiValue getLocation(Value value);
43 }
44
45 public final FrameState state;
46 public final List<ExceptionHandler> exceptionHandlers;
47 public CiDebugInfo debugInfo;
48
49 public LIRDebugInfo(FrameState state, List<ExceptionHandler> exceptionHandlers) {
50 assert state != null;
51 this.state = state;
52 this.exceptionHandlers = exceptionHandlers;
53 }
54
55 private LIRDebugInfo(LIRDebugInfo info) {
56 this.state = info.state;
57
58 // deep copy of exception handlers
59 if (info.exceptionHandlers != null) {
60 this.exceptionHandlers = new ArrayList<ExceptionHandler>(info.exceptionHandlers.size());
61 for (ExceptionHandler h : info.exceptionHandlers) {
62 this.exceptionHandlers.add(new ExceptionHandler(h));
63 }
64 } else {
65 this.exceptionHandlers = null;
66 }
67 }
68
69 public LIRDebugInfo copy() {
70 return new LIRDebugInfo(this);
71 }
72
73 public void setOop(CiValue location, C1XCompilation compilation, CiBitMap frameRefMap, CiBitMap regRefMap) {
74 CiTarget target = compilation.target;
75 if (location.isAddress()) {
76 CiAddress stackLocation = (CiAddress) location;
77 assert stackLocation.index.isIllegal();
78 if (stackLocation.base == CiRegister.Frame.asValue()) {
79 int offset = stackLocation.displacement;
80 assert offset % target.wordSize == 0 : "must be aligned";
81 int stackMapIndex = offset / target.wordSize;
82 setBit(frameRefMap, stackMapIndex);
83 }
84 } else if (location.isStackSlot()) {
85 CiStackSlot stackSlot = (CiStackSlot) location;
86 assert !stackSlot.inCallerFrame();
87 assert target.spillSlotSize == target.wordSize;
88 setBit(frameRefMap, stackSlot.index());
89 } else {
90 assert location.isRegister() : "objects can only be in a register";
91 CiRegisterValue registerLocation = (CiRegisterValue) location;
92 int reg = registerLocation.reg.number;
93 assert reg >= 0 : "object cannot be in non-object register " + registerLocation.reg;
94 assert reg < target.arch.registerReferenceMapBitCount;
95 setBit(regRefMap, reg);
96 }
97 }
98
99 public CiDebugInfo debugInfo() {
100 assert debugInfo != null : "debug info not allocated yet";
101 return debugInfo;
102 }
103
104 public boolean hasDebugInfo() {
105 return debugInfo != null;
106 }
107
108 public static void setBit(CiBitMap refMap, int bit) {
109 assert !refMap.get(bit) : "Ref map entry " + bit + " is already set.";
110 refMap.set(bit);
111 }
112
113 @Override
114 public String toString() {
115 return state.toString();
116 }
117 }