[Mono-devel-list] Flag-ing security actions

Ben Maurer bmaurer at ximian.com
Tue Nov 16 22:01:39 EST 2004

On Tue, 2004-11-16 at 11:57 -0500, Sebastien Pouliot wrote:
> So I'm trying to reduce... There are 4 (well for class/method) times
> when actions needs to be categorized:
> * load time;
> 	- check for [NonCas]InheritanceDemand[Choice] actions;
> * JIT time (2);
> 	- check for [NonCas]LinkDemand[Choice] actions;
> 	- generate code for [NonCas]Demand[Choice] actions;
> * Run time
> 	- check for stack modifiers: Assert, Deny and PermitOnly
> Still too much but...
> Load time is less problematic because
> - it happens only once;
> - it happens first and always (so it's great place to set the flags ;-)
> JIT code generation also only happen once (well if the method gets
> JITted) so doing a "full lookup" in the metadata wouldn't be "too bad".

Yeah, perf is not really an issue there (well, as long as you keep
things sane :-).

> So it could be squeezed into 2 bits like this:
> HasSecurity and bit 0 -> [NonCas]LinkDemand[Choice]
> HasSecurity and bit 1 -> Stack modifiers (Assert | Deny | PermitOnly)

The jit info structure could be used to hold these bits. That structure
is created for fewer methods (only those which are jitted...). Since you
don't need to cache this information for Jit/Load time, it is ok to use
this structure.

And, there just so happens to be a space in the jit info for 31 bools!
What more could one ask for?

Ben Maurer <bmaurer at ximian.com>

More information about the Mono-devel-list mailing list