Michael Munday
e6eb12b268
Implement bit operations.
...
See http://bitop.luajit.org/api.html for more information.
Bytecode listing is now supported, for example:
$ ./luajit -bl -e 'a=1'
-- BYTECODE -- "a=1":0-1
0001 KSHORT 0 1
0002 GSET 0 0 ; "a"
0003 RET0 0 1
2016-12-29 15:07:51 -05:00
Michael Munday
e8ca7b8799
Implement CAT.
...
Allows the use of the '..' operator, for example:
x = "hello"
y = " "
z = "world!"
print(x..y..z) -- prints 'hello world!'
2016-12-29 11:23:45 -05:00
Michael Munday
29223bb979
Implement POW.
...
Allows use of the '^' operator, for example:
x = 2
y = 3
print(x ^ y) -- prints 8
2016-12-29 11:10:18 -05:00
Michael Munday
230a4aa424
Implement KNIL and CALLMT.
2016-12-28 17:55:10 -05:00
Michael Munday
2584c6d5a8
Implement ISNUM, ISTYPE, TGETR and TSETR.
2016-12-28 17:01:09 -05:00
Michael Munday
5dc644ad89
Implement LOOP.
...
Allows for while and repeat loops, for example:
x = 0
while x < 5 do
print(x)
x = x + 1
end
-- prints:
-- 0
-- 1
-- 2
-- 3
-- 4
2016-12-28 14:13:08 -05:00
Michael Munday
6673652fd9
Implement TSETM and VARG.
...
Allows varargs to be used, for example:
function sel(n, ...)
local arg = {...}
return arg[n]
end
print(sel(2, 3, 4, 5)) -- prints 4
2016-12-28 13:21:06 -05:00
Michael Munday
aba9cfb2a8
Implement UGET.
...
Allows simple closures, for example:
function f(x)
return function() return x end
end
y = f(1)
print(y()) -- prints 1
2016-12-28 10:58:45 -05:00
Michael Munday
354b5c748b
Implement a UCLO, ff_assert and a couple of other bits.
...
Needed to get -bl working, still more to do though.
2016-12-22 15:40:25 -05:00
Michael Munday
077ccc8658
Implement LEN.
...
Enables length of tables and strings to be taken, for example:
t = "hello"
print(#t) -- prints 5
t = {1,2}
print(#t) -- prints 2
2016-12-22 14:59:37 -05:00
Michael Munday
c0c155e45e
Implement/fix TGETS and TSETS.
...
Allows string keys in tables, for example:
t = {}
t["hello"] = 1
print(t["hello"]) -- prints 1
2016-12-22 14:40:31 -05:00
Michael Munday
cab03375f1
Implement TGETV and TSETV.
...
Allows table entries to be get and set using variables, for example:
t = {4,5}
i = 1
print(t[i]) -- prints 4
t[i] = 3
print(t[i]) -- prints 3
2016-12-22 14:20:47 -05:00
Michael Munday
20f05a4e20
Implement more tset and tget metamethods.
...
This allows table entries to be get and set even if they don't
already exist, for example:
t = {}
print(t[1]) -- prints nil
t[1] = 3
print(t[1]) -- prints 3
2016-12-22 13:50:59 -05:00
Michael Munday
01dbd6dfa2
Implement TDUP, TGETB and TSETB.
...
Allows some simple table operations, for example:
t = {1, 2}
print(t[1]) -- prints 1
t[1] = 3
print(t[1]) -- prints 3
2016-12-22 13:16:02 -05:00
Michael Munday
6fc4c0c1a8
Fix BC_MCALL
...
RC and RD are the same register on x64, so sometimes it uses them
interchangeably. Probably we should make them the same register
on s390x, but that would involve changing the instruction decode
code which I would rather leave until we have a test suite passing.
2016-12-22 12:41:00 -05:00
Michael Munday
1825037538
Implement table creation and printing.
2016-12-21 18:02:43 -05:00
Michael Munday
e19544ae9a
Implement unary minus.
2016-12-21 14:03:58 -05:00
Michael Munday
9da6ff7ea3
Implement more equality checks.
2016-12-21 13:21:12 -05:00
Michael Munday
8518df8e56
Implement some boolean operations.
2016-12-21 12:49:53 -05:00
Michael Munday
ae38a6913e
Add support for numeric equality checks.
2016-12-21 11:02:53 -05:00
Michael Munday
b5aa0d077c
Fix bug in division.
2016-12-20 17:26:33 -05:00
Michael Munday
eda56c9a44
Add support for if statements.
2016-12-20 17:10:38 -05:00
Michael Munday
90334d3be9
Add support for function definitions.
2016-12-20 15:49:21 -05:00
Michael Munday
e0e98f94d3
Add support for modulo (%) operations.
...
Only the slow path for now.
2016-12-20 14:54:26 -05:00
Michael Munday
d006b07127
Add support for division.
2016-12-20 13:37:42 -05:00
Michael Munday
d94f4ac079
Add support for multiplication.
...
Multiplication instructions don't set the overflow flag so we need
to manually check, which is why this is more complicated than
addition.
2016-12-20 13:14:53 -05:00
Michael Munday
d256d99659
Add support for floating point add/sub.
2016-12-20 12:09:32 -05:00
Michael Munday
5df5e1f144
Add support for integer add/subtract.
...
Still need to support floating point operations. Multiplication is a
little more complicated because it doesn't set the overflow flag.
2016-12-20 09:41:19 -05:00
Michael Munday
e467d784a9
Fix floating point fallback code for for loops.
...
Adds a dependency on clfi. Not sure how to work around (don't
really want to always introduce a temporary).
2016-12-19 16:03:21 -05:00
Michael Munday
299dc34db2
Add basic integer for loop support.
...
> for i=1,3 do print(i) end
1
2
3
2016-12-19 14:21:48 -05:00
Michael Munday
3330f6adc2
Fix KSHORT destination slot address.
2016-12-19 10:49:21 -05:00
Michael Munday
6a9855d988
Add support for print function call.
...
Hello world now works.
> print("hello world!")
hello world!
2016-12-17 19:56:56 -05:00
Michael Munday
bee112d431
Add support for global short assignments.
...
In other words 'a = 1' now works.
2016-12-16 17:23:46 -05:00
Michael Munday
24bdb7576d
Add debug options to Makefile.
...
We're going to need these for a while, so better to put in the
repository. Once we're happy things are working we can disable
the debug info and enable optimizations again.
2016-12-15 11:03:13 -05:00
Michael Munday
2dcbf5be3e
Implement more functions in the VM.
...
Also adds segmentation faults to stubbed out functions to make it
easier to work out what the control flow is.
2016-12-15 11:01:59 -05:00
Michael Munday
ee4b942c94
Add vm_call handling code.
...
Now prints the prompt (!).
2016-12-14 22:22:49 -05:00
Michael Munday
24f2ab48f5
Various fixes for vm_s390x.dasc.
2016-12-14 18:43:21 -05:00
Michael Munday
00d00e995f
Fix extern handling in host vm builder.
2016-12-14 16:31:52 -05:00
Michael Munday
7644f40b1a
Add more interpreter code.
...
Compilation is currently broken, a label is missing.
2016-12-13 18:31:43 -05:00
Michael Munday
0b120ac64b
Add partial implementation of vm_cpcall.
...
Currently works if the call returns 0. Haven't yet written the code
needed to handle the non-zero case.
2016-12-12 17:17:34 -05:00
Michael Munday
625aad5da0
Make LuaJIT compile on s390x.
...
I've disabled both the JIT and FFI for now. I've also stripped almost
all of the assembly out of vm_s390x.dasc, leaving only labels for the
most part. This is enough to get LuaJIT to compile but of course if
you try and run it it will explode.
The idea now is to re-add enough functionality to get a very basic
Lua program to run.
2016-12-09 16:28:39 -05:00
Michael Munday
052eb69750
Make host/buildvm_asm.c compile.
...
I've added a rough implementation of this code. It is untested but
does compile.
2016-12-09 14:32:02 -05:00
Michael Munday
53b627b21c
s/SP/sp/ in vm_s390x.dasc.
...
We support the pseudo-register sp now.
2016-12-06 12:47:23 -05:00
ketank-new
3288e547bf
Update vm_s390x.dasc
...
added definations to macros to test operand type refeered x86 definations
no JUMP instruction found for s390x used BRANCH RELATIVE on CONDITION instead (brc)
Not sure how the condition will be checked , need to discuss this
2016-11-24 14:58:52 +05:30
ketank-new
4ea7607e02
Update vm_s390x.dasc
...
added instructions to macros, referring macro defination of x86
for macro ins_ANDdid not find equivalent s390x replacement instruction for 'Not' hence have currently marked the place as '????'
'????' has to be replaced with s390x complement instruction
2016-11-24 14:02:50 +05:30
ketank-new
372f721e60
Update vm_s390x.dasc
...
used MOVE LONG EXTENDED in place of mov and
MOVE LONG instead of movzx
2016-11-24 11:25:07 +05:30
Michael Munday
5887962b0e
Add assembly for decoding instructions.
...
Still guessing at this point. This code will need to be changed.
2016-11-23 18:02:00 -05:00
Michael Munday
dbf789536c
Fix stack frame layout.
...
f8-f15 are callee-saved (not f0,f2,f4 and f6). There isn't space
for them in the caller's stack frame so we need to increase the
size of the interpreter's stack frame.
2016-11-23 17:30:10 -05:00
Michael Munday
5a69b4638a
Fixup the save/restore register macros.
...
I believe these macros obey the C calling convention, so we need to
allocate our stack frame and save all callee-save registers. We
can tune it later if it turns out we don't need all the registers.
2016-11-22 13:58:10 -05:00
Michael Munday
d505a0e0ba
Cleanup.
2016-11-22 13:47:35 -05:00