mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
tracking of optimization information associated with statements
This commit is contained in:
parent
ed3c87d253
commit
3ac725f44b
3 changed files with 39 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "zeek/Trigger.h"
|
#include "zeek/Trigger.h"
|
||||||
#include "zeek/IntrusivePtr.h"
|
#include "zeek/IntrusivePtr.h"
|
||||||
#include "zeek/logging/Manager.h"
|
#include "zeek/logging/Manager.h"
|
||||||
|
#include "zeek/script_opt/StmtOptInfo.h"
|
||||||
|
|
||||||
#include "zeek/logging/logging.bif.h"
|
#include "zeek/logging/logging.bif.h"
|
||||||
|
|
||||||
|
@ -49,11 +50,14 @@ Stmt::Stmt(StmtTag arg_tag)
|
||||||
last_access = 0;
|
last_access = 0;
|
||||||
access_count = 0;
|
access_count = 0;
|
||||||
|
|
||||||
|
opt_info = new StmtOptInfo();
|
||||||
|
|
||||||
SetLocationInfo(&start_location, &end_location);
|
SetLocationInfo(&start_location, &end_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stmt::~Stmt()
|
Stmt::~Stmt()
|
||||||
{
|
{
|
||||||
|
delete opt_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
StmtList* Stmt::AsStmtList()
|
StmtList* Stmt::AsStmtList()
|
||||||
|
|
|
@ -48,6 +48,8 @@ class Reducer;
|
||||||
class Stmt;
|
class Stmt;
|
||||||
using StmtPtr = IntrusivePtr<Stmt>;
|
using StmtPtr = IntrusivePtr<Stmt>;
|
||||||
|
|
||||||
|
class StmtOptInfo;
|
||||||
|
|
||||||
class Stmt : public Obj {
|
class Stmt : public Obj {
|
||||||
public:
|
public:
|
||||||
StmtTag Tag() const { return tag; }
|
StmtTag Tag() const { return tag; }
|
||||||
|
@ -160,6 +162,10 @@ public:
|
||||||
return Obj::GetLocationInfo();
|
return Obj::GetLocationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access script optimization information associated with
|
||||||
|
// this statement.
|
||||||
|
StmtOptInfo* GetOptInfo() const { return opt_info; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Stmt(StmtTag arg_tag);
|
explicit Stmt(StmtTag arg_tag);
|
||||||
|
|
||||||
|
@ -182,6 +188,10 @@ protected:
|
||||||
// derived, if any. Used as an aid for generating meaningful
|
// derived, if any. Used as an aid for generating meaningful
|
||||||
// and correctly-localized error messages.
|
// and correctly-localized error messages.
|
||||||
StmtPtr original = nullptr;
|
StmtPtr original = nullptr;
|
||||||
|
|
||||||
|
// Information associated with the Stmt for purposes of
|
||||||
|
// script optimization.
|
||||||
|
StmtOptInfo* opt_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
25
src/script_opt/StmtOptInfo.h
Normal file
25
src/script_opt/StmtOptInfo.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
|
// Auxiliary information associated with statements to aid script
|
||||||
|
// optimization.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace zeek::detail {
|
||||||
|
|
||||||
|
class StmtOptInfo {
|
||||||
|
public:
|
||||||
|
// We number statements by their traversal order in the AST.
|
||||||
|
int stmt_num = -1; // -1 = not assigned yet
|
||||||
|
|
||||||
|
// The confluence block nesting associated with the statement.
|
||||||
|
// We number these using 0 for the outermost block of a function
|
||||||
|
// (which, strictly speaking, isn't a confluence block).
|
||||||
|
int block_level = -1;
|
||||||
|
|
||||||
|
// True if we observe that there is a branch out of the statement
|
||||||
|
// to just beyond its extent, such as due to a "break".
|
||||||
|
bool contains_branch_beyond = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace zeek::detail
|
Loading…
Add table
Add a link
Reference in a new issue