[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bytevector VM ops
From: |
Ludovic Courtès |
Subject: |
Re: Bytevector VM ops |
Date: |
Tue, 30 Jun 2009 09:30:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
Good morning,
Andy Wingo <address@hidden> writes:
> On Tue 30 Jun 2009 00:23, address@hidden (Ludovic Courtès) writes:
>
>> "Andy Wingo" <address@hidden> writes:
>>
>>> +#define BV_FIXABLE_INT_REF(stem, fn_stem, type, size) \
>>> +{ \
>>> + long i; \
>>> + ARGS2 (bv, idx); \
>>> + VM_VALIDATE_BYTEVECTOR (bv); \
>>> + if (SCM_LIKELY (SCM_I_INUMP (idx) \
>>> + && ((i = SCM_I_INUM (idx)) >= 0) \
>>> + && (i < SCM_BYTEVECTOR_LENGTH (bv)) \
>>> + && (i % size == 0))) \
>>> + RETURN (SCM_I_MAKINUM (*(scm_t_##type*) \
>>> + (SCM_BYTEVECTOR_CONTENTS (bv) + i))); \
>>
>> Did you test this on SPARC or some such? I'm 90% sure
>> `(bv-u32-ref bv 1)' would lead to SIGBUS there, due to the unaligned access.
>> This is why `INTEGER_REF ()' in `bytevectors.c' uses memcpy(3).
>
> Wouldn't the i % size == 0 case catch that? (This is used in native-ref
> instructions)
Oh yes, probably, I had overlooked this.
>> Given that there's some duplication with `bytevectors.c', maybe we could
>> share some of the accessor macros between both files?
>
> Perhaps! The one difference is that we can fast-path only the normal
> cases here, calling out to those functions to handle stranger things
> (like unaligned access).
Right. So maybe the macros are different enough that we'd be better off
keeping things as they are.
Thanks,
Ludo'.