< prev index next >

make/src/classes/build/tools/jfr/GenerateJfrFiles.java

Print this page
rev 51898 : 8211213: fix aix build after 8196341: Add JFR events for parallel phases of G1


 460             out.write("#if INCLUDE_JFR");
 461             out.write("#include \"jfr/recorder/service/jfrEvent.hpp\"");
 462             out.write("/*");
 463             out.write(" * Each event class has an assert member function verify() which is invoked");
 464             out.write(" * just before the engine writes the event and its fields to the data stream.");
 465             out.write(" * The purpose of verify() is to ensure that all fields in the event are initialized");
 466             out.write(" * and set before attempting to commit.");
 467             out.write(" *");
 468             out.write(" * We enforce this requirement because events are generally stack allocated and therefore");
 469             out.write(" * *not* initialized to default values. This prevents us from inadvertently committing");
 470             out.write(" * uninitialized values to the data stream.");
 471             out.write(" *");
 472             out.write(" * The assert message contains both the index (zero based) as well as the name of the field.");
 473             out.write(" */");
 474             out.write("");
 475             printTypes(out, metadata, false);
 476             out.write("");
 477             out.write("");
 478             out.write("#else // !INCLUDE_JFR");
 479             out.write("");

 480             out.write("class JfrEvent {");
 481             out.write(" public:");
 482             out.write("  JfrEvent() {}");
 483             out.write("  void set_starttime(const Ticks&) const {}");
 484             out.write("  void set_endtime(const Ticks&) const {}");
 485             out.write("  bool should_commit() const { return false; }");
 486             out.write("  static bool is_enabled() { return false; }");
 487             out.write("  void commit() {}");
 488             out.write("};");
 489             out.write("");
 490             printTypes(out, metadata, true);
 491             out.write("");
 492             out.write("");
 493             out.write("#endif // INCLUDE_JFR");
 494             out.write("#endif // JFRFILES_JFREVENTCLASSES_HPP");
 495         }
 496     }
 497 
 498     private static void printTypes(Printer out, Metadata metadata, boolean empty) {
 499         for (TypeElement t : metadata.getStructs()) {
 500             if (empty) {
 501                 out.write("");
 502                 printEmptyType(out, t);
 503             } else {
 504                 printType(out, t);
 505             }
 506             out.write("");
 507         }
 508         for (EventElement e : metadata.getEvents()) {
 509             if (empty) {
 510                 printEmptyEvent(out, e);
 511             } else {
 512                 printEvent(out, e);
 513             }
 514             out.write("");
 515         }
 516     }
 517 
 518     private static void printEmptyEvent(Printer out, EventElement event) {
 519         out.write("class Event" + event.name + " : public JfrEvent");
 520         out.write("{");
 521         out.write(" public:");
 522         out.write("  Event" + event.name + "(EventStartTime ignore=TIMED) {}");
 523         if (event.startTime) {
 524             StringJoiner sj = new StringJoiner(",\n    ");
 525             for (FieldElement f : event.fields) {
 526                 sj.add(f.getParameterType());
 527             }
 528             out.write("  Event" + event.name + "(");
 529             out.write("    " + sj.toString() + ") { }");
 530         }
 531         for (FieldElement f : event.fields) {
 532             out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
 533         }




















 534         out.write("};");
 535     }
 536 
 537     private static void printEmptyType(Printer out, TypeElement t) {
 538         out.write("struct JfrStruct" + t.name);
 539         out.write("{");
 540         out.write(" public:");
 541         for (FieldElement f : t.fields) {
 542             out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
 543         }
 544         out.write("};");
 545     }
 546 
 547     private static void printType(Printer out, TypeElement t) {
 548         out.write("struct JfrStruct" + t.name);
 549         out.write("{");
 550         out.write(" private:");
 551         for (FieldElement f : t.fields) {
 552             printField(out, f);
 553         }




 460             out.write("#if INCLUDE_JFR");
 461             out.write("#include \"jfr/recorder/service/jfrEvent.hpp\"");
 462             out.write("/*");
 463             out.write(" * Each event class has an assert member function verify() which is invoked");
 464             out.write(" * just before the engine writes the event and its fields to the data stream.");
 465             out.write(" * The purpose of verify() is to ensure that all fields in the event are initialized");
 466             out.write(" * and set before attempting to commit.");
 467             out.write(" *");
 468             out.write(" * We enforce this requirement because events are generally stack allocated and therefore");
 469             out.write(" * *not* initialized to default values. This prevents us from inadvertently committing");
 470             out.write(" * uninitialized values to the data stream.");
 471             out.write(" *");
 472             out.write(" * The assert message contains both the index (zero based) as well as the name of the field.");
 473             out.write(" */");
 474             out.write("");
 475             printTypes(out, metadata, false);
 476             out.write("");
 477             out.write("");
 478             out.write("#else // !INCLUDE_JFR");
 479             out.write("");
 480             out.write("template <typename T>");
 481             out.write("class JfrEvent {");
 482             out.write(" public:");
 483             out.write("  JfrEvent() {}");
 484             out.write("  void set_starttime(const Ticks&) const {}");
 485             out.write("  void set_endtime(const Ticks&) const {}");
 486             out.write("  bool should_commit() const { return false; }");
 487             out.write("  static bool is_enabled() { return false; }");
 488             out.write("  void commit() {}");
 489             out.write("};");
 490             out.write("");
 491             printTypes(out, metadata, true);
 492             out.write("");
 493             out.write("");
 494             out.write("#endif // INCLUDE_JFR");
 495             out.write("#endif // JFRFILES_JFREVENTCLASSES_HPP");
 496         }
 497     }
 498 
 499     private static void printTypes(Printer out, Metadata metadata, boolean empty) {
 500         for (TypeElement t : metadata.getStructs()) {
 501             if (empty) {
 502                 out.write("");
 503                 printEmptyType(out, t);
 504             } else {
 505                 printType(out, t);
 506             }
 507             out.write("");
 508         }
 509         for (EventElement e : metadata.getEvents()) {
 510             if (empty) {
 511                 printEmptyEvent(out, e);
 512             } else {
 513                 printEvent(out, e);
 514             }
 515             out.write("");
 516         }
 517     }
 518 
 519     private static void printEmptyEvent(Printer out, EventElement event) {
 520         out.write("class Event" + event.name + " : public JfrEvent<Event" + event.name + ">");
 521         out.write("{");
 522         out.write(" public:");
 523         out.write("  Event" + event.name + "(EventStartTime ignore=TIMED) {}");
 524         if (event.startTime) {
 525             StringJoiner sj = new StringJoiner(",\n    ");
 526             for (FieldElement f : event.fields) {
 527                 sj.add(f.getParameterType());
 528             }
 529             out.write("  Event" + event.name + "(");
 530             out.write("    " + sj.toString() + ") { }");
 531         }
 532         for (FieldElement f : event.fields) {
 533             out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
 534         }
 535         out.write("");
 536         out.write("  using JfrEvent<Event" + event.name + ">::commit; // else commit() is hidden by overloaded versions in this class");
 537         if (event.startTime) {
 538             StringJoiner sj = new StringJoiner(",\n              ");
 539             for (FieldElement f : event.fields) {
 540                 sj.add(f.getParameterType() + " " + f.name);
 541             }
 542             out.write("");
 543             out.write("  void commit(" + sj.toString() + ") { }");
 544         }
 545         out.write("");
 546         StringJoiner sj = new StringJoiner(",\n                     ");
 547         if (event.startTime) {
 548             sj.add("const Ticks& startTicks");
 549             sj.add("const Ticks& endTicks");
 550         }
 551         for (FieldElement f : event.fields) {
 552             sj.add(f.getParameterType() + " " + f.name);
 553         }
 554         out.write("  static void commit(" + sj.toString() + ") { }");
 555         out.write("};");
 556     }
 557 
 558     private static void printEmptyType(Printer out, TypeElement t) {
 559         out.write("struct JfrStruct" + t.name);
 560         out.write("{");
 561         out.write(" public:");
 562         for (FieldElement f : t.fields) {
 563             out.write("  void set_" + f.name + "(" + f.getParameterType() + ") { }");
 564         }
 565         out.write("};");
 566     }
 567 
 568     private static void printType(Printer out, TypeElement t) {
 569         out.write("struct JfrStruct" + t.name);
 570         out.write("{");
 571         out.write(" private:");
 572         for (FieldElement f : t.fields) {
 573             printField(out, f);
 574         }


< prev index next >