annotate src/os/windows/vm/vtune_windows.cpp @ 1375:e0a1a502e402 jdk7-b91

Added tag jdk7-b90 for changeset 605c9707a766
author mikejwre
date Thu, 22 Apr 2010 16:54:23 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_vtune_windows.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 static int current_method_ID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // ------------- iJITProf.h -------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // defined by Intel -- do not change
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 #include "windows.h"
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 enum iJITP_Event {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 ExceptionOccurred_S, // Java exception
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ExceptionOccurred_IDS,
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 Shutdown, // VM exit
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 ThreadCreate, // threads
a61af66fc99e Initial load
duke
parents:
diff changeset
43 ThreadDestroy,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ThreadSwitch,
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 ClassLoadStart, // class loading
a61af66fc99e Initial load
duke
parents:
diff changeset
47 ClassLoadEnd,
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 GCStart, // GC
a61af66fc99e Initial load
duke
parents:
diff changeset
50 GCEnd,
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 NMethodCreate = 13, // nmethod creation
a61af66fc99e Initial load
duke
parents:
diff changeset
53 NMethodDelete
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // rest of event types omitted (call profiling not supported yet)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 };
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // version number -- 0 if VTune not installed
a61af66fc99e Initial load
duke
parents:
diff changeset
59 int WINAPI iJitP_VersionNumber();
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 enum iJITP_ModeFlags {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 NoNotification = 0x0, // don't call vtune
a61af66fc99e Initial load
duke
parents:
diff changeset
63 NotifyNMethodCreate = 0x1, // notify NMethod_Create
a61af66fc99e Initial load
duke
parents:
diff changeset
64 NotifyNMethodDelete = 0x2, // notify NMethod_Create
a61af66fc99e Initial load
duke
parents:
diff changeset
65 NotifyMethodEnter = 0x4, // method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
66 NotifyMethodExit = 0x8, // method exit
a61af66fc99e Initial load
duke
parents:
diff changeset
67 NotifyShutdown = 0x10, // VM exit
a61af66fc99e Initial load
duke
parents:
diff changeset
68 NotifyGC = 0x20, // GC
a61af66fc99e Initial load
duke
parents:
diff changeset
69 };
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // call back function type
a61af66fc99e Initial load
duke
parents:
diff changeset
72 typedef void (WINAPI *ModeChangedFn)(iJITP_ModeFlags flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // ------------- VTune method interfaces ----------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
75 typedef void (WINAPI *RegisterCallbackFn)(ModeChangedFn fn); // register callback
a61af66fc99e Initial load
duke
parents:
diff changeset
76 typedef int (WINAPI *NotifyEventFn)(iJITP_Event, void* event_data);
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // specific event data structures
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // data for NMethodCreate
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 struct VTuneObj { // base class for allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // (can't use CHeapObj -- has vtable ptr)
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void* operator new(size_t size) { return os::malloc(size); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void operator delete(void* p) { fatal("never delete VTune data"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 };
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 struct LineNumberInfo : VTuneObj { // PC-to-line number mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
89 unsigned long offset; // byte offset from start of method
a61af66fc99e Initial load
duke
parents:
diff changeset
90 unsigned long line_num; // corresponding line number
a61af66fc99e Initial load
duke
parents:
diff changeset
91 };
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 struct MethodLoadInfo : VTuneObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 unsigned long methodID; // unique method ID
a61af66fc99e Initial load
duke
parents:
diff changeset
95 const char* name; // method name
a61af66fc99e Initial load
duke
parents:
diff changeset
96 unsigned long instr_start; // start address
a61af66fc99e Initial load
duke
parents:
diff changeset
97 unsigned long instr_size; // length in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
98 unsigned long line_number_size; // size of line number table
a61af66fc99e Initial load
duke
parents:
diff changeset
99 LineNumberInfo* line_number_table; // line number mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
100 unsigned long classID; // unique class ID
a61af66fc99e Initial load
duke
parents:
diff changeset
101 char* class_file_name; // fully qualified class file name
a61af66fc99e Initial load
duke
parents:
diff changeset
102 char* source_file_name; // fully qualified source file name
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 MethodLoadInfo(nmethod* nm); // for real nmethods
a61af66fc99e Initial load
duke
parents:
diff changeset
105 MethodLoadInfo(const char* vm_name, address start, address end);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // for "nmethods" like stubs, interpreter, etc
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 };
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // data for NMethodDelete
a61af66fc99e Initial load
duke
parents:
diff changeset
111 struct MethodInfo : VTuneObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 unsigned long methodID; // unique method ID
a61af66fc99e Initial load
duke
parents:
diff changeset
113 unsigned long classID; // (added for convenience -- not part of Intel interface)
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 MethodInfo(methodOop m);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 };
a61af66fc99e Initial load
duke
parents:
diff changeset
117 };
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 MethodInfo::MethodInfo(methodOop m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // just give it a new ID -- we're not compiling methods twice (usually)
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // (and even if we did, one might want to see the two versions separately)
a61af66fc99e Initial load
duke
parents:
diff changeset
122 methodID = ++current_method_ID;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 MethodLoadInfo::MethodLoadInfo(const char* vm_name, address start, address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 classID = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 methodID = ++current_method_ID;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 name = vm_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 instr_start = (unsigned long)start;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 instr_size = end - start;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 line_number_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 line_number_table = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 class_file_name = source_file_name = "HotSpot JVM";
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 MethodLoadInfo::MethodLoadInfo(nmethod* nm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 methodOop m = nm->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 MethodInfo info(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 classID = info.classID;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 methodID = info.methodID;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 name = strdup(m->name()->as_C_string());
a61af66fc99e Initial load
duke
parents:
diff changeset
142 instr_start = (unsigned long)nm->instructions_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 instr_size = nm->code_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 line_number_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 line_number_table = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 klassOop kl = m->method_holder();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 char* class_name = Klass::cast(kl)->name()->as_C_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 char* file_name = NEW_C_HEAP_ARRAY(char, strlen(class_name) + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 strcpy(file_name, class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 class_file_name = file_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 char* src_name = NEW_C_HEAP_ARRAY(char, strlen(class_name) + strlen(".java") + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 strcpy(src_name, class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 strcat(src_name, ".java");
a61af66fc99e Initial load
duke
parents:
diff changeset
154 source_file_name = src_name;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // --------------------- DLL loading functions ------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 #define DLLNAME "iJitProf.dll"
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 static HINSTANCE load_lib(char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 HINSTANCE lib = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 HKEY hk;
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // try to get VTune directory from the registry
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (RegOpenKey(HKEY_CURRENT_USER, "Software\\VB and VBA Program Settings\\VTune\\StartUp", &hk) == ERROR_SUCCESS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 for (int i = 0; true; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 char szName[MAX_PATH + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
169 char szVal [MAX_PATH + 1];
a61af66fc99e Initial load
duke
parents:
diff changeset
170 DWORD cbName, cbVal;
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 cbName = cbVal = MAX_PATH + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 if (RegEnumValue(hk, i, szName, &cbName, NULL, NULL, (LPBYTE)szVal, &cbVal) == ERROR_SUCCESS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // get VTune directory
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (!strcmp(szName, name)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 char*p = szVal;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 while (*p == ' ') p++; // trim
a61af66fc99e Initial load
duke
parents:
diff changeset
178 char* q = p + strlen(p) - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 while (*q == ' ') *(q--) = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // chdir to the VTune dir
a61af66fc99e Initial load
duke
parents:
diff changeset
182 GetCurrentDirectory(MAX_PATH + 1, szName);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 SetCurrentDirectory(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // load lib
a61af66fc99e Initial load
duke
parents:
diff changeset
185 lib = LoadLibrary(strcat(strcat(p, "\\"), DLLNAME));
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (lib != NULL && WizardMode) tty->print_cr("*loaded VTune DLL %s", p);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // restore current dir
a61af66fc99e Initial load
duke
parents:
diff changeset
188 SetCurrentDirectory(szName);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return lib;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 static RegisterCallbackFn iJIT_RegisterCallback = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 static NotifyEventFn iJIT_NotifyEvent = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 static bool load_iJIT_funcs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // first try to load from PATH
a61af66fc99e Initial load
duke
parents:
diff changeset
204 HINSTANCE lib = LoadLibrary(DLLNAME);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 if (lib != NULL && WizardMode) tty->print_cr("*loaded VTune DLL %s via PATH", DLLNAME);
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // if not successful, try to look in the VTUNE directory
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if (lib == NULL) lib = load_lib("VTUNEDIR30");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 if (lib == NULL) lib = load_lib("VTUNEDIR25");
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (lib == NULL) lib = load_lib("VTUNEDIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (lib == NULL) return false; // unsuccessful
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // try to load the functions
a61af66fc99e Initial load
duke
parents:
diff changeset
215 iJIT_RegisterCallback = (RegisterCallbackFn)GetProcAddress(lib, "iJIT_RegisterCallback");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 iJIT_NotifyEvent = (NotifyEventFn) GetProcAddress(lib, "iJIT_NotifyEvent");
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 if (!iJIT_RegisterCallback) tty->print_cr("*couldn't find VTune entry point iJIT_RegisterCallback");
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (!iJIT_NotifyEvent) tty->print_cr("*couldn't find VTune entry point iJIT_NotifyEvent");
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return iJIT_RegisterCallback != NULL && iJIT_NotifyEvent != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // --------------------- VTune class ------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 static bool active = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 static int flags = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void VTune::start_GC() {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if (active && (flags & NotifyGC)) iJIT_NotifyEvent(GCStart, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 void VTune::end_GC() {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (active && (flags & NotifyGC)) iJIT_NotifyEvent(GCEnd, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void VTune::start_class_load() {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // not yet implemented in VTune
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 void VTune::end_class_load() {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // not yet implemented in VTune
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void VTune::exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (active && (flags & NotifyShutdown)) iJIT_NotifyEvent(Shutdown, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void VTune::register_stub(const char* name, address start, address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 if (flags & NotifyNMethodCreate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 MethodLoadInfo* info = new MethodLoadInfo(name, start, end);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 if (PrintMiscellaneous && WizardMode && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 tty->print_cr("NMethodCreate %s (%d): %#x..%#x", info->name, info->methodID,
a61af66fc99e Initial load
duke
parents:
diff changeset
253 info->instr_start, info->instr_start + info->instr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 iJIT_NotifyEvent(NMethodCreate, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 void VTune::create_nmethod(nmethod* nm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (flags & NotifyNMethodCreate) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 MethodLoadInfo* info = new MethodLoadInfo(nm);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if (PrintMiscellaneous && WizardMode && Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 tty->print_cr("NMethodCreate %s (%d): %#x..%#x", info->name, info->methodID,
a61af66fc99e Initial load
duke
parents:
diff changeset
264 info->instr_start, info->instr_start + info->instr_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 iJIT_NotifyEvent(NMethodCreate, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 void VTune::delete_nmethod(nmethod* nm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 if (flags & NotifyNMethodDelete) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 MethodInfo* info = new MethodInfo(nm->method());
a61af66fc99e Initial load
duke
parents:
diff changeset
273 iJIT_NotifyEvent(NMethodDelete, info);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 static void set_flags(int new_flags) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 flags = new_flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // if (WizardMode) tty->print_cr("*new VTune flags: %#x", flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 void vtune_init() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (!UseVTune) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 active = load_iJIT_funcs();
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (active) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 iJIT_RegisterCallback((ModeChangedFn)set_flags);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 assert(flags == 0, "flags shouldn't be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }