Mercurial > hg > graal-jvmci-8
comparison src/share/vm/compiler/compileLog.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | c3e799c37717 |
children | cc32ccaaf47f |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "ci/ciMethod.hpp" | 26 #include "ci/ciMethod.hpp" |
27 #include "compiler/compileLog.hpp" | 27 #include "compiler/compileLog.hpp" |
28 #include "memory/allocation.inline.hpp" | 28 #include "memory/allocation.inline.hpp" |
29 #include "oops/methodOop.hpp" | 29 #include "oops/method.hpp" |
30 #include "runtime/mutexLocker.hpp" | 30 #include "runtime/mutexLocker.hpp" |
31 #include "runtime/os.hpp" | 31 #include "runtime/os.hpp" |
32 | 32 |
33 CompileLog* CompileLog::_first = NULL; | 33 CompileLog* CompileLog::_first = NULL; |
34 | 34 |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 // ------------------------------------------------------------------ | 100 // ------------------------------------------------------------------ |
101 // CompileLog::identify | 101 // CompileLog::identify |
102 int CompileLog::identify(ciObject* obj) { | 102 int CompileLog::identify(ciBaseObject* obj) { |
103 if (obj == NULL) return 0; | 103 if (obj == NULL) return 0; |
104 int id = obj->ident(); | 104 int id = obj->ident(); |
105 if (id < 0) return id; | 105 if (id < 0) return id; |
106 // If it has already been identified, just return the id. | 106 // If it has already been identified, just return the id. |
107 if (id < _identities_limit && _identities[id] != 0) return id; | 107 if (id < _identities_limit && _identities[id] != 0) return id; |
119 // Mark this id as processed. | 119 // Mark this id as processed. |
120 // (Be sure to do this before any recursive calls to identify.) | 120 // (Be sure to do this before any recursive calls to identify.) |
121 _identities[id] = 1; // mark | 121 _identities[id] = 1; // mark |
122 | 122 |
123 // Now, print the object's identity once, in detail. | 123 // Now, print the object's identity once, in detail. |
124 if (obj->is_klass()) { | 124 if (obj->is_metadata()) { |
125 ciKlass* klass = obj->as_klass(); | 125 ciMetadata* mobj = obj->as_metadata(); |
126 begin_elem("klass id='%d'", id); | 126 if (mobj->is_klass()) { |
127 name(klass->name()); | 127 ciKlass* klass = mobj->as_klass(); |
128 if (!klass->is_loaded()) { | 128 begin_elem("klass id='%d'", id); |
129 print(" unloaded='1'"); | 129 name(klass->name()); |
130 if (!klass->is_loaded()) { | |
131 print(" unloaded='1'"); | |
132 } else { | |
133 print(" flags='%d'", klass->modifier_flags()); | |
134 } | |
135 end_elem(); | |
136 } else if (mobj->is_method()) { | |
137 ciMethod* method = mobj->as_method(); | |
138 ciSignature* sig = method->signature(); | |
139 // Pre-identify items that we will need! | |
140 identify(sig->return_type()); | |
141 for (int i = 0; i < sig->count(); i++) { | |
142 identify(sig->type_at(i)); | |
143 } | |
144 begin_elem("method id='%d' holder='%d'", | |
145 id, identify(method->holder())); | |
146 name(method->name()); | |
147 print(" return='%d'", identify(sig->return_type())); | |
148 if (sig->count() > 0) { | |
149 print(" arguments='"); | |
150 for (int i = 0; i < sig->count(); i++) { | |
151 print((i == 0) ? "%d" : " %d", identify(sig->type_at(i))); | |
152 } | |
153 print("'"); | |
154 } | |
155 if (!method->is_loaded()) { | |
156 print(" unloaded='1'"); | |
157 } else { | |
158 print(" flags='%d'", (jchar) method->flags().as_int()); | |
159 // output a few metrics | |
160 print(" bytes='%d'", method->code_size()); | |
161 method->log_nmethod_identity(this); | |
162 //print(" count='%d'", method->invocation_count()); | |
163 //int bec = method->backedge_count(); | |
164 //if (bec != 0) print(" backedge_count='%d'", bec); | |
165 print(" iicount='%d'", method->interpreter_invocation_count()); | |
166 } | |
167 end_elem(); | |
168 } else if (mobj->is_type()) { | |
169 BasicType type = mobj->as_type()->basic_type(); | |
170 elem("type id='%d' name='%s'", id, type2name(type)); | |
130 } else { | 171 } else { |
131 print(" flags='%d'", klass->modifier_flags()); | 172 // Should not happen. |
173 elem("unknown id='%d'", id); | |
174 ShouldNotReachHere(); | |
132 } | 175 } |
133 end_elem(); | |
134 } else if (obj->is_method()) { | |
135 ciMethod* method = obj->as_method(); | |
136 ciSignature* sig = method->signature(); | |
137 // Pre-identify items that we will need! | |
138 identify(sig->return_type()); | |
139 for (int i = 0; i < sig->count(); i++) { | |
140 identify(sig->type_at(i)); | |
141 } | |
142 begin_elem("method id='%d' holder='%d'", | |
143 id, identify(method->holder())); | |
144 name(method->name()); | |
145 print(" return='%d'", identify(sig->return_type())); | |
146 if (sig->count() > 0) { | |
147 print(" arguments='"); | |
148 for (int i = 0; i < sig->count(); i++) { | |
149 print((i == 0) ? "%d" : " %d", identify(sig->type_at(i))); | |
150 } | |
151 print("'"); | |
152 } | |
153 if (!method->is_loaded()) { | |
154 print(" unloaded='1'"); | |
155 } else { | |
156 print(" flags='%d'", (jchar) method->flags().as_int()); | |
157 // output a few metrics | |
158 print(" bytes='%d'", method->code_size()); | |
159 method->log_nmethod_identity(this); | |
160 //print(" count='%d'", method->invocation_count()); | |
161 //int bec = method->backedge_count(); | |
162 //if (bec != 0) print(" backedge_count='%d'", bec); | |
163 print(" iicount='%d'", method->interpreter_invocation_count()); | |
164 } | |
165 end_elem(); | |
166 } else if (obj->is_symbol()) { | 176 } else if (obj->is_symbol()) { |
167 begin_elem("symbol id='%d'", id); | 177 begin_elem("symbol id='%d'", id); |
168 name(obj->as_symbol()); | 178 name(obj->as_symbol()); |
169 end_elem(); | 179 end_elem(); |
170 } else if (obj->is_null_object()) { | |
171 elem("null_object id='%d'", id); | |
172 } else if (obj->is_type()) { | |
173 BasicType type = obj->as_type()->basic_type(); | |
174 elem("type id='%d' name='%s'", id, type2name(type)); | |
175 } else { | 180 } else { |
176 // Should not happen. | 181 // Should not happen. |
177 elem("unknown id='%d'", id); | 182 elem("unknown id='%d'", id); |
178 } | 183 } |
179 return id; | 184 return id; |
295 // Just allocate a buffer and call finish_log_on_error(). | 300 // Just allocate a buffer and call finish_log_on_error(). |
296 void CompileLog::finish_log(outputStream* file) { | 301 void CompileLog::finish_log(outputStream* file) { |
297 char buf[4 * K]; | 302 char buf[4 * K]; |
298 finish_log_on_error(file, buf, sizeof(buf)); | 303 finish_log_on_error(file, buf, sizeof(buf)); |
299 } | 304 } |
305 | |
306 // ------------------------------------------------------------------ | |
307 // CompileLog::inline_success | |
308 // | |
309 // Print about successful method inlining. | |
310 void CompileLog::inline_success(const char* reason) { | |
311 begin_elem("inline_success reason='"); | |
312 text(reason); | |
313 end_elem("'"); | |
314 } | |
315 | |
316 // ------------------------------------------------------------------ | |
317 // CompileLog::inline_fail | |
318 // | |
319 // Print about failed method inlining. | |
320 void CompileLog::inline_fail(const char* reason) { | |
321 begin_elem("inline_fail reason='"); | |
322 text(reason); | |
323 end_elem("'"); | |
324 } | |
325 | |
326 // ------------------------------------------------------------------ | |
327 // CompileLog::set_context | |
328 // | |
329 // Set XML tag as an optional marker - it is printed only if | |
330 // there are other entries after until it is reset. | |
331 void CompileLog::set_context(const char* format, ...) { | |
332 va_list ap; | |
333 va_start(ap, format); | |
334 clear_context(); | |
335 _context.print("<"); | |
336 _context.vprint(format, ap); | |
337 _context.print_cr("/>"); | |
338 va_end(ap); | |
339 } | |
340 | |
341 // ------------------------------------------------------------------ | |
342 // CompileLog::code_cache_state | |
343 // | |
344 // Print code cache state. | |
345 void CompileLog::code_cache_state() { | |
346 begin_elem("code_cache"); | |
347 CodeCache::log_state(this); | |
348 end_elem(""); | |
349 } |