Giter Site home page Giter Site logo

yuriy-chumak / ol Goto Github PK

View Code? Open in Web Editor NEW
222.0 14.0 11.0 112.33 MB

Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.

Home Page: http://yuriy-chumak.github.io/ol/

License: Other

Makefile 1.74% C 14.80% BitBake 0.03% C++ 0.63% Scheme 82.28% sed 0.01% NSIS 0.16% Shell 0.27% Roff 0.07% Awk 0.01% Batchfile 0.01%
lisp interpreter compiler scheme programming-language language repl tiny ol virtual-machine

ol's People

Contributors

aoh avatar frozen-eye avatar gitter-badger avatar goshhhy avatar xvilka avatar yuriy-chumak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ol's Issues

Owl-Lisp c-code generator

Is it possible to include something like this in otus?

Owl-Lisp can generate c-code with it's binary ol -o hello.c hello.scm.

Though not really cross-platform because it's relying on POSIX.

Would be really cool if otus could do the same with it's more powerful libraries and really platform independence (mostly) :)

TODO: add set-ref! form

add real "set-ref!" form.
this must be assembly operator (set-ref! a n b), n > 0 with logic:

  • if n is 0 or bigger than length of a: return false, end
  • if b is value: set n-th element of a to the b, end
  • if b is reference:
    • if b < a: set n-th element of a to the b, end
    • if b > a:
      • make "mark" to the area [a, fp] with usual root (regs)
      • move a to the new fp and unwind a chain
      • make fake sweep to the area [old a, fp](only unwind all chains, not moving the objects)
      • set n-th element of a to the b, end

now we can emulate set! operator by using (set-ref! (getf toplevel 'symbol) n new-value) or something similar

Add function error-handler

To call it everytime error happens - to be able to handle it, instead of simple exit.
E.g. feeding the pointer of this handler to OL_new()

Target to compile everything in one image

To be able to have 1 bytecode, containing OL base image. So calling (import (owl ff)) for example will import ff module not from the filesystem, but from the precompiled code inside this big image.

Building debug table

May be something like "function name" - bytecode. So it would be easy to match the function name with its bytecode representation.

Prompt is not displayed.

Otus Lisp do not print prompt on mintty of MSYS2.

_isatty return zero always about stdin and stdout on pseudo terminal of Cygwin and Msys, because standard input and output will be connected with mintty via pipe. (pipe is not tty.)

A known workaround is to check pipe name.
Please see Vim for an example.

But this workaround is dirty hack and solves only case of mintty.
There is cases that another pseudo terminal may not named pipe.

I think that a command line option for to change to interactive mode should be added.
Human's judgement is better rather than way do not exist.

Print function name in error in `verbose-vm-error`

When there is arity error - it prints something like:

ERROR: src/olvm.c/2034
error:  function #<function> got did not want 0 arguments 

I found that the code printing this error is in lang/primop.scm in function verbose-vm-error.
Is there any way to print also function name?

sparc64 NaN

Spark64 incorrectly calculates NaN values.

(/ 0 0) produces +nan.0, but (/ 0 (inexact 0)) produces BIG.

Invalid build under Manjaro

The Makefile incorrectly set HAS_DLOPEN, HAS_SOCKETS and HAS_SECCOMP build variables (to '0' instead of actual support).

AddressSanitizer: heap-buffer-overflow src/olvm.c:2181 in runtime

Happened on some scripts - interestingly appears after I remove one of the comments...

================================================================
==6947==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f1393a44c40 at pc 0x00000040937f bp 0x7ffc70be4b20 sp 0x7ffc70be4b10
WRITE of size 1 at 0x7f1393a44c40 thread T0
    #0 0x40937e in runtime src/olvm.c:2181
    #1 0x41e2c5 in OL_eval src/olvm.c:4441
    #2 0x41d70b in main src/olvm.c:4279
    #3 0x7f139d535400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    #4 0x402139 in _start (/home/user/tool/ol/ol+0x402139)

0x7f1393a44c40 is located 0 bytes to the right of 17474624-byte region [0x7f139299a800,0x7f1393a44c40)
allocated by thread T0 here:
    #0 0x7f139dba6210 in realloc (/lib64/libasan.so.3+0xc7210)
    #1 0x4026cd in adjust_heap src/olvm.c:1069
    #2 0x40300b in gc src/olvm.c:1269
    #3 0x4030eb in gc src/olvm.c:1280
    #4 0x404a89 in OL__gc src/olvm.c:1553
    #5 0x405cfd in runtime src/olvm.c:1750
    #6 0x41e2c5 in OL_eval src/olvm.c:4441
    #7 0x41d70b in main src/olvm.c:4279
    #8 0x7f139d535400 in __libc_start_main (/lib64/libc.so.6+0x20400)

SUMMARY: AddressSanitizer: heap-buffer-overflow src/olvm.c:2181 in runtime
Shadow bytes around the buggy address:
  0x0fe2f2740930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe2f2740940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe2f2740950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe2f2740960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe2f2740970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0fe2f2740980: 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa fa fa
  0x0fe2f2740990: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe2f27409a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe2f27409b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe2f27409c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe2f27409d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==6947==ABORTING

Install in Manjaro

Hello, I installed Otus Lisp in Manjaro, but this happens to me:
[spectrumgomas@cacharro ~]$ ol
Welcome to Otus Lisp 2.1-2518-5131665f
type ',help' to help, ',quit' to end session.

(import (otus random!))
;; Library (otus random!) added
;; Imported (otus random!)
(rand! 9)
6

It works :D

(import (lib gl))
Import failed because Failed to load (lib gl) because
Library (lib gl) failed:
Failed to load (otus ffi) because
Library (otus ffi) failed:
error 62011 ->
62011 .. 1 62011

What's wrong?

Cross compilation

Hello, in Void Linux we use folowing patch to make ol cross-build. Could you merge it?

diff --git Makefile Makefile
index 29ea60f..d586472 100644
--- Makefile
+++ Makefile
@@ -7,6 +7,7 @@ export OL_HOME=libraries
 all: release
 
 CC ?= gcc
+LD ?= ld
 UNAME ?= $(shell uname -s)
 
 # 'configure' part:
@@ -167,7 +168,7 @@ src/olvm.c: extensions/ffi.c
 	touch src/olvm.c
 
 $(repl.o): repl
-	ld -r -b binary -o $(repl.o) repl
+	$(LD) -r -b binary -o $(repl.o) repl

Lack of M1 support (FFI)

Build for M1 failing.

cc src/olvm.c -o vm \
   extensions/ffi.c -Iincludes \
   -O2 -g -fno-stack-check -std=gnu99 -fno-exceptions -lm -DHAS_SOCKETS=1 -DHAS_DLOPEN=1 -DHAS_SANDBOX=0 -DSYSCALL_SYSINFO=0  -O2 -DNDEBUG -DPREFIX=\"/usr/local\"
extensions/ffi.c:3024:43: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
                        __asm__("fmov d0, %[reg]" :: [reg]"r" (OL2F(r)));
                                                               ^
extensions/ffi.c:3024:22: note: use constraint modifier "w"
                        __asm__("fmov d0, %[reg]" :: [reg]"r" (OL2F(r)));
                                          ^~~~~~
                                          %w[reg]
<inline asm>:7:2: error: conditional branch requires assembler-local label. '.Lno_more_floats' is external.
        cbz x3, .Lno_more_floats
        ^
<inline asm>:13:2: error: conditional branch requires assembler-local label. '.Lno_more_floats' is external.
        ble .Lno_more_floats
        ^
<inline asm>:20:2: error: conditional branch requires assembler-local label. '.Ltest' is external.
        bge .Ltest
        ^
<inline asm>:22:2: error: conditional branch requires assembler-local label. '.Ltest' is external.
        bge .Ltest
        ^
<inline asm>:26:2: error: conditional branch requires assembler-local label. '.L_a' is external.
        bgt .L_a
        ^
<inline asm>:31:2: error: conditional branch requires assembler-local label. '.L_b' is external.
        bgt .L_b
        ^
<inline asm>:47:2: error: conditional branch requires assembler-local label. '.Lgo' is external.
        cbz x5, .Lgo
        ^
<inline asm>:50:2: error: conditional branch requires assembler-local label. '.Lint' is external.
        beq .Lint
        ^
<inline asm>:52:2: error: conditional branch requires assembler-local label. '.Lpush' is external.
        cbz x13, .Lpush
        ^
<inline asm>:58:2: error: conditional branch requires assembler-local label. '.Lpush' is external.
        cbz x12, .Lpush
        ^
<inline asm>:63:7: error: conditional branch requires assembler-local label. '.Lcall' is external.
        .Lgo:cbz x2, .Lcall
             ^
<inline asm>:65:2: error: conditional branch requires assembler-local label. '.Lless2' is external.
        ble .Lless2
        ^
1 warning and 12 errors generated.
make: *** [Makefile:279: vm] Error 1

rand! with 0

TODO: Update rand!, (rand! 0) should return

  • 0,
  • #false,
  • +nan.0 ??

BUG: mad math

(define a -2559283/18-809/3253196083i)
(define b -6-1077081413775/36080600217217067094272i)
(print
  (/ a (* b b))
)

fails with

Bad math:
  int< #false 0

Can not build Ol anymore

I am getting an error: Looks like you have no libc6-dev, please install.

I have libc6-dev installed.

System: chromeOS (Linux VM)

OL_tb_start() - please add the parameter to load bytecode

Currently I'm doing something like

some_example:
	$(OL_BIN) main.scm
	xxd -i main.bl > main_bytecode.h
	gcc -O0 -ggdb main.c $(OL_PATH)/src/olvm.c $(OL_PATH)/src/boot.c -std=c99 -ldl -DEMBEDDED_VM -DHAS_DLOPEN=1 -DHAS_PINVOKE=1 -o mytestapp \
	-Xlinker --export-dynamic $(OL_INCLUDE) -DSTANDALONE_APP

Where main.c contains code like:

unsigned char *bootstrap = main_bl;
OL* ol = OL_new(bootstrap, NULL);
OL_eval(ol, 0, 0);
OL_free(ol);

Would be nice to be able to load this compiled bytecode of main.scm with OL_tb_start(). As far as I understand, there are some important functions in talkback.lisp. So I'd need to add them in the main.scm as well.

#warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]

On Fedora 25:

[user@localhost ol]$ make
vm repl <src/boot.lisp >src/boot.c
gcc -std=c99  -O2 -DNDEBUG -s    -DNO_SECCOMP -lasan -fsanitize=address -fno-omit-frame-pointer src/olvm.c src/boot.c -o ol \
   -Xlinker --export-dynamic  -ldl
In file included from /usr/include/stdint.h:25:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include/stdint.h:9,
                 from src/olvm.c:223:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^~~~~~~
Ok.

FreeBSD 13.1 arm64 FFI issues

Some errors in FFI numbers handling for FreeBSD/arm64.

# uname -a
FreeBSD freebsd 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC arm64
:~/ol # diff tests/ffi.scm.ok tests/ffi.scm.ok2
103,106c103,106
<    float (1001/8): [125.125000 => 125.125000] 125.125
<    float (125.125): [125.125000 => 125.125000] 125.125
<    float (-1001/8): [-125.125000 => -125.125000] -125.125
<    float (-125.125): [-125.125000 => -125.125000] -125.125
---
>    float (1001/8): [125.125000 => 125.125000] 0.0
>    float (125.125): [125.125000 => 125.125000] 0.0
>    float (-1001/8): [-125.125000 => -125.125000] 0.0
>    float (-125.125): [-125.125000 => -125.125000] 0.0
109,112c109,112
<    double (1001/8): [125.125000 => 125.125000] 125.125
<    double (125.125): [125.125000 => 125.125000] 125.125
<    double (-1001/8): [-125.125000 => -125.125000] -125.125
<    double (-125.125): [-125.125000 => -125.125000] -125.125
---
>    double (1001/8): [125.125000 => 125.125000] 0.0
>    double (125.125): [125.125000 => 125.125000] 0.0
>    double (-1001/8): [-125.125000 => -125.125000] 0.0
>    double (-125.125): [-125.125000 => -125.125000] 0.0
145,147c145,147
<    16 floats (0 11/10 11/5 33/10 22/5 11/2 33/5 77/10 44/5 99/10 101/10 1111/100 303/25 1313/100 707/50 303/20): [0.000000, 1.100000, 2.200000, 3.300000, 4.400000, 5.500000, 6.600000, 7.700000, 8.800000, 9.900000, 10.100000, 11.110000, 12.120000, 13.130000, 14.140000, 15.150000 => 125.250000] 125.25
<    16 floats (303/20 707/50 1313/100 303/25 1111/100 101/10 99/10 44/5 77/10 33/5 11/2 22/5 33/10 11/5 11/10 0): [15.150000, 14.140000, 13.130000, 12.120000, 11.110000, 10.100000, 9.900000, 8.800000, 7.700000, 6.600000, 5.500000, 4.400000, 3.300000, 2.200000, 1.100000, 0.000000 => 125.250000] 125.25
<    16 floats (0.0 1.1 2.2 3.29999999 4.4 5.5 6.59999999 7.7 8.8 9.9 10.09999999 11.1099999 12.1199999 13.13 14.14 15.15): [0.000000, 1.100000, 2.200000, 3.300000, 4.400000, 5.500000, 6.600000, 7.700000, 8.800000, 9.900000, 10.100000, 11.110000, 12.120000, 13.130000, 14.140000, 15.150000 => 125.250000] 125.25
---
>    16 floats (0 11/10 11/5 33/10 22/5 11/2 33/5 77/10 44/5 99/10 101/10 1111/100 303/25 1313/100 707/50 303/20): [0.000000, 1.100000, 2.200000, 3.300000, 4.400000, 5.500000, 6.600000, 7.700000, 8.800000, 9.900000, 10.100000, 11.110000, 12.120000, 13.130000, 14.140000, 15.150000 => 125.250000] 0.0
>    16 floats (303/20 707/50 1313/100 303/25 1111/100 101/10 99/10 44/5 77/10 33/5 11/2 22/5 33/10 11/5 11/10 0): [15.150000, 14.140000, 13.130000, 12.120000, 11.110000, 10.100000, 9.900000, 8.800000, 7.700000, 6.600000, 5.500000, 4.400000, 3.300000, 2.200000, 1.100000, 0.000000 => 125.250000] 0.0
>    16 floats (0.0 1.1 2.2 3.29999999 4.4 5.5 6.59999999 7.7 8.8 9.9 10.09999999 11.1099999 12.1199999 13.13 14.14 15.15): [0.000000, 1.100000, 2.200000, 3.300000, 4.400000, 5.500000, 6.600000, 7.700000, 8.800000, 9.900000, 10.100000, 11.110000, 12.120000, 13.130000, 14.140000, 15.150000 => 125.250000] 0.0
149c149
<    12 arguments (0 1 2 3 4 5 6 7 8 9 9877/8 493825/4): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1234.625000, 123456.250000 => 124735.875000] 124735.875
---
>    12 arguments (0 1 2 3 4 5 6 7 8 9 9877/8 493825/4): [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1234.625000, 123456.250000 => 124735.875000] 0.0
151,153c151,153
<    22 integer arguments (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22): [1, 2, 3.000000, 4.000000, 5, 6, 7.000000, 8.000000, 9, 10, 11.000000, 12.000000, 13, 14, 15.000000, 16.000000, 17, 18, 19.000000, 20.000000, 21.000000, 22.000000 => 253.000000] 253.0
<    22 mixed arguments (1 2 3 9/2 5 6 29/4 35/4 9 10 89/8 103/8 13 14 255/16 267/16 17 18 631/32 671/32 701/32 183/8): [1, 2, 3.000000, 4.500000, 5, 6, 7.250000, 8.750000, 9, 10, 11.125000, 12.875000, 13, 14, 15.937500, 16.687500, 17, 18, 19.718750, 20.968750, 21.906250, 22.875000 => 260.593750] 260.59375
<    22 mixed inexact arguments (1 2 3.0 4.5 5 6 7.25 8.75 9 10 11.125 12.875 13 14 15.9375 16.6875 17 18 19.71875 20.96875 21.90625 22.875): [1, 2, 3.000000, 4.500000, 5, 6, 7.250000, 8.750000, 9, 10, 11.125000, 12.875000, 13, 14, 15.937500, 16.687500, 17, 18, 19.718750, 20.968750, 21.906250, 22.875000 => 260.593750] 260.59375
---
>    22 integer arguments (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22): [1, 2, 3.000000, 4.000000, 5, 6, 7.000000, 8.000000, 9, 10, 11.000000, 12.000000, 13, 14, 15.000000, 16.000000, 17, 18, 19.000000, 20.000000, 21.000000, 22.000000 => 253.000000] 0.0
>    22 mixed arguments (1 2 3 9/2 5 6 29/4 35/4 9 10 89/8 103/8 13 14 255/16 267/16 17 18 631/32 671/32 701/32 183/8): [1, 2, 3.000000, 4.500000, 5, 6, 7.250000, 8.750000, 9, 10, 11.125000, 12.875000, 13, 14, 15.937500, 16.687500, 17, 18, 19.718750, 20.968750, 21.906250, 22.875000 => 260.593750] 0.0
>    22 mixed inexact arguments (1 2 3.0 4.5 5 6 7.25 8.75 9 10 11.125 12.875 13 14 15.9375 16.6875 17 18 19.71875 20.96875 21.90625 22.875): [1, 2, 3.000000, 4.500000, 5, 6, 7.250000, 8.750000, 9, 10, 11.125000, 12.875000, 13, 14, 15.937500, 16.687500, 17, 18, 19.718750, 20.968750, 21.906250, 22.875000 => 260.593750] 0.0
155,158c155,158
< callback: [ (9227469/8388608) ] = 1.100000
< callback: [ (-9227469/8388608) ] = -1.100000
< callback: [ (8319/64) ] = 129.984375
< callback: [ (-8319/64) ] = -129.984375
---
> callback: [ (9227469/8388608) ] = -0.000000
> callback: [ (-9227469/8388608) ] = -0.000000
> callback: [ (8319/64) ] = 0.000000
> callback: [ (-8319/64) ] = 0.000000
160,163c160,163
< callback: [ (1 9227469/8388608 -2 -9227469/4194304) ] = 4.840000
< callback: [ (-1 -9227469/8388608 2 9227469/4194304) ] = 4.840000
< callback: [ (999999 -8319/64 111111 -8295/512) ] = 233988325113856.000000
< callback: [ (-999999 8319/64 -111111 8295/512) ] = 233988325113856.000000
---
> callback: [ (1 9227469/8388608 -2 -9227469/4194304) ] = 0.000000
> callback: [ (-1 -9227469/8388608 2 9227469/4194304) ] = 0.000000
> callback: [ (999999 -8319/64 111111 -8295/512) ] = -3815729081704372947761758208.000000
> callback: [ (-999999 8319/64 -111111 8295/512) ] = -3815729081704372947761758208.000000
218,221c218,221
<    float (1001/8): [125.125000 => 125.125000] 125.125
<    float (125.125): [125.125000 => 125.125000] 125.125
<    float (-1001/8): [-125.125000 => -125.125000] -125.125
<    float (-125.125): [-125.125000 => -125.125000] -125.125
---
>    float (1001/8): [125.125000 => 125.125000] 0.0
>    float (125.125): [125.125000 => 125.125000] 0.0
>    float (-1001/8): [-125.125000 => -125.125000] 0.0
>    float (-125.125): [-125.125000 => -125.125000] 0.0
224,227c224,227
<    double (1001/8): [125.125000 => 125.125000] 125.125
<    double (125.125): [125.125000 => 125.125000] 125.125
<    double (-1001/8): [-125.125000 => -125.125000] -125.125
<    double (-125.125): [-125.125000 => -125.125000] -125.125
---
>    double (1001/8): [125.125000 => 125.125000] 0.0
>    double (125.125): [125.125000 => 125.125000] 0.0
>    double (-1001/8): [-125.125000 => -125.125000] 0.0
>    double (-125.125): [-125.125000 => -125.125000] 0.0
269,271c269,271
<    rf2f ((1.0)): [1.000000 => 1.000000] 1.0
<    rf2f ((125.125)): [125.125000 => 125.125000] 125.125
<    rf2f ((-125.125)): [-125.125000 => -125.125000] -125.125
---
>    rf2f ((1.0)): [1.000000 => 1.000000] 0.0
>    rf2f ((125.125)): [125.125000 => 125.125000] 0.0
>    rf2f ((-125.125)): [-125.125000 => -125.125000] 0.0
273,275c273,275
<    rd2d ((1.0)): [1.000000 => 1.000000] 1.0
<    rd2d ((125.125)): [125.125000 => 125.125000] 125.125
<    rd2d ((-125.125)): [-125.125000 => -125.125000] -125.125
---
>    rd2d ((1.0)): [1.000000 => 1.000000] 0.0
>    rd2d ((125.125)): [125.125000 => 125.125000] 0.0
>    rd2d ((-125.125)): [-125.125000 => -125.125000] 0.0
302,305c302,305
<    rpf2f3 ((1.0 2.0 0.0)): [1.000000, 2.000000, 0.000000 => 3.000000] 3.0 -> (1.0 2.0 3.0)
<    rpf2f3 ((125.125 0.0 0.0)): [125.125000, 0.000000, 0.000000 => 125.125000] 125.125 -> (125.125 0.0 125.125)
<    rpf2f3 ((0.0 125.125 0.0)): [0.000000, 125.125000, 0.000000 => 125.125000] 125.125 -> (0.0 125.125 125.125)
<    rpf2f3 ((-125.125 -125.125 0.0)): [-125.125000, -125.125000, 0.000000 => -250.250000] -250.25 -> (-125.125 -125.125 -250.25)
---
>    rpf2f3 ((1.0 2.0 0.0)): [1.000000, 2.000000, 0.000000 => 3.000000] 0.0 -> (1.0 2.0 3.0)
>    rpf2f3 ((125.125 0.0 0.0)): [125.125000, 0.000000, 0.000000 => 125.125000] 0.0 -> (125.125 0.0 125.125)
>    rpf2f3 ((0.0 125.125 0.0)): [0.000000, 125.125000, 0.000000 => 125.125000] 0.0 -> (0.0 125.125 125.125)
>    rpf2f3 ((-125.125 -125.125 0.0)): [-125.125000, -125.125000, 0.000000 => -250.250000] 0.0 -> (-125.125 -125.125 -250.25)
307,310c307,310
<    rpd2d3 ((1.0 2.0 0.0)): [1.000000, 2.000000, 0.000000 => 3.000000] 3.0 -> (1.0 2.0 3.0)
<    rpd2d3 ((125.125 0.0 0.0)): [125.125000, 0.000000, 0.000000 => 125.125000] 125.125 -> (125.125 0.0 125.125)
<    rpd2d3 ((0.0 125.125 0.0)): [0.000000, 125.125000, 0.000000 => 125.125000] 125.125 -> (0.0 125.125 125.125)
<    rpd2d3 ((-125.125 -125.125 0.0)): [-125.125000, -125.125000, 0.000000 => -250.250000] -250.25 -> (-125.125 -125.125 -250.25)
---
>    rpd2d3 ((1.0 2.0 0.0)): [1.000000, 2.000000, 0.000000 => 3.000000] 0.0 -> (1.0 2.0 3.0)
>    rpd2d3 ((125.125 0.0 0.0)): [125.125000, 0.000000, 0.000000 => 125.125000] 0.0 -> (125.125 0.0 125.125)
>    rpd2d3 ((0.0 125.125 0.0)): [0.000000, 125.125000, 0.000000 => 125.125000] 0.0 -> (0.0 125.125 125.125)
>    rpd2d3 ((-125.125 -125.125 0.0)): [-125.125000, -125.125000, 0.000000 => -250.250000] 0.0 -> (-125.125 -125.125 -250.25)

Cannot find (r5rs srfi-87) library

[user@localhost ol]$ make recompile
Loading code...
Import failed because Failed to load (otus lisp) because 
  Library (otus lisp) failed: 
    I didn't have or find library (r5rs srfi-87) 
diff: boot.fasl: No such file or directory
stat: cannot stat 'boot.fasl': No such file or directory
390795 ->
cp: cannot stat 'boot.fasl': No such file or directory
make[1]: Entering directory '/home/user/tool/ol'
Loading code...
Import failed because Failed to load (otus lisp) because 
  Library (otus lisp) failed: 
    I didn't have or find library (r5rs srfi-87) 
diff: boot.fasl: No such file or directory
stat: cannot stat 'boot.fasl': No such file or directory
390795 ->
cp: cannot stat 'boot.fasl': No such file or directory
make[2]: Entering directory '/home/user/tool/ol'
Loading code...
Import failed because Failed to load (otus lisp) because 
  Library (otus lisp) failed: 
    I didn't have or find library (r5rs srfi-87) 
diff: boot.fasl: No such file or directory
stat: cannot stat 'boot.fasl': No such file or directory
390795 ->

Heap-use-after-free on double include

If you put 2 lines at the beginning of file, then shebang:

(define *include-dirs* (cons "/home/user/ol" *include-dirs*))
(define *include-dirs* (cons "/home/user/ol" *include-dirs*))
#/usr/bin/ol
/home/user/ol/ol main.scm
=================================================================
==19329==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f0b12733288 at pc 0x00000040949f bp 0x7ffdb74a7160 sp 0x7ffdb74a7150
READ of size 8 at 0x7f0b12733288 thread T0
    #0 0x40949e in runtime src/olvm.c:2187
    #1 0x41e3e2 in OL_eval src/olvm.c:4458
    #2 0x41d828 in main src/olvm.c:4296
    #3 0x7f0b1c21e400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    #4 0x402139 in _start (/home/user/ol/ol+0x402139)

0x7f0b12733288 is located 17414792 bytes inside of 17475456-byte region [0x7f0b11697800,0x7f0b12741f80)
freed by thread T0 here:
    #0 0x7f0b1c88f210 in realloc (/lib64/libasan.so.3+0xc7210)
    #1 0x4026cd in adjust_heap src/olvm.c:1073
    #2 0x40300b in gc src/olvm.c:1273
    #3 0x4030eb in gc src/olvm.c:1284
    #4 0x404a89 in OL__gc src/olvm.c:1557
    #5 0x4092cc in runtime src/olvm.c:2177
    #6 0x41e3e2 in OL_eval src/olvm.c:4458
    #7 0x41d828 in main src/olvm.c:4296
    #8 0x7f0b1c21e400 in __libc_start_main (/lib64/libc.so.6+0x20400)

previously allocated by thread T0 here:
    #0 0x7f0b1c88f210 in realloc (/lib64/libasan.so.3+0xc7210)
    #1 0x4026cd in adjust_heap src/olvm.c:1073
    #2 0x40300b in gc src/olvm.c:1273
    #3 0x4030eb in gc src/olvm.c:1284
    #4 0x404a89 in OL__gc src/olvm.c:1557
    #5 0x405cfd in runtime src/olvm.c:1754
    #6 0x41e3e2 in OL_eval src/olvm.c:4458
    #7 0x41d828 in main src/olvm.c:4296
    #8 0x7f0b1c21e400 in __libc_start_main (/lib64/libc.so.6+0x20400)

SUMMARY: AddressSanitizer: heap-use-after-free src/olvm.c:2187 in runtime
Shadow bytes around the buggy address:
  0x0fe1e24de600: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de610: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de620: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de630: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de640: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0fe1e24de650: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de660: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de670: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de680: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de690: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0fe1e24de6a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==19329==ABORTING

Of course it's invalid syntax, but at least it shouldn't corrupt the memory, imho

TODO: Math improvements

Move fxmax and xmbits into one command, move math initialization into one function, use set-car! and set-cdr! to change the builtin fxmax and xmbits values in math module.

TODO: new versioning

move to the new versioning
new version must be A.B.CCC.D

  • change major version (A) only for very! big changes
  • change minor version (B) only after backward incompatibility changes (or for very important updates)
  • automatically calculate build number (CCC) as number of commits for version A.B
  • automatically add commit hash tag (D) to the development (and only to the development) versions

Binary REPL, bootstrapping and reproducibility

Hi Yuriy,

I would like to ask you about the binary dependency of the repl file. In order to compile ol, the binary repl file is needed as far as I have seen. Both using the Makefile or the advance/manual method.

How is this binary file generated? I saw there is a ./libraries/scheme/repl.scm in the repo, but I doubt that it is the file that is needed to generate the ./repl binary.

I am asking because I would like to know if ol is bootstrappable. That means, whether a piece of software can be compiled from scratch or it requires some binary blobs. This is a topic that most people do not care, but I personally do. I am looking for a small Scheme implementation that could be used in the live-bootstrap project. This requires that the Scheme implementation be compilable fully from source, without any pregenerated binaries nor machine-generated files.

I have written about this topic and my goal (to create a bootstrapping compiler for GCC-Ada also known as GNAT) in here. There is this other page where I go more into the details and I have added ol for now, as I did not realise that it required the repl binary.

Could the repl binary be generated by the user from a human readable file without already having ol installed? Is that feasible to achieve?

Thank you for your time and effort! Best regards,
Fer

Ability to add the code in text form to the virtual machine

For example - I have some file some.scm.
It has a bunch of functions, and I compiled it in the bytecode.
But I want also to load those using OL_new, but also want to run some code in the text form on top of that loaded bytecode. Is that possible somehow?
For example I define multiple functions in the my.scm, compiling it in the my.bl, then want to call them from the file.
To do that I need to define callback, but therefore I should define it with (dlsym ) - thus should call on top of loaded bytecode...

TODO: automatic freeing the callbacks

automaticly free unused callbacks as part of GC

  • after gc mark() check the all vaues of callback registers
  • if register value is not an object header, set value to the INULL
    • (as part of mark process all object dependency trees as unwinded to the line with changing the last one object value to the value of left-most object header, so this can be indicator of existing the dependent objects in the tree)
  • continue normal GC process (sweep, etc.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.