8211239: Build fails without JFR: empty JFR events signatures mismatch

Mon, 01 Oct 2018 16:41:10 +0200

author
shade
date
Mon, 01 Oct 2018 16:41:10 +0200
changeset 9869
a5e7fde5ba80
parent 9868
69fb91513217
child 9870
830105382dbd

8211239: Build fails without JFR: empty JFR events signatures mismatch
Reviewed-by: mgronlun, dholmes

src/share/vm/jfr/GenerateJfrFiles.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/jfr/GenerateJfrFiles.java	Thu Nov 15 11:10:04 2018 +0100
     1.2 +++ b/src/share/vm/jfr/GenerateJfrFiles.java	Mon Oct 01 16:41:10 2018 +0200
     1.3 @@ -478,6 +478,7 @@
     1.4              out.write("");
     1.5              out.write("#else // !INCLUDE_JFR");
     1.6              out.write("");
     1.7 +            out.write("template <typename T>");
     1.8              out.write("class JfrEvent {");
     1.9              out.write(" public:");
    1.10              out.write("  JfrEvent() {}");
    1.11 @@ -498,103 +499,83 @@
    1.12  
    1.13      private static void printTypes(Printer out, Metadata metadata, boolean empty) {
    1.14          for (TypeElement t : metadata.getStructs()) {
    1.15 -            if (empty) {
    1.16 -                out.write("");
    1.17 -                printEmptyType(out, t);
    1.18 -            } else {
    1.19 -                printType(out, t);
    1.20 -            }
    1.21 +            printType(out, t, empty);
    1.22              out.write("");
    1.23          }
    1.24          for (EventElement e : metadata.getEvents()) {
    1.25 -            if (empty) {
    1.26 -                printEmptyEvent(out, e);
    1.27 -            } else {
    1.28 -                printEvent(out, e);
    1.29 -            }
    1.30 +            printEvent(out, e, empty);
    1.31              out.write("");
    1.32          }
    1.33      }
    1.34  
    1.35 -    private static void printEmptyEvent(Printer out, EventElement event) {
    1.36 -        out.write("class Event" + event.name + " : public JfrEvent");
    1.37 -        out.write("{");
    1.38 -        out.write(" public:");
    1.39 -        out.write("  Event" + event.name + "(EventStartTime ignore=TIMED) {}");
    1.40 -        if (event.startTime) {
    1.41 -            StringJoiner sj = new StringJoiner(",\n    ");
    1.42 -            for (FieldElement f : event.fields) {
    1.43 -                sj.add(f.getParameterType());
    1.44 -            }
    1.45 -            out.write("  Event" + event.name + "(");
    1.46 -            out.write("    " + sj.toString() + ") { }");
    1.47 -        }
    1.48 -        for (FieldElement f : event.fields) {
    1.49 -            out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
    1.50 -        }
    1.51 -        out.write("};");
    1.52 -    }
    1.53 -
    1.54 -    private static void printEmptyType(Printer out, TypeElement t) {
    1.55 +    private static void printType(Printer out, TypeElement t, boolean empty) {
    1.56          out.write("struct JfrStruct" + t.name);
    1.57          out.write("{");
    1.58 +        if (!empty) {
    1.59 +          out.write(" private:");
    1.60 +          for (FieldElement f : t.fields) {
    1.61 +              printField(out, f);
    1.62 +          }
    1.63 +          out.write("");
    1.64 +        }
    1.65          out.write(" public:");
    1.66          for (FieldElement f : t.fields) {
    1.67 -            out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
    1.68 -        }
    1.69 -        out.write("};");
    1.70 -    }
    1.71 -
    1.72 -    private static void printType(Printer out, TypeElement t) {
    1.73 -        out.write("struct JfrStruct" + t.name);
    1.74 -        out.write("{");
    1.75 -        out.write(" private:");
    1.76 -        for (FieldElement f : t.fields) {
    1.77 -            printField(out, f);
    1.78 +           printTypeSetter(out, f, empty);
    1.79          }
    1.80          out.write("");
    1.81 -        out.write(" public:");
    1.82 -        for (FieldElement f : t.fields) {
    1.83 -            printTypeSetter(out, f);
    1.84 +        if (!empty) {
    1.85 +          printWriteData(out, t.fields);
    1.86          }
    1.87 -        out.write("");
    1.88 -        printWriteData(out, t.fields);
    1.89          out.write("};");
    1.90          out.write("");
    1.91      }
    1.92  
    1.93 -    private static void printEvent(Printer out, EventElement event) {
    1.94 +    private static void printEvent(Printer out, EventElement event, boolean empty) {
    1.95          out.write("class Event" + event.name + " : public JfrEvent<Event" + event.name + ">");
    1.96          out.write("{");
    1.97 -        out.write(" private:");
    1.98 -        for (FieldElement f : event.fields) {
    1.99 -            printField(out, f);
   1.100 +        if (!empty) {
   1.101 +          out.write(" private:");
   1.102 +          for (FieldElement f : event.fields) {
   1.103 +              printField(out, f);
   1.104 +          }
   1.105 +          out.write("");
   1.106          }
   1.107 -        out.write("");
   1.108          out.write(" public:");
   1.109 -        out.write("  static const bool hasThread = " + event.thread + ";");
   1.110 -        out.write("  static const bool hasStackTrace = " + event.stackTrace + ";");
   1.111 -        out.write("  static const bool isInstant = " + !event.startTime + ";");
   1.112 -        out.write("  static const bool hasCutoff = " + event.cutoff + ";");
   1.113 -        out.write("  static const bool isRequestable = " + event.periodic + ";");
   1.114 -        out.write("  static const JfrEventId eventId = Jfr" + event.name + "Event;");
   1.115 -        out.write("");
   1.116 -        out.write("  Event" + event.name + "(EventStartTime timing=TIMED) : JfrEvent<Event" + event.name + ">(timing) {}");
   1.117 +        if (!empty) {
   1.118 +          out.write("  static const bool hasThread = " + event.thread + ";");
   1.119 +          out.write("  static const bool hasStackTrace = " + event.stackTrace + ";");
   1.120 +          out.write("  static const bool isInstant = " + !event.startTime + ";");
   1.121 +          out.write("  static const bool hasCutoff = " + event.cutoff + ";");
   1.122 +          out.write("  static const bool isRequestable = " + event.periodic + ";");
   1.123 +          out.write("  static const JfrEventId eventId = Jfr" + event.name + "Event;");
   1.124 +          out.write("");
   1.125 +        }
   1.126 +        if (!empty) {
   1.127 +          out.write("  Event" + event.name + "(EventStartTime timing=TIMED) : JfrEvent<Event" + event.name + ">(timing) {}");
   1.128 +        } else {
   1.129 +          out.write("  Event" + event.name + "(EventStartTime timing=TIMED) {}");
   1.130 +        }
   1.131          out.write("");
   1.132          int index = 0;
   1.133          for (FieldElement f : event.fields) {
   1.134              out.write("  void set_" + f.name + "(" + f.getParameterType() + " " + f.getParameterName() + ") {");
   1.135 -            out.write("    this->_" + f.name + " = " + f.getParameterName() + ";");
   1.136 -            out.write("    DEBUG_ONLY(set_field_bit(" + index++ + "));");
   1.137 +            if (!empty) {
   1.138 +              out.write("    this->_" + f.name + " = " + f.getParameterName() + ";");
   1.139 +              out.write("    DEBUG_ONLY(set_field_bit(" + index++ + "));");
   1.140 +            }
   1.141              out.write("  }");
   1.142          }
   1.143          out.write("");
   1.144 -        printWriteData(out, event.fields);
   1.145 -        out.write("");
   1.146 +        if (!empty) {
   1.147 +          printWriteData(out, event.fields);
   1.148 +          out.write("");
   1.149 +        }
   1.150          out.write("  using JfrEvent<Event" + event.name + ">::commit; // else commit() is hidden by overloaded versions in this class");
   1.151 -        printConstructor2(out, event);
   1.152 -        printCommitMethod(out, event);
   1.153 -        printVerify(out, event.fields);
   1.154 +        printConstructor2(out, event, empty);
   1.155 +        printCommitMethod(out, event, empty);
   1.156 +        if (!empty) {
   1.157 +          printVerify(out, event.fields);
   1.158 +        }
   1.159          out.write("};");
   1.160      }
   1.161  
   1.162 @@ -611,8 +592,12 @@
   1.163          out.write("  }");
   1.164      }
   1.165  
   1.166 -    private static void printTypeSetter(Printer out, FieldElement field) {
   1.167 -        out.write("  void set_" + field.name + "(" + field.getParameterType() + " new_value) { this->_" + field.name + " = new_value; }");
   1.168 +    private static void printTypeSetter(Printer out, FieldElement field, boolean empty) {
   1.169 +        if (!empty) {
   1.170 +          out.write("  void set_" + field.name + "(" + field.getParameterType() + " new_value) { this->_" + field.name + " = new_value; }");
   1.171 +        } else {
   1.172 +          out.write("  void set_" + field.name + "(" + field.getParameterType() + " new_value) { }");
   1.173 +        }
   1.174      }
   1.175  
   1.176      private static void printVerify(Printer out, List<FieldElement> fields) {
   1.177 @@ -627,7 +612,7 @@
   1.178          out.write("#endif");
   1.179      }
   1.180  
   1.181 -    private static void printCommitMethod(Printer out, EventElement event) {
   1.182 +    private static void printCommitMethod(Printer out, EventElement event, boolean empty) {
   1.183          if (event.startTime) {
   1.184              StringJoiner sj = new StringJoiner(",\n              ");
   1.185              for (FieldElement f : event.fields) {
   1.186 @@ -635,12 +620,14 @@
   1.187              }
   1.188              out.write("");
   1.189              out.write("  void commit(" + sj.toString() + ") {");
   1.190 -            out.write("    if (should_commit()) {");
   1.191 -            for (FieldElement f : event.fields) {
   1.192 -                out.write("      set_" + f.name + "(" + f.name + ");");
   1.193 +            if (!empty) {
   1.194 +              out.write("    if (should_commit()) {");
   1.195 +              for (FieldElement f : event.fields) {
   1.196 +                  out.write("      set_" + f.name + "(" + f.name + ");");
   1.197 +              }
   1.198 +              out.write("      commit();");
   1.199 +              out.write("    }");
   1.200              }
   1.201 -            out.write("      commit();");
   1.202 -            out.write("    }");
   1.203              out.write("  }");
   1.204          }
   1.205          out.write("");
   1.206 @@ -653,22 +640,24 @@
   1.207              sj.add(f.getParameterType() + " " + f.name);
   1.208          }
   1.209          out.write("  static void commit(" + sj.toString() + ") {");
   1.210 -        out.write("    Event" + event.name + " me(UNTIMED);");
   1.211 -        out.write("");
   1.212 -        out.write("    if (me.should_commit()) {");
   1.213 -        if (event.startTime) {
   1.214 -            out.write("      me.set_starttime(startTicks);");
   1.215 -            out.write("      me.set_endtime(endTicks);");
   1.216 +        if (!empty) {
   1.217 +          out.write("    Event" + event.name + " me(UNTIMED);");
   1.218 +          out.write("");
   1.219 +          out.write("    if (me.should_commit()) {");
   1.220 +          if (event.startTime) {
   1.221 +              out.write("      me.set_starttime(startTicks);");
   1.222 +              out.write("      me.set_endtime(endTicks);");
   1.223 +          }
   1.224 +          for (FieldElement f : event.fields) {
   1.225 +              out.write("      me.set_" + f.name + "(" + f.name + ");");
   1.226 +          }
   1.227 +          out.write("      me.commit();");
   1.228 +          out.write("    }");
   1.229          }
   1.230 -        for (FieldElement f : event.fields) {
   1.231 -            out.write("      me.set_" + f.name + "(" + f.name + ");");
   1.232 -        }
   1.233 -        out.write("      me.commit();");
   1.234 -        out.write("    }");
   1.235          out.write("  }");
   1.236      }
   1.237  
   1.238 -    private static void printConstructor2(Printer out, EventElement event) {
   1.239 +    private static void printConstructor2(Printer out, EventElement event, boolean empty) {
   1.240          if (!event.startTime) {
   1.241              out.write("");
   1.242              out.write("");
   1.243 @@ -680,12 +669,16 @@
   1.244              for (FieldElement f : event.fields) {
   1.245                  sj.add(f.getParameterType() + " " + f.name);
   1.246              }
   1.247 -            out.write("    " + sj.toString() + ") : JfrEvent<Event" + event.name + ">(TIMED) {");
   1.248 -            out.write("    if (should_commit()) {");
   1.249 -            for (FieldElement f : event.fields) {
   1.250 -                out.write("      set_" + f.name + "(" + f.name + ");");
   1.251 +            if (!empty) {
   1.252 +              out.write("    " + sj.toString() + ") : JfrEvent<Event" + event.name + ">(TIMED) {");
   1.253 +              out.write("    if (should_commit()) {");
   1.254 +              for (FieldElement f : event.fields) {
   1.255 +                  out.write("      set_" + f.name + "(" + f.name + ");");
   1.256 +              }
   1.257 +              out.write("    }");
   1.258 +            } else {
   1.259 +              out.write("    " + sj.toString() + ") {");
   1.260              }
   1.261 -            out.write("    }");
   1.262              out.write("  }");
   1.263          }
   1.264      }

mercurial