[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Using Gforth with #! "shebang"

From: Anton Ertl
Subject: Re: [gforth] Using Gforth with #! "shebang"
Date: Wed, 21 Nov 2012 17:47:44 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Nov 21, 2012 at 03:54:07PM +0100, Bernd Paysan wrote:
> Am Mittwoch, 21. November 2012, 15:40:15 schrieb David Kuehling:
> > without interfering with shell invocation.  I like the way it's handled
> > in Common Lisp:
> > 
> >
> > 
> > I guess we could easily add the same syntax to Gforth.
> Yes, but 
> ' ( alias #( immediate
> would be even easier to implement, and then your multiarg shebang is
> #! /bin/sh
> #(
> exec gforth-fast --options
> exit
> )

And the "#0 [IF]" works even for existing Gforth installations, so it
seems at least as good.

> > I'd also be happy if Gforth allwed to resize the dictionary and stacks
> > at runtime :)
> Since we use mmap to allocate them, this should not be that hard.  The 
> resized 
> stacks can be copied (i.e. allocate new stacks, copy the old stacks, move the 
> pointers, deallocate the old stack).

Given that there is sp@ fp@ rp@ lp@, this is not safe in general.
Also, the way recent Linuxes handle mmaps (no guard pages, unlike
older Linuxes) has led us to allocate everything in one chunk, and
then put guard pages in with mprotect or munmap.  One would have to
make sure that there are guard pages after the copying, too.

> Resizing the dictionary would require to 
> reserve a large chunk of memory via mmap+mprotect, this is doable (this will 
> still allow you to catch errors from allocating too much).

Actually, this is probably the way to go.  We use MAP_NORESERVE
anyway, so we should be configuring really large areas by default
(say, like -m 1G -d 64M -f 64M -r 64M -l 128M on 32-bit systems).

Up to now we configured relatively small sizes by default, and left it
to installers on larger systems to choose larger sizes with
"./configure FORTHSIZES=...", but most installations are probably on
large systems through third-party distributors (e.g., Linux
distributors) who don't use FORTHSIZES, while for systems like Windows
where the large sizes may be problematic (not sure if it is), we are
doing the configuration ourselves and could choose smaller sizes there.

- anton

reply via email to

[Prev in Thread] Current Thread [Next in Thread]