aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_alloc.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-09-11 16:03:00 +0200
committerRickard Green <[email protected]>2015-11-12 15:25:46 +0100
commitb7f760cee119e1824de0cfc2b34ae6fe971bf505 (patch)
tree2a7794b77bd22e21e3afd7a1c39bc4497e33402e /erts/emulator/beam/erl_alloc.h
parent63466c5522ed58b6e73e35dc29c7c7584f073768 (diff)
downloadotp-b7f760cee119e1824de0cfc2b34ae6fe971bf505.tar.gz
otp-b7f760cee119e1824de0cfc2b34ae6fe971bf505.tar.bz2
otp-b7f760cee119e1824de0cfc2b34ae6fe971bf505.zip
erts: Add support for fast erts_is_literal()
Diffstat (limited to 'erts/emulator/beam/erl_alloc.h')
-rw-r--r--erts/emulator/beam/erl_alloc.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_alloc.h b/erts/emulator/beam/erl_alloc.h
index f540bae20d..a0d8561e84 100644
--- a/erts/emulator/beam/erl_alloc.h
+++ b/erts/emulator/beam/erl_alloc.h
@@ -30,6 +30,7 @@
#ifdef USE_THREADS
#include "erl_threads.h"
#endif
+#include "erl_mmap.h"
#ifdef DEBUG
# undef ERTS_ALC_WANT_INLINE
@@ -204,6 +205,7 @@ void erts_free(ErtsAlcType_t type, void *ptr);
void *erts_alloc_fnf(ErtsAlcType_t type, Uint size);
void *erts_realloc_fnf(ErtsAlcType_t type, void *ptr, Uint size);
int erts_is_allctr_wrapper_prelocked(void);
+int erts_is_literal(void* ptr);
#endif /* #if !ERTS_ALC_DO_INLINE */
@@ -281,6 +283,28 @@ int erts_is_allctr_wrapper_prelocked(void)
&& !!erts_tsd_get(erts_allctr_prelock_tsd_key); /* by me */
}
+ERTS_ALC_INLINE
+int erts_is_literal(void* ptr)
+{
+#if defined(ARCH_32)
+ Uint ix = (UWord)ptr >> ERTS_MMAP_SUPERALIGNED_BITS;
+
+ return erts_literal_vspace_map[ix / ERTS_VSPACE_WORD_BITS]
+ & ((UWord)1 << (ix % ERTS_VSPACE_WORD_BITS));
+
+#elif defined(ARCH_64)
+# if defined(ERTS_HAVE_OS_PHYSICAL_MEMORY_RESERVATION)
+ extern char* erts_literals_start;
+ extern UWord erts_literals_size;
+ return ErtsInArea(ptr, erts_literals_start, erts_literals_size);
+# else
+# error Do the tag thing
+# endif
+#else
+# error No ARCH_xx
+#endif
+}
+
#endif /* #if ERTS_ALC_DO_INLINE || defined(ERTS_ALC_INTERNAL__) */
#define ERTS_ALC_GET_THR_IX() ((int) erts_get_scheduler_id())