Bug 6929 - support constant global variables
Summary: support constant global variables
Status: RESOLVED WORKSFORME
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-01 16:03 UTC by Masami Hiramatsu
Modified: 2015-11-28 14:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Masami Hiramatsu 2008-10-01 16:03:58 UTC
Systemtap global variable can be translated to constant immediate value(or just
a macro) if no one does write access to it(or, const suffix like as global
XXX:const).
Comment 1 Frank Ch. Eigler 2008-10-01 17:36:33 UTC
(In reply to comment #0)
> Systemtap global variable can be translated to constant immediate value(or just
> a macro) if no one does write access to it

This should be straightforward.  We already know when locking is unneeded for just
such globals: bug #2341.
Comment 2 Masami Hiramatsu 2008-10-01 18:38:39 UTC
(In reply to comment #1)
> This should be straightforward.  We already know when locking is unneeded for just
> such globals: bug #2341.

Sure, this request is more advanced one. We expect some formula including
immediate values are compounded to simpler formula. For example,
---
global TICKS:const=100
global HZ:const=1000

function ticktohz:long (tick) {
   return tick * HZ / TICKS; # this will be translated to tick * 10
}
---
Comment 3 Frank Ch. Eigler 2008-10-01 18:44:53 UTC
> Sure, this request is more advanced one. We expect some formula including
> immediate values are compounded to simpler formula. For example,
> ---
> global TICKS:const=100
> global HZ:const=1000
> 
> function ticktohz:long (tick) {
>    return tick * HZ / TICKS; # this will be translated to tick * 10
> }

Reusing the same analysis already done for lock elision, it should not be
necessary to designate anything with ":const" for this treatment.
Comment 4 Frank Ch. Eigler 2008-10-10 20:24:33 UTC
Note that this conflicts with bug #5642 and existing staprun GLOBAL=VALUE
functionality, since globals can be reinitialized later via staprun.
That means we couldn't literally substitute them at translate time.
Comment 5 Masami Hiramatsu 2008-10-10 23:53:33 UTC
(In reply to comment #4)
> Note that this conflicts with bug #5642 and existing staprun GLOBAL=VALUE
> functionality, since globals can be reinitialized later via staprun.
> That means we couldn't literally substitute them at translate time.

Hmm, even though, as I mentioned in comment #1, const suffix or something like that
can solve that conflict.
(or, const XXXXX=NNNN instead of global XXXXX:const=NNNNN)
Comment 6 Frank Ch. Eigler 2015-11-28 14:20:11 UTC
this may now be implemented via macros


@define const_global_foo %( 1 %)
probe begin { println(@const_global_foo) }