src/share/vm/trace/traceEventClasses.xsl

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/trace/traceEventClasses.xsl	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,257 @@
     1.4 +<?xml version="1.0" encoding="utf-8"?>
     1.5 +<!--
     1.6 + Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7 + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 +
     1.9 + This code is free software; you can redistribute it and/or modify it
    1.10 + under the terms of the GNU General Public License version 2 only, as
    1.11 + published by the Free Software Foundation.
    1.12 +
    1.13 + This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 + FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 + version 2 for more details (a copy is included in the LICENSE file that
    1.17 + accompanied this code).
    1.18 +
    1.19 + You should have received a copy of the GNU General Public License version
    1.20 + 2 along with this work; if not, write to the Free Software Foundation,
    1.21 + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 +
    1.23 + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 + or visit www.oracle.com if you need additional information or have any
    1.25 + questions.
    1.26 +-->
    1.27 +
    1.28 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    1.29 +<xsl:import href="xsl_util.xsl"/>
    1.30 +<xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
    1.31 +
    1.32 +<xsl:template match="/">
    1.33 +  <xsl:call-template name="file-header"/>
    1.34 +
    1.35 +#ifndef TRACEFILES_TRACEEVENTCLASSES_HPP
    1.36 +#define TRACEFILES_TRACEEVENTCLASSES_HPP
    1.37 +
    1.38 +// On purpose outside the INCLUDE_TRACE
    1.39 +// Some parts of traceEvent.hpp are used outside of
    1.40 +// INCLUDE_TRACE
    1.41 +
    1.42 +#include "memory/resourceArea.hpp"
    1.43 +#include "tracefiles/traceTypes.hpp"
    1.44 +#include "trace/traceEvent.hpp"
    1.45 +#include "utilities/macros.hpp"
    1.46 +#include "utilities/ticks.hpp"
    1.47 +
    1.48 +#if INCLUDE_TRACE
    1.49 +
    1.50 +
    1.51 +#include "trace/traceStream.hpp"
    1.52 +#include "utilities/ostream.hpp"
    1.53 +
    1.54 +  <xsl:apply-templates select="trace/events/struct" mode="trace"/>
    1.55 +  <xsl:apply-templates select="trace/events/event" mode="trace"/>
    1.56 +
    1.57 +#else
    1.58 +
    1.59 +class TraceEvent {
    1.60 +public:
    1.61 +  TraceEvent() {}
    1.62 +  void set_starttime(const Ticks&amp; time) {}
    1.63 +  void set_endtime(const Ticks&amp; time) {}
    1.64 +  bool should_commit() const { return false; }
    1.65 +  void commit() const {}
    1.66 +};
    1.67 +
    1.68 +  <xsl:apply-templates select="trace/events/struct" mode="empty"/>
    1.69 +  <xsl:apply-templates select="trace/events/event" mode="empty"/>
    1.70 +
    1.71 +#endif
    1.72 +
    1.73 +#endif
    1.74 +</xsl:template>
    1.75 +
    1.76 +<xsl:template match="struct" mode="trace">
    1.77 +struct TraceStruct<xsl:value-of select="@id"/>
    1.78 +{
    1.79 +private:
    1.80 +<xsl:apply-templates select="value" mode="write-fields"/>
    1.81 +public:
    1.82 +<xsl:apply-templates select="value" mode="write-setters"/>
    1.83 +
    1.84 +  void writeStruct(TraceStream&amp; ts) {
    1.85 +<xsl:apply-templates select="value" mode="write-data"/>
    1.86 +  }
    1.87 +};
    1.88 +
    1.89 +</xsl:template>
    1.90 +
    1.91 +<xsl:template match="struct" mode="empty">
    1.92 +struct TraceStruct<xsl:value-of select="@id"/> 
    1.93 +{
    1.94 +public:
    1.95 +<xsl:apply-templates select="value" mode="write-empty-setters"/>
    1.96 +};
    1.97 +</xsl:template>
    1.98 +
    1.99 +
   1.100 +<xsl:template match="event" mode="empty">
   1.101 +  <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent')"/>
   1.102 +{
   1.103 + public:
   1.104 +<xsl:value-of select="concat('  Event', @id, '(bool ignore=true) {}')"/>
   1.105 +<xsl:text>
   1.106 +</xsl:text>
   1.107 +
   1.108 +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-empty-setters"/>
   1.109 +};
   1.110 +
   1.111 +</xsl:template>
   1.112 +
   1.113 +
   1.114 +<xsl:template match="event" mode="trace">
   1.115 +  <xsl:value-of select="concat('class Event', @id, ' : public TraceEvent&lt;Event', @id, '&gt;')"/>
   1.116 +{
   1.117 + public:
   1.118 +  static const bool hasThread = <xsl:value-of select="@has_thread"/>;
   1.119 +  static const bool hasStackTrace = <xsl:value-of select="@has_stacktrace"/>;
   1.120 +  static const bool isInstant = <xsl:value-of select="@is_instant"/>;
   1.121 +  static const bool isRequestable = <xsl:value-of select="@is_requestable"/>;
   1.122 +  static const TraceEventId eventId = <xsl:value-of select="concat('Trace', @id, 'Event')"/>;
   1.123 +
   1.124 + private:
   1.125 +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-fields"/>
   1.126 +
   1.127 +  void writeEventContent(void) {
   1.128 +    TraceStream ts(*tty);
   1.129 +    ts.print("<xsl:value-of select="@label"/>: [");
   1.130 +<xsl:apply-templates select="value|structvalue" mode="write-data"/>
   1.131 +    ts.print("]\n");
   1.132 +  }
   1.133 +
   1.134 + public:
   1.135 +<xsl:apply-templates select="value|structvalue|transition_value|relation" mode="write-setters"/>
   1.136 +
   1.137 +  bool should_write(void) {
   1.138 +    return true;
   1.139 +  }
   1.140 +<xsl:text>
   1.141 +
   1.142 +</xsl:text>
   1.143 +  <xsl:value-of select="concat('  Event', @id, '(EventStartTime timing=TIMED) : TraceEvent&lt;Event', @id, '&gt;(timing) {}', $newline)"/>
   1.144 +  void writeEvent(void) {
   1.145 +    ResourceMark rm;
   1.146 +    if (UseLockedTracing) {
   1.147 +      ttyLocker lock;
   1.148 +      writeEventContent();
   1.149 +    } else {
   1.150 +      writeEventContent();
   1.151 +    }
   1.152 +  }
   1.153 +};
   1.154 +
   1.155 +</xsl:template>
   1.156 +
   1.157 +<xsl:template match="value|transition_value|relation" mode="write-empty-setters">
   1.158 +  <xsl:param name="cls"/>
   1.159 +  <xsl:variable name="type" select="@type"/>
   1.160 +  <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
   1.161 +  <xsl:value-of select="concat('  void set_', @field, '(', $wt, ' value) { }')"/>
   1.162 +  <xsl:if test="position() != last()">
   1.163 +    <xsl:text>
   1.164 +</xsl:text>
   1.165 +  </xsl:if>
   1.166 +</xsl:template>
   1.167 +
   1.168 +<xsl:template match="structvalue" mode="write-empty-setters">
   1.169 +  <xsl:param name="cls"/>
   1.170 +  <xsl:value-of select="concat('  void set_', @field, '(const TraceStruct', @type, '&amp; value) { }')"/>
   1.171 +  <xsl:if test="position() != last()">
   1.172 +    <xsl:text>
   1.173 +</xsl:text>
   1.174 +  </xsl:if>
   1.175 +</xsl:template>
   1.176 +
   1.177 +<xsl:template match="value[@type='TICKS']" mode="write-setters">
   1.178 +#if INCLUDE_TRACE
   1.179 +<xsl:value-of select="concat('  void set_', @field, '(const Ticks&amp; time) { _', @field, ' = time; }')"/>
   1.180 +#else
   1.181 +<xsl:value-of select="concat('  void set_', @field, '(const Ticks&amp; ignore) {}')"/>
   1.182 +#endif
   1.183 +</xsl:template>
   1.184 +
   1.185 +<xsl:template match="value[@type='TICKSPAN']" mode="write-setters">
   1.186 +#if INCLUDE_TRACE
   1.187 +  <xsl:value-of select="concat('  void set_', @field, '(const Tickspan&amp; time) { _', @field, ' = time; }')"/>
   1.188 +#else
   1.189 +  <xsl:value-of select="concat('  void set_', @field, '(const Tickspan&amp; ignore) {}')"/>
   1.190 +#endif
   1.191 +</xsl:template>
   1.192 +
   1.193 +
   1.194 +<xsl:template match="value" mode="write-fields">
   1.195 +  <xsl:variable name="type" select="@type"/>
   1.196 +  <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
   1.197 +  <xsl:value-of select="concat('  ', $wt, ' _', @field, ';')"/>
   1.198 +  <xsl:if test="position() != last()">
   1.199 +    <xsl:text> 
   1.200 +</xsl:text>
   1.201 +  </xsl:if>
   1.202 +</xsl:template>
   1.203 +
   1.204 +<xsl:template match="structvalue" mode="write-fields">
   1.205 +  <xsl:value-of select="concat('  TraceStruct', @type, ' _', @field, ';')"/>
   1.206 +  <xsl:text>
   1.207 +</xsl:text>
   1.208 +</xsl:template>
   1.209 +
   1.210 +<xsl:template match="value|transition_value|relation" mode="write-setters">
   1.211 +  <xsl:param name="cls"/>
   1.212 +  <xsl:variable name="type" select="@type"/>
   1.213 +  <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@type"/>
   1.214 +  <xsl:value-of select="concat('  void set_', @field, '(', $wt, ' value) { this->_', @field, ' = value; }')"/>
   1.215 +  <xsl:if test="position() != last()">
   1.216 +    <xsl:text>
   1.217 +</xsl:text>
   1.218 +  </xsl:if>
   1.219 +</xsl:template>
   1.220 +
   1.221 +<xsl:template match="structvalue" mode="write-setters">
   1.222 +  <xsl:param name="cls"/>
   1.223 +  <xsl:value-of select="concat('  void set_', @field, '(const TraceStruct', @type, '&amp; value) { this->_', @field, ' = value; }')"/>
   1.224 +  <xsl:if test="position() != last()">
   1.225 +    <xsl:text>
   1.226 +</xsl:text>
   1.227 +  </xsl:if>
   1.228 +</xsl:template>
   1.229 +
   1.230 +<xsl:template match="value" mode="write-data">
   1.231 +  <xsl:variable name="type" select="@type"/>
   1.232 +  <xsl:variable name="wt" select="//primary_type[@symbol=$type]/@writetype"/>
   1.233 +  <xsl:choose>
   1.234 +    <xsl:when test="@type='TICKSPAN'">
   1.235 +      <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
   1.236 +    </xsl:when>
   1.237 +    <xsl:when test="@type='TICKS'">
   1.238 +      <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, '.value());')"/>
   1.239 +    </xsl:when>
   1.240 +    <xsl:otherwise>
   1.241 +      <xsl:value-of select="concat('    ts.print_val(&quot;', @label, '&quot;, _', @field, ');')"/>
   1.242 +    </xsl:otherwise>
   1.243 +  </xsl:choose>
   1.244 +  <xsl:if test="position() != last()">
   1.245 +    <xsl:text>
   1.246 +    ts.print(", ");
   1.247 +</xsl:text>
   1.248 +  </xsl:if>
   1.249 +</xsl:template>
   1.250 +
   1.251 +<xsl:template match="structvalue" mode="write-data">
   1.252 +  <xsl:value-of select="concat('    _', @field, '.writeStruct(ts);')"/>
   1.253 +  <xsl:if test="position() != last()">
   1.254 +    <xsl:text>
   1.255 +    ts.print(", ");
   1.256 +</xsl:text>
   1.257 +  </xsl:if>
   1.258 +</xsl:template>
   1.259 +
   1.260 +</xsl:stylesheet>

mercurial