Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/win32_x86/Win32X86JavaThreadPDAccess.java @ 17736:58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
Reviewed-by: tschatzl, pliden
author | brutisso |
---|---|
date | Fri, 14 Mar 2014 10:15:46 +0100 |
parents | 43badbe2717a |
children |
rev | line source |
---|---|
0 | 1 /* |
7974 | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.runtime.win32_x86; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.debugger.x86.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 import sun.jvm.hotspot.runtime.x86.*; | |
33 import sun.jvm.hotspot.types.*; | |
34 import sun.jvm.hotspot.utilities.*; | |
35 | |
36 /** This class is only public to allow using the VMObjectFactory to | |
37 instantiate these. | |
38 */ | |
39 | |
40 public class Win32X86JavaThreadPDAccess implements JavaThreadPDAccess { | |
41 private static AddressField lastJavaFPField; | |
42 private static AddressField osThreadField; | |
43 | |
44 // Field from OSThread | |
7974 | 45 private static Field osThreadThreadIdField; |
0 | 46 |
47 // This is currently unneeded but is being kept in case we change | |
48 // the currentFrameGuess algorithm | |
49 private static final long GUESS_SCAN_RANGE = 128 * 1024; | |
50 | |
51 static { | |
52 VM.registerVMInitializedObserver(new Observer() { | |
53 public void update(Observable o, Object data) { | |
54 initialize(VM.getVM().getTypeDataBase()); | |
55 } | |
56 }); | |
57 } | |
58 | |
59 private static synchronized void initialize(TypeDataBase db) { | |
60 Type type = db.lookupType("JavaThread"); | |
61 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
62 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | |
63 osThreadField = type.getAddressField("_osthread"); | |
64 | |
65 type = db.lookupType("OSThread"); | |
7974 | 66 osThreadThreadIdField = type.getField("_thread_id"); |
0 | 67 } |
68 | |
69 public Address getLastJavaFP(Address addr) { | |
70 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | |
71 } | |
72 | |
73 public Address getLastJavaPC(Address addr) { | |
74 return null; | |
75 } | |
76 | |
77 public Address getBaseOfStackPointer(Address addr) { | |
78 return null; | |
79 } | |
80 | |
81 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
82 Address fp = thread.getLastJavaFP(); | |
83 if (fp == null) { | |
84 return null; // no information | |
85 } | |
86 Address pc = thread.getLastJavaPC(); | |
87 if ( pc != null ) { | |
88 return new X86Frame(thread.getLastJavaSP(), fp, pc); | |
89 } else { | |
90 return new X86Frame(thread.getLastJavaSP(), fp); | |
91 } | |
92 } | |
93 | |
94 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
95 return new X86RegisterMap(thread, updateMap); | |
96 } | |
97 | |
98 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
99 ThreadProxy t = getThreadProxy(addr); | |
100 X86ThreadContext context = (X86ThreadContext) t.getContext(); | |
101 X86CurrentFrameGuess guesser = new X86CurrentFrameGuess(context, thread); | |
102 if (!guesser.run(GUESS_SCAN_RANGE)) { | |
103 return null; | |
104 } | |
105 if (guesser.getPC() == null) { | |
106 return new X86Frame(guesser.getSP(), guesser.getFP()); | |
107 } else { | |
108 return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); | |
109 } | |
110 } | |
111 | |
112 public void printThreadIDOn(Address addr, PrintStream tty) { | |
113 tty.print(getThreadProxy(addr)); | |
114 } | |
115 | |
116 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
117 } | |
118 | |
119 public Address getLastSP(Address addr) { | |
120 ThreadProxy t = getThreadProxy(addr); | |
121 X86ThreadContext context = (X86ThreadContext) t.getContext(); | |
122 return context.getRegisterAsAddress(X86ThreadContext.ESP); | |
123 } | |
124 | |
125 public ThreadProxy getThreadProxy(Address addr) { | |
126 // Addr is the address of the JavaThread. | |
127 // Fetch the OSThread (for now and for simplicity, not making a | |
128 // separate "OSThread" class in this package) | |
129 Address osThreadAddr = osThreadField.getValue(addr); | |
7974 | 130 // Get the address of the thread_id within the OSThread |
131 Address threadIdAddr = | |
132 osThreadAddr.addOffsetTo(osThreadThreadIdField.getOffset()); | |
0 | 133 JVMDebugger debugger = VM.getVM().getDebugger(); |
7974 | 134 return debugger.getThreadForIdentifierAddress(threadIdAddr); |
0 | 135 } |
136 } |