From f50c788f9886e4b44c8978696ed4993b58e5512b Mon Sep 17 00:00:00 2001 From: Craig Long Date: Fri, 30 Sep 2022 19:15:29 -0400 Subject: [PATCH] Fix Regression with GetCLRObject impacting Node Preview and Tessellation (#13363) * RevertCode * Remove clear function Co-authored-by: Craig Long --- .../Reflection/GraphicDataProvider.cs | 35 +++++-------------- src/Engine/ProtoCore/RuntimeCore.cs | 2 -- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs index 80602067e8f..2910720456b 100644 --- a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs +++ b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Reflection; @@ -141,50 +141,31 @@ internal List GetGraphicItems(DSASM.StackValue svData, RuntimeCore return null; } - //Store marshaller for repeated calls to GetCLRObject. Used for short-circuit of re-allocation of marshaller / interpreter object. - private static Interpreter interpreter; - private static ProtoFFI.FFIObjectMarshaler marshaler; - internal object GetCLRObject(StackValue svData, RuntimeCore runtimeCore) { if (null == runtimeCore.DSExecutable.classTable) return null; - //The GetCLRObject function is typically utilized to retrieve a ClrObject from a StackValue of type pointer. - //There is an edge cases for pointers where the pointer references a non CLR object. This code - //checks for this edge case by verifying that the requested StackValue pointer is associated with an - //imported library. An example is the "Function" pointer which does not have an associated CLRObject. - //In that case, the return value should be null. - var classNode = runtimeCore.DSExecutable.classTable.GetClassNodeAtIndex(svData.metaData.type); - if (classNode != null && !classNode.IsImportedClass) - { + IList classNodes = runtimeCore.DSExecutable.classTable.ClassNodes; + if (null == classNodes || (classNodes.Count <= 0)) return null; - } - if (marshaler != null) - { - return marshaler.UnMarshal(svData, null, interpreter, typeof(object)); - } + ClassNode classnode = runtimeCore.DSExecutable.classTable.ClassNodes[svData.metaData.type]; + if (!classnode.IsImportedClass) //TODO: look at properties to see if it contains any FFI objects. + return null; try { - interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore, false); + ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore, false); var helper = ProtoFFI.DLLFFIHandler.GetModuleHelper(ProtoFFI.FFILanguage.CSharp); - marshaler = helper.GetMarshaler(runtimeCore); + var marshaler = helper.GetMarshaler(runtimeCore); return marshaler.UnMarshal(svData, null, interpreter, typeof(object)); } catch (System.Exception) { - marshaler = null; return null; } } - - internal static void ClearMarshaller() - { - interpreter = null; - marshaler = null; - } } /// diff --git a/src/Engine/ProtoCore/RuntimeCore.cs b/src/Engine/ProtoCore/RuntimeCore.cs index 9caef966b2e..d5c88188c96 100644 --- a/src/Engine/ProtoCore/RuntimeCore.cs +++ b/src/Engine/ProtoCore/RuntimeCore.cs @@ -6,7 +6,6 @@ using ProtoCore.DSASM; using ProtoCore.Lang; using ProtoCore.Lang.Replication; -using ProtoCore.Mirror; using ProtoCore.Runtime; using ProtoCore.Utils; using ProtoFFI; @@ -272,7 +271,6 @@ public void Cleanup() { OnDispose(); CLRModuleType.ClearTypes(); - GraphicDataProvider.ClearMarshaller(); } public void NotifyExecutionEvent(ExecutionStateEventArgs.State state)