Only generate probes where it is supported
This commit is contained in:
parent
13e101c441
commit
8eb06f7ab4
|
@ -162,18 +162,38 @@ function(add_flow_target)
|
|||
add_library(${AFT_NAME} OBJECT ${sources})
|
||||
else()
|
||||
foreach(src IN LISTS AFT_SRCS AFT_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
if(${src} MATCHES ".*\\.actor\\.(h|cpp)")
|
||||
list(APPEND actors ${src})
|
||||
if(${src} MATCHES ".*\\.h")
|
||||
string(REPLACE ".actor.h" ".actor.g.h" generated ${src})
|
||||
else()
|
||||
string(REPLACE ".actor.cpp" ".actor.g.cpp" generated ${src})
|
||||
endif()
|
||||
set(actor_compiler_flags "")
|
||||
foreach(s IN LISTS AFT_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
if("${s}" STREQUAL "${src}")
|
||||
set(actor_compiler_flags "--disable-actor-without-wait-warning")
|
||||
break()
|
||||
if(${src} MATCHES ".*\\.actor\\.(h|cpp)")
|
||||
list(APPEND actors ${src})
|
||||
if(${src} MATCHES ".*\\.h")
|
||||
if (SUPPORT_DTRACE AND USE_LD STREQUAL "LLD")
|
||||
list(APPEND actor_compiler_flags "--generate-probes")
|
||||
endif()
|
||||
string(REPLACE ".actor.h" ".actor.g.h" generated ${src})
|
||||
else()
|
||||
if (SUPPORT_DTRACE)
|
||||
list(APPEND actor_compiler_flags "--generate-probes")
|
||||
endif()
|
||||
string(REPLACE ".actor.cpp" ".actor.g.cpp" generated ${src})
|
||||
endif()
|
||||
foreach(s IN LISTS AFT_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
if("${s}" STREQUAL "${src}")
|
||||
list(APPEND actor_compiler_flags "--disable-actor-without-wait-warning")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND sources ${generated})
|
||||
list(APPEND generated_files ${CMAKE_CURRENT_BINARY_DIR}/${generated})
|
||||
if(WIN32)
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${generated}"
|
||||
COMMAND $<TARGET_FILE:actorcompiler> "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${generated}" ${actor_compiler_flags} ${actor_compiler_flags}
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler
|
||||
COMMENT "Compile actor: ${src}")
|
||||
else()
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${generated}"
|
||||
COMMAND ${MONO_EXECUTABLE} ${actor_exe} "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${generated}" ${actor_compiler_flags} ${actor_compiler_flags} > /dev/null
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler
|
||||
COMMENT "Compile actor: ${src}")
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND sources ${generated})
|
||||
|
|
|
@ -285,13 +285,15 @@ namespace actorcompiler
|
|||
bool LineNumbersEnabled;
|
||||
int chooseGroups = 0, whenCount = 0;
|
||||
string This;
|
||||
bool generateProbes;
|
||||
|
||||
public ActorCompiler(Actor actor, string sourceFile, bool isTopLevel, bool lineNumbersEnabled)
|
||||
public ActorCompiler(Actor actor, string sourceFile, bool isTopLevel, bool lineNumbersEnabled, bool generateProbes)
|
||||
{
|
||||
this.actor = actor;
|
||||
this.sourceFile = sourceFile;
|
||||
this.isTopLevel = isTopLevel;
|
||||
this.LineNumbersEnabled = lineNumbersEnabled;
|
||||
this.generateProbes = generateProbes;
|
||||
|
||||
if (actor.returnType == null)
|
||||
actor.isUncancellable = true;
|
||||
|
@ -783,12 +785,16 @@ namespace actorcompiler
|
|||
};
|
||||
functions.Add(string.Format("{0}#{1}", cbFunc.name, ch.Index), cbFunc);
|
||||
cbFunc.Indent(codeIndent);
|
||||
cbFunc.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
cbFunc.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
}
|
||||
cbFunc.WriteLine("{0};", exitFunc.call());
|
||||
TryCatch(cx.WithTarget(cbFunc), cx.catchFErr, cx.tryLoopDepth, () => {
|
||||
cbFunc.WriteLine("{0};", ch.Body.call("value", "0"));
|
||||
}, false);
|
||||
cbFunc.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
cbFunc.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
}
|
||||
|
||||
var errFunc = new Function
|
||||
{
|
||||
|
@ -802,13 +808,17 @@ namespace actorcompiler
|
|||
};
|
||||
functions.Add(string.Format("{0}#{1}", errFunc.name, ch.Index), errFunc);
|
||||
errFunc.Indent(codeIndent);
|
||||
errFunc.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
errFunc.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
}
|
||||
errFunc.WriteLine("{0};", exitFunc.call());
|
||||
TryCatch(cx.WithTarget(errFunc), cx.catchFErr, cx.tryLoopDepth, () =>
|
||||
{
|
||||
errFunc.WriteLine("{0};", cx.catchFErr.call("err", "0"));
|
||||
}, false);
|
||||
errFunc.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
errFunc.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
}
|
||||
}
|
||||
|
||||
bool firstChoice = true;
|
||||
|
@ -1164,9 +1174,13 @@ namespace actorcompiler
|
|||
constructor.Indent(-1);
|
||||
constructor.WriteLine("{");
|
||||
constructor.Indent(+1);
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_enter, \"{0}\");", actor.name);
|
||||
}
|
||||
constructor.WriteLine("this->{0};", body.call());
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_exit, \"{0}\");", actor.name);
|
||||
}
|
||||
WriteFunction(writer, constructor, constructor.BodyText);
|
||||
}
|
||||
|
||||
|
@ -1207,7 +1221,9 @@ namespace actorcompiler
|
|||
constructor.Indent(-1);
|
||||
constructor.WriteLine("{");
|
||||
constructor.Indent(+1);
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_create, \"{0}\");", actor.name);
|
||||
if (generateProbes) {
|
||||
constructor.WriteLine("FDB_TRACE_PROBE1(actor_create, \"{0}\");", actor.name);
|
||||
}
|
||||
WriteFunction(writer, constructor, constructor.BodyText);
|
||||
}
|
||||
|
||||
|
@ -1224,7 +1240,9 @@ namespace actorcompiler
|
|||
destructor.Indent(-1);
|
||||
destructor.WriteLine("{");
|
||||
destructor.Indent(+1);
|
||||
destructor.WriteLine(String.Format("FDB_TRACE_PROBE1(actor_destroy, \"{0}\");", actor.name));
|
||||
if (generateProbes) {
|
||||
destructor.WriteLine(String.Format("FDB_TRACE_PROBE1(actor_destroy, \"{0}\");", actor.name));
|
||||
}
|
||||
WriteFunction(writer, destructor, destructor.BodyText);
|
||||
}
|
||||
|
||||
|
|
|
@ -214,11 +214,13 @@ namespace actorcompiler
|
|||
Token[] tokens;
|
||||
string sourceFile;
|
||||
ErrorMessagePolicy errorMessagePolicy;
|
||||
public bool generateProbes;
|
||||
|
||||
public ActorParser(string text, string sourceFile, ErrorMessagePolicy errorMessagePolicy)
|
||||
public ActorParser(string text, string sourceFile, ErrorMessagePolicy errorMessagePolicy, bool generateProbes)
|
||||
{
|
||||
this.sourceFile = sourceFile;
|
||||
this.errorMessagePolicy = errorMessagePolicy;
|
||||
this.generateProbes = generateProbes;
|
||||
tokens = Tokenize(text).Select(t=>new Token{ Value=t }).ToArray();
|
||||
CountParens();
|
||||
//if (sourceFile.EndsWith(".h")) LineNumbersEnabled = false;
|
||||
|
@ -249,7 +251,7 @@ namespace actorcompiler
|
|||
var actor = ParseActor(i, out end);
|
||||
var actorWriter = new System.IO.StringWriter();
|
||||
actorWriter.NewLine = "\n";
|
||||
new ActorCompiler(actor, sourceFile, inBlocks==0, LineNumbersEnabled).Write(actorWriter);
|
||||
new ActorCompiler(actor, sourceFile, inBlocks==0, LineNumbersEnabled, generateProbes).Write(actorWriter);
|
||||
string[] actorLines = actorWriter.ToString().Split('\n');
|
||||
|
||||
bool hasLineNumber = false;
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace actorcompiler
|
|||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
bool generateProbes = false;
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.WriteLine("Usage:");
|
||||
|
@ -43,11 +44,14 @@ namespace actorcompiler
|
|||
{
|
||||
errorMessagePolicy.DisableActorWithoutWaitWarning = true;
|
||||
}
|
||||
if (args.Contains("--generateProbes")) {
|
||||
generateProbes = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
var inputData = File.ReadAllText(input);
|
||||
using (var outputStream = new StreamWriter(outputtmp))
|
||||
new ActorParser(inputData, input.Replace('\\', '/'), errorMessagePolicy).Write(outputStream, output.Replace('\\', '/'));
|
||||
new ActorParser(inputData, input.Replace('\\', '/'), errorMessagePolicy, generateProbes).Write(outputStream, output.Replace('\\', '/'));
|
||||
if (File.Exists(output))
|
||||
{
|
||||
File.SetAttributes(output, FileAttributes.Normal);
|
||||
|
|
Loading…
Reference in New Issue