Skip to content

Commit

Permalink
#258 allow setting opt level on MIR
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Jun 9, 2024
1 parent a5fdd19 commit 6df0fa0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/lauxlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
** =======================================================
*/

typedef struct luaL_Buffer {
struct luaL_Buffer {
char *b; /* buffer address */
size_t size; /* buffer size */
size_t n; /* number of characters in buffer */
lua_State *L;
char initb[LUAL_BUFFERSIZE]; /* initial buffer */
} luaL_Buffer;
};


#define luaL_addchar(B,c) \
Expand Down
8 changes: 7 additions & 1 deletion src/ravi_complib.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#define LUA_CORE

#include "ravi_jit.h"
#include "ravi_mirjit.h"
#include "ravi_alloc.h"

Expand Down Expand Up @@ -85,6 +86,11 @@ static int load_and_compile_internal(lua_State* L, const char* s, const char* op
.memory_allocator = &allocator,
.debug_message = debug_message,
.error_message = error_message};
int opt_level = raviV_getoptlevel(L); // Get default opt level
if (strstr(options, "-O3")) opt_level = 3;
else if (strstr(options, "-O2")) opt_level = 2;
else if (strstr(options, "-O1")) opt_level = 1;
else if (strstr(options, "-O0")) opt_level = 0;
#ifdef USE_MIRJIT
snprintf(ravicomp_interface.main_func_name, sizeof ravicomp_interface.main_func_name, "__luachunk_%lld",
ccontext.jit->id++);
Expand All @@ -101,7 +107,7 @@ static int load_and_compile_internal(lua_State* L, const char* s, const char* op
#ifdef USE_MIRJIT
/* Compile C code */
LClosure* (*load_in_lua)(lua_State * L) = NULL;
mir_prepare(ccontext.jit->jit, 2);
mir_prepare(ccontext.jit->jit, opt_level);
MIR_module_t M =
mir_compile_C_module(&ccontext.jit->options, ccontext.jit->jit, ravicomp_interface.generated_code, "input");
if (M != NULL) {
Expand Down

0 comments on commit 6df0fa0

Please sign in to comment.