Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin <imun@tarantool.org>
To: Olga Arkhangelskaia <arkholga@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] luajit: adde flag of partial comp. with Lua 5.2
Date: Tue, 19 Nov 2019 15:03:37 +0300	[thread overview]
Message-ID: <20191119120337.GA18878@tarantool.org> (raw)
In-Reply-To: <20191119093111.91687-1-arkholga@tarantool.org>

Olya,

Thanks for the patch. It provides the requested feature but in slightly
different way than we discussed before. The partial support of Lua 5.2
is already provided via LUAJIT_ENABLE_LUA52COMPAT flag, and the new flag
is designed to introduce only __pairs/__ipairs metamethods handling
(I've written this in a review for the patch with box.cfg modification fix
and in #4560[1]).

Furthermore, let's see whether any tests can be added for this
changeset.

On 19.11.19, Olga Arkhangelskaia wrote:

Use imperative mood in the subject.

> Although we do not turn on full compatibility with Lua 5.2 we do need some of
> its features (eg. __pairs/__ipairs).This functionality brakes existing code.

Typo: s/brakes/breakes/ + adjust whitespace.

> However, if the necessity is very high or is strongly demanded we should
> have possibility to use it. We introduce LUAJIT_ENABLE_LUA52COMPAT_PART
> flag.
> 
> Some of the Lua 5.2's features that are likely to break existing code can be
> turned on under this flag. At the moment it is pirs/ipairs metmethod.

Typo: s/pirs/pairs/.

Feel free to add `Part-of tarantool gh-4560` here referring the issue
where the feature has been requested.

> ---
>  src/Makefile    | 4 ++++
>  src/lib_base.c  | 4 ++--
>  src/lj_arch.h   | 6 ++++++
>  src/lj_obj.h    | 2 +-
>  src/vm_x86.dasc | 4 ++--
>  5 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/src/Makefile b/src/Makefile
> index 827d4a4..e8fd91a 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -101,6 +101,10 @@ XCFLAGS=
>  # Note: this does not provide full compatibility with Lua 5.2 at this time.
>  #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
>  #
> +#Features from Lua 5.2 that was demanded more than once or are essential for
> +#for the project. At the moment only pairs/ipairs can be enabled via this flag.
> +#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT_PART
> +#
>  # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
>  #XCFLAGS+= -DLUAJIT_DISABLE_JIT
>  #
> diff --git a/src/lib_base.c b/src/lib_base.c
> index 3a75787..6cc0fcc 100644
> --- a/src/lib_base.c
> +++ b/src/lib_base.c
> @@ -81,12 +81,12 @@ LJLIB_ASM(next)
>    return FFH_UNREACHABLE;
>  }
>  
> -#if LJ_52 || LJ_HASFFI
> +#if LJ_52_PART || LJ_HASFFI
>  static int ffh_pairs(lua_State *L, MMS mm)
>  {
>    TValue *o = lj_lib_checkany(L, 1);
>    cTValue *mo = lj_meta_lookup(L, o, mm);
> -  if ((LJ_52 || tviscdata(o)) && !tvisnil(mo)) {
> +  if ((LJ_52_PART || tviscdata(o)) && !tvisnil(mo)) {
>      L->top = o+1;  /* Only keep one argument. */
>      copyTV(L, L->base-1-LJ_FR2, mo);  /* Replace callable. */
>      return FFH_TAILCALL;
> diff --git a/src/lj_arch.h b/src/lj_arch.h
> index c8d7138..39d70d5 100644
> --- a/src/lj_arch.h
> +++ b/src/lj_arch.h
> @@ -564,4 +564,10 @@
>  #define LJ_52			0
>  #endif
>  
> +/* Partial compatibility with Lua 5.2 */
> +#if defined(LUAJIT_ENABLE_LUA52COMPAT_PART) || defined (LUAJIT_ENABLE_LUA52COMPAT)
> +#define LJ_52_PART			1
> +#else
> +#define LJ_52_PART			0
> +#endif
>  #endif
> diff --git a/src/lj_obj.h b/src/lj_obj.h
> index f368578..3788cee 100644
> --- a/src/lj_obj.h
> +++ b/src/lj_obj.h
> @@ -530,7 +530,7 @@ enum {
>  #define MMDEF_FFI(_)
>  #endif
>  
> -#if LJ_52 || LJ_HASFFI
> +#if LJ_52 || LJ_HASFFI || LJ_52_PART

Minor: check for LJ_52 is an excess here considering the introduced
flag.

>  #define MMDEF_PAIRS(_) _(pairs) _(ipairs)
>  #else
>  #define MMDEF_PAIRS(_)
> diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
> index 56bee14..ad6216e 100644
> --- a/src/vm_x86.dasc
> +++ b/src/vm_x86.dasc
> @@ -1724,7 +1724,7 @@ static void build_subroutines(BuildCtx *ctx)
>    |.ffunc_1 pairs
>    |  mov TAB:RB, [BASE]
>    |  cmp dword [BASE+4], LJ_TTAB;  jne ->fff_fallback
> -#if LJ_52
> +#if LJ_52_PART
>    |  cmp dword TAB:RB->metatable, 0; jne ->fff_fallback
>  #endif
>    |  mov CFUNC:RB, [BASE-8]
> @@ -1791,7 +1791,7 @@ static void build_subroutines(BuildCtx *ctx)
>    |.ffunc_1 ipairs
>    |  mov TAB:RB, [BASE]
>    |  cmp dword [BASE+4], LJ_TTAB;  jne ->fff_fallback
> -#if LJ_52
> +#if LJ_52_PART
>    |  cmp dword TAB:RB->metatable, 0; jne ->fff_fallback
>  #endif
>    |  mov CFUNC:RB, [BASE-8]
> -- 
> 2.20.1 (Apple Git-117)
> 

[1]: https://github.com/tarantool/tarantool/issues/4560#issuecomment-552891850

-- 
Best regards,
IM

  reply	other threads:[~2019-11-19 12:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19  9:31 Olga Arkhangelskaia
2019-11-19 12:03 ` Igor Munkin [this message]
2019-11-19 11:01 Olga Arkhangelskaia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119120337.GA18878@tarantool.org \
    --to=imun@tarantool.org \
    --cc=arkholga@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] luajit: adde flag of partial comp. with Lua 5.2' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox