mate.git
11 years agocodegen: workaround for a emitBB bug
Bernhard Urban [Wed, 13 Jun 2012 22:09:00 +0000 (00:09 +0200)]
codegen: workaround for a emitBB bug

11 years agocodegen: print every jvm instruction as label in disasm output
Bernhard Urban [Wed, 13 Jun 2012 14:37:56 +0000 (16:37 +0200)]
codegen: print every jvm instruction as label in disasm output

11 years agocodegen: some more tests
Bernhard Urban [Tue, 12 Jun 2012 20:08:36 +0000 (22:08 +0200)]
codegen: some more tests

11 years agocodegen: eliminate code duplication
Bernhard Urban [Tue, 12 Jun 2012 19:40:28 +0000 (21:40 +0200)]
codegen: eliminate code duplication

11 years agorefactor: better names for TrapInfo^WTrapCause
Bernhard Urban [Tue, 12 Jun 2012 10:43:22 +0000 (12:43 +0200)]
refactor: better names for TrapInfo^WTrapCause

11 years agoMakefile: let testfiles be a dependency for the tests target
Bernhard Urban [Tue, 12 Jun 2012 10:32:42 +0000 (12:32 +0200)]
Makefile: let testfiles be a dependency for the tests target

- just compile java files needed for executing mate (e.g. java/* stuff)
- also satisify a dependency with a wrong classfile as we test something
  different here (see ClassPath3.*). yes, it's a hack, as our "test framework"
  isn't really mature :-)

11 years agohlint: more fixes
Bernhard Urban [Tue, 12 Jun 2012 10:06:05 +0000 (12:06 +0200)]
hlint: more fixes

not everything fixed though. some ugly things in the codegen hopefully disappears
sometimes (e.g. due to an awesome reg allocator ;))

11 years agoffi: don't use C for obtaining an address of a haskell function
Bernhard Urban [Mon, 11 Jun 2012 19:02:20 +0000 (21:02 +0200)]
ffi: don't use C for obtaining an address of a haskell function

i.e. get rid of dirty FFI hacks.

thanks to simonmar:
http://stackoverflow.com/questions/10967598/get-the-address-of-a-function-without-ffi#comment14326263_10967598

11 years agotools: cabal: update to new harpy version
Bernhard Urban [Thu, 24 May 2012 13:53:57 +0000 (15:53 +0200)]
tools: cabal: update to new harpy version

11 years agocodegen: add instanceof stub
Bernhard Urban [Sun, 20 May 2012 21:29:37 +0000 (23:29 +0200)]
codegen: add instanceof stub

gnuclasspath is going crazy now o_O

11 years agotools: install libs with profile information
Bernhard Urban [Sun, 20 May 2012 20:56:24 +0000 (22:56 +0200)]
tools: install libs with profile information

11 years agotrapmap: delete entry after information is consumed
Bernhard Urban [Sun, 20 May 2012 20:10:36 +0000 (22:10 +0200)]
trapmap: delete entry after information is consumed

11 years agodebug.h: define DBG_ALL
Bernhard Urban [Sun, 20 May 2012 20:04:19 +0000 (22:04 +0200)]
debug.h: define DBG_ALL

11 years agocodegen: extra handling if calldisplacement doesn't fit in 8bit
Bernhard Urban [Sun, 20 May 2012 19:56:49 +0000 (21:56 +0200)]
codegen: extra handling if calldisplacement doesn't fit in 8bit

harpy generates different code for
- call (Disp  (0x33 :: Word32) (eax)
- call (Disp (0x444 :: Word32) (eax))
although if both immediates are declared as Word32, harpy checks
at emmitting if it's able to reduce code size.

hopefully we find a easier way to fix this issue, because this way
just introduces more complexity.

11 years agocodegen/div: clear edx before use div insn
Bernhard Urban [Sun, 20 May 2012 19:55:47 +0000 (21:55 +0200)]
codegen/div: clear edx before use div insn

11 years agocodegen: a few more hacks to get more of classpath running
Bernhard Urban [Sun, 20 May 2012 13:35:31 +0000 (15:35 +0200)]
codegen: a few more hacks to get more of classpath running

11 years agomethodlookup: unique identifier for methods are name+signature
Bernhard Urban [Sun, 20 May 2012 19:50:49 +0000 (21:50 +0200)]
methodlookup: unique identifier for methods are name+signature

in our case always the "first" method with the name was taken
(the signature was ignored)

11 years agoclasspool: staticfields calculation: bugfix
Bernhard Urban [Sun, 20 May 2012 19:49:22 +0000 (21:49 +0200)]
classpool: staticfields calculation: bugfix

span doesn't do what I believed it does (it aborts on first predicate match)

11 years agotests: generics
Bernhard Urban [Sun, 20 May 2012 13:17:23 +0000 (15:17 +0200)]
tests: generics

11 years agotraps: debugging
Bernhard Urban [Sun, 20 May 2012 19:47:05 +0000 (21:47 +0200)]
traps: debugging

11 years agotests: static classes
Bernhard Urban [Sun, 20 May 2012 12:27:26 +0000 (14:27 +0200)]
tests: static classes

11 years agoclasspool: cache class file access
Bernhard Urban [Sun, 20 May 2012 19:42:48 +0000 (21:42 +0200)]
classpool: cache class file access

it was designed for that, so do it... *sigh*
sometimes I'm so dumb

most things are intend stuff

11 years agostring: allocate a real java object for strings
Bernhard Urban [Sun, 20 May 2012 10:32:07 +0000 (12:32 +0200)]
string: allocate a real java object for strings

incl. fieldtable, array, ...

also see:
http://www.javamex.com/tutorials/memory/string_memory_usage.shtml

11 years agodebug: malloc stuff
Bernhard Urban [Sun, 20 May 2012 10:21:57 +0000 (12:21 +0200)]
debug: malloc stuff

11 years agoarray: char array support
Bernhard Urban [Sun, 20 May 2012 19:37:08 +0000 (21:37 +0200)]
array: char array support

11 years agoMakefile: optional call file for testcases
Bernhard Urban [Sun, 20 May 2012 00:00:10 +0000 (02:00 +0200)]
Makefile: optional call file for testcases

in order to easier pass arguments to the JVM for certain testcases,
e.g. classpath stuff

11 years agomain: some kind of argument parsing
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

11 years agoClassPool: JAR and ClassPath support
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...

11 years agohs-java: upgrade to 0.3.1
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/

11 years agofixed bug in mate.cabal '.' should be in include dir not included itself
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

11 years agoMakefile: delete *_stub.* files
Bernhard Urban [Sat, 19 May 2012 10:31:45 +0000 (12:31 +0200)]
Makefile: delete *_stub.* files

those are generated exporting things with FFI

11 years agomate.cabal switched to our version of harpy (git://wien.tomnetworks.com/harpy.git...
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)

11 years agotools: new custom repo for disassembler
Bernhard Urban [Sat, 19 May 2012 10:10:56 +0000 (12:10 +0200)]
tools: new custom repo for disassembler

11 years agotraps: do more things in haskell world
Bernhard Urban [Sat, 19 May 2012 09:52:33 +0000 (11:52 +0200)]
traps: do more things in haskell world

11 years agotools: missed a possible failed case
Bernhard Urban [Fri, 18 May 2012 22:31:08 +0000 (00:31 +0200)]
tools: missed a possible failed case

11 years agofixed mate-common. cabal build should work now
Harald Steinlechner [Fri, 18 May 2012 23:03:11 +0000 (01:03 +0200)]
fixed mate-common. cabal build should work now

11 years agoadded cabal stubs for mate-common and mate;
Harald Steinlechner [Fri, 18 May 2012 22:58:24 +0000 (00:58 +0200)]
added cabal stubs for mate-common and mate;

11 years agoscratch/ffiTest: removed export
Harald Steinlechner [Fri, 18 May 2012 20:00:05 +0000 (22:00 +0200)]
scratch/ffiTest: removed export

11 years agorefactor: use `unsafePerformIO hack' for global var
Bernhard Urban [Fri, 18 May 2012 09:30:33 +0000 (11:30 +0200)]
refactor: use `unsafePerformIO hack' for global var

11 years agorefactor: reduce global var in trap.c to one pointer
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 :/

11 years agoglobalvars: get rid of `trap_map'
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)

11 years agoscratch: sync sketch code for FFI,Signal...
Harald Steinlechner [Thu, 17 May 2012 16:25:49 +0000 (18:25 +0200)]
scratch: sync sketch code for FFI,Signal...

11 years agotools: let `make tests' fail, if there's a failed testcase
Bernhard Urban [Wed, 16 May 2012 22:50:38 +0000 (00:50 +0200)]
tools: let `make tests' fail, if there's a failed testcase

11 years agohlint: fix suggested improvements
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

11 years agohlint: use CamelCase for printf stuff
Bernhard Urban [Thu, 10 May 2012 10:42:44 +0000 (12:42 +0200)]
hlint: use CamelCase for printf stuff

11 years agoMakefile: hlint target
Bernhard Urban [Thu, 10 May 2012 11:08:20 +0000 (13:08 +0200)]
Makefile: hlint target

requires some CPP hack magic...

11 years agotodo: update
Bernhard Urban [Wed, 16 May 2012 22:52:24 +0000 (00:52 +0200)]
todo: update

11 years agogc: factor out allocation
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.

11 years agoMakefile: target for executing a single testcase
Bernhard Urban [Tue, 8 May 2012 21:52:39 +0000 (23:52 +0200)]
Makefile: target for executing a single testcase

see `HACKING'

11 years agodebug: get rid of #ifdef guards
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.

11 years agoexception: small example of how interfacing hs-java
Bernhard Urban [Tue, 8 May 2012 19:06:27 +0000 (21:06 +0200)]
exception: small example of how interfacing hs-java

11 years agotests: one more static initializer
Bernhard Urban [Tue, 8 May 2012 11:04:08 +0000 (13:04 +0200)]
tests: one more static initializer

testcase suggested by harald

11 years agoTODO: update
Bernhard Urban [Thu, 3 May 2012 18:49:19 +0000 (20:49 +0200)]
TODO: update

11 years agointerface: one testcase
Bernhard Urban [Tue, 1 May 2012 08:41:01 +0000 (10:41 +0200)]
interface: one testcase

11 years agorefactor: trap.c
Bernhard Urban [Mon, 30 Apr 2012 22:43:43 +0000 (00:43 +0200)]
refactor: trap.c

just moving code around

11 years agoclasspool: add interface-table-ptr to method-table-ptr
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

11 years agodebug: use #ifdef guards
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'

11 years agoWall: kill ghc warning
Bernhard Urban [Mon, 30 Apr 2012 12:54:57 +0000 (14:54 +0200)]
Wall: kill ghc warning

11 years agoPrintStream: reorganize `printf' and `println'
Bernhard Urban [Mon, 30 Apr 2012 12:12:44 +0000 (14:12 +0200)]
PrintStream: reorganize `printf' and `println'

11 years agoMakefile: s/test/tests/g
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*

11 years agostrings: memset allocated memory
Bernhard Urban [Mon, 30 Apr 2012 12:20:04 +0000 (14:20 +0200)]
strings: memset allocated memory

11 years agoclasspool: we want the object size
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 :-(

12 years agorefactor: rename types (more consistent style)
Bernhard Urban [Fri, 27 Apr 2012 10:39:27 +0000 (12:39 +0200)]
refactor: rename types (more consistent style)

12 years agotest: testcase stolen from JorthVM
Bernhard Urban [Fri, 27 Apr 2012 10:23:08 +0000 (12:23 +0200)]
test: testcase stolen from JorthVM

12 years agotools: openjdktest.sh: check for arguments
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

12 years agotools: some safety checks in openjdktest.sh
Bernhard Urban [Thu, 26 Apr 2012 19:05:13 +0000 (21:05 +0200)]
tools: some safety checks in openjdktest.sh

12 years agotools: script for installing the required haskell environment
Bernhard Urban [Thu, 26 Apr 2012 19:04:14 +0000 (21:04 +0200)]
tools: script for installing the required haskell environment

12 years agotools: test against openjdk
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

12 years agotests: don't use `pop' hack anymore, but System.out.printf \o/
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/

12 years agovarargs: make printf working
Bernhard Urban [Thu, 26 Apr 2012 15:10:17 +0000 (17:10 +0200)]
varargs: make printf working

although it's still a hack: WOOOT

12 years agostrings: other solution
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

12 years agojava.lang: add Integer wrapper
Bernhard Urban [Thu, 26 Apr 2012 15:05:59 +0000 (17:05 +0200)]
java.lang: add Integer wrapper

12 years agofields: don't multiple the offset with 4
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...

12 years agocodegen: implement `iastore' and `iaload'
Bernhard Urban [Thu, 26 Apr 2012 12:41:01 +0000 (14:41 +0200)]
codegen: implement `iastore' and `iaload'

12 years agocodegen: implement `newarray' and `arraylength'
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.

12 years agocodegen: kill unsafePerformIO
Bernhard Urban [Thu, 26 Apr 2012 11:36:33 +0000 (13:36 +0200)]
codegen: kill unsafePerformIO

thanks to MonadIO \o/

12 years agocodegen: implement IF_ACMP
Bernhard Urban [Thu, 26 Apr 2012 09:37:45 +0000 (11:37 +0200)]
codegen: implement IF_ACMP

it's just IF_ICMP actually

12 years agostrings: put every String from the constantpool in a Map
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" :-)

12 years agotrap: sigception: allow signal in signal handler context
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.

12 years agojava.io: PrintStream
Bernhard Urban [Wed, 25 Apr 2012 20:47:47 +0000 (22:47 +0200)]
java.io: PrintStream

12 years agoinvokevirtual: native methods
Bernhard Urban [Wed, 25 Apr 2012 19:24:29 +0000 (21:24 +0200)]
invokevirtual: native methods

12 years agoinvokevirtual: get the actual class at run-time
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.

12 years agoinvokevirtual: implemented. not very well tested though
Bernhard Urban [Wed, 25 Apr 2012 15:31:28 +0000 (17:31 +0200)]
invokevirtual: implemented. not very well tested though

TODO: cleaner code ;-(

12 years agocallconv: once again, fail...
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*

12 years agofields: use offsets from ClassInfo in codegen
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'?

12 years agoclasspool: also calculate offsets for non-static fields
Bernhard Urban [Wed, 25 Apr 2012 08:26:12 +0000 (10:26 +0200)]
classpool: also calculate offsets for non-static fields

12 years agoclasspool: refactor, refactor, ...
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)

12 years agofield access: first primitive attempt
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

12 years agotrap: move assertion to the top
Bernhard Urban [Tue, 24 Apr 2012 21:21:12 +0000 (23:21 +0200)]
trap: move assertion to the top

better for debugging.

12 years agomethodpool: bug fix
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...

12 years agostatic initializer: execute it when loading the class file
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'.

12 years agojava.lang: use Object.class from GNU Classpath
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.

12 years agostatic methods: add inheritance capability
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

12 years agostatic fields: testcase: overwriting of fields
Bernhard Urban [Mon, 23 Apr 2012 23:22:24 +0000 (01:22 +0200)]
static fields: testcase: overwriting of fields

12 years agocodegen: fix bug in calling conv
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.

12 years agojava.lang: add Object.class from rt.jar (OpenJDK)
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 ;-)

12 years agomake test: less verbose plzkkthx
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*

12 years agoclasspool: copy field members refs from superclass
Bernhard Urban [Mon, 23 Apr 2012 20:38:00 +0000 (22:38 +0200)]
classpool: copy field members refs from superclass

12 years agocodegen: factor offset calculation
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
codegen: factor offset calculation

12 years agocodegen: {put,get}static for static field access
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