/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "ci/ciMethod.hpp"
#include "compiler/compileLog.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/methodOop.hpp"
#include "runtime/mutexLocker.hpp"
// ------------------------------------------------------------------
// CompileLog::CompileLog
{
_file_end = 0;
_identities_limit = 0;
_identities_capacity = 400;
// link into the global list
_first = this;
}
}
CompileLog::~CompileLog() {
delete _out;
}
// Advance kind up to a null or space, return this tail.
// Make sure kind is null-terminated, not space-terminated.
// Use the buffer if necessary.
// Tease apart the first word from the rest:
return ""; // no attrs, no split
((char*) attrs)[-1] = 0;
return attrs;
} else {
// park it in the buffer, so we can put a null on the end
return attrs;
}
}
// see_tag, pop_tag: Override the default do-nothing methods on xmlStream.
// These methods provide a hook for managing the the extra context markup.
}
}
}
// ------------------------------------------------------------------
// CompileLog::identify
// If it has already been identified, just return the id.
// Lengthen the array, if necessary.
if (id >= _identities_capacity) {
}
while (id >= _identities_limit) {
_identities[_identities_limit++] = 0;
}
// Mark this id as processed.
// (Be sure to do this before any recursive calls to identify.)
// Now, print the object's identity once, in detail.
print(" unloaded='1'");
} else {
}
end_elem();
// Pre-identify items that we will need!
}
begin_elem("method id='%d' holder='%d'",
print(" arguments='");
}
print("'");
}
print(" unloaded='1'");
} else {
// output a few metrics
method->log_nmethod_identity(this);
//print(" count='%d'", method->invocation_count());
//int bec = method->backedge_count();
//if (bec != 0) print(" backedge_count='%d'", bec);
}
end_elem();
end_elem();
} else if (obj->is_null_object()) {
} else {
// Should not happen.
}
return id;
}
print(" name='");
print("'");
}
// ------------------------------------------------------------------
// CompileLog::clear_identities
// Forget which identities have been printed.
_identities_limit = 0;
}
// ------------------------------------------------------------------
// CompileLog::finish_log_on_error
//
// Note: This function is called after fatal error, avoid unnecessary memory
// or stack allocation, use only async-safe functions. It's possible JVM is
// only partially initialized.
static bool called_exit = false;
if (called_exit) return;
called_exit = true;
if (partial_fd != -1) {
// strings, here we use snprintf() and print_raw() instead.
// Copy data up to the end of the last <event> element:
while (to_read > 0) {
if (nr <= 0) break;
}
// Copy any remaining data inside a quote:
bool saw_slop = false;
if (!saw_slop) {
saw_slop = true;
}
// The rest of this loop amounts to a simple copy operation:
// { file->write(buf, nr); }
// However, it must sometimes output the buffer in parts,
// in case there is a CDATA quote embedded in the fragment.
// Write up to any problematic CDATA delimiter (usually all of nr).
// First, scan ahead into the buf, checking the state machine.
case ']':
continue; // keep scanning
case '>':
// else fall through:
default:
end_cdata = 0;
continue; // keep scanning
}
// If we get here, nw is pointing at a bad '>'.
// It is very rare for this to happen.
// However, this code has been tested by introducing
// CDATA sequences into the compilation log.
break;
}
// Now nw is the number of characters to write, usually == nr.
// We are about to go around the loop again.
// But first, disrupt the ]]> by closing and reopening the quote.
end_cdata = 0; // reset state machine
}
}
}
if (saw_slop) {
}
}
}
}
// ------------------------------------------------------------------
// CompileLog::finish_log
//
// Called during normal shutdown. For now, any clean-up needed in normal
// shutdown is also needed in VM abort, so is covered by finish_log_on_error().
// Just allocate a buffer and call finish_log_on_error().
}
// ------------------------------------------------------------------
// CompileLog::inline_success
//
// Print about successful method inlining.
begin_elem("inline_success reason='");
end_elem("'");
}
// ------------------------------------------------------------------
// CompileLog::inline_fail
//
// Print about failed method inlining.
begin_elem("inline_fail reason='");
end_elem("'");
}
// ------------------------------------------------------------------
// CompileLog::set_context
//
// Set XML tag as an optional marker - it is printed only if
// there are other entries after until it is reset.
}
// ------------------------------------------------------------------
// CompileLog::code_cache_state
//
// Print code cache state.
begin_elem("code_cache");
end_elem("");
}