================
@@ -92,119 +99,456 @@ class QualType;
   X(double, Double)                                                            
\
   X(long double, LongDouble)
 
-class REPL_EXTERNAL_VISIBILITY Value {
-  union Storage {
-#define X(type, name) type m_##name;
+class Value;
+
+/// \struct ValueCleanup
+/// \brief Encapsulates destructor invocation for REPL values.
----------------
SahilPatidar wrote:

To support this both out-of-process and in-process, we need to call the 
destructor using the ORC `callWrapper`. We can obtain the address of the 
destructor, but it must be invoked in a way that works consistently across 
different execution environments.

Currently, `ValueCleanup` only applies to `Record`-type PRValues. In the 
previous design, calling the destructor in-process was straightforward, but 
it’s unclear how that would work out-of-process. The old design allocated 
memory directly on the `Value` (controller) side, which isn’t possible in an 
OOP context, and the same limitation applies to arrays.

Here, `ValueCleanup` does two things. First, it uses a runtime call via the 
`rundtor` wrapper function, which handles destructor calls. We have the 
`*_destroyObj` call that deallocates memory in both environments. Second, it 
makes the individual destructor call for the object: we obtain the destructor’s 
address using `CompileDtorCall` and pass `Value::getAddr` (the object’s 
address), similar to how we previously used `Value::getPtr`.

https://github.com/llvm/llvm-project/pull/156649
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to