poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/5] pvm: remove PVM_TYPE_ANY


From: Jose E. Marchesi
Subject: Re: [PATCH 1/5] pvm: remove PVM_TYPE_ANY
Date: Mon, 24 Oct 2022 00:02:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.
OK for master.

Thanks!


> 2022-10-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * libpoke/pvm.jitter (wrapped-functions): Remove `pvm_make_any_type'.
>       (mktyany): Remove instruction.
>       * libpoke/pkl-insn.def (PKL_INSN_MKTYANY): Remove instruction.
>       * libpoke/pvm.h (pvm_make_any_type): Remove function decl.
>       * libpoke/pvm-val.h (enum pvm_type_code): Remove PVM_TYPE_ANY.
>       * libpoke/pk-val.c (pk_type_code): Remove case for PVM_TYPE_ANY.
>       (pk_make_any_type): Remove function def.
>       * libpoke/pkl-gen.c (pkl_gen_ps_type_any): Replace PKL_INSN_MKTYANY
>       with PVM_NULL.  And use PVM_NULL as the result of construction.
>       * libpoke/pkl.c (pvm_type_to_ast_type): Remove case for PVM_TYPE_ANY.
>       * libpoke/pvm-val.c (any_type): Remove variable.
>       (pvm_make_any_type): Remove function.
>       (pvm_print_val_1): Remove case for PVM_TYPE_ANY.
>       (pvm_type_equal_p): Likewise.
>       (pvm_val_initialize): Remove `any_type'.
>       (pvm_val_finalize): Likewise.
>       * libpoke/libpoke.h (PK_TYPE_ANY): Remove macro.
>       (PK_TYPE_VOID): Add macro.
>       * libpoke/pkl-gen.pks (emit_tv_field_absent): s/mktyany/push null/.
>       (struct_field_mapper): Likewise.
> ---
>  ChangeLog            | 23 +++++++++++++++++++++++
>  libpoke/libpoke.h    |  2 +-
>  libpoke/pk-val.c     | 10 ++--------
>  libpoke/pkl-gen.c    |  6 +++---
>  libpoke/pkl-gen.pks  |  4 ++--
>  libpoke/pkl-insn.def |  1 -
>  libpoke/pkl.c        |  4 ++--
>  libpoke/pvm-val.c    | 16 ----------------
>  libpoke/pvm-val.h    |  1 -
>  libpoke/pvm.h        |  2 --
>  libpoke/pvm.jitter   | 13 -------------
>  11 files changed, 33 insertions(+), 49 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 2bef1337..d674f6de 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,26 @@
> +2022-10-23  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * libpoke/pvm.jitter (wrapped-functions): Remove `pvm_make_any_type'.
> +     (mktyany): Remove instruction.
> +     * libpoke/pkl-insn.def (PKL_INSN_MKTYANY): Remove instruction.
> +     * libpoke/pvm.h (pvm_make_any_type): Remove function decl.
> +     * libpoke/pvm-val.h (enum pvm_type_code): Remove PVM_TYPE_ANY.
> +     * libpoke/pk-val.c (pk_type_code): Remove case for PVM_TYPE_ANY.
> +     (pk_make_any_type): Remove function def.
> +     * libpoke/pkl-gen.c (pkl_gen_ps_type_any): Replace PKL_INSN_MKTYANY
> +     with PVM_NULL.  And use PVM_NULL as the result of construction.
> +     * libpoke/pkl.c (pvm_type_to_ast_type): Remove case for PVM_TYPE_ANY.
> +     * libpoke/pvm-val.c (any_type): Remove variable.
> +     (pvm_make_any_type): Remove function.
> +     (pvm_print_val_1): Remove case for PVM_TYPE_ANY.
> +     (pvm_type_equal_p): Likewise.
> +     (pvm_val_initialize): Remove `any_type'.
> +     (pvm_val_finalize): Likewise.
> +     * libpoke/libpoke.h (PK_TYPE_ANY): Remove macro.
> +     (PK_TYPE_VOID): Add macro.
> +     * libpoke/pkl-gen.pks (emit_tv_field_absent): s/mktyany/push null/.
> +     (struct_field_mapper): Likewise.
> +
>  2022-10-21  Jose E. Marchesi  <jemarch@gnu.org>
>  
>       * libpoke/pvm.jitter (aset): Do not check for ebounds nor sbounds.
> diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h
> index 9d72ff4b..11271ca5 100644
> --- a/libpoke/libpoke.h
> +++ b/libpoke/libpoke.h
> @@ -1171,7 +1171,7 @@ pk_val pk_typeof (pk_val val) LIBPOKE_API;
>  #define PK_TYPE_ARRAY   5
>  #define PK_TYPE_STRUCT  6
>  #define PK_TYPE_CLOSURE 7
> -#define PK_TYPE_ANY     8
> +#define PK_TYPE_VOID    8
>  
>  int pk_type_code (pk_val val) LIBPOKE_API;
>  
> diff --git a/libpoke/pk-val.c b/libpoke/pk-val.c
> index 7c975ae9..07cbdf86 100644
> --- a/libpoke/pk-val.c
> +++ b/libpoke/pk-val.c
> @@ -223,8 +223,8 @@ pk_type_code (pk_val val)
>        return PK_TYPE_OFFSET;
>      case PVM_TYPE_CLOSURE:
>        return PK_TYPE_CLOSURE;
> -    case PVM_TYPE_ANY:
> -      return PK_TYPE_ANY;
> +    case PVM_TYPE_VOID:
> +      return PK_TYPE_VOID;
>      default:
>        return PK_TYPE_UNKNOWN;
>      }
> @@ -395,12 +395,6 @@ pk_offset_type_unit (pk_val type)
>    return PVM_VAL_TYP_O_UNIT (type);
>  }
>  
> -pk_val
> -pk_make_any_type (void)
> -{
> -  return pvm_make_any_type ();
> -}
> -
>  pk_val
>  pk_make_struct_type (pk_val nfields, pk_val name, pk_val *fnames, pk_val 
> *ftypes)
>  {
> diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c
> index 71317e17..caa3c810 100644
> --- a/libpoke/pkl-gen.c
> +++ b/libpoke/pkl-gen.c
> @@ -1844,7 +1844,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_funcall)
>        pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_REV, aindex);
>  
>        /* Create the array of variable arguments.  */
> -      pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_any_type ());
> +      pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL);
>        pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL);
>        pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MKTYA);
>        pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH,
> @@ -2911,10 +2911,10 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_type_any)
>      {
>        /* This value is arbitrary... literally `any' value.. :D */
>        pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP);
> -      pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_int (0, 32));
> +      pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL);
>      }
>    else if (PKL_GEN_IN_CTX_P (PKL_GEN_CTX_IN_TYPE))
> -    pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MKTYANY);
> +    pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL);
>  }
>  PKL_PHASE_END_HANDLER
>  
> diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
> index fb838938..ad4f13ed 100644
> --- a/libpoke/pkl-gen.pks
> +++ b/libpoke/pkl-gen.pks
> @@ -571,7 +571,7 @@
>  ;;; event.
>  
>          .macro emit_tv_field_absent
> -        mktyany
> +        push null
>          push null
>          mktya
>          push ulong<64>1
> @@ -997,7 +997,7 @@
>     .c {
>          ;; Generate a PK_TV_FIELD_MAPPED tracer event.
>          ;; First, create an empty any[] array for the arguments.
> -        mktyany                 ; ... BOFF STR VAL ANYT
> +        push null               ; ... BOFF STR VAL ANYT
>          push null               ; ... BOFF STR VAL ANYT NULL
>          mktya                   ; ... BOFF STR VAL ATYPE
>          push ulong<64>6         ; ... BOFF STR VAL ATYPE NELEM
> diff --git a/libpoke/pkl-insn.def b/libpoke/pkl-insn.def
> index e5aa1840..332231c4 100644
> --- a/libpoke/pkl-insn.def
> +++ b/libpoke/pkl-insn.def
> @@ -325,7 +325,6 @@ PKL_DEF_INSN(PKL_INSN_MSETSIZ,"","msetsiz")
>  PKL_DEF_INSN(PKL_INSN_ISA,"","isa")
>  
>  PKL_DEF_INSN(PKL_INSN_MKTYV,"","mktyv")
> -PKL_DEF_INSN(PKL_INSN_MKTYANY,"","mktyany")
>  PKL_DEF_INSN(PKL_INSN_MKTYI,"","mktyi")
>  PKL_DEF_INSN(PKL_INSN_MKTYS,"","mktys")
>  PKL_DEF_INSN(PKL_INSN_MKTYO,"","mktyo")
> diff --git a/libpoke/pkl.c b/libpoke/pkl.c
> index 53a2e5d9..47302937 100644
> --- a/libpoke/pkl.c
> +++ b/libpoke/pkl.c
> @@ -816,8 +816,8 @@ pvm_type_to_ast_type (pkl_ast ast, pvm_val type)
>          return pkl_ast_make_offset_type (ast, base_type, unit);
>          break;
>        }
> -    case PVM_TYPE_ANY:
> -      return pkl_ast_make_any_type (ast);
> +    case PVM_TYPE_VOID:
> +      return pkl_ast_make_void_type (ast);
>        break;
>      case PVM_TYPE_STRUCT:
>        /* XXX writeme */
> diff --git a/libpoke/pvm-val.c b/libpoke/pvm-val.c
> index b6bee64e..85d1453a 100644
> --- a/libpoke/pvm-val.c
> +++ b/libpoke/pvm-val.c
> @@ -38,7 +38,6 @@
>  
>  static pvm_val string_type;
>  static pvm_val void_type;
> -static pvm_val any_type;
>  
>  /* We are currently only supporting a relatively small number of
>     integral types, i.e. signed and unsigned types of sizes 1 to 64
> @@ -517,12 +516,6 @@ pvm_make_void_type (void)
>    return void_type;
>  }
>  
> -pvm_val
> -pvm_make_any_type (void)
> -{
> -  return any_type;
> -}
> -
>  pvm_val
>  pvm_make_offset_type (pvm_val base_type, pvm_val unit)
>  {
> @@ -1501,11 +1494,6 @@ pvm_print_val_1 (pvm vm, int depth, int mode, int 
> base, int indent,
>          case PVM_TYPE_VOID:
>            pk_puts ("void");
>            break;
> -        case PVM_TYPE_ANY:
> -          pk_term_class ("any");
> -          pk_puts ("any");
> -          pk_term_end_class ("any");
> -          break;
>          case PVM_TYPE_ARRAY:
>            PVM_PRINT_VAL_1 (PVM_VAL_TYP_A_ETYPE (val), ndepth);
>            pk_puts ("[");
> @@ -1682,7 +1670,6 @@ pvm_type_equal_p (pvm_val type1, pvm_val type2)
>          return (t1_size == t2_size && t1_signed == t2_signed);
>        }
>      case PVM_TYPE_STRING:
> -    case PVM_TYPE_ANY:
>      case PVM_TYPE_VOID:
>        return 1;
>      case PVM_TYPE_ARRAY:
> @@ -1823,12 +1810,10 @@ pvm_val_initialize (void)
>  
>    pvm_alloc_add_gc_roots (&string_type, 1);
>    pvm_alloc_add_gc_roots (&void_type, 1);
> -  pvm_alloc_add_gc_roots (&any_type, 1);
>    pvm_alloc_add_gc_roots (&common_int_types, 65 * 2);
>  
>    string_type = pvm_make_type (PVM_TYPE_STRING);
>    void_type = pvm_make_type (PVM_TYPE_VOID);
> -  any_type = pvm_make_type (PVM_TYPE_ANY);
>  
>    for (i = 0; i < 65; ++i)
>      for (j = 0; j < 2; ++j)
> @@ -1840,6 +1825,5 @@ pvm_val_finalize (void)
>  {
>    pvm_alloc_remove_gc_roots (&string_type, 1);
>    pvm_alloc_remove_gc_roots (&void_type, 1);
> -  pvm_alloc_remove_gc_roots (&any_type, 1);
>    pvm_alloc_remove_gc_roots (&common_int_types, 65 * 2);
>  }
> diff --git a/libpoke/pvm-val.h b/libpoke/pvm-val.h
> index 8b3d5962..2398079a 100644
> --- a/libpoke/pvm-val.h
> +++ b/libpoke/pvm-val.h
> @@ -446,7 +446,6 @@ enum pvm_type_code
>    PVM_TYPE_STRUCT,
>    PVM_TYPE_OFFSET,
>    PVM_TYPE_CLOSURE,
> -  PVM_TYPE_ANY,
>    PVM_TYPE_VOID
>  };
>  
> diff --git a/libpoke/pvm.h b/libpoke/pvm.h
> index 21adea7e..0dc2b048 100644
> --- a/libpoke/pvm.h
> +++ b/libpoke/pvm.h
> @@ -298,8 +298,6 @@ pvm_val pvm_make_string_type (void);
>  
>  pvm_val pvm_make_void_type (void);
>  
> -pvm_val pvm_make_any_type (void);
> -
>  pvm_val pvm_make_array_type (pvm_val type, pvm_val bound);
>  
>  pvm_val pvm_make_struct_type (pvm_val nfields, pvm_val name,
> diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
> index a2b6cd23..4f94d8f7 100644
> --- a/libpoke/pvm.jitter
> +++ b/libpoke/pvm.jitter
> @@ -108,7 +108,6 @@ wrapped-functions
>    pvm_array_rem
>    pvm_env_set_var
>    pvm_get_struct_method
> -  pvm_make_any_type
>    pvm_make_closure_type
>    pvm_make_void_type
>    pvm_make_cls
> @@ -5788,18 +5787,6 @@ instruction mktyv ()
>    end
>  end
>  
> -# Instruction: mktyany
> -#
> -# Build an "any" type and push it on the stack.
> -#
> -# Stack: ( -- TYPE )
> -
> -instruction mktyany ()
> -  code
> -    JITTER_PUSH_STACK (pvm_make_any_type ());
> -  end
> -end
> -
>  # Instruction: mktyi
>  #
>  # Given an unsigned long denoting a bit width, and an unsigned int



reply via email to

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