Re: Modified Proposal for Context Sensitive Function Calls


Subject: Re: Modified Proposal for Context Sensitive Function Calls
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Wed Nov 20 2002 - 11:13:44 PST


> From john_stickley@mentorg.com Wed Nov 20 10:40:16 2002
>
> Kevin,
>
> Kevin Cameron wrote:
>
> > I'm afraid I have to disagree. Since your scheme has a single C-to-SV
> > entry-point per module, and mine can create an entry-point per instance
> > there is no way that your scheme will be as fast - it always has to decode
> > the instance on each call.
> >
> > To get the same/better efficiency with your approach you would have to
> > add the instance name to the export statement.
> >
> > There is still no way to check that arguments match if you just link by
> > C name.
 
 
> I kind of see what you're saying here but it is unclear to me why
> any implementor would want to create a distinct fragment of code
> for each call instance. The only thing you would gain is to be able to
> make the pointer to the internal data structure associated with
> that instance an "immediate" argument of some assembly instruction
> which would be of little added value.

Each instance of a module can have different parameters, so things like
array bounds can be different for every version of a routine/task in that
module and consequently they may get code generated seperately.
 
> Am I missing something ? Even pure C++ with all its efficiency
> only has one copy of code in a method that reused with all
> caller sites and instantiations of its containing class.

Virtual functions are the C++ method of addressing this kind of problem,
i.e. the method code varies by subclass but you can call one virtual
function to get to it when you don't know which subclass you actually
have.

> In my view, calling the SV function with a pre-determined context
> pointer is equivalent to calling a C++ method with a passed in "this"
> pointer which is always what is implicity done in the code that
> is compiled for a statement such as,
>
> myInstance->myClassMethod( args ... );
>
> What's really happening behind the scenes is that the C++
> compiler generates code that makes a function call like this:
>
> _myClassMethod( myInstance, args ... )
>
> -- johnS

C++ virtual functions still have to do a look-up on the instance (through
the virtual function table) to get the right implementation of the code,
so it's still less efficient than the dynamic binding I was suggesting
(plus we don't have supporting syntax in SV).

Kev.

>
> > Kev.
> > --
> > National Semiconductor, Tel: (408) 721 3251
> > 2900 Semiconductor Drive, Mail Stop D3-500, Santa Clara, CA 95052-8090
> >
> >
>
> --
>
> This email may contain material that is confidential, privileged
> and/or attorney work product for the sole use of the intended
> recipient. Any review, reliance or distribution by others or
> forwarding without express permission is strictly prohibited.
> If you are not the intended recipient, please contact the sender
> and delete all copies.
> __
> ______ | \
> ______________________/ \__ / \
> \ H Dome ___/ |
> John Stickley E | a __ ___/ / \____
> Principal Engineer l | l | \ /
> Verification Solutions Group | f | \/ ____
> Mentor Graphics Corp. - MED C \ -- / /
> 17 E. Cedar Place a \ __/ / /
> Ramsey, NJ 07446 p | / ___/
> | / /
> mailto:John_Stickley@mentor.com \ /
> Phone: (201)818-2585 \ /
> ---------
>
>
>
>



This archive was generated by hypermail 2b28 : Wed Nov 20 2002 - 11:14:20 PST