[gcc r12-7307] d: Remove handling of deleting GC allocated classes.
Iain Buclaw
ibuclaw@gcc.gnu.org
Sun Feb 20 23:15:53 GMT 2022
https://gcc.gnu.org/g:1d98337c6bebf41743dd3d1cc36222aa30e8f382
commit r12-7307-g1d98337c6bebf41743dd3d1cc36222aa30e8f382
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Mon Feb 21 00:06:16 2022 +0100
d: Remove handling of deleting GC allocated classes.
Now that the `delete' keyword has been removed from the front-end, only
compiler-generated uses of DeleteExp reach the code generator via the
auto-destruction of `scope class' variables.
The run-time library helpers that previously were used to delete GC
class objects can now be removed from the compiler.
gcc/d/ChangeLog:
* expr.cc (ExprVisitor::visit (DeleteExp *)): Remove handling of
deleting GC allocated classes.
* runtime.def (DELCLASS): Remove.
(DELINTERFACE): Remove.
Diff:
---
gcc/d/expr.cc | 24 ++++++------------------
gcc/d/runtime.def | 6 +-----
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index d5e4df7f563..2a7fb690862 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -1438,28 +1438,16 @@ public:
{
/* For class object references, if there is a destructor for that class,
the destructor is called for the object instance. */
- libcall_fn libcall;
+ gcc_assert (e->e1->op == EXP::variable);
- if (e->e1->op == EXP::variable)
- {
- VarDeclaration *v = e->e1->isVarExp ()->var->isVarDeclaration ();
- if (v && v->onstack)
- {
- libcall = tb1->isClassHandle ()->isInterfaceDeclaration ()
- ? LIBCALL_CALLINTERFACEFINALIZER : LIBCALL_CALLFINALIZER;
+ VarDeclaration *v = e->e1->isVarExp ()->var->isVarDeclaration ();
+ gcc_assert (v && v->onstack);
- this->result_ = build_libcall (libcall, Type::tvoid, 1, t1);
- return;
- }
- }
+ libcall_fn libcall = tb1->isClassHandle ()->isInterfaceDeclaration ()
+ ? LIBCALL_CALLINTERFACEFINALIZER : LIBCALL_CALLFINALIZER;
- /* Otherwise, the garbage collector is called to immediately free the
- memory allocated for the class instance. */
- libcall = tb1->isClassHandle ()->isInterfaceDeclaration ()
- ? LIBCALL_DELINTERFACE : LIBCALL_DELCLASS;
-
- t1 = build_address (t1);
this->result_ = build_libcall (libcall, Type::tvoid, 1, t1);
+ return;
}
else
{
diff --git a/gcc/d/runtime.def b/gcc/d/runtime.def
index acb610f71f0..534f8661b3e 100644
--- a/gcc/d/runtime.def
+++ b/gcc/d/runtime.def
@@ -63,11 +63,7 @@ DEF_D_RUNTIME (ARRAYBOUNDS_INDEXP, "_d_arraybounds_indexp", RT(VOID),
DEF_D_RUNTIME (NEWCLASS, "_d_newclass", RT(OBJECT), P1(CONST_CLASSINFO), 0)
DEF_D_RUNTIME (NEWTHROW, "_d_newThrowable", RT(OBJECT), P1(CONST_CLASSINFO), 0)
-/* Used when calling delete on a class or interface. */
-DEF_D_RUNTIME (DELCLASS, "_d_delclass", RT(VOID), P1(VOIDPTR), 0)
-DEF_D_RUNTIME (DELINTERFACE, "_d_delinterface", RT(VOID), P1(VOIDPTR), 0)
-
-/* Same as deleting a class, but used for stack-allocated classes. */
+/* Used when calling delete on a stack-allocated class or interface. */
DEF_D_RUNTIME (CALLFINALIZER, "_d_callfinalizer", RT(VOID), P1(VOIDPTR), 0)
DEF_D_RUNTIME (CALLINTERFACEFINALIZER, "_d_callinterfacefinalizer", RT(VOID),
P1(VOIDPTR), 0)
More information about the Gcc-cvs
mailing list