Mercurial > hg > graal-compiler
diff src/share/vm/trace/traceEventClasses.xsl @ 10405:f2110083203d
8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author | sla |
---|---|
date | Mon, 10 Jun 2013 11:30:51 +0200 |
parents | |
children | 042cf42c72bd |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/trace/traceEventClasses.xsl Mon Jun 10 11:30:51 2013 +0200 @@ -0,0 +1,246 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + + This code is free software; you can redistribute it and/or modify it + 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. +--> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> +<xsl:output method="text" indent="no" omit-xml-declaration="yes"/> +<xsl:import href="xsl_util.xsl"/> + +<xsl:template match="/"> + <xsl:call-template name="file-header"/> + +#ifndef TRACEFILES_TRACEEVENTCLASSES_HPP +#define TRACEFILES_TRACEEVENTCLASSES_HPP + +// On purpose outside the INCLUDE_TRACE +// Some parts of traceEvent.hpp are used outside of +// INCLUDE_TRACE + +#include "memory/resourceArea.hpp" +#include "tracefiles/traceTypes.hpp" +#include "trace/traceEvent.hpp" +#include "utilities/macros.hpp" + +#if INCLUDE_TRACE + + +#include "trace/traceStream.hpp" +#include "utilities/ostream.hpp" + + <xsl:apply-templates select="trace/events/struct" mode="trace"/> + <xsl:apply-templates select="trace/events/event" mode="trace"/> + +#else + +class TraceEvent { +public: + TraceEvent() {} + void set_starttime(jlong time) const {} + void set_endtime(jlong time) const {} + bool should_commit() const { return false; } + void commit() const {} +}; + + <xsl:apply-templates select="trace/events/struct" mode="empty"/> + <xsl:apply-templates select="trace/events/event" mode="empty"/> + +#endif + +#endif +</xsl:template> + +<xsl:template match="struct" mode="trace"> +struct TraceStruct<xsl:value-of select="@id"/> +{ +private: +<xsl:apply-templates select="value" mode="write-fields"/> +public: +<xsl:apply-templates select="value" mode="write-setters"/> + + void writeStruct(TraceStream& ts) { +<xsl:apply-templates select="value" mode="write-data"/> + } +}; + +</xsl:template> + +<xsl:template match="struct" mode="empty"> +struct TraceStruct<xsl:value-of select="@id"/> +{ +public: +<xsl:apply-templates select="value" mode="write-empty-setters"/> +}; +</xsl:template> + + +<xsl:template match="event" mode="empty"> + <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent')"/> +{ + public: +<xsl:value-of select="concat(' Event', @id, '(bool ignore=true) {}')"/> +<xsl:text> +</xsl:text> + +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-empty-setters"/> +}; + +</xsl:template> + + +<xsl:template match="event" mode="trace"> + <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent<Event', @id, '>')"/> +{ + public: + static const bool hasThread = <xsl:value-of select="@has_thread"/>; + static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>; + static const bool isInstant = <xsl:value-of select="@is_instant"/>; + static const bool isRequestable = <xsl:value-of select="@is_requestable"/>; + static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>; + + private: +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/> + + void writeEventContent(void) { + TraceStream ts(*tty); + ts.print("<xsl:value-of select="@label"/>: ["); +<xsl:apply-templates select="value|structvalue" mode="write-data"/> + ts.print("]\n"); + } + + public: +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/> + + bool should_write(void) { + return true; + } +<xsl:text> + +</xsl:text> + <xsl:value-of select="concat(' Event', @id, '(EventStartTime timing=TIMED) : TraceEvent<Event', @id, '>(timing) {}', $newline)"/> + void writeEvent(void) { + ResourceMark rm; + if (UseLockedTracing) { + ttyLocker lock; + writeEventContent(); + } else { + writeEventContent(); + } + } +}; + +</xsl:template> + +<xsl:template match="value|transition_value|relation" mode="write-empty-setters"> + <xsl:param name="cls"/> + <xsl:variable name="type" select="@type"/> + <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/> + <xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { }')"/> + <xsl:if test="position() != last()"> + <xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="structvalue" mode="write-empty-setters"> + <xsl:param name="cls"/> + <xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '& value) { }')"/> + <xsl:if test="position() != last()"> + <xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + + +<xsl:template match="value[@type='TICKS']" mode="write-setters"> +#if INCLUDE_TRACE + <xsl:value-of select="concat('void set_', @field, '(jlong time) { _', @field, ' = time; }')"/> +#else + <xsl:value-of select="concat('void set_', @field, '(jlong ignore) {}')"/> +#endif +</xsl:template> + +<xsl:template match="value[@type='RELATIVE_TICKS']" mode="write-setters"> +#if INCLUDE_TRACE + <xsl:value-of select="concat('void set_', @field, '(jlong time) { _', @field, ' = time; }')"/> +#else + <xsl:value-of select="concat('void set_', @field, '(jlong ignore) {}')"/> +#endif +</xsl:template> + +<xsl:template match="value" mode="write-fields"> + <xsl:variable name="type" select="@type"/> + <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/> + <xsl:value-of select="concat(' ', $wt, ' _', @field, ';')"/> + <xsl:if test="position() != last()"> + <xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="structvalue" mode="write-fields"> + <xsl:value-of select="concat(' TraceStruct', @type, ' _', @field, ';')"/> + <xsl:text> +</xsl:text> +</xsl:template> + +<xsl:template match="value|transition_value|relation" mode="write-setters"> + <xsl:param name="cls"/> + <xsl:variable name="type" select="@type"/> + <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/> + <xsl:value-of select="concat(' void set_', @field, '(', $wt, ' value) { this->_', @field, ' = value; }')"/> + <xsl:if test="position() != last()"> + <xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="structvalue" mode="write-setters"> + <xsl:param name="cls"/> + <xsl:value-of select="concat(' void set_', @field, '(const TraceStruct', @type, '& value) { this->_', @field, ' = value; }')"/> + <xsl:if test="position() != last()"> + <xsl:text> +</xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="value" mode="write-data"> + <xsl:variable name="type" select="@type"/> + <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@writetype"/> + <xsl:value-of select="concat(' ts.print_val("', @label, '", _', @field, ');')"/> + <xsl:if test="position() != last()"> + <xsl:text> + ts.print(", "); +</xsl:text> + </xsl:if> +</xsl:template> + +<xsl:template match="structvalue" mode="write-data"> + <xsl:value-of select="concat(' _', @field, '.writeStruct(ts);')"/> + <xsl:if test="position() != last()"> + <xsl:text> + ts.print(", "); +</xsl:text> + </xsl:if> +</xsl:template> + +</xsl:stylesheet>