picobit/chj.git
14 years agop: show a usable message from Scheme if the subprocess terminates by signalsmaster
Christian Jaeger [Fri, 26 Jun 2009 20:33:52 +0000 (26 16:33 -0400)]
p: show a usable message from Scheme if the subprocess terminates by signals

Give at least *some* hinting about segfaults happening in subprocesses.

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoFix bracketig in the transition from / to >>
Christian Jaeger [Fri, 26 Jun 2009 19:27:50 +0000 (26 15:27 -0400)]
Fix bracketig in the transition from / to >>

Unlike the division operator, the shift operator has lower precedence
than the plus operator, so parentheses are necessary.

This manifested itself for example when running tests/test-pairs.hex:
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000400a46 in ram_set_gc_tags (o=<value optimized out>, tags=0 '\0') at picobit-vm.c:68

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoRemove sed usage as "p" now strips the suffix by itself
Christian Jaeger [Tue, 23 Jun 2009 00:18:18 +0000 (22 20:18 -0400)]
Remove sed usage as "p" now strips the suffix by itself

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agop: replace shell script with Scheme implementation
Christian Jaeger [Tue, 23 Jun 2009 00:14:54 +0000 (22 20:14 -0400)]
p: replace shell script with Scheme implementation

To avoid requiring a shell and truncate the file path portably.

(And to be able to output a newline after the vm output and still be
able to pass on the vm's exit code. Although adding the newline
somehow doesn't give the intended effect (thus not included in the
patch here), and passing on the exit code portably is not done yet.)

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agop: use dirname and basename to get the base of the path
Christian Jaeger [Mon, 22 Jun 2009 23:50:54 +0000 (22 19:50 -0400)]
p: use dirname and basename to get the base of the path

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agop: add a newline after the output
Christian Jaeger [Mon, 22 Jun 2009 23:48:14 +0000 (22 19:48 -0400)]
p: add a newline after the output

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoAdd README
Christian Jaeger [Mon, 22 Jun 2009 23:38:26 +0000 (22 19:38 -0400)]
Add README

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agop: quote variables and die on variable referencing errors
Christian Jaeger [Mon, 22 Jun 2009 22:48:48 +0000 (22 18:48 -0400)]
p: quote variables and die on variable referencing errors

Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoNetworking is now an option (compile with -DNETWORKING).
Vincent St-Amour [Mon, 22 Jun 2009 22:34:24 +0000 (22 18:34 -0400)]
Networking is now an option (compile with -DNETWORKING).
Some int32 were changed to int16.

14 years agoOther changes to please SIXPIC: (void) -> ()
Vincent St-Amour [Mon, 11 May 2009 22:21:03 +0000 (11 18:21 -0400)]
Other changes to please SIXPIC: (void) -> ()

[pflanze@gmx.ch: split original patch into two separate patches, this
  being the second one]
Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoChanged divisions to shifts, there were only divisions by 2 or 4.
Vincent St-Amour [Mon, 11 May 2009 22:21:03 +0000 (11 18:21 -0400)]
Changed divisions to shifts, there were only divisions by 2 or 4.

[pflanze@gmx.ch: split original patch into two separate patches, this
  being the first one]
Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
14 years agoPut some debugging functions in an ifdef, since they are only relevant
Vincent St-Amour [Wed, 29 Apr 2009 21:41:33 +0000 (29 17:41 -0400)]
Put some debugging functions in an ifdef, since they are only relevant
on a workstation.

14 years agoMoved some code around.
Vincent St-Amour [Wed, 29 Apr 2009 19:07:47 +0000 (29 15:07 -0400)]
Moved some code around.

14 years agoVarious cleanup.
Vincent St-Amour [Fri, 27 Feb 2009 21:49:46 +0000 (27 16:49 -0500)]
Various cleanup.

14 years agoSplit the compiler into several files and repository cleanup.
Vincent St-Amour [Fri, 27 Feb 2009 20:15:48 +0000 (27 15:15 -0500)]
Split the compiler into several files and repository cleanup.

14 years agoAdded ior and xor tests to the repository.
Vincent St-Amour [Fri, 27 Feb 2009 17:11:04 +0000 (27 12:11 -0500)]
Added ior and xor tests to the repository.

14 years agoAdded bitwise ior and xor for bignums.
Vincent St-Amour [Fri, 27 Feb 2009 17:06:07 +0000 (27 12:06 -0500)]
Added bitwise ior and xor for bignums.

14 years agoRemoved some hard-coded paths, to make release easier.
Vincent St-Amour [Sat, 21 Feb 2009 03:23:11 +0000 (20 22:23 -0500)]
Removed some hard-coded paths, to make release easier.

14 years agoAdded the picobit script to the repository, which should have been
Vincent St-Amour [Sat, 21 Feb 2009 03:19:55 +0000 (20 22:19 -0500)]
Added the picobit script to the repository, which should have been
there all along.

14 years agoFurther cleanup and code reorganization.
Vincent St-Amour [Sun, 8 Feb 2009 04:02:57 +0000 (7 23:02 -0500)]
Further cleanup and code reorganization.

[pflanze@gmx.ch: moved the following fix from later patch "Networking
  is now an option" to here, so that git bisect could work:
 +#ifdef WORKSTATION
 +char *prim_name[64];
 +#endif
]
Signed-off-by: Christian Jaeger <pflanze@gmx.ch>
15 years agoFurther cleanup and code reorganization.
Vincent St-Amour [Sun, 8 Feb 2009 03:37:33 +0000 (7 22:37 -0500)]
Further cleanup and code reorganization.

15 years agoCleanup. Split the code into various files.
Vincent St-Amour [Sun, 8 Feb 2009 00:12:29 +0000 (7 19:12 -0500)]
Cleanup. Split the code into various files.

15 years agoTests added to the repository.
Vincent St-Amour [Sat, 7 Feb 2009 22:48:35 +0000 (7 17:48 -0500)]
Tests added to the repository.

New, much simpler, code for bignum encoding has been added to the
compiler. All the tests so far pass, so it seems to be working.
Bignum division and remainder primitives were implemented, which means
display of bignums can work.

15 years agoPrimitive bignum encoding added in the compiler. Doesn't work for all
Vincent St-Amour [Sat, 7 Feb 2009 20:30:12 +0000 (7 15:30 -0500)]
Primitive bignum encoding added in the compiler. Doesn't work for all
cases. For now is an ugly iterative kludge. Next step is to put it
into CPS, like the rest of this pass.

15 years agoFixed a bug related to negative fixnum encoding (i.e. -1). -1 was
Vincent St-Amour [Wed, 4 Feb 2009 22:25:50 +0000 (4 17:25 -0500)]
Fixed a bug related to negative fixnum encoding (i.e. -1). -1 was
casted to unsigned, and became 255, which was then encoded as fixnum.

15 years agoFixed a couple of issues with bignums. Most notably, negative_carry
Vincent St-Amour [Wed, 4 Feb 2009 21:30:48 +0000 (4 16:30 -0500)]
Fixed a couple of issues with bignums. Most notably, negative_carry
took a boolean, which has a width of 8, but was given results of a
bitwise and on 16 bits. Now uses the integer type instead of boolean.

Bignums have not been thoroughly tested yet.

15 years agoAdded math.scm to the repository, which contains bignum functions.
Vincent St-Amour [Thu, 8 Jan 2009 05:14:59 +0000 (8 00:14 -0500)]
Added math.scm to the repository, which contains bignum functions.

15 years agoIntegrated code for bignums. Most of it wasn't checked, though, so it
Vincent St-Amour [Thu, 8 Jan 2009 05:12:35 +0000 (8 00:12 -0500)]
Integrated code for bignums. Most of it wasn't checked, though, so it
likely won't work. What's left to do for this is to check the added
code, and to make sure it works. Also, make sure the compiler is
aware, if necessary of these new bignums.

15 years agoAdded networking, improved error messages and various minor changes.
Vincent St-Amour [Wed, 7 Jan 2009 23:04:49 +0000 (7 18:04 -0500)]
Added networking, improved error messages and various minor changes.

15 years agoVarious cleanup.
Vincent St-Amour [Thu, 31 Jul 2008 22:07:14 +0000 (31 18:07 -0400)]
Various cleanup.

15 years agoExposed a few type-checking primitives from the library.
Vincent St-Amour [Thu, 31 Jul 2008 21:44:12 +0000 (31 17:44 -0400)]
Exposed a few type-checking primitives from the library.
General cleanup.

15 years agoVector copy now works, or at least, looks like it does.
Vincent St-Amour [Thu, 31 Jul 2008 20:37:26 +0000 (31 16:37 -0400)]
Vector copy now works, or at least, looks like it does.
Rom vectors are back to ordinary lists, much simpler that way.

15 years agoWork has begun on efficient vector copy.
Vincent St-Amour [Thu, 31 Jul 2008 16:38:43 +0000 (31 12:38 -0400)]
Work has begun on efficient vector copy.
However, rom vectors as dotted lists end up complicating this, and
will be removed.

15 years agoWe can now have up to 64 primitives. None of the new are used yet, but
Vincent St-Amour [Wed, 30 Jul 2008 20:16:58 +0000 (30 16:16 -0400)]
We can now have up to 64 primitives. None of the new are used yet, but
vector-copy is next.

15 years agoVectors should now be working. All lengths are stored raw, not encoded
Vincent St-Amour [Tue, 29 Jul 2008 22:35:24 +0000 (29 18:35 -0400)]
Vectors should now be working. All lengths are stored raw, not encoded
as ints.

15 years agoVectors are slightly broken, in the middle of fixing them.
Vincent St-Amour [Tue, 29 Jul 2008 22:19:35 +0000 (29 18:19 -0400)]
Vectors are slightly broken, in the middle of fixing them.
Still deciding whether to stored the length of the vector raw or int encoded.

15 years agoDummy commit.
Vincent St-Amour [Tue, 29 Jul 2008 20:26:34 +0000 (29 16:26 -0400)]
Dummy commit.
Had a problem with the last commit comment.
It should have said that the make-u8vector primitive now sets the
right default values (and takes 2 parameters).

15 years agothat in the scheme code was much too costly.
Vincent St-Amour [Tue, 29 Jul 2008 20:23:39 +0000 (29 16:23 -0400)]
that in the scheme code was much too costly.
Various other corrections.

15 years agoRom vectors are now stored as fotted lists, which saves 1 pair per
Vincent St-Amour [Mon, 28 Jul 2008 23:05:24 +0000 (28 19:05 -0400)]
Rom vectors are now stored as fotted lists, which saves 1 pair per
vector. We'll have to see if the effect on the size of the vm is too
much or not.

15 years agoMerged most of Etienne's improvements from last year, including
Vincent St-Amour [Mon, 28 Jul 2008 21:08:26 +0000 (28 17:08 -0400)]
Merged most of Etienne's improvements from last year, including
macros, named lets, letrecs, etc.
They seem to work.

15 years agoAdded Etienne's error messages to the vm, which give the name of the
Vincent St-Amour [Mon, 28 Jul 2008 18:57:00 +0000 (28 14:57 -0400)]
Added Etienne's error messages to the vm, which give the name of the
primitive where the error occurred.

15 years agoGlobals are now dynamically allocated, up to 256 of them.
Vincent St-Amour [Mon, 28 Jul 2008 18:22:45 +0000 (28 14:22 -0400)]
Globals are now dynamically allocated, up to 256 of them.
The stack can now theoretically run.

15 years agoWe can now have up to 128 globals. The number is arbitrary, but could
Vincent St-Amour [Fri, 25 Jul 2008 21:21:54 +0000 (25 17:21 -0400)]
We can now have up to 128 globals. The number is arbitrary, but could
go up to 256, since we have a byte to encode them. For now, their
number is statically determined, which can cause wasted space if not
all are used. We'll change this to be dynamic, the number of globals
will be encoded in the beginning of the bytecode, as is the case with
constants and globals will simply occupy the beginning of ordinary ram.

15 years agoShort instructions are there, they are coded both in the compiler and
Vincent St-Amour [Fri, 25 Jul 2008 19:49:34 +0000 (25 15:49 -0400)]
Short instructions are there, they are coded both in the compiler and
the VM, but they cause segfaults. I'll debug these later since they
are not too important.

15 years agoPush-long now uses a 4-bit opcode. Reduces size a bit.
Vincent St-Amour [Thu, 24 Jul 2008 22:00:56 +0000 (24 18:00 -0400)]
Push-long now uses a 4-bit opcode. Reduces size a bit.
Now we have a lot of free opcodes.
I'll try to add some "short" versions to the label instrs, with only 8
bit of address.

15 years agoConcentrated all the label instructions (call-toplevel, goto, etc)
Vincent St-Amour [Thu, 24 Jul 2008 21:39:15 +0000 (24 17:39 -0400)]
Concentrated all the label instructions (call-toplevel, goto, etc)
under a single 4-bit opcode. Now to find a way to use this freed
space. Push long is first in line.

15 years agoExtended the primitive substitution to binary arithmetic operators.
Vincent St-Amour [Thu, 24 Jul 2008 20:15:57 +0000 (24 16:15 -0400)]
Extended the primitive substitution to binary arithmetic operators.
As long as an arithmetic operation has only 2 operands, the
corresponding primitive is used instead of the wrapper.
Stack down to 5691 bytes.

15 years agoAdded a little optimization. Calls to certain functions can now be
Vincent St-Amour [Thu, 24 Jul 2008 19:44:03 +0000 (24 15:44 -0400)]
Added a little optimization. Calls to certain functions can now be
replaced directly by primitive calls y the compiler, saving a
call/return each time. Stack is down to 5805 bytes thanks to that.

15 years agoOptimized the library a bit by calling primitives directly instead of wrappers.
Vincent St-Amour [Wed, 23 Jul 2008 21:16:16 +0000 (23 17:16 -0400)]
Optimized the library a bit by calling primitives directly instead of wrappers.

15 years agoLiteral byte-vectors now end up in rom, as lists, as should be.
Vincent St-Amour [Wed, 23 Jul 2008 20:13:26 +0000 (23 16:13 -0400)]
Literal byte-vectors now end up in rom, as lists, as should be.
Maybe another representation could be better, but for now, that will do.

15 years agoByte vectors are now working. They can only be created at runtime yet,
Vincent St-Amour [Wed, 23 Jul 2008 15:08:56 +0000 (23 11:08 -0400)]
Byte vectors are now working. They can only be created at runtime yet,
though. Now, let's see what we can do for rom/literal vectors.

15 years agoVarious cleanup.
Vincent St-Amour [Fri, 18 Jul 2008 20:50:26 +0000 (18 16:50 -0400)]
Various cleanup.

15 years agoCode is now cleaner, no more second_half.
Vincent St-Amour [Fri, 18 Jul 2008 19:44:24 +0000 (18 15:44 -0400)]
Code is now cleaner, no more second_half.

15 years agoGC bug solved. Now new objects should work completely.
Vincent St-Amour [Fri, 18 Jul 2008 19:24:48 +0000 (18 15:24 -0400)]
GC bug solved. Now new objects should work completely.
Now, I'll get rid of second_half (can be replaced by arg1..4) and
implement true vectors.

15 years agoFixnums now go from 0 to 255 instead of -5 to 40. Nothings seems to
Vincent St-Amour [Thu, 17 Jul 2008 21:38:42 +0000 (17 17:38 -0400)]
Fixnums now go from 0 to 255 instead of -5 to 40. Nothings seems to
have broken because of this, but the GC bug subsists.
Saves us about 200 bytes for the stack (from 5980 to 5808).

15 years agoNew objects mostly work, procedure calls are ok, but GC messes things up.
Vincent St-Amour [Thu, 17 Jul 2008 19:42:19 +0000 (17 15:42 -0400)]
New objects mostly work, procedure calls are ok, but GC messes things up.
After a GC, both env and the continuation stack are messed up.
However, the vm now uses all memory, not just 8 bits, so GC happens
only in big programs.

