mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
gen-zam: hooks for supporting ZAM profiling
This commit is contained in:
parent
4e07a9681d
commit
f9385ef88d
2 changed files with 17 additions and 2 deletions
|
@ -663,9 +663,13 @@ void ZAM_OpTemplate::InstantiateAssignOp(const vector<ZAM_OperandType>& ot, cons
|
||||||
Emit("case " + op + ":");
|
Emit("case " + op + ":");
|
||||||
BeginBlock();
|
BeginBlock();
|
||||||
GenAssignOpCore(ot, eval, ti.accessor, ti.is_managed);
|
GenAssignOpCore(ot, eval, ti.accessor, ti.is_managed);
|
||||||
|
if ( ! post_eval.empty() )
|
||||||
|
Emit(post_eval);
|
||||||
Emit("break;");
|
Emit("break;");
|
||||||
EndBlock();
|
EndBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post_eval.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAM_OpTemplate::GenAssignOpCore(const vector<ZAM_OperandType>& ot, const string& eval,
|
void ZAM_OpTemplate::GenAssignOpCore(const vector<ZAM_OperandType>& ot, const string& eval,
|
||||||
|
@ -1785,7 +1789,7 @@ void ZAM_InternalOpTemplate::Parse(const string& attr, const string& line, const
|
||||||
auto arg_offset = HasAssignVal() ? 1 : 0;
|
auto arg_offset = HasAssignVal() ? 1 : 0;
|
||||||
auto arg_slot = arg_offset + 1;
|
auto arg_slot = arg_offset + 1;
|
||||||
|
|
||||||
string func = "z.func";
|
string func = "z.aux->func";
|
||||||
|
|
||||||
if ( n == 1 )
|
if ( n == 1 )
|
||||||
{
|
{
|
||||||
|
@ -1841,16 +1845,24 @@ void ZAM_InternalOpTemplate::Parse(const string& attr, const string& line, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eval += "f->SetOnlyCall(z.call_expr.get());\n";
|
eval += "f->SetOnlyCall(z.aux->call_expr.get());\n";
|
||||||
|
eval += "ZAM_PROFILE_PRE_CALL\n";
|
||||||
|
|
||||||
if ( HasAssignVal() )
|
if ( HasAssignVal() )
|
||||||
{
|
{
|
||||||
auto av = GetAssignVal();
|
auto av = GetAssignVal();
|
||||||
eval += "auto " + av + " = " + func + "->Invoke(&args, f);\n";
|
eval += "auto " + av + " = " + func + "->Invoke(&args, f);\n";
|
||||||
eval += "if ( ! " + av + " ) { ZAM_error = true; break; }\n";
|
eval += "if ( ! " + av + " ) { ZAM_error = true; break; }\n";
|
||||||
|
|
||||||
|
// Postpone the profiling follow-up until after we process
|
||||||
|
// the assignment.
|
||||||
|
post_eval = "ZAM_PROFILE_POST_CALL\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
eval += "(void) " + func + "->Invoke(&args, f);\n";
|
eval += "(void) " + func + "->Invoke(&args, f);\n";
|
||||||
|
eval += "ZAM_PROFILE_POST_CALL\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TemplateInput::ScanLine(string& line)
|
bool TemplateInput::ScanLine(string& line)
|
||||||
|
|
|
@ -523,6 +523,9 @@ protected:
|
||||||
// The C++ evaluation; may span multiple lines.
|
// The C++ evaluation; may span multiple lines.
|
||||||
string eval;
|
string eval;
|
||||||
|
|
||||||
|
// Postlog C++ code (currently only used in support of profiling).
|
||||||
|
string post_eval;
|
||||||
|
|
||||||
// Any associated custom method.
|
// Any associated custom method.
|
||||||
string custom_method;
|
string custom_method;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue