diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbe5cb..85b3fe3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,12 +19,6 @@ if (LLVM_JIT AND GCC_JIT) "Both LLVM_JIT and GCC_JIT cannot be set to ON at the same time") endif () -# At least one JIT option is required -if (NOT LLVM_JIT AND NOT GCC_JIT) - message(FATAL_ERROR - "One of LLVM_JIT and GCC_JIT must be set to ON") -endif () - if (LLVM_JIT) find_package(LLVM REQUIRED CONFIG) @@ -134,6 +128,9 @@ if (GCC_JIT) src/ravi_gccarith1.c src/ravi_gcccall.c src/ravi_gcctable.c src/ravi_gccarith2.c src/ravi_gcctforcall.c src/ravi_gccrest.c) endif () +if (NOT LLVM_JIT AND NOT GCC_JIT) + set(NO_JIT_SRCS src/ravi_nojit.c) +endif() # define the lua core source files set(LUA_CORE_SRCS src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c src/llex.c src/lmem.c src/lobject.c src/lopcodes.c @@ -195,10 +192,13 @@ if (LLVM_JIT) endif () #Main library -add_library(ravi SHARED ${RAVI_HEADERS} - ${LUA_LIB_SRCS} ${LUA_CORE_SRCS} +add_library(ravi SHARED + ${RAVI_HEADERS} + ${LUA_LIB_SRCS} + ${LUA_CORE_SRCS} ${LLVM_JIT_SRCS} - ${GCC_JIT_SRCS}) + ${GCC_JIT_SRCS} + ${NO_JIT_SRCS}) if (WIN32) # enable DLL export set_target_properties(ravi PROPERTIES DEFINE_SYMBOL "LUA_BUILD_AS_DLL") diff --git a/lua-5.3.1-tests/ltests/ltests.c b/lua-5.3.1-tests/ltests/ltests.c index 18536dc..e6293f0 100644 --- a/lua-5.3.1-tests/ltests/ltests.c +++ b/lua-5.3.1-tests/ltests/ltests.c @@ -1558,6 +1558,7 @@ int luaB_opentests (lua_State *L) { lua_assert(ud == cast(void *, &l_memcontrol)); lua_setallocf(L, lua_getallocf(L, NULL), ud); luaL_newlib(L, tests_funcs); + printf("Lua Test Library enabled") return 1; } diff --git a/src/ravi_nojit.c b/src/ravi_nojit.c new file mode 100644 index 0000000..aed7eb8 --- /dev/null +++ b/src/ravi_nojit.c @@ -0,0 +1,136 @@ +/****************************************************************************** +* Copyright (C) 2015 Dibyendu Majumdar +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + +#include + +int raviV_compile(struct lua_State *L, struct Proto *p, + ravi_compile_options_t *options) { + (void)L; + (void)p; + (void)options; +} + +void raviV_freeproto(struct lua_State *L, struct Proto *p) { + (void)L; + (void)p; +} + +// Initialize the JIT State and attach it to the +// Global Lua State +// If a JIT State already exists then this function +// will return -1 +int raviV_initjit(struct lua_State *L) { + (void)L; + return 0; +} + +// Free up the JIT State +void raviV_close(struct lua_State *L) { + (void)L; +} + +// Dump the LLVM IR +void raviV_dumpIR(struct lua_State *L, struct Proto *p) { + (void)L; + (void)p; +} + +// Dump the LLVM ASM +void raviV_dumpASM(struct lua_State *L, struct Proto *p) { + (void)L; + (void)p; +} + +void raviV_setminexeccount(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getminexeccount(struct lua_State *L) { + (void)L; + return 0; +} + +void raviV_setmincodesize(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getmincodesize(struct lua_State *L) { + (void)L; + return 0; +} + +void raviV_setauto(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getauto(struct lua_State *L) { + (void)L; + return 0; +} + +// Turn on/off the JIT compiler +void raviV_setjitenabled(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getjitenabled(struct lua_State *L) { + (void)L; + return 0; +} + +void raviV_setoptlevel(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getoptlevel(struct lua_State *L) { + (void)L; + return 0; +} + +void raviV_setsizelevel(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getsizelevel(struct lua_State *L) { + (void)L; + return 0; +} + +void raviV_setgcstep(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_getgcstep(struct lua_State *L) { + (void)L; + return 0; +} + +// Turn on/off the JIT compiler +void raviV_settraceenabled(struct lua_State *L, int value) { + (void)L; + (void)value; +} +int raviV_gettraceenabled(struct lua_State *L) { + (void)L; + return 0; +} \ No newline at end of file