diff options
author | jfrijters <jfrijters> | 2011-12-12 13:57:23 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-12-12 13:57:23 +0400 |
commit | ac2d14a082886e4ea645e944df108152271457dd (patch) | |
tree | edb7dd995f7d7904840e3c4b064dc6bcdf2f7eba | |
parent | 387c7b17f6f81de693ad7473b23005925d468092 (diff) |
Moved indy call site state into FinishContext.
-rw-r--r-- | runtime/DynamicTypeWrapper.cs | 8 | ||||
-rw-r--r-- | runtime/compiler.cs | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 6ebadc58..1800af73 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -5320,6 +5320,14 @@ namespace IKVM.Internal } return cb; } + + internal TypeBuilder DefineIndyCallSiteType() + { + int id = nestedTypeBuilders == null ? 0 : nestedTypeBuilders.Count; + TypeBuilder tb = typeBuilder.DefineNestedType("__<>IndyCS" + id, TypeAttributes.NestedPrivate | TypeAttributes.Abstract | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit); + RegisterNestedTypeBuilder(tb); + return tb; + } } private static bool CheckRequireOverrideStub(MethodWrapper mw1, MethodWrapper mw2) diff --git a/runtime/compiler.cs b/runtime/compiler.cs index 6ca27139..d39f7554 100644 --- a/runtime/compiler.cs +++ b/runtime/compiler.cs @@ -2983,12 +2983,11 @@ sealed class Compiler } } - private sealed class InvokeDynamicBuilder + private static class InvokeDynamicBuilder { private static readonly Type typeofOpenIndyCallSite; private static readonly Type typeofCallSite; private static readonly MethodInfo methodLookup; - private int count; static InvokeDynamicBuilder() { @@ -3007,7 +3006,7 @@ sealed class Compiler methodLookup = typeofMethodHandles.GetMethod("lookup", new Type[] { CoreClasses.ikvm.@internal.CallerID.Wrapper.TypeAsSignatureType }); } - internal void Emit(Compiler compiler, ClassFile.ConstantPoolItemInvokeDynamic cpi, Type delegateType) + internal static void Emit(Compiler compiler, ClassFile.ConstantPoolItemInvokeDynamic cpi, Type delegateType) { Type typeofIndyCallSite = typeofOpenIndyCallSite.MakeGenericType(delegateType); MethodInfo methodCreateBootStrap; @@ -3022,7 +3021,7 @@ sealed class Compiler methodCreateBootStrap = typeofIndyCallSite.GetMethod("CreateBootstrap"); methodGetTarget = typeofIndyCallSite.GetMethod("GetTarget"); } - TypeBuilder tb = compiler.clazz.TypeAsBuilder.DefineNestedType("__<>IndyCS" + (count++), TypeAttributes.NestedPrivate | TypeAttributes.Abstract | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit); + TypeBuilder tb = compiler.context.DefineIndyCallSiteType(); FieldBuilder fb = tb.DefineField("value", typeofIndyCallSite, FieldAttributes.Static | FieldAttributes.Assembly); ConstructorBuilder cb = tb.DefineConstructor(MethodAttributes.Static, CallingConventions.Standard, Type.EmptyTypes); CodeEmitter ilgen = CodeEmitter.Create(cb); @@ -3033,7 +3032,6 @@ sealed class Compiler ilgen.Emit(OpCodes.Stsfld, fb); ilgen.Emit(OpCodes.Ret); ilgen.DoEmit(); - tb.CreateType(); compiler.ilGenerator.Emit(OpCodes.Ldsfld, fb); compiler.ilGenerator.Emit(OpCodes.Call, methodGetTarget); @@ -3240,7 +3238,7 @@ sealed class Compiler ilgen.Emit(OpCodes.Stloc, temps[i]); } Type delegateType = MethodHandleUtil.CreateDelegateType(args, cpi.GetRetType()); - context.GetValue<InvokeDynamicBuilder>(0).Emit(this, cpi, delegateType); + InvokeDynamicBuilder.Emit(this, cpi, delegateType); for (int i = 0; i < args.Length; i++) { ilgen.Emit(OpCodes.Ldloc, temps[i]); |