Bernhard Urban [Sun, 20 May 2012 00:10:12 +0000 (02:10 +0200)]
main: some kind of argument parsing
o -cp, -classpath and -jar support now from commandline.
args parsing is a mess, I know. Unfortunately I can't use
getopt here, because the weird argument syntax of openjdk
java.
o finally, calls like `./mate tests.Static5' are also possible now
(before it was `./mate tests/Static5' only)
o new dependency: package split
Bernhard Urban [Sat, 19 May 2012 21:42:49 +0000 (23:42 +0200)]
ClassPool: JAR and ClassPath support
thanks hs-java awesomeness, although the implemented Java.ClassPath
Modell doesn't really fit nicely in our current implementation :/
so it's a bit hackish...
Bernhard Urban [Sat, 19 May 2012 13:56:18 +0000 (15:56 +0200)]
hs-java: upgrade to 0.3.1
0.3 has JAR support, so stay tuned \o/
Harald Steinlechner [Sat, 19 May 2012 10:39:46 +0000 (12:39 +0200)]
fixed bug in mate.cabal '.' should be in include dir not included itself
Bernhard Urban [Sat, 19 May 2012 10:31:45 +0000 (12:31 +0200)]
Makefile: delete *_stub.* files
those are generated exporting things with FFI
Harald Steinlechner [Sat, 19 May 2012 10:11:03 +0000 (12:11 +0200)]
mate.cabal switched to our version of harpy (git://wien.tomnetworks.com/harpy.git,
d654f45c8dbc81f86d680d4562013761b1d2e0ee) and hs-java (git://wien.tomnetworks.com/hs-java.git;
c96825da50f655d1732b61a0bc9da857d784a4ec)
Bernhard Urban [Sat, 19 May 2012 10:10:56 +0000 (12:10 +0200)]
tools: new custom repo for disassembler
Bernhard Urban [Sat, 19 May 2012 09:52:33 +0000 (11:52 +0200)]
traps: do more things in haskell world
Bernhard Urban [Fri, 18 May 2012 22:31:08 +0000 (00:31 +0200)]
tools: missed a possible failed case
Harald Steinlechner [Fri, 18 May 2012 23:03:11 +0000 (01:03 +0200)]
fixed mate-common. cabal build should work now
Harald Steinlechner [Fri, 18 May 2012 22:58:24 +0000 (00:58 +0200)]
added cabal stubs for mate-common and mate;
Harald Steinlechner [Fri, 18 May 2012 20:00:05 +0000 (22:00 +0200)]
scratch/ffiTest: removed export
Bernhard Urban [Fri, 18 May 2012 09:30:33 +0000 (11:30 +0200)]
refactor: use `unsafePerformIO hack' for global var
Bernhard Urban [Thu, 17 May 2012 22:43:49 +0000 (00:43 +0200)]
refactor: reduce global var in trap.c to one pointer
still not really what we want :/
Bernhard Urban [Thu, 17 May 2012 21:35:02 +0000 (23:35 +0200)]
globalvars: get rid of `trap_map'
we can do that differently (still ugly though)
Harald Steinlechner [Thu, 17 May 2012 16:25:49 +0000 (18:25 +0200)]
scratch: sync sketch code for FFI,Signal...
Bernhard Urban [Wed, 16 May 2012 22:50:38 +0000 (00:50 +0200)]
tools: let `make tests' fail, if there's a failed testcase
Bernhard Urban [Thu, 10 May 2012 11:55:29 +0000 (13:55 +0200)]
hlint: fix suggested improvements
nice tool \o/ some code duplication stuff need to be fixed yet
Bernhard Urban [Thu, 10 May 2012 10:42:44 +0000 (12:42 +0200)]
hlint: use CamelCase for printf stuff
Bernhard Urban [Thu, 10 May 2012 11:08:20 +0000 (13:08 +0200)]
Makefile: hlint target
requires some CPP hack magic...
Bernhard Urban [Wed, 16 May 2012 22:52:24 +0000 (00:52 +0200)]
todo: update
Bernhard Urban [Thu, 10 May 2012 10:27:48 +0000 (12:27 +0200)]
gc: factor out allocation
in order to have central place when starting with garbage collection.
Bernhard Urban [Tue, 8 May 2012 21:52:39 +0000 (23:52 +0200)]
Makefile: target for executing a single testcase
see `HACKING'
Bernhard Urban [Tue, 8 May 2012 21:56:03 +0000 (23:56 +0200)]
debug: get rid of #ifdef guards
this can be done differently. unfortunately it requires some hacks, see
`Mate/Debug.hs' and `debug.h', but I think it's more convient to use.
note, that there're now different `printf_*' functions to use, in
order to map the desired debuglevel.
also see the file `HACKING' for usage.
Bernhard Urban [Tue, 8 May 2012 19:06:27 +0000 (21:06 +0200)]
exception: small example of how interfacing hs-java
Bernhard Urban [Tue, 8 May 2012 11:04:08 +0000 (13:04 +0200)]
tests: one more static initializer
testcase suggested by harald
Bernhard Urban [Thu, 3 May 2012 18:49:19 +0000 (20:49 +0200)]
TODO: update
Bernhard Urban [Tue, 1 May 2012 08:41:01 +0000 (10:41 +0200)]
interface: one testcase
Bernhard Urban [Mon, 30 Apr 2012 22:43:43 +0000 (00:43 +0200)]
refactor: trap.c
just moving code around
Bernhard Urban [Mon, 30 Apr 2012 22:37:13 +0000 (00:37 +0200)]
classpool: add interface-table-ptr to method-table-ptr
at codegen it's very similiar to invokevirtual, but in the
classpool we have to build a quite big table for interface
methods offsets for each class.
misc notes:
- introduced a traptype lookup for trap.c
- interface-table-ptr is stored at offset 0 of the method-table
Bernhard Urban [Mon, 30 Apr 2012 13:06:49 +0000 (15:06 +0200)]
debug: use #ifdef guards
new targets:
$ make mate.dbg # build debug version of mate
$ make tests/Fac.dbg # use debug build for executing `tests/Fac.class'
Bernhard Urban [Mon, 30 Apr 2012 12:54:57 +0000 (14:54 +0200)]
Wall: kill ghc warning
Bernhard Urban [Mon, 30 Apr 2012 12:12:44 +0000 (14:12 +0200)]
PrintStream: reorganize `printf' and `println'
Bernhard Urban [Mon, 30 Apr 2012 12:05:59 +0000 (14:05 +0200)]
Makefile: s/test/tests/g
autocompletion always wants to expand to `make tests', since
there is a directory `tests' *sigh*
Bernhard Urban [Mon, 30 Apr 2012 12:20:04 +0000 (14:20 +0200)]
strings: memset allocated memory
Bernhard Urban [Mon, 30 Apr 2012 11:50:44 +0000 (13:50 +0200)]
classpool: we want the object size
i.e. the number of bytes to allocate for field members of the object.
... not the amount of (virtual) methods this object has.
what an ugly bug :-(
Bernhard Urban [Fri, 27 Apr 2012 10:39:27 +0000 (12:39 +0200)]
refactor: rename types (more consistent style)
Bernhard Urban [Fri, 27 Apr 2012 10:23:08 +0000 (12:23 +0200)]
test: testcase stolen from JorthVM
Bernhard Urban [Thu, 26 Apr 2012 19:25:32 +0000 (21:25 +0200)]
tools: openjdktest.sh: check for arguments
also, one "--enable-shared" was missing installhaskellenv.sh
Bernhard Urban [Thu, 26 Apr 2012 19:05:13 +0000 (21:05 +0200)]
tools: some safety checks in openjdktest.sh
Bernhard Urban [Thu, 26 Apr 2012 19:04:14 +0000 (21:04 +0200)]
tools: script for installing the required haskell environment
Bernhard Urban [Thu, 26 Apr 2012 17:07:37 +0000 (19:07 +0200)]
tools: test against openjdk
see `make test' after a change, to check if you broke something
hint: use `make -j8 test' or similar (depending on your machine...)
but note, it's only a high level test
Bernhard Urban [Thu, 26 Apr 2012 15:42:34 +0000 (17:42 +0200)]
tests: don't use `pop' hack anymore, but System.out.printf \o/
Bernhard Urban [Thu, 26 Apr 2012 15:10:17 +0000 (17:10 +0200)]
varargs: make printf working
although it's still a hack: WOOOT
Bernhard Urban [Thu, 26 Apr 2012 15:11:08 +0000 (17:11 +0200)]
strings: other solution
strings got free'd by the GHC runtime, ooops
Bernhard Urban [Thu, 26 Apr 2012 15:05:59 +0000 (17:05 +0200)]
java.lang: add Integer wrapper
Bernhard Urban [Thu, 26 Apr 2012 14:44:54 +0000 (16:44 +0200)]
fields: don't multiple the offset with 4
it's already correct in the table, noob...
Bernhard Urban [Thu, 26 Apr 2012 12:41:01 +0000 (14:41 +0200)]
codegen: implement `iastore' and `iaload'
Bernhard Urban [Thu, 26 Apr 2012 12:26:27 +0000 (14:26 +0200)]
codegen: implement `newarray' and `arraylength'
the length is stored at offset 0.
Bernhard Urban [Thu, 26 Apr 2012 11:36:33 +0000 (13:36 +0200)]
codegen: kill unsafePerformIO
thanks to MonadIO \o/
Bernhard Urban [Thu, 26 Apr 2012 09:37:45 +0000 (11:37 +0200)]
codegen: implement IF_ACMP
it's just IF_ICMP actually
Bernhard Urban [Thu, 26 Apr 2012 08:39:10 +0000 (10:39 +0200)]
strings: put every String from the constantpool in a Map
because the spec requires that every constant string
has the same address.
w0000t @ "Hello World" :-)
Bernhard Urban [Wed, 25 Apr 2012 21:47:46 +0000 (23:47 +0200)]
trap: sigception: allow signal in signal handler context
this can hapen in combination with the static initializer:
(1) some code in class B wants to access a static field in class A
(2) SEGSEGV is issued. we are in a signal context now
(3) this is the first usage of class A, so we have to load it
and execute the static initializer
(4) in the static initializer of class A, there is also a static
field access, which again causes a SIGSEGV
without `SA_NODEFER', the second SIGSEGV would be ignored.
Bernhard Urban [Wed, 25 Apr 2012 20:47:47 +0000 (22:47 +0200)]
java.io: PrintStream
Bernhard Urban [Wed, 25 Apr 2012 19:24:29 +0000 (21:24 +0200)]
invokevirtual: native methods
Bernhard Urban [Wed, 25 Apr 2012 19:17:33 +0000 (21:17 +0200)]
invokevirtual: get the actual class at run-time
we don't know the actual class in the CodeGen Monad, so we have to
deduce it at run-time. we use the method-table-ptr for that, since
it has an unique address which we can use to map the actual class.
Bernhard Urban [Wed, 25 Apr 2012 15:31:28 +0000 (17:31 +0200)]
invokevirtual: implemented. not very well tested though
TODO: cleaner code ;-(
Bernhard Urban [Wed, 25 Apr 2012 15:13:49 +0000 (17:13 +0200)]
callconv: once again, fail...
the arguments were in the wrong order, which wasn't covered by the test cases,
because I use addition everywhere... *d'oh*
Bernhard Urban [Wed, 25 Apr 2012 09:03:06 +0000 (11:03 +0200)]
fields: use offsets from ClassInfo in codegen
BUT:
Couldn't match expected type `IO CUInt'
against inferred type `CodeGen e s CUInt'
any idea how to solve this problem *without* `unsafePerformIO'?
Bernhard Urban [Wed, 25 Apr 2012 08:26:12 +0000 (10:26 +0200)]
classpool: also calculate offsets for non-static fields
Bernhard Urban [Tue, 24 Apr 2012 22:38:11 +0000 (00:38 +0200)]
classpool: refactor, refactor, ...
we also need to load classes *without* executing the static
initializer (to access field-offset data at compile-time
for non-static fields)
Bernhard Urban [Tue, 24 Apr 2012 21:35:25 +0000 (23:35 +0200)]
field access: first primitive attempt
constantpool index is used as offset to access
fields of an object (which isn't correct)
TODO:
- proper table index setup
- allocate bytes according table size
- consider inheritance
Bernhard Urban [Tue, 24 Apr 2012 21:21:12 +0000 (23:21 +0200)]
trap: move assertion to the top
better for debugging.
Bernhard Urban [Tue, 24 Apr 2012 17:43:34 +0000 (19:43 +0200)]
methodpool: bug fix
doesn't make sense otherwise.
why no testcase covers this? well, when we lose information
about already compiled methods, we just compile them again...
Bernhard Urban [Tue, 24 Apr 2012 15:55:55 +0000 (17:55 +0200)]
static initializer: execute it when loading the class file
unfortunately, we have a circle dependency now, hence the file
`Mate/MethodPool.hs-boot'.
Bernhard Urban [Tue, 24 Apr 2012 15:49:22 +0000 (17:49 +0200)]
java.lang: use Object.class from GNU Classpath
it doesn't have a static initializer.
java/lang/Object from OpenJDK does something weird
in the static initializer:
invokestatic #17; //Method registerNatives:()V
we don't want that.
Bernhard Urban [Tue, 24 Apr 2012 09:10:42 +0000 (11:10 +0200)]
static methods: add inheritance capability
if the method isn't found when compiling, check the superclasses for
this certain method. if one is found eventually, add an map entry
for each class to the same method entry.
see tests/Static5.java
Bernhard Urban [Mon, 23 Apr 2012 23:22:24 +0000 (01:22 +0200)]
static fields: testcase: overwriting of fields
Bernhard Urban [Mon, 23 Apr 2012 23:17:12 +0000 (01:17 +0200)]
codegen: fix bug in calling conv
the callee used elements of the callers stack as storage for local vars.
don't do that.
Bernhard Urban [Mon, 23 Apr 2012 20:44:28 +0000 (22:44 +0200)]
java.lang: add Object.class from rt.jar (OpenJDK)
building java/lang/Object.class with javac isn't that easy, so... let's steal it :-/
TODO:
- replace binary blob with some actual code. actually, we can
use hs-java for that ;-)
Bernhard Urban [Mon, 23 Apr 2012 20:38:00 +0000 (22:38 +0200)]
make test: less verbose plzkkthx
... and, there is something broken @ Fac.java :-(
stay tuned... *sigh*
Bernhard Urban [Mon, 23 Apr 2012 20:38:00 +0000 (22:38 +0200)]
classpool: copy field members refs from superclass
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
codegen: factor offset calculation
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
codegen: {put,get}static for static field access
TODO:
- execute static initializer upon first loading
- inheritance
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
refactor: s/C(aller)Map/T(rap)Map/g
we want to store more information for traps, hence an more appropriate name
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
global map hack: refactor
TODO: do some haskell magic for conversion functions.
type class? template haskell?
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
classpool: do classloading at central point. omit '.class' when calling `mate'
Bernhard Urban [Sun, 22 Apr 2012 23:14:45 +0000 (01:14 +0200)]
methodpool: also call native methods
some comments:
(1) we need shared libs now, otherwise the binary too big (~24MB).
please recompile from cabal (see README)
(2) as C doesn't allow '/', '(' and ')' as identifier names (unlike
forth <3), we replace them with '_', in order to identify a
(unique) native function. the pattern is as follows:
class__methodname__methodsignature
(3) `loadNativeFunction' is quite hackisch now. I don't know if we
get troubles with it at some point. we should consider:
(3a) ask on stackoverflow
(3b) patch this wtf stuff in ghc
(3c) just determine addresses at compile-time.
(3c) sucks, because you have to write much glue-code for every
native method. but maybe we could solve it with some magic TH
stuff (as suggested by hs_)
Bernhard Urban [Sun, 22 Apr 2012 23:14:45 +0000 (01:14 +0200)]
types: oops, we don't want the index at this point (MethodInfo)
it would be valid just for one certain class anyway... and we don't need it really
Bernhard Urban [Sun, 22 Apr 2012 18:42:50 +0000 (20:42 +0200)]
modules: move (public) datatypes into a new module
Bernhard Urban [Sun, 22 Apr 2012 18:42:50 +0000 (20:42 +0200)]
classloading: load classfile on demand
first step, not really done cleanly at the moment.
TODO: introduce a classpool, where the
(1) static initializer is executed upon first loading
(2) reference to `Class Resolved' is saved somewhere
Bernhard Urban [Sun, 22 Apr 2012 18:42:50 +0000 (20:42 +0200)]
trap: give disasm some nop's, so it shows the label
the disasm doesn't show labels on invalid opcode, but
that's convenient when debugging.
one can argue it's not really efficient here, because two cycles are wastet.
imho that's not true, since modern x86 cpu's eliminate such instructions
sequences.
we could benchmark/test that, but well, it's just on the first hit, so suck it.
Bernhard Urban [Sun, 22 Apr 2012 18:42:50 +0000 (20:42 +0200)]
codegen: correct argument handling
after a call, we have to decrement the stack pointer again, according how many
arguments that method has. also, we have to push the result in %eax only when
there's a result (i.e. /= void)
Bernhard Urban [Sun, 22 Apr 2012 18:33:03 +0000 (20:33 +0200)]
README: some notes about a ghc 7.4.1 install (shipped with Ubuntu LTS 12.04)
Harald Steinlechner [Sat, 21 Apr 2012 10:31:05 +0000 (12:31 +0200)]
Mate: exposed internal functions of BasicBlocks for external benchmarks
scratch: implemented kind of benchmark (non trustworthy currently)
Harald Steinlechner [Fri, 20 Apr 2012 16:20:05 +0000 (18:20 +0200)]
scratch: refactored ScratchHS into separate files.
scratch: more refactoring. cyclic cfg finally works
Harald Steinlechner [Fri, 20 Apr 2012 14:52:59 +0000 (16:52 +0200)]
scratch: implemented [node][edge] -> circular structure.
Harald Steinlechner [Wed, 18 Apr 2012 19:06:56 +0000 (21:06 +0200)]
scratch: checked out some abstractions, sandboxing, mostly broken ;-)
tests: added for version of fac to Fac
Bernhard Urban [Wed, 18 Apr 2012 10:51:56 +0000 (12:51 +0200)]
scratch: Makefile dependencies, LaTeX fun, .gitignore
pdflatex ftw!
Bernhard Urban [Wed, 18 Apr 2012 10:40:14 +0000 (12:40 +0200)]
trap: use SIGILL instead of SIGSEGV
therefore we can use SIGSEGV for other things (e.g. exception handling)
Bernhard Urban [Wed, 18 Apr 2012 10:21:37 +0000 (12:21 +0200)]
doc: more related stuff
thx @ hs_
Harald Steinlechner [Wed, 18 Apr 2012 01:04:10 +0000 (03:04 +0200)]
scratch: sketched monadic foldTree stuff. Maybe quite senseless but given this a CFG could be formulated in a functional way.
Bernhard Urban [Tue, 17 Apr 2012 21:57:31 +0000 (23:57 +0200)]
basicblocks: also consider back references
as we just iterate the instruction stream when generating basicblocks, we need
extra handling for back references.
the solution adds a further pass, which marks targets of jumps (actually it
marks the instruction right *before* the target)
kudos @ tests/Fac.java for being a useful testcase :-)
Bernhard Urban [Tue, 17 Apr 2012 21:57:31 +0000 (23:57 +0200)]
tests: calculate factorial (non-recursive)
Harald Steinlechner [Tue, 17 Apr 2012 11:58:57 +0000 (13:58 +0200)]
Merge branch 'master' of wien.tomnetworks.com:mate
Harald Steinlechner [Tue, 17 Apr 2012 11:58:28 +0000 (13:58 +0200)]
scratch: Translation scheme latex/literal haskell setup. Translation.lhs should contain documentation for intermediate representation and its compilation schemes
Bernhard Urban [Tue, 17 Apr 2012 11:22:00 +0000 (13:22 +0200)]
.gitignore: *.swp and object files
Harald Steinlechner [Tue, 17 Apr 2012 10:30:10 +0000 (12:30 +0200)]
ffi: added strange hack in order to build master on my machine:
Linux version 3.0.0-12-generic (buildd@aro 4.6.1-9ubuntu3)
#20-Ubuntu SMP Fri Oct 7 14:50:42 UTC 2011,
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1;
Harald Steinlechner [Tue, 17 Apr 2012 10:11:10 +0000 (12:11 +0200)]
added scratch - for design experimentation and sandboxing
Bernhard Urban [Mon, 16 Apr 2012 20:01:41 +0000 (22:01 +0200)]
gdb: small howto debug generated code
not very convenient yet, but hey, better than nothing!