From: Anirudh Agnihotry Date: Fri, 3 Aug 2018 20:03:35 +0000 (-0700) Subject: Moved LocalVariableInfo to shared (#19184) X-Git-Tag: accepted/tizen/unified/20190422.045933~1523 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b3db1041998be9c63a730240a8f16918597c0ed5;p=platform%2Fupstream%2Fcoreclr.git Moved LocalVariableInfo to shared (#19184) * File Modified * Moved to shared * Introducing RuntimeLocalVariableInfo * Build Corefx change * sealed added --- diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj index f8adb1c..d231b4d 100644 --- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -314,7 +314,6 @@ - @@ -326,6 +325,7 @@ + diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index dd56943..afb7c6b 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -349,6 +349,7 @@ + diff --git a/src/System.Private.CoreLib/src/System/Reflection/LocalVariableInfo.cs b/src/System.Private.CoreLib/shared/System/Reflection/LocalVariableInfo.cs similarity index 50% rename from src/System.Private.CoreLib/src/System/Reflection/LocalVariableInfo.cs rename to src/System.Private.CoreLib/shared/System/Reflection/LocalVariableInfo.cs index 241a3c4..1540bde 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/LocalVariableInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/LocalVariableInfo.cs @@ -8,17 +8,10 @@ namespace System.Reflection { public class LocalVariableInfo { - #region Private Data Members - private RuntimeType m_type; - private int m_isPinned; - private int m_localIndex; - #endregion - - #region Constructor + public virtual Type LocalType { get { Debug.Fail("type must be set!"); return null; } } + public virtual int LocalIndex => 0; + public virtual bool IsPinned => false; protected LocalVariableInfo() { } - #endregion - - #region Object Overrides public override string ToString() { string toString = LocalType.ToString() + " (" + LocalIndex + ")"; @@ -28,13 +21,6 @@ namespace System.Reflection return toString; } - #endregion - - #region Public Members - public virtual Type LocalType { get { Debug.Assert(m_type != null, "type must be set!"); return m_type; } } - public virtual bool IsPinned { get { return m_isPinned != 0; } } - public virtual int LocalIndex { get { return m_localIndex; } } - #endregion } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs new file mode 100644 index 0000000..77b4591 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeLocalVariableInfo.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; + +namespace System.Reflection +{ + internal sealed class RuntimeLocalVariableInfo : LocalVariableInfo + { + private RuntimeType _type; + private int _localIndex; + private bool _isPinned; + + protected RuntimeLocalVariableInfo() { } + + public override Type LocalType { get { Debug.Assert(_type != null, "type must be set!"); return _type; } } + public override int LocalIndex => _localIndex; + public override bool IsPinned => _isPinned; + } +} diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h index d6caea2..dcd434e 100644 --- a/src/vm/mscorlib.h +++ b/src/vm/mscorlib.h @@ -552,11 +552,11 @@ DEFINE_FIELD_U(m_catchMetadataToken, ExceptionHandlingClause, m_cat DEFINE_FIELD_U(m_filterOffset, ExceptionHandlingClause, m_filterOffset) DEFINE_CLASS(EH_CLAUSE, Reflection, ExceptionHandlingClause) -DEFINE_CLASS_U(Reflection, LocalVariableInfo, LocalVariableInfo) -DEFINE_FIELD_U(m_type, LocalVariableInfo, m_type) -DEFINE_FIELD_U(m_isPinned, LocalVariableInfo, m_bIsPinned) -DEFINE_FIELD_U(m_localIndex, LocalVariableInfo, m_localIndex) -DEFINE_CLASS(LOCAL_VARIABLE_INFO, Reflection, LocalVariableInfo) +DEFINE_CLASS_U(Reflection, RuntimeLocalVariableInfo, RuntimeLocalVariableInfo) +DEFINE_FIELD_U(_type, RuntimeLocalVariableInfo, _type) +DEFINE_FIELD_U(_localIndex, RuntimeLocalVariableInfo, _localIndex) +DEFINE_FIELD_U(_isPinned, RuntimeLocalVariableInfo, _isPinned) +DEFINE_CLASS(RUNTIME_LOCAL_VARIABLE_INFO, Reflection, RuntimeLocalVariableInfo) DEFINE_CLASS_U(Reflection, MethodBody, MethodBody) DEFINE_FIELD_U(m_IL, MethodBody, m_IL) diff --git a/src/vm/runtimehandles.cpp b/src/vm/runtimehandles.cpp index 1d0fb95..f587b4c 100644 --- a/src/vm/runtimehandles.cpp +++ b/src/vm/runtimehandles.cpp @@ -2430,7 +2430,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p { METHODBODYREF MethodBodyObj; EXCEPTIONHANDLINGCLAUSEREF EHClauseObj; - LOCALVARIABLEINFOREF LocalVariableInfoObj; + RUNTIMELOCALVARIABLEINFOREF RuntimeLocalVariableInfoObj; U1ARRAYREF U1Array; BASEARRAYREF TempArray; REFLECTCLASSBASEREF declaringType; @@ -2439,7 +2439,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p gc.MethodBodyObj = NULL; gc.EHClauseObj = NULL; - gc.LocalVariableInfoObj = NULL; + gc.RuntimeLocalVariableInfoObj = NULL; gc.U1Array = NULL; gc.TempArray = NULL; gc.declaringType = (REFLECTCLASSBASEREF)ObjectToOBJECTREF(pDeclaringTypeUNSAFE); @@ -2469,7 +2469,7 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p MethodTable * pExceptionHandlingClauseMT = MscorlibBinder::GetClass(CLASS__EH_CLAUSE); TypeHandle thEHClauseArray = ClassLoader::LoadArrayTypeThrowing(TypeHandle(pExceptionHandlingClauseMT), ELEMENT_TYPE_SZARRAY); - MethodTable * pLocalVariableMT = MscorlibBinder::GetClass(CLASS__LOCAL_VARIABLE_INFO); + MethodTable * pLocalVariableMT = MscorlibBinder::GetClass(CLASS__RUNTIME_LOCAL_VARIABLE_INFO); TypeHandle thLocalVariableArray = ClassLoader::LoadArrayTypeThrowing(TypeHandle(pLocalVariableMT), ELEMENT_TYPE_SZARRAY); Module* pModule = pMethod->GetModule(); @@ -2551,21 +2551,21 @@ FCIMPL2(MethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *p for (INT32 i = 0; i < cLocals; i ++) { - gc.LocalVariableInfoObj = (LOCALVARIABLEINFOREF)AllocateObject(pLocalVariableMT); + gc.RuntimeLocalVariableInfoObj = (RUNTIMELOCALVARIABLEINFOREF)AllocateObject(pLocalVariableMT); - gc.LocalVariableInfoObj->m_localIndex = i; + gc.RuntimeLocalVariableInfoObj->_localIndex = i; metaSig.NextArg(); CorElementType eType; IfFailThrow(metaSig.GetArgProps().PeekElemType(&eType)); if (ELEMENT_TYPE_PINNED == eType) - gc.LocalVariableInfoObj->m_bIsPinned = TRUE; + gc.RuntimeLocalVariableInfoObj->_isPinned = TRUE; TypeHandle tempType= metaSig.GetArgProps().GetTypeHandleThrowing(pModule, &sigTypeContext); OBJECTREF refLocalType = tempType.GetManagedClassObject(); - gc.LocalVariableInfoObj->SetType(refLocalType); - gc.MethodBodyObj->m_localVariables->SetAt(i, (OBJECTREF) gc.LocalVariableInfoObj); + gc.RuntimeLocalVariableInfoObj->SetType(refLocalType); + gc.MethodBodyObj->m_localVariables->SetAt(i, (OBJECTREF) gc.RuntimeLocalVariableInfoObj); } } else diff --git a/src/vm/runtimehandles.h b/src/vm/runtimehandles.h index c757f9d..f35ef44 100644 --- a/src/vm/runtimehandles.h +++ b/src/vm/runtimehandles.h @@ -32,16 +32,16 @@ typedef enum ReflectionCallConv { class ExceptionHandlingClause; class MethodBody; -class LocalVariableInfo; +class RuntimeLocalVariableInfo; #ifdef USE_CHECKED_OBJECTREFS typedef REF EXCEPTIONHANDLINGCLAUSEREF; typedef REF METHODBODYREF; -typedef REF LOCALVARIABLEINFOREF; +typedef REF RUNTIMELOCALVARIABLEINFOREF; #else typedef DPTR(ExceptionHandlingClause) EXCEPTIONHANDLINGCLAUSEREF; typedef DPTR(MethodBody) METHODBODYREF; -typedef DPTR(LocalVariableInfo) LOCALVARIABLEINFOREF; +typedef DPTR(RuntimeLocalVariableInfo) RUNTIMELOCALVARIABLEINFOREF; #endif class ExceptionHandlingClause : Object @@ -80,28 +80,28 @@ public: CLR_BOOL m_initLocals; }; -class LocalVariableInfo : Object +class RuntimeLocalVariableInfo : Object { private: // Disallow creation and copy construction of these. - LocalVariableInfo() { } - LocalVariableInfo(LocalVariableInfo &r) { } + RuntimeLocalVariableInfo() { } + RuntimeLocalVariableInfo(RuntimeLocalVariableInfo &r) { } public: REFLECTCLASSBASEREF GetType() { - return (REFLECTCLASSBASEREF)m_type; + return (REFLECTCLASSBASEREF)_type; } void SetType(OBJECTREF type) { - SetObjectReference(&m_type, type, GetAppDomain()); + SetObjectReference(&_type, type, GetAppDomain()); } - OBJECTREF m_type; - INT32 m_bIsPinned; - INT32 m_localIndex; + OBJECTREF _type; + INT32 _localIndex; + CLR_BOOL _isPinned; }; class MdUtf8String {