diff options
author | Patrik Nyblom <pan@erlang.org> | 2010-01-20 16:26:14 +0100 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2010-03-10 14:24:45 +0100 |
commit | fb94cd974dc03baf149264ca4f4d50c6d1f80f21 (patch) | |
tree | ab913eae685670165acd3a5f2b3f39c0d085292d /erts/emulator/beam/sys.h | |
parent | 775191a1e033b4b93a4615c629d90fdb82f39a98 (diff) | |
download | otp-fb94cd974dc03baf149264ca4f4d50c6d1f80f21.tar.gz otp-fb94cd974dc03baf149264ca4f4d50c6d1f80f21.tar.bz2 otp-fb94cd974dc03baf149264ca4f4d50c6d1f80f21.zip |
Store pointers to heap data in 32-bit words
Store Erlang terms in 32-bit entities on the heap, expanding the
pointers to 64-bit when needed. This works because all terms are stored
on addresses in the 32-bit address range (the 32 most significant bits
of pointers to term data are always 0).
Introduce a new datatype called UWord (along with its companion SWord),
which is an integer having the exact same size as the machine word
(a void *), but might be larger than Eterm/Uint.
Store code as machine words, as the instructions are pointers to
executable code which might reside outside the 32-bit address range.
Continuation pointers are stored on the 32-bit stack and hence must
point to addresses in the low range, which means that loaded beam code
much be placed in the low 32-bit address range (but, as said earlier,
the instructions themselves are full words).
No Erlang term data can be stored on C stacks (enforced by an
earlier commit).
This version gives a prompt, but test cases still fail (and dump core).
The loader (and emulator loop) has instruction packing disabled.
The main issues has been in rewriting loader and actual virtual
machine. Subsystems (like distribution) does not work yet.
Diffstat (limited to 'erts/emulator/beam/sys.h')
-rw-r--r-- | erts/emulator/beam/sys.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h index 4b949523fa..b48b147953 100644 --- a/erts/emulator/beam/sys.h +++ b/erts/emulator/beam/sys.h @@ -20,6 +20,7 @@ #ifndef __SYS_H__ #define __SYS_H__ + #if defined(VALGRIND) && !defined(NO_FPE_SIGNALS) # define NO_FPE_SIGNALS #endif @@ -233,6 +234,10 @@ EXTERN_FUNCTION(int, real_printf, (const char *fmt, ...)); ** UInt: An unsigned integer exactly as large as an Eterm. ** SInt: A signed integer exactly as large as an eterm and therefor large ** enough to hold the return value of the signed_val() macro. +** UWord: An unsigned integer at least as large as a void * and also as large +** or larger than an Eterm +** SWord: A signed integer at least as large as a void * and also as large +** or larger than an Eterm ** Uint32: An unsigned integer of 32 bits exactly ** Sint32: A signed integer of 32 bits exactly ** Uint16: An unsigned integer of 16 bits exactly @@ -253,11 +258,43 @@ EXTERN_FUNCTION(int, real_printf, (const char *fmt, ...)); #else #error Neither 32 nor 64 bit architecture #endif +#ifdef ARCH_64 +# ifdef HALFWORD_HEAP_EMULATOR +# define HALFWORD_HEAP 1 +# define HALFWORD_ASSERT 1 +# else +# define HALFWORD_HEAP 0 +# define HALFWORD_ASSERT 1 +# endif +#endif #if SIZEOF_VOID_P != SIZEOF_SIZE_T #error sizeof(void*) != sizeof(size_t) #endif +#if HALFWORD_HEAP + +#if SIZEOF_INT == 4 +typedef unsigned int Eterm; +typedef unsigned int Uint; +typedef int Sint; +#define ERTS_SIZEOF_ETERM SIZEOF_INT +#else +#error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint' +#endif + +#if SIZEOF_VOID_P == SIZEOF_LONG +typedef unsigned long UWord; +typedef long SWord; +#elif SIZEOF_VOID_P == SIZEOF_INT +typedef unsigned int UWord; +typedef int SWord; +#else +#error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint' +#endif + +#else /* !HALFWORD_HEAP */ + #if SIZEOF_VOID_P == SIZEOF_LONG typedef unsigned long Eterm; typedef unsigned long Uint; @@ -272,6 +309,11 @@ typedef int Sint; #error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint' #endif +typedef Uint UWord; +typedef Sint SWord; + +#endif /* HALFWORD_HEAP */ + #ifndef HAVE_INT64 #if SIZEOF_LONG == 8 #define HAVE_INT64 1 |