Subject: Re: [sv-cc] DPI context - setting/preserving&resetting a scope
From: Stickley, John (john_stickley@mentorg.com)
Date: Fri Mar 14 2003 - 14:10:56 PST
Andrzej,
Andrzej Litwiniuk wrote:
> Hi Michael,
>
> Thanks for catching my mistake in my cooked-up scenario!
>
>
> > > Consider the folowing sequence of DPI calls (interleaved context and
> > > non-context functions):
> > > SV --> context_cfunc1 --> SV --> non_context_cfunc2 --> SV
> > >
> > > The scope set at the call of context_cfunc1 is preserved and that way
> > > still avaialble while non_context_cfunc2 is executed; we don't want
> > > to do anything with a scope (overhead!) for non-context calls, do we?
>
> > Calling SV from a non-context function is considered illegal and the
> result is therefore undefined.
>
> Right! A call 'non_context_cfunc2 --> SV' is of course illegal and
> therefore
> any weird behaviour may happen.
>
> I was very concerned with one part of the specification of svScope
> svGetScope():
> "Returns NULL if invoked from within a non-context function"
> I was wondering whether this can be (efficiently) supported and this is
> how I
> came to that cooked-up call chain. For the sake of performance the calls
> of "regular" external functions (i.e. non-context) will not be
> instrumented;
> specifically, there will be no additional code for resetting the current
> context.
> Thus a non-context function will simply inherit the most recently set
> scope.
> I have no problem with this. It cannot be claimed, however, that
> svGetScope()
> will return NULL if called from a non-context function, although it can be
> claimed that it will return NULL if called from a call chain that does
> not start with a context function. This is my main point.
johnS:
There are probably a number of different "right" answers here.
What you say here probably is acceptible.
Most likely it will be safer however, if the current context
is set to NULL by the infrastructure whenever a non-context
function is called.
This way, an application will never inadventently use an
unintended scope.
Really the way a non-context function might typically call
an exported function in the (most likely rare) case that
it finds a need to, it would probably use a scope handle
that was derived from svGetScopeFromName(). This would be
equivalent to making a function call though a hierarchical
reference in SV.
-- johnS
__
______ | \
______________________/ \__ / \
\ 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 : Fri Mar 14 2003 - 14:13:20 PST