public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "fche at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/18431] New: runtime function overloading facility
Date: Tue, 19 May 2015 15:46:00 -0000	[thread overview]
Message-ID: <bug-18431-6586@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=18431

            Bug ID: 18431
           Summary: runtime function overloading facility
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: fche at redhat dot com
  Target Milestone: ---

It turns out to be necessary to have a facility that allows end-user scripts to
call generic functions like jstack(), while multiple alternative
implementations available in the tapset library.  The method of choosing
between the alternatives must be done at run-time (since it's run-time state
such as "which VM is this thread running in?" that decides), so we're talking
about a control-flow extension rather than translate-time processing like c++
overloading.

Possible syntax at call site: foo() - i.e., no visible change.

Possible syntax at definitions:
   function foo () {
      ...
      ... if (condition) next; ...
      ...
   }

Possible semantics: for a call, expand to:

- at translate time, construct sorted list of functions that match call
  - prefer end-user script highest/first, to provide override capability
  - sort others somehow (maybe have explicit ranking like begin(N) probes)

- pseudocode for generated call:
  - evaluate PARAMS into temporary variable, for side-effects
  - foreach FUNCTION in ALTERNATIVES
    - call FUNCTION(PARAM_copies)
    - if it returned normally or with an exception/error, done
    - else it exited with a 'next' (a new flag in the context structure);
      continue looping
  - if all alternatives functions exited with 'next', throw an exception
  - (All this can be optimized to current code etc, if the translator
    detects no 'next' statements in the function body.  Ignore
    transitively called functions.)

- pseudocode for function-side next: easy peasy
  - set function-context nexted-out flag
  - return

In this model, any side-effects caused by the alternative functions, before
they run 'next', will persist.

-- 
You are receiving this mail because:
You are the assignee for the bug.

             reply	other threads:[~2015-05-19 15:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 15:46 fche at redhat dot com [this message]
2015-09-23 21:54 ` [Bug translator/18431] " ajakop at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-18431-6586@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).