mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Use tailcall interpreter if musttail is available
This commit is contained in:
parent
79da4ea176
commit
078b17da92
2 changed files with 17 additions and 7 deletions
14
vm_exec.h
14
vm_exec.h
|
@ -11,6 +11,8 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ruby/internal/has/attribute.h"
|
||||
|
||||
typedef long OFFSET;
|
||||
typedef unsigned long lindex_t;
|
||||
typedef VALUE GENTRY;
|
||||
|
@ -60,18 +62,20 @@ error !
|
|||
/************************************************/
|
||||
#elif OPT_TAILCALL_THREADED_CODE
|
||||
|
||||
/* Same as __attribute__((musttail)), but slightly wider support (GCC 15) */
|
||||
#define MUSTTAIL [[clang::musttail]]
|
||||
#if !RBIMPL_HAS_ATTRIBUTE(musttail)
|
||||
#error support for musttail attribute is required for tailcall threading
|
||||
#endif
|
||||
|
||||
/* Declares that the function call MUST be tailcall optimized */
|
||||
#define MUSTTAIL __attribute__((musttail))
|
||||
|
||||
#define LABEL(x) insn_func_##x
|
||||
#define ELABEL(x)
|
||||
#define LABEL_PTR(x) &LABEL(x)
|
||||
|
||||
#if defined __has_attribute
|
||||
#if __has_attribute (preserve_none)
|
||||
#if RBIMPL_HAS_ATTRIBUTE(preserve_none)
|
||||
#define ATTR_PRESERVE_NONE __attribute__((preserve_none))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ATTR_PRESERVE_NONE
|
||||
#define INSN_FUNC_CONV ATTR_PRESERVE_NONE
|
||||
|
|
10
vm_opts.h
10
vm_opts.h
|
@ -10,6 +10,8 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ruby/internal/has/attribute.h"
|
||||
|
||||
/* Compile options.
|
||||
* You can change these options at runtime by VM::CompileOption.
|
||||
* Following definitions are default values.
|
||||
|
@ -34,9 +36,13 @@
|
|||
* 2: call (function call for each insn dispatch)
|
||||
* 3: call continuation (musttail attribute)
|
||||
*/
|
||||
//#ifndef OPT_THREADED_CODE
|
||||
#ifndef OPT_THREADED_CODE
|
||||
#if RBIMPL_HAS_ATTRIBUTE(musttail)
|
||||
#define OPT_THREADED_CODE 3
|
||||
//#endif
|
||||
#else
|
||||
#define OPT_THREADED_CODE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define OPT_DIRECT_THREADED_CODE (OPT_THREADED_CODE == 0)
|
||||
#define OPT_TOKEN_THREADED_CODE (OPT_THREADED_CODE == 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue