mate.git
12 years agorefactor: s/C(aller)Map/T(rap)Map/g
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

12 years agoglobal map hack: refactor
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?

12 years agoclasspool: do classloading at central point. omit '.class' when calling `mate'
Bernhard Urban [Mon, 23 Apr 2012 14:10:21 +0000 (16:10 +0200)]
classpool: do classloading at central point. omit '.class' when calling `mate'

12 years agomethodpool: also call native methods
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_)

12 years agotypes: oops, we don't want the index at this point (MethodInfo)
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

12 years agomodules: move (public) datatypes into a new module
Bernhard Urban [Sun, 22 Apr 2012 18:42:50 +0000 (20:42 +0200)]
modules: move (public) datatypes into a new module

12 years agoclassloading: load classfile on demand
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

12 years agotrap: give disasm some nop's, so it shows the label
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.

12 years agocodegen: correct argument handling
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)

12 years agoREADME: some notes about a ghc 7.4.1 install (shipped with Ubuntu LTS 12.04)
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)

12 years agoMate: exposed internal functions of BasicBlocks for external benchmarks
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)

12 years agoscratch: refactored ScratchHS into separate files.
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

12 years agoscratch: implemented [node][edge] -> circular structure.
Harald Steinlechner [Fri, 20 Apr 2012 14:52:59 +0000 (16:52 +0200)]
scratch: implemented [node][edge] -> circular structure.

12 years agoscratch: checked out some abstractions, sandboxing, mostly broken ;-)
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

12 years agoscratch: Makefile dependencies, LaTeX fun, .gitignore
Bernhard Urban [Wed, 18 Apr 2012 10:51:56 +0000 (12:51 +0200)]
scratch: Makefile dependencies, LaTeX fun, .gitignore

pdflatex ftw!

12 years agotrap: use SIGILL instead of SIGSEGV
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)

12 years agodoc: more related stuff
Bernhard Urban [Wed, 18 Apr 2012 10:21:37 +0000 (12:21 +0200)]
doc: more related stuff

thx @ hs_

12 years agoscratch: sketched monadic foldTree stuff. Maybe quite senseless but given this a...
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.

12 years agobasicblocks: also consider back references
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 :-)

12 years agotests: calculate factorial (non-recursive)
Bernhard Urban [Tue, 17 Apr 2012 21:57:31 +0000 (23:57 +0200)]
tests: calculate factorial (non-recursive)

12 years agoMerge branch 'master' of wien.tomnetworks.com:mate
Harald Steinlechner [Tue, 17 Apr 2012 11:58:57 +0000 (13:58 +0200)]
Merge branch 'master' of wien.tomnetworks.com:mate

12 years agoscratch: Translation scheme latex/literal haskell setup. Translation.lhs should conta...
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

12 years ago.gitignore: *.swp and object files
Bernhard Urban [Tue, 17 Apr 2012 11:22:00 +0000 (13:22 +0200)]
.gitignore: *.swp and object files

12 years agoffi: added strange hack in order to build master on my machine:
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;

12 years agoadded scratch - for design experimentation and sandboxing
Harald Steinlechner [Tue, 17 Apr 2012 10:11:10 +0000 (12:11 +0200)]
added scratch - for design experimentation and sandboxing

12 years agogdb: small howto debug generated code
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!

12 years agomethodpool: save information in codegen context
Bernhard Urban [Mon, 16 Apr 2012 20:01:41 +0000 (22:01 +0200)]
methodpool: save information in codegen context

use that for on-demand compiling

12 years agotests: add package definition
Bernhard Urban [Mon, 16 Apr 2012 20:01:41 +0000 (22:01 +0200)]
tests: add package definition

12 years agoMakefile: forgot slash at clean target
Bernhard Urban [Mon, 16 Apr 2012 20:01:40 +0000 (22:01 +0200)]
Makefile: forgot slash at clean target

12 years agoREADME: more notes on dependencies
Bernhard Urban [Mon, 16 Apr 2012 11:14:20 +0000 (13:14 +0200)]
README: more notes on dependencies

12 years agomethodPool: compile methods on-demand
Bernhard Urban [Sat, 14 Apr 2012 17:54:20 +0000 (19:54 +0200)]
methodPool: compile methods on-demand

just works with `fib' atm. we need a second "tracker-map" when emitting an
`invoke*' instruction. there we have to lookup and save related method
information.

12 years agoMakefile: GHCi still broken
Bernhard Urban [Sat, 14 Apr 2012 12:51:41 +0000 (14:51 +0200)]
Makefile: GHCi still broken

although
http://stackoverflow.com/questions/10123040/ghci-doesnt-work-with-ffi-export-declarations-shared-libaries
fixed an issue, there is now a different one:
> $ make ghci
> [...]
> Ok, modules loaded: Main, Mate.X86CodeGen, Mate.MethodPool, Mate.BasicBlocks, Mate.Utilities.
> Prelude Main> main
>
>
> GHCi runtime linker: fatal error: I found a duplicate definition for symbol
>    MateziUtilities_lookupMethod_srt
> whilst processing object file
>    ./Mate/Utilities.o
> This could be caused by:
>    * Loading two different object files which export the same symbol
>    * Specifying the same object file twice on the GHCi command line
>    * An incorrect `package.conf' entry, causing some object to be
>      loaded twice.
> GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
>
> make: *** [ghci] Error 1

so, `make ghci' and `make tags' still doesn't work due to FFI stuff.
we have to use `make test' until we fix it :-(

12 years agoMakefile: update rules
Bernhard Urban [Sun, 8 Apr 2012 22:35:44 +0000 (00:35 +0200)]
Makefile: update rules

12 years agobuild: fix -Wall warnings
Bernhard Urban [Sun, 8 Apr 2012 22:35:44 +0000 (00:35 +0200)]
build: fix -Wall warnings

12 years agomethodpool: small demo how to access a Data.Map instance from C
Bernhard Urban [Sun, 8 Apr 2012 22:35:44 +0000 (00:35 +0200)]
methodpool: small demo how to access a Data.Map instance from C

yes. it's ugly, unsafe, etc.
but it works :-)

12 years agomain: remove PoC code
Bernhard Urban [Sun, 8 Apr 2012 18:22:15 +0000 (20:22 +0200)]
main: remove PoC code

12 years agocodegen: patch method calls on-demand via traps
Bernhard Urban [Sun, 8 Apr 2012 18:21:56 +0000 (20:21 +0200)]
codegen: patch method calls on-demand via traps

we can determine the source of an invalid memory access via unix signal
handling. to do so, we write
 > mov (Addr 0) eax    ; 0x8905 0000 0000
which tries to access memory at address 0. upon first execution of this
instruction the signalhandler is called. there, we replace it with
 > nop                 ; 0x90
 > call <target>       ; 0xe8 YYYY YYYY  ; Y = target

at the moment, this just works with Fib.fib() (or other recursive methods)
as the <target> address is more or less hardcoded.

several TODOs:
- determine address of target method in a different way
- after a call, we have to throw away arguments of the call.
  this is hardcoded now.

12 years agocodegen: execute generated code
Bernhard Urban [Sat, 7 Apr 2012 01:44:22 +0000 (03:44 +0200)]
codegen: execute generated code

woot! :-)  looks good

12 years agocodegen: use label mechanism of harpy
Bernhard Urban [Sat, 7 Apr 2012 01:44:21 +0000 (03:44 +0200)]
codegen: use label mechanism of harpy

more convenient than manual patching

12 years agobasicblock: change order of `TwoTarget'
Bernhard Urban [Sat, 7 Apr 2012 01:44:21 +0000 (03:44 +0200)]
basicblock: change order of `TwoTarget'

12 years agobasicblock: also generate BB #0 when it's labeld with `Nothing' (BBEnd)
Bernhard Urban [Sat, 7 Apr 2012 01:44:21 +0000 (03:44 +0200)]
basicblock: also generate BB #0 when it's labeld with `Nothing' (BBEnd)

12 years agocodegen: simple code generation stuff
Bernhard Urban [Tue, 3 Apr 2012 22:49:00 +0000 (00:49 +0200)]
codegen: simple code generation stuff

generated code isn't tested yet

12 years agobasicblock: remove warning
Bernhard Urban [Tue, 3 Apr 2012 22:49:00 +0000 (00:49 +0200)]
basicblock: remove warning

it can happen now ;-)

12 years agobasicblock: refactor function interface
Bernhard Urban [Tue, 3 Apr 2012 22:49:00 +0000 (00:49 +0200)]
basicblock: refactor function interface

12 years agobasicblock: build BBs from instructionstream
Bernhard Urban [Mon, 2 Apr 2012 23:32:26 +0000 (01:32 +0200)]
basicblock: build BBs from instructionstream

12 years agobasicblock: get jump offsets from instructions
Bernhard Urban [Mon, 2 Apr 2012 19:40:00 +0000 (21:40 +0200)]
basicblock: get jump offsets from instructions

12 years agobasicblock: calculate offset in instructionstream
Bernhard Urban [Mon, 2 Apr 2012 19:40:00 +0000 (21:40 +0200)]
basicblock: calculate offset in instructionstream

12 years agosrc: move files into a Mate package
Bernhard Urban [Mon, 2 Apr 2012 19:40:00 +0000 (21:40 +0200)]
src: move files into a Mate package

