提交 7b8f4d16 编写于 作者: S shade

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

Reviewed-by: mgronlun, dholmes
上级 8d36b439
...@@ -478,6 +478,7 @@ public class GenerateJfrFiles { ...@@ -478,6 +478,7 @@ public class GenerateJfrFiles {
out.write(""); out.write("");
out.write("#else // !INCLUDE_JFR"); out.write("#else // !INCLUDE_JFR");
out.write(""); out.write("");
out.write("template <typename T>");
out.write("class JfrEvent {"); out.write("class JfrEvent {");
out.write(" public:"); out.write(" public:");
out.write(" JfrEvent() {}"); out.write(" JfrEvent() {}");
...@@ -498,80 +499,49 @@ public class GenerateJfrFiles { ...@@ -498,80 +499,49 @@ public class GenerateJfrFiles {
private static void printTypes(Printer out, Metadata metadata, boolean empty) { private static void printTypes(Printer out, Metadata metadata, boolean empty) {
for (TypeElement t : metadata.getStructs()) { for (TypeElement t : metadata.getStructs()) {
if (empty) { printType(out, t, empty);
out.write("");
printEmptyType(out, t);
} else {
printType(out, t);
}
out.write(""); out.write("");
} }
for (EventElement e : metadata.getEvents()) { for (EventElement e : metadata.getEvents()) {
if (empty) { printEvent(out, e, empty);
printEmptyEvent(out, e);
} else {
printEvent(out, e);
}
out.write(""); out.write("");
} }
} }
private static void printEmptyEvent(Printer out, EventElement event) { private static void printType(Printer out, TypeElement t, boolean empty) {
out.write("class Event" + event.name + " : public JfrEvent");
out.write("{");
out.write(" public:");
out.write(" Event" + event.name + "(EventStartTime ignore=TIMED) {}");
if (event.startTime) {
StringJoiner sj = new StringJoiner(",\n ");
for (FieldElement f : event.fields) {
sj.add(f.getParameterType());
}
out.write(" Event" + event.name + "(");
out.write(" " + sj.toString() + ") { }");
}
for (FieldElement f : event.fields) {
out.write(" void set_" + f.name + "(" + f.getParameterType() + ") { }");
}
out.write("};");
}
private static void printEmptyType(Printer out, TypeElement t) {
out.write("struct JfrStruct" + t.name);
out.write("{");
out.write(" public:");
for (FieldElement f : t.fields) {
out.write(" void set_" + f.name + "(" + f.getParameterType() + ") { }");
}
out.write("};");
}
private static void printType(Printer out, TypeElement t) {
out.write("struct JfrStruct" + t.name); out.write("struct JfrStruct" + t.name);
out.write("{"); out.write("{");
if (!empty) {
out.write(" private:"); out.write(" private:");
for (FieldElement f : t.fields) { for (FieldElement f : t.fields) {
printField(out, f); printField(out, f);
} }
out.write(""); out.write("");
}
out.write(" public:"); out.write(" public:");
for (FieldElement f : t.fields) { for (FieldElement f : t.fields) {
printTypeSetter(out, f); printTypeSetter(out, f, empty);
} }
out.write(""); out.write("");
if (!empty) {
printWriteData(out, t.fields); printWriteData(out, t.fields);
}
out.write("};"); out.write("};");
out.write(""); out.write("");
} }
private static void printEvent(Printer out, EventElement event) { private static void printEvent(Printer out, EventElement event, boolean empty) {
out.write("class Event" + event.name + " : public JfrEvent<Event" + event.name + ">"); out.write("class Event" + event.name + " : public JfrEvent<Event" + event.name + ">");
out.write("{"); out.write("{");
if (!empty) {
out.write(" private:"); out.write(" private:");
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
printField(out, f); printField(out, f);
} }
out.write(""); out.write("");
}
out.write(" public:"); out.write(" public:");
if (!empty) {
out.write(" static const bool hasThread = " + event.thread + ";"); out.write(" static const bool hasThread = " + event.thread + ";");
out.write(" static const bool hasStackTrace = " + event.stackTrace + ";"); out.write(" static const bool hasStackTrace = " + event.stackTrace + ";");
out.write(" static const bool isInstant = " + !event.startTime + ";"); out.write(" static const bool isInstant = " + !event.startTime + ";");
...@@ -579,22 +549,33 @@ public class GenerateJfrFiles { ...@@ -579,22 +549,33 @@ public class GenerateJfrFiles {
out.write(" static const bool isRequestable = " + event.periodic + ";"); out.write(" static const bool isRequestable = " + event.periodic + ";");
out.write(" static const JfrEventId eventId = Jfr" + event.name + "Event;"); out.write(" static const JfrEventId eventId = Jfr" + event.name + "Event;");
out.write(""); out.write("");
}
if (!empty) {
out.write(" Event" + event.name + "(EventStartTime timing=TIMED) : JfrEvent<Event" + event.name + ">(timing) {}"); out.write(" Event" + event.name + "(EventStartTime timing=TIMED) : JfrEvent<Event" + event.name + ">(timing) {}");
} else {
out.write(" Event" + event.name + "(EventStartTime timing=TIMED) {}");
}
out.write(""); out.write("");
int index = 0; int index = 0;
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
out.write(" void set_" + f.name + "(" + f.getParameterType() + " " + f.getParameterName() + ") {"); out.write(" void set_" + f.name + "(" + f.getParameterType() + " " + f.getParameterName() + ") {");
if (!empty) {
out.write(" this->_" + f.name + " = " + f.getParameterName() + ";"); out.write(" this->_" + f.name + " = " + f.getParameterName() + ";");
out.write(" DEBUG_ONLY(set_field_bit(" + index++ + "));"); out.write(" DEBUG_ONLY(set_field_bit(" + index++ + "));");
}
out.write(" }"); out.write(" }");
} }
out.write(""); out.write("");
if (!empty) {
printWriteData(out, event.fields); printWriteData(out, event.fields);
out.write(""); out.write("");
}
out.write(" using JfrEvent<Event" + event.name + ">::commit; // else commit() is hidden by overloaded versions in this class"); out.write(" using JfrEvent<Event" + event.name + ">::commit; // else commit() is hidden by overloaded versions in this class");
printConstructor2(out, event); printConstructor2(out, event, empty);
printCommitMethod(out, event); printCommitMethod(out, event, empty);
if (!empty) {
printVerify(out, event.fields); printVerify(out, event.fields);
}
out.write("};"); out.write("};");
} }
...@@ -611,8 +592,12 @@ public class GenerateJfrFiles { ...@@ -611,8 +592,12 @@ public class GenerateJfrFiles {
out.write(" }"); out.write(" }");
} }
private static void printTypeSetter(Printer out, FieldElement field) { private static void printTypeSetter(Printer out, FieldElement field, boolean empty) {
if (!empty) {
out.write(" void set_" + field.name + "(" + field.getParameterType() + " new_value) { this->_" + field.name + " = new_value; }"); out.write(" void set_" + field.name + "(" + field.getParameterType() + " new_value) { this->_" + field.name + " = new_value; }");
} else {
out.write(" void set_" + field.name + "(" + field.getParameterType() + " new_value) { }");
}
} }
private static void printVerify(Printer out, List<FieldElement> fields) { private static void printVerify(Printer out, List<FieldElement> fields) {
...@@ -627,7 +612,7 @@ public class GenerateJfrFiles { ...@@ -627,7 +612,7 @@ public class GenerateJfrFiles {
out.write("#endif"); out.write("#endif");
} }
private static void printCommitMethod(Printer out, EventElement event) { private static void printCommitMethod(Printer out, EventElement event, boolean empty) {
if (event.startTime) { if (event.startTime) {
StringJoiner sj = new StringJoiner(",\n "); StringJoiner sj = new StringJoiner(",\n ");
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
...@@ -635,12 +620,14 @@ public class GenerateJfrFiles { ...@@ -635,12 +620,14 @@ public class GenerateJfrFiles {
} }
out.write(""); out.write("");
out.write(" void commit(" + sj.toString() + ") {"); out.write(" void commit(" + sj.toString() + ") {");
if (!empty) {
out.write(" if (should_commit()) {"); out.write(" if (should_commit()) {");
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
out.write(" set_" + f.name + "(" + f.name + ");"); out.write(" set_" + f.name + "(" + f.name + ");");
} }
out.write(" commit();"); out.write(" commit();");
out.write(" }"); out.write(" }");
}
out.write(" }"); out.write(" }");
} }
out.write(""); out.write("");
...@@ -653,6 +640,7 @@ public class GenerateJfrFiles { ...@@ -653,6 +640,7 @@ public class GenerateJfrFiles {
sj.add(f.getParameterType() + " " + f.name); sj.add(f.getParameterType() + " " + f.name);
} }
out.write(" static void commit(" + sj.toString() + ") {"); out.write(" static void commit(" + sj.toString() + ") {");
if (!empty) {
out.write(" Event" + event.name + " me(UNTIMED);"); out.write(" Event" + event.name + " me(UNTIMED);");
out.write(""); out.write("");
out.write(" if (me.should_commit()) {"); out.write(" if (me.should_commit()) {");
...@@ -665,10 +653,11 @@ public class GenerateJfrFiles { ...@@ -665,10 +653,11 @@ public class GenerateJfrFiles {
} }
out.write(" me.commit();"); out.write(" me.commit();");
out.write(" }"); out.write(" }");
}
out.write(" }"); out.write(" }");
} }
private static void printConstructor2(Printer out, EventElement event) { private static void printConstructor2(Printer out, EventElement event, boolean empty) {
if (!event.startTime) { if (!event.startTime) {
out.write(""); out.write("");
out.write(""); out.write("");
...@@ -680,12 +669,16 @@ public class GenerateJfrFiles { ...@@ -680,12 +669,16 @@ public class GenerateJfrFiles {
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
sj.add(f.getParameterType() + " " + f.name); sj.add(f.getParameterType() + " " + f.name);
} }
if (!empty) {
out.write(" " + sj.toString() + ") : JfrEvent<Event" + event.name + ">(TIMED) {"); out.write(" " + sj.toString() + ") : JfrEvent<Event" + event.name + ">(TIMED) {");
out.write(" if (should_commit()) {"); out.write(" if (should_commit()) {");
for (FieldElement f : event.fields) { for (FieldElement f : event.fields) {
out.write(" set_" + f.name + "(" + f.name + ");"); out.write(" set_" + f.name + "(" + f.name + ");");
} }
out.write(" }"); out.write(" }");
} else {
out.write(" " + sj.toString() + ") {");
}
out.write(" }"); out.write(" }");
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册