issue #157 Add Ravi api functions to return JIT name and options

memtest
Dibyendu Majumdar 4 years ago
parent 7dd5c1fdf0
commit 2934cbe5c0

@ -102,7 +102,7 @@ typedef LUAI_UACINT l_uacInt;
#if defined(lua_assert)
/** RAVI changes */
#if !defined(RAVI_OPTION_STRING1)
#define RAVI_OPTION_STRING1 " assertions"
#define RAVI_OPTION_STRING1 "assertions "
#endif
#if !defined(RAVI_OPTION_STRING2)
#define RAVI_OPTION_STRING2
@ -114,7 +114,7 @@ typedef LUAI_UACINT l_uacInt;
#define lua_assert(c) ((void)0)
#define check_exp(c,e) (e)
#define lua_longassert(c) ((void)0)
/** RVAI changes */
/** RAVI changes */
#define RAVI_OPTION_STRING1
#define RAVI_OPTION_STRING2
#endif

@ -140,10 +140,10 @@ typedef void(*ravi_Writestringerror)(const char *fmt, const char *p);
#define lua_assert(c) assert(c)
#if !defined(RAVI_OPTION_STRING1)
#define RAVI_OPTION_STRING1 " assertions"
#define RAVI_OPTION_STRING1 "assertions "
#endif
#define RAVI_OPTION_STRING2 " ltests"
#define RAVI_OPTION_STRING2 "ltests "
/* to avoid warnings, and to make sure value is really unused */
#define UNUSED(x) (x=0, (void)(x))

@ -93,6 +93,12 @@ void raviV_dumpIR(struct lua_State *L, struct Proto *p);
/* Dump the compiled assembly code if available */
void raviV_dumpASM(struct lua_State *L, struct Proto *p);
/* Return JIT backend identifier */
const char *raviV_jit_id(struct lua_State *L);
/* Options */
const char *raviV_options(struct lua_State *L);
#ifdef __cplusplus
}
#endif

@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ravi_jit.h>
#include "lua.h"
@ -44,20 +45,6 @@
#define LUA_INITVARVERSION LUA_INIT_VAR LUA_VERSUFFIX
#ifdef USE_LLVM
#define ravi_xstringify(s) ravi_stringify(s)
#define ravi_stringify(s) #s
#define RAVI_OPTION_STRING3 " LLVM-" LLVM_VERSION_STRING " ORC=" ravi_xstringify(USE_ORC_JIT) " v2=" ravi_xstringify(USE_ORCv2_JIT)
#elif USE_OMRJIT
#define RAVI_OPTION_STRING3 " omrjit"
#elif USE_MIRJIT
#define RAVI_OPTION_STRING3 " mirjit"
#else
#define RAVI_OPTION_STRING3 " nojit"
#endif
#define RAVI_OPTIONS "\nOptions" RAVI_OPTION_STRING1 RAVI_OPTION_STRING2 RAVI_OPTION_STRING3
/*
** lua_stdin_is_tty detects whether the standard input is a 'tty' (that
** is, whether we're running lua interactively).
@ -228,7 +215,12 @@ static int docall (lua_State *L, int narg, int nres) {
static void print_version (lua_State *L) {
lua_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT));
lua_writestring(RAVI_OPTIONS, strlen(RAVI_OPTIONS));
const char *options = raviV_options(L);
lua_writeline();
#define OPTSTR "Options "
lua_writestring(OPTSTR, strlen(OPTSTR));
#undef OPTSTR
lua_writestring(options, strlen(options));
lua_writeline();
}

@ -238,6 +238,18 @@ static int ravi_listcode(lua_State *L) {
return ravi_list_code(L);
}
static int ravi_get_jit_id(lua_State *L) {
const char *id = raviV_jit_id(L);
lua_pushstring(L, id);
return 1;
}
static int ravi_get_options(lua_State *L) {
const char *options = raviV_options(L);
lua_pushstring(L, options);
return 1;
}
static const luaL_Reg ravilib[] = {{"iscompiled", ravi_is_compiled},
{"compile", ravi_compile_n},
{"dumplua", ravi_dump_luacode},
@ -254,6 +266,8 @@ static const luaL_Reg ravilib[] = {{"iscompiled", ravi_is_compiled},
{"tracehook", ravi_traceenable},
{"listcode", ravi_listcode},
{"limits", ravi_get_limits},
{"jitname", ravi_get_jit_id},
{"options", ravi_get_options},
{NULL, NULL}};
#include <math.h>

@ -1080,3 +1080,17 @@ int raviV_gettraceenabled(lua_State *L) {
}
extern "C" int ravi_compile_C(lua_State *L) { return 0; }
const char *raviV_jit_id(struct lua_State *L) {
return "llvm";
}
#define ravi_xstringify(s) ravi_stringify(s)
#define ravi_stringify(s) #s
#define RAVI_OPTION_STRING3 "LLVM-" LLVM_VERSION_STRING " ORC=" ravi_xstringify(USE_ORC_JIT) " v2=" ravi_xstringify(USE_ORCv2_JIT)
#define RAVI_OPTIONS RAVI_OPTION_STRING1 RAVI_OPTION_STRING2 RAVI_OPTION_STRING3
const char *raviV_options(struct lua_State *L) {
return RAVI_OPTIONS;
}

@ -494,4 +494,15 @@ void raviV_freeproto(struct lua_State *L, struct Proto *p) {
int ravi_compile_C(lua_State *L) {
(void)L;
return 0;
}
}
const char *raviV_jit_id(struct lua_State *L) {
return "mir";
}
#define RAVI_OPTION_STRING3 "mirjit"
#define RAVI_OPTIONS RAVI_OPTION_STRING1 RAVI_OPTION_STRING2 RAVI_OPTION_STRING3
const char *raviV_options(struct lua_State *L) {
return RAVI_OPTIONS;
}

@ -166,4 +166,16 @@ int raviV_gettraceenabled(struct lua_State *L) {
int ravi_compile_C(lua_State *L) {
(void)L;
return 0;
}
}
const char *raviV_jit_id(struct lua_State *L) {
return "nojit";
}
#define RAVI_OPTION_STRING3 "nojit"
#define RAVI_OPTIONS RAVI_OPTION_STRING1 RAVI_OPTION_STRING2 RAVI_OPTION_STRING3
const char *raviV_options(struct lua_State *L) {
return RAVI_OPTIONS;
}

Loading…
Cancel
Save