15 years agoNew object representation works partially.
Vincent St-Amour [Mon, 14 Jul 2008 21:36:52 +0000 (14 17:36 -0400)]
New object representation works partially.
test-globals works without any problem, but still some trouble with red-green.

15 years agoIntegrated modifications for the new PIC.
Vincent St-Amour [Fri, 11 Jul 2008 20:13:38 +0000 (11 16:13 -0400)]
Integrated modifications for the new PIC.
Changed the compiler with new representation.
Changed the representation of closures and continuations, since we
learned that closures were used as pairs when doing lookup.
Tried to add global to constant conversion in the compiler, but didn't
work. When we fix it, make it work only for globals that contain
numbers, bools and co. No pairs, vectors, etc, so we can only check
for set!s and not set-car!s and co.

15 years agoGC was changed to consider the new representation.
Vincent St-Amour [Mon, 7 Jul 2008 18:49:25 +0000 (7 14:49 -0400)]
GC was changed to consider the new representation.
The compiler still has to be changed.
This is the last version for the old PIC, from now on, the code for
picoboard-v2 will be merged.

15 years agoMost of the vm has been changed to use the 13-bit representation.
Vincent St-Amour [Wed, 2 Jul 2008 22:10:01 +0000 (2 18:10 -0400)]
Most of the vm has been changed to use the 13-bit representation.
I think only the gc still needs to be changed.
No work has started on the conversion of the compiler. A lot of work
will be needed, since now many instructions take more arguments (bytes
after the opcode) than they used to.

15 years agoGC seems to work with 12 bits.
Vincent St-Amour [Wed, 2 Jul 2008 17:22:49 +0000 (2 13:22 -0400)]
GC seems to work with 12 bits.
Compiler still does not work correctly with 12 bits.
12-bit representation will be abandoned and Marc's 13-bit one will be
used instead. This will require some modifications to the VM (should
not be too hard) and some serious changes to the compiler (which would
need to change anyways since 12 bits don't work).

15 years agoPartial 12-bit support. VM mostly works (GC is left) but compiler does not.
Vincent St-Amour [Mon, 30 Jun 2008 20:43:36 +0000 (30 16:43 -0400)]
Partial 12-bit support. VM mostly works (GC is left) but compiler does not.
The GC still needs to be adapted to the new representation, and the
compiler also does, but it would require a lot more work.
We'll also need to store immutable globals as constants, since we have
some constants left and no more globals. Maybe find a way to get rid
of some globals/constants, and do propagation.
For now, the red-green example works, but not much else.

15 years agoVectors are now r-a-lists, bitwise operations are there.
Vincent St-Amour [Wed, 25 Jun 2008 15:33:52 +0000 (25 11:33 -0400)]
Vectors are now r-a-lists, bitwise operations are there.
All the features needed by PICOBIT are implemented.
Now, we have a problem of address space, as well as constant and
global variable counts.
Next steps : change representation of objets to increase address space
     add vectors as contiguous space

15 years agoPicobit now has triplets, which can be used to implement
Vincent St-Amour [Tue, 3 Jun 2008 02:46:54 +0000 (2 22:46 -0400)]
Picobit now has triplets, which can be used to implement
vectors. Actually, 3 implementations of vectors have been written. One
that makes linked lists of triplets, another that used Chris Okasaki's
random access lists (the O(1) list operations are useless here since
we are implementing vectors, which have fixed size) and a last one
that has simple complete binary trees (the code is actually uglier
than the r-a-lists, since we have to build the tree all at once (no
cheap "consing"), and we have to find the smallest size of tree that
fits, which uses an ugly binary search through powers of 2).

Will have to get rid of some of the least useful primitives to make
room for ior and xor, and maybe others.

15 years agoInitial commit.
Vincent St-Amour [Wed, 28 May 2008 21:27:47 +0000 (28 17:27 -0400)]
Initial commit.
Already did some work. u8vector constructor works, it's actually just
a parser hack that generates a string and the parse it. Since strings
are stored as byte vectors, this gives the result we
want. u8vector-ref also works, it's implemented as a library
function. I added a primitive, which ended up being unnecessary, I'll
get rid of it.