hence, ghc(i) is able to figuring out the correct path

12 years agoMakefile: generate tags (for vim)
Bernhard Urban [Mon, 2 Apr 2012 19:40:00 +0000 (21:40 +0200)]
Makefile: generate tags (for vim)

12 years agoREADME: more install instructions
Bernhard Urban [Mon, 2 Apr 2012 00:15:28 +0000 (02:15 +0200)]
README: more install instructions

12 years agotests: add class with {do-,}while keyword
Bernhard Urban [Mon, 2 Apr 2012 00:00:49 +0000 (02:00 +0200)]
tests: add class with {do-,}while keyword

... which unfortunately fails to parse due to a bug in hs-java.

the bogus instructions are goto and if<cond>, which hs-java
misses to parse their immediate values from the instructionstream.

fix:
$ git clone git@wien.tomnetworks.com:hs-java.git || git clone git://wien.tomnetworks.com/hs-java.git
$ cd hs-java; cabal configure; cabal build; cabal install

12 years agobasicblock: put \n between instructions
Bernhard Urban [Mon, 2 Apr 2012 00:00:49 +0000 (02:00 +0200)]
basicblock: put \n between instructions

12 years agoMakefile: build all class files in tests/
Bernhard Urban [Mon, 2 Apr 2012 00:00:48 +0000 (02:00 +0200)]
Makefile: build all class files in tests/

12 years agocompile: use relative call
Bernhard Urban [Mon, 2 Apr 2012 00:00:48 +0000 (02:00 +0200)]
compile: use relative call

we have to calculate the offset, but it's cheaper than a register call

12 years agodoc: some related papers
Bernhard Urban [Mon, 2 Apr 2012 00:00:48 +0000 (02:00 +0200)]
doc: some related papers

12 years agofixed broken Makefile (sry - forgot to check Makefile), added RegisterAllocation...
Harald Steinlechner [Tue, 27 Mar 2012 20:22:51 +0000 (22:22 +0200)]
fixed broken Makefile (sry - forgot to check Makefile), added RegisterAllocation playground

12 years agoUtilities, BasicBlock into src folder, BasicBlock sketching
Harald Steinlechner [Tue, 27 Mar 2012 20:13:42 +0000 (22:13 +0200)]
Utilities, BasicBlock into src folder, BasicBlock sketching

12 years agoMate.hs now uses lately introduced Utilities lookupMethod
Harald Steinlechner [Tue, 27 Mar 2012 19:07:59 +0000 (21:07 +0200)]
Mate.hs now uses lately introduced Utilities lookupMethod

12 years agomoved lookupMethod into separate Utilities file. added BasicBlocks playground
Harald Steinlechner [Tue, 27 Mar 2012 19:06:56 +0000 (21:06 +0200)]
moved lookupMethod into separate Utilities file. added BasicBlocks playground

12 years agoMerge branch 'master' of wien.tomnetworks.com:mate
Harald Steinlechner [Thu, 22 Mar 2012 15:44:25 +0000 (16:44 +0100)]
Merge branch 'master' of wien.tomnetworks.com:mate

12 years agodoc: fixed english grammar mistakes (an on demand manner, analyses is plural of analysis)
Harald Steinlechner [Thu, 22 Mar 2012 15:41:55 +0000 (16:41 +0100)]
doc: fixed english grammar mistakes (an on demand manner, analyses is plural of analysis)

12 years agodoc: fixed englisch grammar mistakes (an on demand manner, analyses is plural of...
Harald Steinlechner [Thu, 22 Mar 2012 15:41:55 +0000 (16:41 +0100)]
doc: fixed englisch grammar mistakes (an on demand manner, analyses is plural of analysis)

12 years agodoc: README
Bernhard Urban [Wed, 21 Mar 2012 14:40:39 +0000 (15:40 +0100)]
doc: README

12 years agodoc: added TODO
Harald Steinlechner [Wed, 21 Mar 2012 14:09:50 +0000 (15:09 +0100)]
doc: added TODO

12 years agotrapping code: transition from native to haskell rts PoC
Bernhard Urban [Sun, 18 Mar 2012 04:19:43 +0000 (05:19 +0100)]
trapping code: transition from native to haskell rts

12 years agopatching existing code
Bernhard Urban [Sat, 17 Mar 2012 22:10:52 +0000 (23:10 +0100)]
patching existing code

12 years agoplaying around with generated codebuffers
Bernhard Urban [Sat, 17 Mar 2012 20:20:39 +0000 (21:20 +0100)]
playing around with generated codebuffers

be aware, generated code doesn't make sense yet ;-)

12 years agomate: Initial commit
Bernhard Urban [Thu, 15 Mar 2012 21:27:16 +0000 (22:27 +0100)]
mate: Initial commit