|[2 earlier articles]|
|Re: Language design/VM design firstname.lastname@example.org (Jeremy Boden) (2000-03-06)|
|Re: Language design/VM design email@example.com (Floris 'Tamama' van Gog) (2000-03-11)|
|Re: Language design/VM design firstname.lastname@example.org (Jeremy Boden) (2000-03-23)|
|Re: Language design/VM design email@example.com (Alan Fargusson) (2000-03-23)|
|Re: Language design/VM design firstname.lastname@example.org (Joachim Durchholz) (2000-03-23)|
|Re: Language design/VM design email@example.com (Floris 'Tamama' van Gog) (2000-03-28)|
|Re: Language design/VM design firstname.lastname@example.org (2000-04-01)|
|From:||email@example.com (Stephan Houben)|
|Date:||1 Apr 2000 14:05:48 -0500|
|Organization:||Eindhoven University of Technology, The Netherlands|
|References:||00-02-138 00-03-102 00-03-147|
Floris 'Tamama' van Gog <firstname.lastname@example.org> wrote:
>Now it would be kinda bad if the VM would execute a script that then
>crashes the host-program. For this I need this pointer safety (static
>arrays are bound-checked at compile time if possible). But while
>thinking I came up with the idea not to check if the access is within
>VM space, but whether or not that access is within it's array it's
>supposed to be in as well.
I.e. you want to have boundary-checked arrays.
This is commonly implemented by adding to every array a header
that contains the number of elements. Your array (pointed to by p)
now looks like this:
p -> +------+
The disadvantage is that you have to add some constant offset to
p before referencing into the array. A trick to avoid this is to
have p pointed to the first item:
p -> +------+
But now you have to subtract a constant offset from p to get the size.
However, whenever your compiler can do compile-time boundary checking,
this can be avoided, and then array indexing is as fast as in C.
Having pointers that point into the middle of an array is more
problematic. One way is to represent such pointers as a pair
(array base, offset). Then do boundary checking when dereferencing
On a language design point of view: I think that C's way of
confusing arrays and pointers is difficult to understand and difficult
to implement. So perhaps you shouldn't try to reproduce it.
Return to the
Search the comp.compilers archives again.