Groups | Blog | Home
all groups > dotnet clr > january 2005 >

dotnet clr : bytecode verifier vs. delegates


George
1/26/2005 9:33:09 AM
Could anyone help me in the following problems?

The ECMA standard states the following concerning the delegate constructors:

"The verification algorithm shall require that one of the following code
sequences is used for constructing delegates; no other code sequence in
verifiable code shall contain a newobj instruction for a delegate type."

Delegating via Virtual Dispatch:

dup
ldvirtftn mthd
newobj

Delegating via Instance Dispatch:

ldftn
newobj

I understand that the bytecode verifier needs a "dup" instruction in case of
"Virtual Dispatch". I do not see why the verifier requires the order of
instructions given in the "Instance Dispatch".

Why cannot I have any instructions between "ldftn" and "newobj"?
Why there should be a null or an object on the stack *right before* the
ldftn instruction?

Many thanks!
Daniel O'Connell [C# MVP]
1/27/2005 9:42:56 AM
[quoted text, click to view]

Its easier to verify. By using a specific stream of instructions there is no
chance an incorrect function can be loaded.

[quoted text, click to view]

Because the constructor takes an object and a function pointer, thus an
object has to be on the stack before the sequence begins or you would have
no stack value to pass to the constructor.

AddThis Social Bookmark Button