[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Hash Table Collisions (n.runs-SA-2011.004)
- From: William Ahern <william@...>
- Date: Sun, 8 Jan 2012 00:46:15 -0800
On Fri, Jan 06, 2012 at 11:00:11PM -0700, HyperHacker wrote:
> On Fri, Jan 6, 2012 at 12:17, Roberto Ierusalimschy
<snip>
> > I do not see a simple way to write this in a portable way (respecting
> > alignment requirements for word access). For strings already internal to
> > Lua we know about their alignment, but external strings (the ones to be
> > internalized) may start anywhere. We would need to do some arithmetic
> > with addresses, something invalid in ANSI C.
> >
> > -- Roberto
> >
>
> That seems terribly amusing, given that C is supposed to be low-level.
> There's no way to convert the address to an integer and slow-copy the
> first few bytes until we're at an aligned address?
Yes and no. In environments like Unix and Win32 this is perfectly fine as
long as your stride and alignment are less than the page size. But reading
even single byte beyond a malloc'd region is undefined behavior in ISO C,
and of course Lua strives to adhere to the C standard. There may very well
be environments where doing so could cause things to go sideways. Also, it
would cause Valgrind to pitch a fit, and in my book anything which makes
Valgrind bothersome to use had better be exceptionally worthwhile.
- References:
- Re: Hash Table Collisions (n.runs-SA-2011.004), Ashwin Hirschi
- Re: Hash Table Collisions (n.runs-SA-2011.004), Miles Bader
- Re: Hash Table Collisions (n.runs-SA-2011.004), David Kolf
- Re: Hash Table Collisions (n.runs-SA-2011.004), Miles Bader
- Re: Hash Table Collisions (n.runs-SA-2011.004), Alexander Gladysh
- Re: Hash Table Collisions (n.runs-SA-2011.004), Roberto Ierusalimschy
- Re: Hash Table Collisions (n.runs-SA-2011.004), Roberto Ierusalimschy
- Re: Hash Table Collisions (n.runs-SA-2011.004), Leo Razoumov
- Re: Hash Table Collisions (n.runs-SA-2011.004), Roberto Ierusalimschy
- Re: Hash Table Collisions (n.runs-SA-2011.004), HyperHacker