winddbg
sxe ld clrjit .loadby sos clr !procinfo g go k call stack native !name2ee memory structure EEClass method table
!dumpmd !U decompile k=native stack !dumpil [addr] !clrstack ~0s main thread !dumpheap -stat
!dumpheap -stat System.Byte[] !do [address] !dumpmt -md (object vs. method table)
!dso stack obj (.prefer_dml 1 will has link to address ease of use) k native callstack !dumheap -type DynamicMethod
F6, Break !gcroot [addr] who is holding obj
compiler tools
dumpbin corflags.exe csc /platform:x86 => corflags corflags /32bitreq- or + will change exe header
csc /r:a=foo.dll /o+ (extern alias a; a::foo.f();)
ildasm/ilspy
ldstr,ldarg.0,stloc.0, ldfld, brtrue.s,callvirt, switch,<>_dictionary,WinForm/WPF single thread custom add/Remove event no CAS,
cache delegate inst vs c_displayClass for closure, heap allocated. lambda/expression tree delegate instance caching
expression node: const, lambdad node, BiOp node param shared ref vs. delegate instance Func'1<int32>
f.Compile() will jit efficient code home-iconicity Enumerable<T> vs Queryable<T>, Delegate vs. Expression tree, Where/Select.
ldtoken method valuetype refelection getMethodFromHandle
Language Extension
dynamic d=new myD() class myD : DynamincObject {override bool TrySetMemeber(binder,v){_dict[binder.Name]=v;
git.com has AsDynamic make obj dynamic by reflection
await button1 public static class Ext { btnAwaiter GetAwaiter(this Buttont b) { return new btnAwaiter(btn);}}
class btnAwaiter :INotifyCompletion { IsCompleted; GetResult(); OnCompleted(action continuation) {_b.Clicked=continuation();}
IAsyncStateMachine.MoveNext(), Stack Splilling, f1()+f2()+ await f3(), need to have splill stack onto heap due to await
List<T> !dumpheap -stat
!dumpmt -md [addr] will trck down List'1[int32, string, reftype] !dumpclass [EEClass Addr] __Cannon ref type
u clr!ArrayStoreCheck native stack covariant check start from clr code clr!... covariant IRead<out T> contravariant IWrite<in T>
C++ Export Symbol
win32 C++ project check export sysmbol will InterOp COM, csc /link=Embed InterOp, PIA as dev tool, no pIA deployment.
[DllImport("test.dll",CallingConvention=Cdecl)] public static extern "C" void com_function() convention= Stack mgt.
safe pointer:
struct IntPtr { unsafe void* m_value} struct TypeReference { IntPtr type; IntPtr value;}
int x=42; TypeReference r=__makeref(x); //local only, cannot return __refvalue(r,int)= -42; Type t=__reftype(r);
var boxing =TypeReference.ToObject(r); int* p=&x; is unsafe. CAS uses __makeref to be performance native code
Syste.ValueType is System.Object, Heap has MT method table.
__arglist only usefull c# interOp c++/CLI
mySafe::tryout_arglist^ u = gcnew Unsafe::tryout_arglist();
u->Test(1, 2, 3, "y");
public class tryout_arglist {
public void Test(__arglist){
var itr = new ArgIterator(__arglist);
for(int i=0;i<itr.GetRemainingCount();i++){
var r = itr.GetNextArg();
var v = TypedReference.ToObject(r);
Iterator:
yield return is a statemachine, ILSpy _state=-1; switch(_state) case 0: _state=1
local var is on heap, so must set var=null if eager GC. GC.GetTotalMemory(fullgccollection:true) shows big
IEnumerable cannot have out/ref since stackframe is on heap, danger.
IEnumerable<T> and IEnumerator<T> both yield return but former need GetEnumerator() and check Env.GetManagedThreadId
INPC using expression tree---Notify(()=>Bid0)
VMBase::Nofity<T>(<Expression<Func<T>> s) { PropertyChangeEventHandler h=this.PropertyChanged;
var pi=(s as MemberExpression).Member).Body as PropertyInfo; h(this,pi.Name);
_state=-2 vs _state=-1 start in ILSpy.
Wednesday, March 9, 2016
C# blast
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment