pull/168/head
Dibyendu Majumdar 5 years ago
commit 46c64ba704

@ -6,25 +6,18 @@ env:
compiler:
- gcc
cache: ccache
dist: xenial
addons:
apt:
sources:
- llvm-toolchain-precise
- ubuntu-toolchain-r-test
packages:
- clang-3.7
- g++-5
- gcc-5
- g++
- gcc
- ccache
install:
- if [ "$CXX" = "g++" ]; then export CXX="ccache g++-5" CC="ccache gcc-5"; fi
- if [ "$CXX" = "clang++" ]; then export CXX="ccache clang++-3.7" CC="ccache clang-3.7"; fi
- curl https://cmake.org/files/v3.4/cmake-3.4.0-Linux-x86_64.tar.gz | tar -xzf -
- curl http://releases.llvm.org/6.0.1/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-14.04.tar.xz | tar -xJf -
- curl http://releases.llvm.org/6.0.1/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJf -
script:
- if [ "$CXX" = "g++" ]; then export CXX="ccache g++-5" CC="ccache gcc-5"; fi
- if [ "$CXX" = "clang++" ]; then export CXX="ccache clang++-3.7" CC="ccache clang-3.7"; fi
- mkdir $TRAVIS_BUILD_DIR/build
- cd $TRAVIS_BUILD_DIR/build && $TRAVIS_BUILD_DIR/cmake-3.4.0-Linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_DIR=$TRAVIS_BUILD_DIR/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-14.04/lib/cmake/llvm -G "Unix Makefiles" -DLLVM_JIT=ON ..
- cd $TRAVIS_BUILD_DIR/build && $TRAVIS_BUILD_DIR/cmake-3.4.0-Linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_DIR=$TRAVIS_BUILD_DIR/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-16.04/lib/cmake/llvm -G "Unix Makefiles" -DLLVM_JIT=ON ..
- cd $TRAVIS_BUILD_DIR/build && make
- cd $TRAVIS_BUILD_DIR/lua-tests && sh ./run_travis_tests.sh $TRAVIS_BUILD_DIR/build/ravi

@ -3,5 +3,5 @@ cd llvm64
rem pre LLVM 3.9
rem cmake -DCMAKE_INSTALL_PREFIX=c:\ravi -G "Visual Studio 14 Win64" -DLLVM_JIT=ON -DLLVM_DIR=c:\LLVM37\share\llvm\cmake ..
rem cmake -DCMAKE_INSTALL_PREFIX=c:\ravi -G "Visual Studio 15 2017 Win64" -DLLVM_JIT=ON -DLLVM_DIR=c:\d\LLVM40_64\lib\cmake\llvm ..
cmake -DCMAKE_INSTALL_PREFIX=c:\Software\ravi -G "Visual Studio 15 2017 Win64" -DSTATIC_BUILD=ON -DLLVM_JIT=ON -DLLVM_DIR=c:\Software\llvm501r\lib\cmake\llvm ..
cmake -DCMAKE_INSTALL_PREFIX=c:\Software\ravi -G "Visual Studio 15 2017 Win64" -DSTATIC_BUILD=ON -DLLVM_JIT=ON -DLLVM_DIR=c:\Software\llvm601r\lib\cmake\llvm ..
cd ..

@ -599,10 +599,10 @@ typedef enum RaviArrayModifer {
/** RAVI extension */
typedef struct RaviArray {
char *data;
unsigned int len; /* RAVI len specialization */
unsigned int size; /* amount of memory allocated */
lu_byte array_type; /* RAVI specialization */
char *data; /* Note that the array data is 0-based so this holds 1+Lua length items */
unsigned int len; /* RAVI len specialization, holds real length which is 1+Lua length */
unsigned int size; /* amount of memory allocated */
lu_byte array_type; /* RAVI specialization */
lu_byte array_modifier; /* Flags that affect how the array is handled */
} RaviArray;

@ -77,27 +77,33 @@ required to get to a node in the hash table
#endif
#if defined(RAVI_ENABLED)
/*
** search function for short strings
*/
#if !RAVI_USE_INLINE_SHORTSTR_TGET
LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
#else
LUAI_FUNC const TValue *luaH_getshortstr_continue(Table *t, TString *key, Node *n);
static RAVI_ALWAYS_INLINE const TValue *luaH_getshortstr(Table *t, TString *key) {
/* We inline the lookup in first two slots */
Node *n = hashstr(t, key);
lua_assert(key->tt == LUA_TSHRSTR);
for (;;) { /* check whether 'key' is somewhere in the chain */
const TValue *k = gkey(n);
if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
return gval(n); /* that's it */
else {
int nx = gnext(n);
if (nx == 0)
return luaO_nilobject; /* not found */
n += nx;
}
}
const TValue *k = gkey(n);
if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
return gval(n); /* that's it */
int nx = gnext(n);
if (nx == 0)
return luaO_nilobject; /* not found */
n += nx;
k = gkey(n);
if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
return gval(n); /* that's it */
nx = gnext(n);
if (nx == 0)
return luaO_nilobject; /* not found */
/* Okay continue search slowly */
return luaH_getshortstr_continue(t, key, n);
}
#else
LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
#endif
LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
@ -197,8 +203,8 @@ LUAI_FUNC const TValue *raviH_slice_parent(lua_State *L, TValue *slice);
raviH_set_float(L, t, ukey, (value)); \
}
LUAI_FUNC void raviH_get_number_array_rawdata(lua_State *L, Table *t, lua_Number **startp, lua_Number **endp);
LUAI_FUNC void raviH_get_integer_array_rawdata(lua_State *L, Table *t, lua_Integer **startp, lua_Integer **endp);
LUAI_FUNC void raviH_get_number_array_rawdata(lua_State *L, Table *t, Ravi_NumberArray *data);
LUAI_FUNC void raviH_get_integer_array_rawdata(lua_State *L, Table *t, Ravi_IntegerArray *data);
#if defined(LUA_DEBUG)
LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);

@ -23,7 +23,7 @@
#define LUA_VERSION "Ravi " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
#define LUA_COPYRIGHT LUA_RELEASE "\nCopyright (C) 1994-2018 Lua.org, PUC-Rio\nPortions Copyright (C) 2015-2018 Dibyendu Majumdar"
#define LUA_COPYRIGHT LUA_RELEASE "\nCopyright (C) 1994-2019 Lua.org, PUC-Rio\nPortions Copyright (C) 2015-2019 Dibyendu Majumdar"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes, Dibyendu Majumdar"
@ -551,9 +551,11 @@ LUA_API void (ravi_pushcfastcall)(lua_State *L, void *ptr, int tag);
/* Allowed tags - subject to change. Max value is 128. Note that
each tag requires special handling in ldo.c */
#define RAVI_TFCF_EXP 1
#define RAVI_TFCF_LOG 2
#define RAVI_TFCF_D_D 3
enum {
RAVI_TFCF_EXP = 1,
RAVI_TFCF_LOG = 2,
RAVI_TFCF_D_D = 3,
};
/* Create an integer array (specialization of Lua table)
* of given size and initialize array with supplied initial value
@ -592,10 +594,24 @@ LUA_API int ravi_is_integer_array(lua_State *L, int idx);
/* Get the raw data associated with the number array at idx.
* Note that Ravi arrays have an extra element at offset 0 - this
* function returns a pointer to &data[0]. The number of
* array elements is returned in len.
* array elements is returned in length.
*/
typedef struct {
lua_Number *data;
unsigned int length;
} Ravi_NumberArray;
LUA_API void ravi_get_number_array_rawdata(lua_State *L, int idx, Ravi_NumberArray *array_data);
/* Get the raw data associated with the integer array at idx.
* Note that Ravi arrays have an extra element at offset 0 - this
* function returns a pointer to &data[0]. The number of
* array elements is returned in length.
*/
LUA_API lua_Number *ravi_get_number_array_rawdata(lua_State *L, int idx, size_t *len);
LUA_API lua_Integer *ravi_get_integer_array_rawdata(lua_State *L, int idx, size_t *len);
typedef struct {
lua_Integer *data;
unsigned int length;
} Ravi_IntegerArray;
LUA_API void ravi_get_integer_array_rawdata(lua_State *L, int idx, Ravi_IntegerArray *array_data);
/* API to set the output functions used by Lua / Ravi
* This allows the default implementations to be overridden
@ -640,7 +656,6 @@ LUA_API void ravi_set_debuglevel(int level);
#define RAVI_DEBUG_STACK(p) if ((ravi_parser_debug & 8) != 0) {p;} else {}
#define RAVI_ENABLED 1
#define RAVI_BYTECODE_PROFILING_ENABLED 0

@ -824,6 +824,7 @@
#define RAVI_USE_NEWHASH 1
#define RAVI_USE_INLINE_SHORTSTR_TGET 1
#define RAVI_USE_LLVM_BRANCH_WEIGHTS 1
/* If following is defined as true then LLVM instructions emitted for arithmetic ops
priority floating point ops, else default is to prioritise integer ops */

