Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStackFrameReference.java @ 16529:f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 15 Jul 2014 16:34:53 -0700 |
parents | 36e1a11a72b3 |
children | a8cff27ca2e1 |
rev | line source |
---|---|
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
1 /* |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
4 * |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
8 * |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
14 * |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
18 * |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
21 * questions. |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
22 */ |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
24 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
26 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.api.code.stack.*; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.hotspot.bridge.*; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.hotspot.meta.*; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
31 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
32 public class HotSpotStackFrameReference implements InspectedFrame { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
33 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
34 private CompilerToVM compilerToVM; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
35 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
36 // information used to find the stack frame |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
37 private long stackPointer; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
38 private int frameNumber; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
39 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
40 // information about the stack frame's contents |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
41 private int bci; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
42 private long metaspaceMethod; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
43 private Object[] locals; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
44 private boolean[] localIsVirtual; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
45 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
46 public long getStackPointer() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
47 return stackPointer; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
48 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
49 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
50 public int getFrameNumber() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
51 return frameNumber; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
52 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
53 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
54 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
55 public Object getLocal(int index) { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
56 return locals[index]; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
57 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
58 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
59 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
60 public boolean isVirtual(int index) { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
61 return localIsVirtual == null ? false : localIsVirtual[index]; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
62 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
63 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
64 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
65 public void materializeVirtualObjects(boolean invalidateCode) { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
66 compilerToVM.materializeVirtualObjects(this, invalidateCode); |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
67 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
68 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
69 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
70 public int getBytecodeIndex() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
71 return bci; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
72 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
73 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
74 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
75 public ResolvedJavaMethod getMethod() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
76 return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
77 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
78 |
16529
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
79 @Override |
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
80 public boolean isMethod(ResolvedJavaMethod method) { |
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
81 return metaspaceMethod == ((HotSpotResolvedJavaMethod) method).getMetaspaceMethod(); |
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
82 } |
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
83 |
f6ac86d3334e
Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15063
diff
changeset
|
84 @Override |
15063
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
85 public boolean hasVirtualObjects() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
86 return localIsVirtual != null; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
87 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
88 |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
89 @Override |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
90 public String toString() { |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
91 return "HotSpotStackFrameReference [stackPointer=" + stackPointer + ", frameNumber=" + frameNumber + ", bci=" + bci + ", method=" + getMethod() + ", locals=" + Arrays.toString(locals) + |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
92 ", localIsVirtual=" + Arrays.toString(localIsVirtual) + "]"; |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
93 } |
36e1a11a72b3
new StackIntrospection interface to allow access to stack contents
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff
changeset
|
94 } |