Skip to content

This starts a port to OS X.#3

Merged
mntmn merged 7 commits intomntmn:masterfrom
jeapostrophe:master
Sep 16, 2015
Merged

This starts a port to OS X.#3
mntmn merged 7 commits intomntmn:masterfrom
jeapostrophe:master

Conversation

@jeapostrophe
Copy link
Contributor

Presently it doesn't work, because it can't eval shell.l. A function
is called with a NULL pointer for the first argument. Not sure yet
what the function is though.

Here's the present run:

[compiler] creating global env hash table…
[compiler] init_allocator…

++ cell heap at 0x10a000000, 240000000 bytes reserved
[allocator] initialized.
[compiler] inserting symbols…
[compiler] arithmetic…
[compiler] compare…
[compiler] flow…
[compiler] lists…
[compiler] strings…
[compiler] write/eval…
sledge knows 47 symbols. enter (symbols) to see them.
[fs] mounted: /framebuffer
[fs] mounted: /keyboard
[fs] mounted: /sd
sledge>
JIT ---------------------
movq $0x10a001f80, %rdi
mov $0x10000c730, %rax
subq $8, %rsp
callq *%rax # fs_open
addq $8, %rsp
movq %rax, %rdi
mov $0x10000ce90, %rax
subq $8, %rsp
callq *%rax # stream_read
addq $8, %rsp
movq %rax, %rdi
mov $0x100009d40, %rax
subq $8, %rsp
callq *%rax # read_string_cell
addq $8, %rsp
movq %rax, %rdi
mov $0x1000071d0, %rax
subq $8, %rsp
callq *%rax # platform_eval
addq $8, %rsp

ret

<assembled bytes: 100 at: 0x1091fb000>
warning: nm: no name list
[open] found matching fs: /sd for path: /sd/os/shell.l
[open] open_fn: 0x10000d8e0
filename: os/shell.l
[posixfs] trying to read file of len 13594…

JIT ---------------------
push %rdi
jmp f1_0x10a026910
f0_0x10a026910:
movq $0xf00000010a026911, %rsi
push %rsi
movq %r12, %rax
movq (%rax), %rax
cmp $0, %rax
je else_1
movq %r13, %rax
movq (%rax), %rax
cmp $0, %rax
je else_2
movq $0x10a0022b0, %rax
jmp endif_3
else_2:
movq $0x10a0022e0, %rax
endif_3:
jmp endif_4
else_1:
movq $0x10a002328, %rax
endif_4:
addq $8, %rsp
ret
f1_0x10a026910:
movq $0x10a026910, %rax
movq %rax, %rsi
pop %rdi
movq $0x10a0020e8, %rdi
mov $0x100001640, %rax
subq $8, %rsp
callq *%rax # insert_global_symbol
addq $8, %rsp

ret

<assembled bytes: 139 at: 0x1091fd000>
Process 90261 stopped

  • thread cleaned building & running scripts up and fixed some stuff #1: tid = 0x1e9cf6, 0x00000001091fd014, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001091fd014
    -> 0x1091fd014: movq (%rax), %rax
    0x1091fd017: cmpq $0x0, %rax
    0x1091fd01b: je 0x1091fd021
    0x1091fd021: movq %r13, %rax

@mntmn
Copy link
Owner

mntmn commented Sep 16, 2015

Thanks a lot! I'll boot OSX and look into this.

@mntmn mntmn merged commit 0707cb8 into mntmn:master Sep 16, 2015
@mntmn
Copy link
Owner

mntmn commented Sep 16, 2015

Hi again, I played around a bit more on OSX and fixed many little problems. The biggest issue was that the "as" shipped with OSX seems to ignore labels that are not starting with the letter "L" and generates empty jmps (jmps to 0) without warning – or at least treats them as external symbols to be linked later. So I adopted the "L…" labeling convention and it works. I also tweaked the stack align code a bit (thanks for that hint), which is probably inefficient. To make this bullet-proof on OSX, stack frame allocation will have to be redesigned.
Anyway, it can load and display the shell now, though file operations inside the shell still crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments