gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5009-g6a11ea74


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-5009-g6a11ea74
Date: Tue, 7 Mar 2023 12:59:02 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-5.2-stable has been updated
       via  6a11ea7447e82c887ef4d50bac1ebdd1fbba7b23 (commit)
      from  4d58c1551c6fae952142de6427dbbbe94c1df7e2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=6a11ea7447e82c887ef4d50bac1ebdd1fbba7b23

commit 6a11ea7447e82c887ef4d50bac1ebdd1fbba7b23
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Tue Mar 7 19:58:37 2023 +0200

    Improve revamped field assignment.

diff --git a/ChangeLog b/ChangeLog
index 9ad1e036..84d8d0c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-07         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * awkgram.y (optimize_assignment): Turn Op_store_field_exp
+       into Op_store_field.  Add some explanatory comments.
+
 2023-03-02         Arnold D. Robbins     <arnold@skeeve.com>
 
        * interpret.h (r_interpret): Revert this change of 2023-01-23,
diff --git a/awkgram.c b/awkgram.c
index 7f833c73..352dac5a 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -8332,6 +8332,22 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
        return rule_block[rule];
 }
 
+/*
+ * 3/2023:
+ * mk_assignment() is called when an assignment statement is seen,
+ * as an expression.  optimize_assignment() is called when an expression
+ * is seen as statement (inside braces).
+ *
+ * When a field assignment is seen, it needs to be optizimed into
+ * Op_store_field_exp or Op_store_field to avoid memory management
+ * issues. Thus, the Op_field_spec_lhs -> Op_store_field_expr
+ * change is done in mk_assignment. (Consider foo && $0 = $1, the
+ * assignment is part of an expression.)
+ *
+ * If the assignment is in a statement, then optimize_assignment()
+ * turn Op_store_field_expr into Op_store_field.
+ */
+
 /* mk_assignment --- assignment bytecodes */
 
 static INSTRUCTION *
@@ -8434,6 +8450,11 @@ optimize_assignment(INSTRUCTION *exp)
        i2 = NULL;
        i1 = exp->lasti;
 
+       if (i1->opcode == Op_store_field_exp) {
+               i1->opcode = Op_store_field;
+               return exp;
+       }
+
        if (   i1->opcode != Op_assign
            && i1->opcode != Op_field_assign)
                return list_append(exp, instruction(Op_pop));
diff --git a/awkgram.y b/awkgram.y
index 9e4a64ae..69e64017 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -5830,6 +5830,22 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
        return rule_block[rule];
 }
 
+/*
+ * 3/2023:
+ * mk_assignment() is called when an assignment statement is seen,
+ * as an expression.  optimize_assignment() is called when an expression
+ * is seen as statement (inside braces).
+ *
+ * When a field assignment is seen, it needs to be optizimed into
+ * Op_store_field_exp or Op_store_field to avoid memory management
+ * issues. Thus, the Op_field_spec_lhs -> Op_store_field_expr
+ * change is done in mk_assignment. (Consider foo && $0 = $1, the
+ * assignment is part of an expression.)
+ *
+ * If the assignment is in a statement, then optimize_assignment()
+ * turn Op_store_field_expr into Op_store_field.
+ */
+
 /* mk_assignment --- assignment bytecodes */
 
 static INSTRUCTION *
@@ -5932,6 +5948,11 @@ optimize_assignment(INSTRUCTION *exp)
        i2 = NULL;
        i1 = exp->lasti;
 
+       if (i1->opcode == Op_store_field_exp) {
+               i1->opcode = Op_store_field;
+               return exp;
+       }
+
        if (   i1->opcode != Op_assign
            && i1->opcode != Op_field_assign)
                return list_append(exp, instruction(Op_pop));

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog |  5 +++++
 awkgram.c | 21 +++++++++++++++++++++
 awkgram.y | 21 +++++++++++++++++++++
 3 files changed, 47 insertions(+)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]