public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Uday P. Khedker" <uday@cse.iitb.ac.in>
To: gcc@gcc.gnu.org
Cc: J Decker <d3ck0r@gmail.com>
Subject: Re: Guidance needed: hi-level steps to track an object until its destruction
Date: Sun, 29 Aug 2010 19:49:00 -0000	[thread overview]
Message-ID: <4C7A918F.2010101@cse.iitb.ac.in> (raw)
In-Reply-To: <AANLkTi=kWdtP5V87ZpJLm22cPFdEagkknWNb-jHtVCYj@mail.gmail.com>

Unfortunately I am not aware of C# implementation so can't respond to this...

Uday.

J Decker wrote, On Sunday 29 August 2010 05:32 PM:
> Just out of curiosity - isn't this what C# does with objects?  would
> it perhaps be something like that in how mcs (mono) builds objects and
> tracks their lifespan?
>
> On Sun, Aug 29, 2010 at 4:43 AM, Uday P. Khedker<uday@cse.iitb.ac.in>  wrote:
>>
>>> I am not sure that is easily feasible. I would believe it is impossible.
>>>
>>> Within the compiler (or inside a GCC plugin, or inside a GCC extension
>>> coded in MELT), you probably are able change/inspect C++ classes&    every
>>> other declaration any compiler is tracking. You are also able to find
>>> every occurrence of variables containing a pointer to such classes.
>>
>>>
>>> However, you are apparently willing to track a single *instance* of such
>>> a class, and this instance is in the execution of the compiled program
>>> [not inside the compiler]. This means that you are able to deal with all
>>
>>
>> To put it in other words: Here the issue is seeking runtime information at
>> compile time. An object is a run time entity. At compile time, we only see
>> the class. However, we also see the statements that create an object and
>> manipulate it. Although it is not possible to track each object distinctly,
>> a compile time approximation is certainly possible. And that is where
>> creativity
>> in compiler research lies. The better the approximations, the better the
>> gains.
>> For example, all objects that get created by a given statement can be
>> treated
>> alike. There is no way of distinguishing between them at compile time, but
>> perhaps
>> there is no need to do so because all of them are likely to be treated alike
>> at run time. if an object O1 and O2 are created by the same statement,
>> asking
>> the question whether a method m1 is invoked for O1 does not need us to
>> distinguish
>> between O1 and O2.
>>
>> To summarize, a good approximation is indeed possible at compile time.
>>
>>
>>> the aliasing&    pointer equivalence issues (a task known to be
>>> impossible). How can the compiler surely know that pointer p in [a
>>> particular instruction of] method YourClass::foo() is never (or
>>> sometimes, or always) pointing to the same instance -in the running
>>> process of the compiled program- as pointer q in method yourclass::bar()
>>
>> Basile, you keep mentioning that English is not your first language and I
>> appreciate your politeness for reminding the reader for that (English is not
>> the first language for me too). It is in that light that I would like to
>> point
>> out that your use of word "impossible" is a little too strong. Perhaps you
>> mean
>> difficult. It is impossible if you want exact information. However, if
>> imprecisions can be tolerated for some gains, excellent approximations are
>> possible _within_ a procedure body which is what Jeff asked for, to begin
>> with.
>>
>> We have been working on this problem (pointer analysis) for a while but
>> are quite far from production implementation. Our ideas now seem to mature
>> a bit and whenever we have a conference paper, I will be happy to share it
>> with the gcc folks.
>>
>>> Or maybe you want to instrument your compiler so that for every code
>>> emitted for method yourclass::gee() you add a first block which checks
>>> that the this reciever is not a given pointer.
>>>
>>> In other words&    C++ parlance, you could (this is doable, but not
>>> trivial) hack the compiler so that at the start of every method (i.e.
>>> member function in C++) the equivalent of the following C++ code has
>>> been magically added
>>>
>>>    extern "C" YourClass* hunted_yourclass_pointer;
>>>    extern "C" void some_error_routine(void);
>>>
>>>    if (this == hunted_yourclass_pointer)
>>>      some_error_routine();
>>
>> This is a very good way of paraphrasing the "ideal" requirement.
>>
>> Regards,
>>
>> Uday.
>>

  reply	other threads:[~2010-08-29 16:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  9:49 Beginner: Declarations do not show up when iterating through Gimple stmts Jeff Saremi
2010-08-26 10:16 ` Richard Guenther
2010-08-27  4:10   ` Jeff Saremi
2010-08-27  8:00   ` Guidance needed: hi-level steps to track an object until its destruction Jeff Saremi
2010-08-28 17:44     ` Basile Starynkevitch
2010-08-28 17:53       ` Jeff Saremi
2010-08-29 13:25       ` Uday P. Khedker
2010-08-29 16:58         ` J Decker
2010-08-29 19:49           ` Uday P. Khedker [this message]
2010-08-29 17:50         ` Basile Starynkevitch

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=4C7A918F.2010101@cse.iitb.ac.in \
    --to=uday@cse.iitb.ac.in \
    --cc=d3ck0r@gmail.com \
    --cc=gcc@gcc.gnu.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).