mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
removal of unused functionality and some follow-on simplifications
This commit is contained in:
parent
ecc93606c4
commit
b6b4a81e0d
9 changed files with 17 additions and 143 deletions
|
@ -52,7 +52,6 @@ const char* stmt_name(StmtTag t)
|
||||||
"check-any-length",
|
"check-any-length",
|
||||||
"compiled-C++",
|
"compiled-C++",
|
||||||
"ZAM",
|
"ZAM",
|
||||||
"ZAM-resumption",
|
|
||||||
"null",
|
"null",
|
||||||
"assert",
|
"assert",
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,6 @@ enum StmtTag
|
||||||
STMT_CHECK_ANY_LEN, // internal reduced statement
|
STMT_CHECK_ANY_LEN, // internal reduced statement
|
||||||
STMT_CPP, // compiled C++
|
STMT_CPP, // compiled C++
|
||||||
STMT_ZAM, // a ZAM function body
|
STMT_ZAM, // a ZAM function body
|
||||||
STMT_ZAM_RESUMPTION, // resumes ZAM execution for "when" statements
|
|
||||||
STMT_NULL,
|
STMT_NULL,
|
||||||
STMT_ASSERT,
|
STMT_ASSERT,
|
||||||
#define NUM_STMTS (int(STMT_ASSERT) + 1)
|
#define NUM_STMTS (int(STMT_ASSERT) + 1)
|
||||||
|
|
|
@ -138,7 +138,6 @@ public:
|
||||||
std::shared_ptr<ProfileFunc> ProfilePtr() const { return pf; }
|
std::shared_ptr<ProfileFunc> ProfilePtr() const { return pf; }
|
||||||
|
|
||||||
void SetBody(StmtPtr new_body) { body = std::move(new_body); }
|
void SetBody(StmtPtr new_body) { body = std::move(new_body); }
|
||||||
// void SetProfile(std::shared_ptr<ProfileFunc> _pf);
|
|
||||||
void SetProfile(std::shared_ptr<ProfileFunc> _pf) { pf = std::move(_pf); }
|
void SetProfile(std::shared_ptr<ProfileFunc> _pf) { pf = std::move(_pf); }
|
||||||
|
|
||||||
// The following provide a way of marking FuncInfo's as
|
// The following provide a way of marking FuncInfo's as
|
||||||
|
|
|
@ -927,47 +927,6 @@ const ZInstI* ZAMCompiler::EndOfLoop(const ZInstI* inst, int depth) const
|
||||||
return insts1[i];
|
return insts1[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZAMCompiler::VarIsAssigned(int slot) const
|
|
||||||
{
|
|
||||||
for ( auto& inst : insts1 )
|
|
||||||
if ( inst->live && VarIsAssigned(slot, inst) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZAMCompiler::VarIsAssigned(int slot, const ZInstI* i) const
|
|
||||||
{
|
|
||||||
// Special-case for table iterators, which assign to a bunch
|
|
||||||
// of variables but they're not immediately visible in the
|
|
||||||
// instruction layout.
|
|
||||||
if ( i->op == OP_NEXT_TABLE_ITER_VAL_VAR_VVV || i->op == OP_NEXT_TABLE_ITER_VV )
|
|
||||||
{
|
|
||||||
auto& iter_vars = i->aux->loop_vars;
|
|
||||||
for ( auto v : iter_vars )
|
|
||||||
if ( v == slot )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ( i->op != OP_NEXT_TABLE_ITER_VAL_VAR_VVV )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Otherwise fall through, since that flavor of iterate
|
|
||||||
// *does* also assign to slot 1.
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( i->op == OP_NEXT_VECTOR_ITER_VAL_VAR_VVVV && i->v2 == slot )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ( i->op_type == OP_VV_FRAME )
|
|
||||||
// We don't want to consider these as assigning to the
|
|
||||||
// variable, since the point of this method is to figure
|
|
||||||
// out which variables don't need storing to the frame
|
|
||||||
// because their internal value is never modified.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return i->AssignsToSlot1() && i->v1 == slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ZAMCompiler::VarIsUsed(int slot) const
|
bool ZAMCompiler::VarIsUsed(int slot) const
|
||||||
{
|
{
|
||||||
for ( auto& inst : insts1 )
|
for ( auto& inst : insts1 )
|
||||||
|
|
|
@ -459,14 +459,6 @@ private:
|
||||||
const ZInstI* BeginningOfLoop(const ZInstI* inst, int depth) const;
|
const ZInstI* BeginningOfLoop(const ZInstI* inst, int depth) const;
|
||||||
const ZInstI* EndOfLoop(const ZInstI* inst, int depth) const;
|
const ZInstI* EndOfLoop(const ZInstI* inst, int depth) const;
|
||||||
|
|
||||||
// True if any statement other than a frame sync assigns to the
|
|
||||||
// given slot.
|
|
||||||
bool VarIsAssigned(int slot) const;
|
|
||||||
|
|
||||||
// True if the given statement assigns to the given slot, and
|
|
||||||
// it's not a frame sync.
|
|
||||||
bool VarIsAssigned(int slot, const ZInstI* i) const;
|
|
||||||
|
|
||||||
// True if any statement other than a frame sync uses the given slot.
|
// True if any statement other than a frame sync uses the given slot.
|
||||||
bool VarIsUsed(int slot) const;
|
bool VarIsUsed(int slot) const;
|
||||||
|
|
||||||
|
|
|
@ -33,20 +33,9 @@ void ZAMCompiler::Init()
|
||||||
{
|
{
|
||||||
InitGlobals();
|
InitGlobals();
|
||||||
InitArgs();
|
InitArgs();
|
||||||
|
InitCaptures();
|
||||||
InitLocals();
|
InitLocals();
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Complain about unused aggregates ... but not if we're inlining,
|
|
||||||
// as that can lead to optimizations where they wind up being unused
|
|
||||||
// but the original logic for using them was sound.
|
|
||||||
if ( ! analysis_options.inliner )
|
|
||||||
for ( auto a : pf->Inits() )
|
|
||||||
{
|
|
||||||
if ( pf->Locals().find(a) == pf->Locals().end() )
|
|
||||||
reporter->Warning("%s unused", a->Name());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TrackMemoryManagement();
|
TrackMemoryManagement();
|
||||||
|
|
||||||
non_recursive = non_recursive_funcs.count(func) > 0;
|
non_recursive = non_recursive_funcs.count(func) > 0;
|
||||||
|
@ -216,11 +205,6 @@ StmtPtr ZAMCompiler::CompileBody()
|
||||||
// Could erase insts1 here to recover memory, but it's handy
|
// Could erase insts1 here to recover memory, but it's handy
|
||||||
// for debugging.
|
// for debugging.
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ( non_recursive )
|
|
||||||
func->UseStaticFrame();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto zb = make_intrusive<ZBody>(func->Name(), this);
|
auto zb = make_intrusive<ZBody>(func->Name(), this);
|
||||||
zb->SetInsts(insts2);
|
zb->SetInsts(insts2);
|
||||||
|
|
||||||
|
|
|
@ -1109,19 +1109,6 @@ const ZAMStmt ZAMCompiler::DoCall(const CallExpr* c, const NameExpr* n)
|
||||||
z.func = func_id->GetVal()->AsFunc();
|
z.func = func_id->GetVal()->AsFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( n )
|
|
||||||
{
|
|
||||||
auto id = n->Id();
|
|
||||||
if ( id->IsGlobal() )
|
|
||||||
{
|
|
||||||
AddInst(z);
|
|
||||||
auto global_slot = global_id_to_info[id];
|
|
||||||
z = ZInstI(OP_STORE_GLOBAL_V, global_slot);
|
|
||||||
z.op_type = OP_V_I1;
|
|
||||||
z.t = globalsI[global_slot].id->GetType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AddInst(z);
|
return AddInst(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,10 +193,10 @@ ZBody::~ZBody()
|
||||||
|
|
||||||
void ZBody::SetInsts(vector<ZInst*>& _insts)
|
void ZBody::SetInsts(vector<ZInst*>& _insts)
|
||||||
{
|
{
|
||||||
ninst = _insts.size();
|
end_pc = _insts.size();
|
||||||
auto insts_copy = new ZInst[ninst];
|
auto insts_copy = new ZInst[end_pc];
|
||||||
|
|
||||||
for ( auto i = 0U; i < ninst; ++i )
|
for ( auto i = 0U; i < end_pc; ++i )
|
||||||
insts_copy[i] = *_insts[i];
|
insts_copy[i] = *_insts[i];
|
||||||
|
|
||||||
insts = insts_copy;
|
insts = insts_copy;
|
||||||
|
@ -206,10 +206,10 @@ void ZBody::SetInsts(vector<ZInst*>& _insts)
|
||||||
|
|
||||||
void ZBody::SetInsts(vector<ZInstI*>& instsI)
|
void ZBody::SetInsts(vector<ZInstI*>& instsI)
|
||||||
{
|
{
|
||||||
ninst = instsI.size();
|
end_pc = instsI.size();
|
||||||
auto insts_copy = new ZInst[ninst];
|
auto insts_copy = new ZInst[end_pc];
|
||||||
|
|
||||||
for ( auto i = 0U; i < ninst; ++i )
|
for ( auto i = 0U; i < end_pc; ++i )
|
||||||
{
|
{
|
||||||
auto& iI = *instsI[i];
|
auto& iI = *instsI[i];
|
||||||
insts_copy[i] = iI;
|
insts_copy[i] = iI;
|
||||||
|
@ -228,7 +228,7 @@ void ZBody::InitProfile()
|
||||||
{
|
{
|
||||||
inst_count = new vector<int>;
|
inst_count = new vector<int>;
|
||||||
inst_CPU = new vector<double>;
|
inst_CPU = new vector<double>;
|
||||||
for ( auto i = 0U; i < ninst; ++i )
|
for ( auto i = 0U; i < end_pc; ++i )
|
||||||
{
|
{
|
||||||
inst_count->push_back(0);
|
inst_count->push_back(0);
|
||||||
inst_CPU->push_back(0.0);
|
inst_CPU->push_back(0.0);
|
||||||
|
@ -245,7 +245,7 @@ ValPtr ZBody::Exec(Frame* f, StmtFlowType& flow)
|
||||||
double t = analysis_options.profile_ZAM ? util::curr_CPU_time() : 0.0;
|
double t = analysis_options.profile_ZAM ? util::curr_CPU_time() : 0.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto val = DoExec(f, 0, flow);
|
auto val = DoExec(f, flow);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( analysis_options.profile_ZAM )
|
if ( analysis_options.profile_ZAM )
|
||||||
|
@ -255,10 +255,9 @@ ValPtr ZBody::Exec(Frame* f, StmtFlowType& flow)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
|
ValPtr ZBody::DoExec(Frame* f, StmtFlowType& flow)
|
||||||
{
|
{
|
||||||
int pc = start_pc;
|
int pc = 0;
|
||||||
const int end_pc = ninst;
|
|
||||||
|
|
||||||
// Return value, or nil if none.
|
// Return value, or nil if none.
|
||||||
const ZVal* ret_u = nullptr;
|
const ZVal* ret_u = nullptr;
|
||||||
|
@ -293,6 +292,9 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
|
||||||
|
|
||||||
flow = FLOW_RETURN; // can be over-written by a Hook-Break
|
flow = FLOW_RETURN; // can be over-written by a Hook-Break
|
||||||
|
|
||||||
|
// Clear any leftover error state.
|
||||||
|
ZAM_error = false;
|
||||||
|
|
||||||
while ( pc < end_pc && ! ZAM_error )
|
while ( pc < end_pc && ! ZAM_error )
|
||||||
{
|
{
|
||||||
auto& z = insts[pc];
|
auto& z = insts[pc];
|
||||||
|
@ -369,9 +371,6 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
|
||||||
delete[] frame;
|
delete[] frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear any error state.
|
|
||||||
ZAM_error = false;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +448,7 @@ void ZBody::Dump() const
|
||||||
|
|
||||||
printf("Final code:\n");
|
printf("Final code:\n");
|
||||||
|
|
||||||
for ( unsigned i = 0; i < ninst; ++i )
|
for ( unsigned i = 0; i < end_pc; ++i )
|
||||||
{
|
{
|
||||||
auto& inst = insts[i];
|
auto& inst = insts[i];
|
||||||
printf("%d: ", i);
|
printf("%d: ", i);
|
||||||
|
@ -472,25 +471,6 @@ TraversalCode ZBody::Traverse(TraversalCallback* cb) const
|
||||||
HANDLE_TC_STMT_POST(tc);
|
HANDLE_TC_STMT_POST(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValPtr ZAMResumption::Exec(Frame* f, StmtFlowType& flow)
|
|
||||||
{
|
|
||||||
return am->DoExec(f, xfer_pc, flow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZAMResumption::StmtDescribe(ODesc* d) const
|
|
||||||
{
|
|
||||||
d->Add("<resumption of compiled code>");
|
|
||||||
}
|
|
||||||
|
|
||||||
TraversalCode ZAMResumption::Traverse(TraversalCallback* cb) const
|
|
||||||
{
|
|
||||||
TraversalCode tc = cb->PreStmt(this);
|
|
||||||
HANDLE_TC_STMT_PRE(tc);
|
|
||||||
|
|
||||||
tc = cb->PostStmt(this);
|
|
||||||
HANDLE_TC_STMT_POST(tc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unary vector operation of v1 <vec-op> v2.
|
// Unary vector operation of v1 <vec-op> v2.
|
||||||
static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const ZInst& z)
|
static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const ZInst& z)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,12 +52,10 @@ public:
|
||||||
void ProfileExecution() const;
|
void ProfileExecution() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class ZAMResumption;
|
|
||||||
|
|
||||||
// Initializes profiling information, if needed.
|
// Initializes profiling information, if needed.
|
||||||
void InitProfile();
|
void InitProfile();
|
||||||
|
|
||||||
ValPtr DoExec(Frame* f, int start_pc, StmtFlowType& flow);
|
ValPtr DoExec(Frame* f, StmtFlowType& flow);
|
||||||
|
|
||||||
// Run-time checking for "any" type being consistent with
|
// Run-time checking for "any" type being consistent with
|
||||||
// expected typed. Returns true if the type match is okay.
|
// expected typed. Returns true if the type match is okay.
|
||||||
|
@ -73,7 +71,7 @@ private:
|
||||||
const char* func_name = nullptr;
|
const char* func_name = nullptr;
|
||||||
|
|
||||||
const ZInst* insts = nullptr;
|
const ZInst* insts = nullptr;
|
||||||
unsigned int ninst = 0;
|
unsigned int end_pc = 0;
|
||||||
|
|
||||||
FrameReMap frame_denizens;
|
FrameReMap frame_denizens;
|
||||||
int frame_size;
|
int frame_size;
|
||||||
|
@ -117,29 +115,6 @@ private:
|
||||||
CaseMaps<std::string> str_cases;
|
CaseMaps<std::string> str_cases;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is a statement that resumes execution into a code block in a
|
|
||||||
// ZBody. Used for deferred execution for "when" statements.
|
|
||||||
|
|
||||||
class ZAMResumption : public Stmt
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ZAMResumption(ZBody* _am, int _xfer_pc) : Stmt(STMT_ZAM_RESUMPTION), am(_am), xfer_pc(_xfer_pc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ValPtr Exec(Frame* f, StmtFlowType& flow) override;
|
|
||||||
|
|
||||||
StmtPtr Duplicate() override { return {NewRef{}, this}; }
|
|
||||||
|
|
||||||
void StmtDescribe(ODesc* d) const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
|
||||||
|
|
||||||
ZBody* am;
|
|
||||||
int xfer_pc = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Prints the execution profile.
|
// Prints the execution profile.
|
||||||
extern void report_ZOP_profile();
|
extern void report_ZOP_profile();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue