[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pkl-gen: avoid leaking dynamic environment frames
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pkl-gen: avoid leaking dynamic environment frames |
Date: |
Mon, 09 Nov 2020 00:37:52 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2020-11-09 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-gen.c (pkl_gen_ps_func): Functions always introduce
a lexical environment for arguments even if they get none.
(pkl_gen_ps_return_stmt): Likewise.
---
ChangeLog | 6 ++++++
libpoke/pkl-gen.c | 13 ++++---------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 184d945b..6148c167 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-11-09 Jose E. Marchesi <jemarch@gnu.org>
+
+ * libpoke/pkl-gen.c (pkl_gen_ps_func): Functions always introduce
+ a lexical environment for arguments even if they get none.
+ (pkl_gen_ps_return_stmt): Likewise.
+
2020-11-08 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-ast.h: Rename pkl_ast_type_promoteable to
diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c
index 87762621..0a427d01 100644
--- a/libpoke/pkl-gen.c
+++ b/libpoke/pkl-gen.c
@@ -998,12 +998,9 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_return_stmt)
pkl_ast_node function = PKL_AST_RETURN_STMT_FUNCTION (return_stmt);
pkl_ast_node function_type = PKL_AST_TYPE (function);
+ /* Note the + 1 is for the function argument's frame. */
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPF,
- PKL_AST_RETURN_STMT_NFRAMES (PKL_PASS_NODE));
-
- /* Pop the function argument's frame. */
- if (PKL_AST_FUNC_ARGS (function))
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPF, 1);
+ PKL_AST_RETURN_STMT_NFRAMES (PKL_PASS_NODE) + 1);
/* In a void function, return PVM_NULL in the stack. */
if (PKL_AST_TYPE_CODE (PKL_AST_TYPE_F_RTYPE (function_type))
@@ -1445,7 +1442,6 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_func)
pkl_ast_node function = PKL_PASS_NODE;
pkl_ast_node function_type = PKL_AST_TYPE (function);
- int method_p = PKL_AST_FUNC_METHOD_P (PKL_PASS_NODE);
/* In a void function, return PVM_NULL in the stack. Otherwise, it
is a run-time error to reach this point. */
@@ -1460,9 +1456,8 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_func)
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RAISE);
}
- /* Pop the function's argument environment, if any, and return. */
- if (PKL_AST_FUNC_ARGS (function) || method_p)
- pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPF, 1);
+ /* Pop the function's argument environment. */
+ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPF, 1);
pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RETURN);
}
PKL_PHASE_END_HANDLER
--
2.25.0.2.g232378479e
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pkl-gen: avoid leaking dynamic environment frames,
Jose E. Marchesi <=