This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Global constants


Hi Frank,

On Mon, 2006-02-13 at 14:28 -0500, Frank Ch. Eigler wrote:

> If the main purpose of this syntax is to compress initialization of
> globals into a single line, one can do it with less effort.  The
> parser could rewrite
>     global var = expr
> to
>     global var; probe begin { var = expr }
> There need be no performance concerns here, partly because the
> optimizer will get rid of any such globals that are not read.

	Does the optimizer currently get rid of such globals? Maybe I missed
something, but I thought it didn't ... wouldn't be hard to fix that
though, granted.

>   It
> could similarly get rid of or merge initialization "begin" probes. 
> 
> Even with this sort of rewriting, if the right hand side of such
> assignments can be an expression, not just a literal, analysis &
> runtime considerations could become complicated.  Consider dependency
> ordering, context setup, error checking, if for example expr is a
> function call dealing with other globals.
> 
> If read-only-ness of these globals is important, then a new "const"
> keyword would indeed come in handy.  (I'd promptly reuse it as a
> qualifier for embedded-C functions that are declared to have no
> side-effects.)  I would implement this angle by a new flag on vardecl,
> enforced non-lvalueness during elaboration or translation, rather than
> whole new staptree.h classes.

	I guess there's a few reasons why I did it this way:

  - The fact that it's read-only means you don't need all the locking 
    that other variables need

  - By only allowing simple literals, you don't have to worry about 
    complexities with evaluating fully fledged expressions at runtime. 
    Although, simple symbol-free expressions like:

      const O_CREAT = 2 << 5

    would probably be a fairly straightforward addition.

  - It's a nice simple syntax for something that would be very useful 
    in the system tapsets

	You guys know best, though :-)

Cheers,
Mark.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]