@ -11,6 +11,7 @@ Key Features of Lua
* Lua versions matter
* Lua is dynamically typed like Python
* By default variables in Lua are global unless declared local
* Lua has no line terminators
* There is a single complex / aggregate type called a 'table', which combines hash table/map and array features
* Functions in Lua are values stored in variables; in particular functions do not have names
* Globals in Lua are just values stored in a special Lua table
@ -83,6 +84,19 @@ There are some exceptions to the rule:
* the iterator variables declared in a ``for`` loop are implicitly local.
* function parameters are local to the function
Lua has no line terminators
===========================
Strictly speaking you can terminate Lua statements using ``;``. However it is not necessary except in some cases to avoid ambiguity.
This design has some consequences that took me by surprise::
local x y = 5
Above creates a local variable ``x`` and sets a global ``y`` to ``5``. Because it actually parses as::
local x
y = 5
The 'table' type
================
Lua's only complex / aggregate data type is a table. Tables are used for many things in Lua, even internally within Lua.

@ -851,28 +851,24 @@ LUA_API int ravi_is_integer_array(lua_State *L, int idx) {
/* Get the raw data associated with the number array at idx.
* Note that Ravi arrays have an extra element at offset 0 - this
* function returns a pointer to &data[0] - bear in mind that
* function returns a pointer to &data[0]
*/
LUA_API lua_Number* ravi_get_number_array_rawdata(lua_State *L, int idx, size_t *len) {
LUA_API void ravi_get_number_array_rawdata(lua_State *L, int idx, Ravi_NumberArray *data) {
StkId o = index2addr(L, idx);
lua_assert(ttisfarray(o));
lua_Number *startp, *endp;
raviH_get_number_array_rawdata(L, hvalue(o), &startp, &endp);
*len = (endp - startp);
return startp;
if (!ttisfarray(o))
luaG_runerror(L, "number[] required");
raviH_get_number_array_rawdata(L, hvalue(o), data);
}
/* Get the raw data associated with the number array at idx.
* Note that Ravi arrays have an extra element at offset 0 - this
* function returns a pointer to &data[0] - bear in mind that
*/
LUA_API lua_Integer* ravi_get_integer_array_rawdata(lua_State *L, int idx, size_t *len) {
* Note that Ravi arrays have an extra element at offset 0 - this
* function returns a pointer to &data[0]
*/
LUA_API void ravi_get_integer_array_rawdata(lua_State *L, int idx, Ravi_IntegerArray *data) {
StkId o = index2addr(L, idx);
lua_assert(ttisiarray(o));
lua_Integer *startp, *endp;
raviH_get_integer_array_rawdata(L, hvalue(o), &startp, &endp);
*len = (endp - startp);
return startp;
if (!ttisiarray(o))
luaG_runerror(L, "integer[] required");
raviH_get_integer_array_rawdata(L, hvalue(o), data);
}
/* Create a slice of an existing array

@ -598,7 +598,8 @@ const TValue *luaH_getint (Table *t, lua_Integer key) {
}
}
#if !defined(RAVI_ENABLED)
#if !RAVI_USE_INLINE_SHORTSTR_TGET
/* RAVI Change - we have split this into two parts - an inline part and a continue part */
/*
** search function for short strings
*/
@ -617,6 +618,19 @@ const TValue *luaH_getshortstr (Table *t, TString *key) {
}
}
}
#else
/* Continue search from n */
const TValue *luaH_getshortstr_continue(Table *t, TString *key, Node *n) {
for (;;) { /* check whether 'key' is somewhere in the chain starting from next node after n */
int nx = gnext(n);
if (nx == 0)
return luaO_nilobject; /* not found */
n += nx;
const TValue *k = gkey(n);
if (ttisshrstring(k) && eqshrstr(tsvalue(k), key))
return gval(n); /* that's it */
}
}
#endif
/*
@ -877,20 +891,18 @@ Table *raviH_new_number_array(lua_State *L, unsigned int len,
return t;
}
void raviH_get_number_array_rawdata(lua_State *L, Table *t, lua_Number **startp, lua_Number **endp) {
void raviH_get_number_array_rawdata(lua_State *L, Table *t, Ravi_NumberArray *data) {
(void)L;
lua_assert(t->ravi_array.array_type == RAVI_TARRAYFLT);
lua_Number *data = (lua_Number *)t->ravi_array.data;
*startp = data;
*endp = data + t->ravi_array.len;
data->data = (lua_Number *)t->ravi_array.data;
data->length = t->ravi_array.len;
}
void raviH_get_integer_array_rawdata(lua_State *L, Table *t, lua_Integer **startp, lua_Integer **endp) {
void raviH_get_integer_array_rawdata(lua_State *L, Table *t, Ravi_IntegerArray *data) {
(void)L;
lua_assert(t->ravi_array.array_type == RAVI_TARRAYINT);
lua_Integer *data = (lua_Integer *)t->ravi_array.data;
*startp = data;
*endp = data + t->ravi_array.len;
data->data = (lua_Integer *)t->ravi_array.data;
data->length = t->ravi_array.len;
}
static const char *key_orig_table = "Originaltable";

Loading…
Cancel
Save