aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/configure.in1
-rw-r--r--erts/doc/src/erlang.xml8
-rw-r--r--erts/doc/src/notes.xml16
-rw-r--r--erts/doc/src/run_erl.xml8
-rw-r--r--erts/emulator/beam/beam_bif_load.c12
-rw-r--r--erts/emulator/beam/bif.c28
-rw-r--r--erts/emulator/beam/big.c6
-rw-r--r--erts/emulator/beam/big.h4
-rw-r--r--erts/emulator/beam/erl_alloc.c190
-rw-r--r--erts/emulator/beam/erl_alloc.types57
-rw-r--r--erts/emulator/beam/erl_alloc_util.c28
-rw-r--r--erts/emulator/beam/erl_alloc_util.h3
-rw-r--r--erts/emulator/beam/erl_db_hash.c9
-rw-r--r--erts/emulator/beam/erl_db_tree.c62
-rw-r--r--erts/emulator/beam/erl_gc.c2
-rw-r--r--erts/emulator/beam/erl_lock_check.c10
-rw-r--r--erts/emulator/beam/erl_lock_check.h2
-rw-r--r--erts/emulator/beam/erl_printf_term.c101
-rw-r--r--erts/emulator/beam/erl_printf_term.h4
-rw-r--r--erts/emulator/beam/erl_process.c70
-rw-r--r--erts/emulator/beam/erl_process.h4
-rw-r--r--erts/emulator/beam/utils.c2
-rw-r--r--erts/emulator/drivers/common/inet_drv.c2
-rw-r--r--erts/emulator/sys/common/erl_mseg.c35
-rw-r--r--erts/emulator/sys/common/erl_mseg.h11
-rw-r--r--erts/emulator/test/process_SUITE.erl40
-rw-r--r--erts/etc/unix/run_erl.c21
-rwxr-xr-xerts/etc/win32/nsis/find_redist.sh15
-rw-r--r--erts/include/internal/erl_printf_format.h2
-rw-r--r--erts/lib_src/common/erl_printf_format.c29
-rw-r--r--erts/preloaded/ebin/prim_file.beambin31588 -> 31528 bytes
-rw-r--r--erts/preloaded/src/prim_file.erl6
32 files changed, 559 insertions, 229 deletions
diff --git a/erts/configure.in b/erts/configure.in
index 31d1d55b8a..e4c6a7852f 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -769,6 +769,7 @@ if test "$enable_halfword_emulator" = "yes"; then
if test "$ARCH" = "amd64"; then
AC_DEFINE(HALFWORD_HEAP_EMULATOR, [1],
[Define if building a halfword-heap 64bit emulator])
+ ENABLE_ALLOC_TYPE_VARS="$ENABLE_ALLOC_TYPE_VARS halfword"
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR(no; halfword emulator not supported on this architecture)
diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml
index 19f501391f..f98e15cb52 100644
--- a/erts/doc/src/erlang.xml
+++ b/erts/doc/src/erlang.xml
@@ -2356,6 +2356,14 @@ os_prompt%</pre>
<seealso marker="tools:instrument">instrument(3)</seealso>
and/or <seealso marker="erts:erl">erl(1)</seealso>.</p>
</item>
+ <tag><c>low</c></tag>
+ <item>
+ <p>Only on 64-bit halfword emulator.</p>
+ <p>The total amount of memory allocated in low memory areas
+ that are restricted to less than 4 Gb even though
+ the system may have more physical memory.</p>
+ <p>May be removed in future releases of halfword emulator.</p>
+ </item>
</taglist>
<note>
<p>The <c>system</c> value is not complete. Some allocated
diff --git a/erts/doc/src/notes.xml b/erts/doc/src/notes.xml
index e91839572b..f5607945a8 100644
--- a/erts/doc/src/notes.xml
+++ b/erts/doc/src/notes.xml
@@ -30,6 +30,22 @@
</header>
<p>This document describes the changes made to the ERTS application.</p>
+<section><title>Erts 5.8.3.2</title>
+
+ <section><title>Known Bugs and Problems</title>
+ <list>
+ <item>
+ <p>
+ Fix halfword emulator bug in <c>ets:select_delete</c> for
+ <c>ordered_set</c> that caused emulator to crash.</p>
+ <p>
+ Own Id: OTP-9258 Aux Id: seq11836 </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Erts 5.8.3.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/erts/doc/src/run_erl.xml b/erts/doc/src/run_erl.xml
index 7bf7f559c5..da08859c7b 100644
--- a/erts/doc/src/run_erl.xml
+++ b/erts/doc/src/run_erl.xml
@@ -144,6 +144,14 @@
<item>The size (in bytes) of a log file before switching to a
new log file. Default is 100000, minimum is 1000 and maximum is
approximately 2^30.</item>
+ <tag>RUN_ERL_DISABLE_FLOWCNTRL</tag>
+ <item>If defined, disables input and output flow control for the pty opend by run_erl.
+ Useful if you want to remove any risk of accidentally blocking the flow control
+ by hit Ctrl-S (instead of Ctrl-D to detach).
+ Which may result in blocking of the entire beam process
+ and in the case of running heart as supervisor
+ even the heart process will be blocked when writing log message to terminal.
+ Leaving the heart process unable to do its work.</item>
</taglist>
</section>
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index 1ca405961f..1dbf6f9b92 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -175,8 +175,12 @@ check_process_code_2(BIF_ALIST_2)
Eterm res;
if (internal_pid_index(BIF_ARG_1) >= erts_max_processes)
goto error;
- rp = erts_pid2proc_not_running(BIF_P, ERTS_PROC_LOCK_MAIN,
- BIF_ARG_1, ERTS_PROC_LOCK_MAIN);
+#ifdef ERTS_SMP
+ rp = erts_pid2proc_suspend(BIF_P, ERTS_PROC_LOCK_MAIN,
+ BIF_ARG_1, ERTS_PROC_LOCK_MAIN);
+#else
+ rp = erts_pid2proc(BIF_P, 0, BIF_ARG_1, 0);
+#endif
if (!rp) {
BIF_RET(am_false);
}
@@ -187,8 +191,10 @@ check_process_code_2(BIF_ALIST_2)
modp = erts_get_module(BIF_ARG_2);
res = check_process_code(rp, modp);
#ifdef ERTS_SMP
- if (BIF_P != rp)
+ if (BIF_P != rp) {
+ erts_resume(rp, ERTS_PROC_LOCK_MAIN);
erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_MAIN);
+ }
#endif
BIF_RET(res);
}
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index e886792ba7..ac93b10d12 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -3341,20 +3341,32 @@ BIF_RETTYPE garbage_collect_1(BIF_ALIST_1)
BIF_ERROR(BIF_P, BADARG);
}
- rp = erts_pid2proc_not_running(BIF_P, ERTS_PROC_LOCK_MAIN,
+ if (BIF_P->id == BIF_ARG_1)
+ rp = BIF_P;
+ else {
+#ifdef ERTS_SMP
+ rp = erts_pid2proc_suspend(BIF_P, ERTS_PROC_LOCK_MAIN,
BIF_ARG_1, ERTS_PROC_LOCK_MAIN);
- if (!rp)
- BIF_RET(am_false);
- if (rp == ERTS_PROC_LOCK_BUSY)
- ERTS_BIF_YIELD1(bif_export[BIF_garbage_collect_1], BIF_P, BIF_ARG_1);
+ if (rp == ERTS_PROC_LOCK_BUSY)
+ ERTS_BIF_YIELD1(bif_export[BIF_garbage_collect_1], BIF_P, BIF_ARG_1);
+#else
+ rp = erts_pid2proc(BIF_P, 0, BIF_ARG_1, 0);
+#endif
+ if (!rp)
+ BIF_RET(am_false);
+ }
/* The GC cost is taken for the process executing this BIF. */
FLAGS(rp) |= F_NEED_FULLSWEEP;
reds = erts_garbage_collect(rp, 0, rp->arg_reg, rp->arity);
- if (BIF_P != rp)
+#ifdef ERTS_SMP
+ if (BIF_P != rp) {
+ erts_resume(rp, ERTS_PROC_LOCK_MAIN);
erts_smp_proc_unlock(rp, ERTS_PROC_LOCK_MAIN);
+ }
+#endif
BIF_RET2(am_true, reds);
}
@@ -3486,7 +3498,7 @@ BIF_RETTYPE erts_debug_display_1(BIF_ALIST_1)
erts_dsprintf_buf_t *dsbufp = erts_create_tmp_dsbuf(64);
pres = erts_dsprintf(dsbufp, "%.*T\n", INT_MAX, BIF_ARG_1);
if (pres < 0)
- erl_exit(1, "Failed to convert term to string: %d (s)\n",
+ erl_exit(1, "Failed to convert term to string: %d (%s)\n",
-pres, erl_errno_id(-pres));
hp = HAlloc(BIF_P, 2*dsbufp->str_len); /* we need length * 2 heap words */
res = buf_to_intlist(&hp, dsbufp->str, dsbufp->str_len, NIL);
@@ -3604,7 +3616,7 @@ term2list_dsprintf(Process *p, Eterm term)
erts_dsprintf_buf_t *dsbufp = erts_create_tmp_dsbuf(64);
pres = erts_dsprintf(dsbufp, "%T", term);
if (pres < 0)
- erl_exit(1, "Failed to convert term to list: %d (s)\n",
+ erl_exit(1, "Failed to convert term to list: %d (%s)\n",
-pres, erl_errno_id(-pres));
hp = HAlloc(p, 2*dsbufp->str_len); /* we need length * 2 heap words */
res = buf_to_intlist(&hp, dsbufp->str, dsbufp->str_len, NIL);
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c
index f47f5a9c0c..d18de9ae5d 100644
--- a/erts/emulator/beam/big.c
+++ b/erts/emulator/beam/big.c
@@ -1588,7 +1588,7 @@ big_to_double(Wterm x, double* resp)
/*
** Estimate the number of decimal digits (include sign)
*/
-int big_decimal_estimate(Eterm x)
+int big_decimal_estimate(Wterm x)
{
Eterm* xp = big_val(x);
int lg = I_lg(BIG_V(xp), BIG_SIZE(xp));
@@ -1602,7 +1602,7 @@ int big_decimal_estimate(Eterm x)
** Convert a bignum into a string of decimal numbers
*/
-static void write_big(Eterm x, void (*write_func)(void *, char), void *arg)
+static void write_big(Wterm x, void (*write_func)(void *, char), void *arg)
{
Eterm* xp = big_val(x);
ErtsDigit* dx = BIG_V(xp);
@@ -1681,7 +1681,7 @@ write_string(void *arg, char c)
*(--(*((char **) arg))) = c;
}
-char *erts_big_to_string(Eterm x, char *buf, Uint buf_sz)
+char *erts_big_to_string(Wterm x, char *buf, Uint buf_sz)
{
char *big_str = buf + buf_sz - 1;
*big_str = '\0';
diff --git a/erts/emulator/beam/big.h b/erts/emulator/beam/big.h
index f28a390aea..2afc37004f 100644
--- a/erts/emulator/beam/big.h
+++ b/erts/emulator/beam/big.h
@@ -114,9 +114,9 @@ typedef Uint dsize_t; /* Vector size type */
#endif
-int big_decimal_estimate(Eterm);
+int big_decimal_estimate(Wterm);
Eterm erts_big_to_list(Eterm, Eterm**);
-char *erts_big_to_string(Eterm x, char *buf, Uint buf_sz);
+char *erts_big_to_string(Wterm x, char *buf, Uint buf_sz);
Eterm small_times(Sint, Sint, Eterm*);
diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c
index 673eac7fea..cda404af5e 100644
--- a/erts/emulator/beam/erl_alloc.c
+++ b/erts/emulator/beam/erl_alloc.c
@@ -90,6 +90,10 @@ typedef union {
static ErtsAllocatorState_t sl_alloc_state;
static ErtsAllocatorState_t std_alloc_state;
static ErtsAllocatorState_t ll_alloc_state;
+#if HALFWORD_HEAP
+static ErtsAllocatorState_t std_alloc_low_state;
+static ErtsAllocatorState_t ll_alloc_low_state;
+#endif
static ErtsAllocatorState_t temp_alloc_state;
static ErtsAllocatorState_t eheap_alloc_state;
static ErtsAllocatorState_t binary_alloc_state;
@@ -166,6 +170,10 @@ typedef struct {
struct au_init binary_alloc;
struct au_init ets_alloc;
struct au_init driver_alloc;
+#if HALFWORD_HEAP
+ struct au_init std_alloc_low;
+ struct au_init ll_alloc_low;
+#endif
} erts_alc_hndl_args_init_t;
#define ERTS_AU_INIT__ {0, 0, GOODFIT, DEFAULT_ALLCTR_INIT, {1,1,1,1}}
@@ -193,6 +201,10 @@ set_default_sl_alloc_opts(struct au_init *ip)
#endif
ip->init.util.ts = ERTS_ALC_MTA_SHORT_LIVED;
ip->init.util.rsbcst = 80;
+#if HALFWORD_HEAP
+ ip->init.util.low_mem = 1;
+#endif
+
}
static void
@@ -256,6 +268,9 @@ set_default_temp_alloc_opts(struct au_init *ip)
ip->init.util.ts = ERTS_ALC_MTA_TEMPORARY;
ip->init.util.rsbcst = 90;
ip->init.util.rmbcmt = 100;
+#if HALFWORD_HEAP
+ ip->init.util.low_mem = 1;
+#endif
}
static void
@@ -275,6 +290,9 @@ set_default_eheap_alloc_opts(struct au_init *ip)
#endif
ip->init.util.ts = ERTS_ALC_MTA_EHEAP;
ip->init.util.rsbcst = 50;
+#if HALFWORD_HEAP
+ ip->init.util.low_mem = 1;
+#endif
}
static void
@@ -531,6 +549,20 @@ erts_alloc_init(int *argc, char **argv, ErtsAllocInitOpts *eaiop)
erts_allctrs[ERTS_ALC_A_SYSTEM].free = erts_sys_free;
erts_allctrs_info[ERTS_ALC_A_SYSTEM].enabled = 1;
+#if HALFWORD_HEAP
+ /* Init low memory variants by cloning */
+ init.std_alloc_low = init.std_alloc;
+ init.std_alloc_low.init.util.alloc_no = ERTS_ALC_A_STANDARD_LOW;
+ init.std_alloc_low.init.util.low_mem = 1;
+
+ init.ll_alloc_low = init.ll_alloc;
+ init.ll_alloc_low.init.util.alloc_no = ERTS_ALC_A_LONG_LIVED_LOW;
+ init.ll_alloc_low.init.util.low_mem = 1;
+
+ set_au_allocator(ERTS_ALC_A_STANDARD_LOW, &init.std_alloc_low);
+ set_au_allocator(ERTS_ALC_A_LONG_LIVED_LOW, &init.ll_alloc_low);
+#endif /* HALFWORD */
+
set_au_allocator(ERTS_ALC_A_TEMPORARY, &init.temp_alloc);
set_au_allocator(ERTS_ALC_A_SHORT_LIVED, &init.sl_alloc);
set_au_allocator(ERTS_ALC_A_STANDARD, &init.std_alloc);
@@ -576,7 +608,14 @@ erts_alloc_init(int *argc, char **argv, ErtsAllocInitOpts *eaiop)
start_au_allocator(ERTS_ALC_A_LONG_LIVED,
&init.ll_alloc,
&ll_alloc_state);
-
+#if HALFWORD_HEAP
+ start_au_allocator(ERTS_ALC_A_LONG_LIVED_LOW,
+ &init.ll_alloc_low,
+ &ll_alloc_low_state);
+ start_au_allocator(ERTS_ALC_A_STANDARD_LOW,
+ &init.std_alloc_low,
+ &std_alloc_low_state);
+#endif
start_au_allocator(ERTS_ALC_A_EHEAP,
&init.eheap_alloc,
&eheap_alloc_state);
@@ -612,11 +651,9 @@ erts_alloc_init(int *argc, char **argv, ErtsAllocInitOpts *eaiop)
erts_set_fix_size(ERTS_ALC_T_PROC, sizeof(Process));
erts_set_fix_size(ERTS_ALC_T_DB_TABLE, sizeof(DbTable));
erts_set_fix_size(ERTS_ALC_T_ATOM, sizeof(Atom));
- erts_set_fix_size(ERTS_ALC_T_EXPORT, sizeof(Export));
+
erts_set_fix_size(ERTS_ALC_T_MODULE, sizeof(Module));
erts_set_fix_size(ERTS_ALC_T_REG_PROC, sizeof(RegProc));
- erts_set_fix_size(ERTS_ALC_T_MONITOR_SH, ERTS_MONITOR_SH_SIZE*sizeof(Uint));
- erts_set_fix_size(ERTS_ALC_T_NLINK_SH, ERTS_LINK_SH_SIZE*sizeof(Uint));
erts_set_fix_size(ERTS_ALC_T_FUN_ENTRY, sizeof(ErlFunEntry));
#ifdef ERTS_ALC_T_DRV_EV_D_STATE
erts_set_fix_size(ERTS_ALC_T_DRV_EV_D_STATE,
@@ -626,6 +663,11 @@ erts_alloc_init(int *argc, char **argv, ErtsAllocInitOpts *eaiop)
erts_set_fix_size(ERTS_ALC_T_DRV_SEL_D_STATE,
sizeof(ErtsDrvSelectDataState));
#endif
+#if !HALFWORD_HEAP
+ erts_set_fix_size(ERTS_ALC_T_EXPORT, sizeof(Export));
+ erts_set_fix_size(ERTS_ALC_T_MONITOR_SH, ERTS_MONITOR_SH_SIZE*sizeof(Uint));
+ erts_set_fix_size(ERTS_ALC_T_NLINK_SH, ERTS_LINK_SH_SIZE*sizeof(Uint));
+#endif
#endif
#endif
@@ -638,6 +680,15 @@ set_au_allocator(ErtsAlcType_t alctr_n, struct au_init *init)
ErtsAllocatorInfo_t *ai = &erts_allctrs_info[alctr_n];
ErtsAllocatorThrSpec_t *tspec = &erts_allctr_thr_spec[alctr_n];
+#if HALFWORD_HEAP
+ /* If halfword heap, silently ignore any disabling of internal
+ * allocators for low memory
+ */
+ if (init->init.util.low_mem) {
+ init->enable = 1;
+ }
+#endif
+
if (!init->enable) {
af->alloc = erts_sys_alloc;
af->realloc = erts_sys_realloc;
@@ -1348,14 +1399,6 @@ handle_args(int *argc, char **argv, erts_alc_hndl_args_init_t *init)
argv[j++] = argv[i];
}
*argc = j;
-#if HALFWORD_HEAP
- /* If halfword heap, silently ignore any disabling of internal
- allocators */
- for (i = 0; i < aui_sz; ++i)
- aui[i]->enable = 1;
-#endif
-
-
}
static char *type_no_str(ErtsAlcType_t n)
@@ -1528,10 +1571,10 @@ erts_realloc_n_enomem(ErtsAlcType_t n, void *ptr, Uint size)
erts_alc_fatal_error(ERTS_ALC_E_NOMEM, ERTS_ALC_O_REALLOC, n, size);
}
-static ERTS_INLINE Uint
+static ERTS_INLINE UWord
alcu_size(ErtsAlcType_t ai)
{
- Uint res = 0;
+ UWord res = 0;
ASSERT(erts_allctrs_info[ai].enabled);
ASSERT(erts_allctrs_info[ai].alloc_util);
@@ -1563,6 +1606,49 @@ alcu_size(ErtsAlcType_t ai)
return res;
}
+#if HALFWORD_HEAP
+static ERTS_INLINE int
+alcu_is_low(ErtsAlcType_t ai)
+{
+ int is_low = 0;
+ ASSERT(erts_allctrs_info[ai].enabled);
+ ASSERT(erts_allctrs_info[ai].alloc_util);
+
+ if (!erts_allctrs_info[ai].thr_spec) {
+ Allctr_t *allctr = erts_allctrs_info[ai].extra;
+ is_low = allctr->mseg_opt.low_mem;
+ }
+ else {
+ ErtsAllocatorThrSpec_t *tspec = &erts_allctr_thr_spec[ai];
+ int i;
+# ifdef DEBUG
+ int found_one = 0;
+# endif
+
+ ASSERT(tspec->all_thr_safe);
+ ASSERT(tspec->enabled);
+
+ for (i = tspec->size - 1; i >= 0; i--) {
+ Allctr_t *allctr = tspec->allctr[i];
+ if (allctr) {
+# ifdef DEBUG
+ if (!found_one) {
+ is_low = allctr->mseg_opt.low_mem;
+ found_one = 1;
+ }
+ else ASSERT(is_low == allctr->mseg_opt.low_mem);
+# else
+ is_low = allctr->mseg_opt.low_mem;
+ break;
+# endif
+ }
+ }
+ ASSERT(found_one);
+ }
+ return is_low;
+}
+#endif /* HALFWORD */
+
Eterm
erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
{
@@ -1579,22 +1665,28 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
int code;
int ets;
int maximum;
+#if HALFWORD_HEAP
+ int low;
+#endif
} want = {0};
struct {
- Uint total;
- Uint processes;
- Uint processes_used;
- Uint system;
- Uint atom;
- Uint atom_used;
- Uint binary;
- Uint code;
- Uint ets;
- Uint maximum;
+ UWord total;
+ UWord processes;
+ UWord processes_used;
+ UWord system;
+ UWord atom;
+ UWord atom_used;
+ UWord binary;
+ UWord code;
+ UWord ets;
+ UWord maximum;
+#if HALFWORD_HEAP
+ UWord low;
+#endif
} size = {0};
- Eterm atoms[sizeof(size)/sizeof(Uint)];
- Uint *uintps[sizeof(size)/sizeof(Uint)];
- Eterm euints[sizeof(size)/sizeof(Uint)];
+ Eterm atoms[sizeof(size)/sizeof(UWord)];
+ UWord *uintps[sizeof(size)/sizeof(UWord)];
+ Eterm euints[sizeof(size)/sizeof(UWord)];
int want_tot_or_sys;
int length;
Eterm res = THE_NON_VALUE;
@@ -1646,7 +1738,11 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
atoms[length] = am_maximum;
uintps[length++] = &size.maximum;
}
-
+#if HALFWORD_HEAP
+ want.low = 1;
+ atoms[length] = am_low;
+ uintps[length++] = &size.low;
+#endif
}
else {
DeclareTmpHeapNoproc(tmp_heap,2);
@@ -1740,6 +1836,15 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
return am_badarg;
}
break;
+#if HALFWORD_HEAP
+ case am_low:
+ if (!want.low) {
+ want.low = 1;
+ atoms[length] = am_low;
+ uintps[length++] = &size.low;
+ }
+ break;
+#endif
default:
UnUseTmpHeapNoproc(2);
return am_badarg;
@@ -1769,7 +1874,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
ASSERT(length <= sizeof(atoms)/sizeof(Eterm));
ASSERT(length <= sizeof(euints)/sizeof(Eterm));
- ASSERT(length <= sizeof(uintps)/sizeof(Uint));
+ ASSERT(length <= sizeof(uintps)/sizeof(UWord));
if (proc) {
@@ -1788,8 +1893,8 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
for (ai = ERTS_ALC_A_MIN; ai <= ERTS_ALC_A_MAX; ai++) {
if (erts_allctrs_info[ai].alloc_util) {
- Uint *save;
- Uint asz;
+ UWord *save;
+ UWord asz;
switch (ai) {
case ERTS_ALC_A_TEMPORARY:
/*
@@ -1814,6 +1919,11 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
if (save)
*save = asz;
size.total += asz;
+#if HALFWORD_HEAP
+ if (alcu_is_low(ai)) {
+ size.low += asz;
+ }
+#endif
}
}
}
@@ -1821,7 +1931,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
if (want_tot_or_sys || want.processes || want.processes_used) {
- Uint tmp;
+ UWord tmp;
if (ERTS_MEM_NEED_ALL_ALCU)
tmp = size.processes;
@@ -1836,6 +1946,9 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
size.processes = size.processes_used = tmp;
+#if HALFWORD_HEAP
+ /* BUG: We ignore link and monitor memory */
+#else
erts_fix_info(ERTS_ALC_T_NLINK_SH, &efi);
size.processes += efi.total;
size.processes_used += efi.used;
@@ -1843,6 +1956,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
erts_fix_info(ERTS_ALC_T_MONITOR_SH, &efi);
size.processes += efi.total;
size.processes_used += efi.used;
+#endif
erts_fix_info(ERTS_ALC_T_PROC, &efi);
size.processes += efi.total;
@@ -1879,8 +1993,12 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
erts_fix_info(ERTS_ALC_T_MODULE, &efi);
size.code += efi.used;
size.code += export_table_sz();
+#if HALFWORD_HEAP
+ size.code += export_list_size() * sizeof(Export);
+#else
erts_fix_info(ERTS_ALC_T_EXPORT, &efi);
size.code += efi.used;
+#endif
size.code += erts_fun_table_sz();
erts_fix_info(ERTS_ALC_T_FUN_ENTRY, &efi);
size.code += efi.used;
@@ -1913,7 +2031,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
/* Print result... */
erts_print(to, arg, "=memory\n");
for (i = 0; i < length; i++)
- erts_print(to, arg, "%T: %beu\n", atoms[i], *uintps[i]);
+ erts_print(to, arg, "%T: %bpu\n", atoms[i], *uintps[i]);
}
if (proc) {
@@ -1926,9 +2044,9 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
if (only_one_value) {
ASSERT(length == 1);
hsz = 0;
- erts_bld_uint(NULL, &hsz, *uintps[0]);
+ erts_bld_uword(NULL, &hsz, *uintps[0]);
hp = hsz ? HAlloc((Process *) proc, hsz) : NULL;
- res = erts_bld_uint(&hp, NULL, *uintps[0]);
+ res = erts_bld_uword(&hp, NULL, *uintps[0]);
}
else {
Uint **hpp = NULL;
@@ -1938,7 +2056,7 @@ erts_memory(int *print_to_p, void *print_to_arg, void *proc, Eterm earg)
while (1) {
int i;
for (i = 0; i < length; i++)
- euints[i] = erts_bld_uint(hpp, hszp, *uintps[i]);
+ euints[i] = erts_bld_uword(hpp, hszp, *uintps[i]);
res = erts_bld_2tup_list(hpp, hszp, length, atoms, euints);
if (hpp)
break;
diff --git a/erts/emulator/beam/erl_alloc.types b/erts/emulator/beam/erl_alloc.types
index ca71798917..c6cc0e1fac 100644
--- a/erts/emulator/beam/erl_alloc.types
+++ b/erts/emulator/beam/erl_alloc.types
@@ -75,6 +75,11 @@ allocator EHEAP true eheap_alloc
allocator ETS true ets_alloc
allocator FIXED_SIZE true fix_alloc
++if halfword
+allocator LONG_LIVED_LOW true ll_alloc_low
+allocator STANDARD_LOW true std_alloc_low
++endif
+
+else # Non smp build
allocator TEMPORARY false temp_alloc
@@ -85,12 +90,18 @@ allocator EHEAP false eheap_alloc
allocator ETS false ets_alloc
allocator FIXED_SIZE false fix_alloc
++if halfword
+allocator LONG_LIVED_LOW false ll_alloc_low
+allocator STANDARD_LOW false std_alloc_low
++endif
+
+endif
allocator BINARY true binary_alloc
allocator DRIVER true driver_alloc
+
# --- Class declarations -----------------------------------------------------
#
# Syntax: class <CLASS> <DESCRIPTION>
@@ -125,14 +136,9 @@ class SYSTEM system_data
type PROC FIXED_SIZE PROCESSES proc
type ATOM FIXED_SIZE ATOM atom_entry
-type EXPORT FIXED_SIZE CODE export_entry
type MODULE FIXED_SIZE CODE module_entry
type REG_PROC FIXED_SIZE PROCESSES reg_proc
type LINK_LH STANDARD PROCESSES link_lh
-type MONITOR_SH FIXED_SIZE PROCESSES monitor_sh
-type MONITOR_LH STANDARD PROCESSES monitor_lh
-type NLINK_SH FIXED_SIZE PROCESSES nlink_sh
-type NLINK_LH STANDARD PROCESSES nlink_lh
type SUSPEND_MON STANDARD PROCESSES suspend_monitor
type PEND_SUSPEND SHORT_LIVED PROCESSES pending_suspend
type PROC_LIST SHORT_LIVED PROCESSES proc_list
@@ -175,7 +181,6 @@ type DRIVER STANDARD SYSTEM driver
type NIF DRIVER SYSTEM nif_internal
type BINARY BINARY BINARIES binary
type NBIF_TABLE SYSTEM SYSTEM nbif_tab
-type CODE LONG_LIVED CODE code
type ARG_REG STANDARD PROCESSES arg_reg
type PROC_DICT STANDARD PROCESSES proc_dict
type CALLS_BUF STANDARD PROCESSES calls_buf
@@ -193,10 +198,8 @@ type DB_FIXATION SHORT_LIVED ETS db_fixation
type DB_FIX_DEL SHORT_LIVED ETS fixed_del
type DB_TABLES LONG_LIVED ETS db_tabs
type DB_NTAB_ENT STANDARD ETS db_named_table_entry
-type DB_HEIR_DATA STANDARD ETS db_heir_data
type DB_TMP TEMPORARY ETS db_tmp
type DB_MC_STK TEMPORARY ETS db_mc_stack
-type DB_MS_PSDO_PROC LONG_LIVED ETS db_match_pseudo_proc
type DB_MS_RUN_HEAP SHORT_LIVED ETS db_match_spec_run_heap
type DB_MS_CMPL_HEAP TEMPORARY ETS db_match_spec_cmpl_heap
type DB_SEG ETS ETS db_segment
@@ -213,10 +216,8 @@ type LOGGER_DSBUF TEMPORARY SYSTEM logger_dsbuf
type TMP_DSBUF TEMPORARY SYSTEM tmp_dsbuf
type INFO_DSBUF SYSTEM SYSTEM info_dsbuf
# INFO_DSBUF have to use the SYSTEM allocator; otherwise, a deadlock might occur
-type SCHDLR_DATA LONG_LIVED SYSTEM scheduler_data
type SCHDLR_SLP_INFO LONG_LIVED SYSTEM scheduler_sleep_info
type RUNQS LONG_LIVED SYSTEM run_queues
-type DDLL_PROCESS STANDARD SYSTEM ddll_processes
type DDLL_HANDLE STANDARD SYSTEM ddll_handle
type DDLL_ERRCODES LONG_LIVED SYSTEM ddll_errcodes
type DDLL_TMP_BUF TEMPORARY SYSTEM ddll_tmp_buf
@@ -327,13 +328,45 @@ type SSB SHORT_LIVED PROCESSES ssb
+endif
++if halfword
+
+type DDLL_PROCESS STANDARD_LOW SYSTEM ddll_processes
+type MONITOR_LH STANDARD_LOW PROCESSES monitor_lh
+type NLINK_LH STANDARD_LOW PROCESSES nlink_lh
+type CODE LONG_LIVED_LOW CODE code
+type DB_HEIR_DATA STANDARD_LOW ETS db_heir_data
+type DB_MS_PSDO_PROC LONG_LIVED_LOW ETS db_match_pseudo_proc
+type SCHDLR_DATA LONG_LIVED_LOW SYSTEM scheduler_data
+type LL_TEMP_TERM LONG_LIVED_LOW SYSTEM ll_temp_term
+
+# no FIXED_SIZE for low memory
+type EXPORT STANDARD_LOW CODE export_entry
+type MONITOR_SH STANDARD_LOW PROCESSES monitor_sh
+type NLINK_SH STANDARD_LOW PROCESSES nlink_sh
+
++else # "fullword"
+
+type DDLL_PROCESS STANDARD SYSTEM ddll_processes
+type MONITOR_LH STANDARD PROCESSES monitor_lh
+type NLINK_LH STANDARD PROCESSES nlink_lh
+type CODE LONG_LIVED CODE code
+type DB_HEIR_DATA STANDARD ETS db_heir_data
+type DB_MS_PSDO_PROC LONG_LIVED ETS db_match_pseudo_proc
+type SCHDLR_DATA LONG_LIVED SYSTEM scheduler_data
+type LL_TEMP_TERM LONG_LIVED SYSTEM ll_temp_term
+
+type EXPORT FIXED_SIZE CODE export_entry
+type MONITOR_SH FIXED_SIZE PROCESSES monitor_sh
+type NLINK_SH FIXED_SIZE PROCESSES nlink_sh
+
++endif
+
+
#
# Types used by system specific code
#
type TEMP_TERM TEMPORARY SYSTEM temp_term
-type LL_TEMP_TERM LONG_LIVED SYSTEM ll_temp_term
-
type DRV_TAB LONG_LIVED SYSTEM drv_tab
type DRV_EV_STATE LONG_LIVED SYSTEM driver_event_state
type DRV_EV_D_STATE FIXED_SIZE SYSTEM driver_event_data_state
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c
index 84c72439a3..cc04ef65bf 100644
--- a/erts/emulator/beam/erl_alloc_util.c
+++ b/erts/emulator/beam/erl_alloc_util.c
@@ -1639,6 +1639,9 @@ static struct {
Eterm e;
Eterm t;
Eterm ramv;
+#if HALFWORD_HEAP
+ Eterm low;
+#endif
Eterm sbct;
#if HAVE_ERTS_MSEG
Eterm asbcst;
@@ -1724,6 +1727,9 @@ init_atoms(Allctr_t *allctr)
AM_INIT(e);
AM_INIT(t);
AM_INIT(ramv);
+#if HALFWORD_HEAP
+ AM_INIT(low);
+#endif
AM_INIT(sbct);
#if HAVE_ERTS_MSEG
AM_INIT(asbcst);
@@ -2168,6 +2174,9 @@ info_options(Allctr_t *allctr,
"option e: true\n"
"option t: %s\n"
"option ramv: %s\n"
+#if HALFWORD_HEAP
+ "option low: %s\n"
+#endif
"option sbct: %beu\n"
#if HAVE_ERTS_MSEG
"option asbcst: %bpu\n"
@@ -2185,6 +2194,9 @@ info_options(Allctr_t *allctr,
"option mbcgs: %beu\n",
topt,
allctr->ramv ? "true" : "false",
+#if HALFWORD_HEAP
+ allctr->mseg_opt.low_mem ? "true" : "false",
+#endif
allctr->sbc_threshold,
#if HAVE_ERTS_MSEG
allctr->mseg_opt.abs_shrink_th,
@@ -2243,6 +2255,9 @@ info_options(Allctr_t *allctr,
add_2tup(hpp, szp, &res,
am.sbct,
bld_uint(hpp, szp, allctr->sbc_threshold));
+#if HALFWORD_HEAP
+ add_2tup(hpp, szp, &res, am.low, allctr->mseg_opt.low_mem ? am_true : am_false);
+#endif
add_2tup(hpp, szp, &res, am.ramv, allctr->ramv ? am_true : am_false);
add_2tup(hpp, szp, &res, am.t, (allctr->t
? bld_uint(hpp, szp, (Uint) allctr->t)
@@ -3105,13 +3120,12 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init)
goto error;
#if HAVE_ERTS_MSEG
- {
- ErtsMsegOpt_t mseg_opt = ERTS_MSEG_DEFAULT_OPT_INITIALIZER;
-
- sys_memcpy((void *) &allctr->mseg_opt,
- (void *) &mseg_opt,
- sizeof(ErtsMsegOpt_t));
- }
+ sys_memcpy((void *) &allctr->mseg_opt,
+ (void *) &erts_mseg_default_opt,
+ sizeof(ErtsMsegOpt_t));
+# if HALFWORD_HEAP
+ allctr->mseg_opt.low_mem = init->low_mem;
+# endif
#endif
allctr->name_prefix = init->name_prefix;
diff --git a/erts/emulator/beam/erl_alloc_util.h b/erts/emulator/beam/erl_alloc_util.h
index d296081714..ddf84c086c 100644
--- a/erts/emulator/beam/erl_alloc_util.h
+++ b/erts/emulator/beam/erl_alloc_util.h
@@ -38,6 +38,7 @@ typedef struct {
int tspec;
int tpref;
int ramv;
+ int low_mem; /* HALFWORD only */
UWord sbct;
UWord asbcst;
UWord rsbcst;
@@ -70,6 +71,7 @@ typedef struct {
0, /* (bool) tspec: thread specific */\
0, /* (bool) tpref: thread preferred */\
0, /* (bool) ramv: realloc always moves */\
+ 0, /* (bool) low_mem: HALFWORD only */\
512*1024, /* (bytes) sbct: sbc threshold */\
2*1024*2024, /* (amount) asbcst: abs sbc shrink threshold */\
20, /* (%) rsbcst: rel sbc shrink threshold */\
@@ -97,6 +99,7 @@ typedef struct {
0, /* (bool) tspec: thread specific */\
0, /* (bool) tpref: thread preferred */\
0, /* (bool) ramv: realloc always moves */\
+ 0, /* (bool) low_mem: HALFWORD only */\
64*1024, /* (bytes) sbct: sbc threshold */\
2*1024*2024, /* (amount) asbcst: abs sbc shrink threshold */\
20, /* (%) rsbcst: rel sbc shrink threshold */\
diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index 9ef990cc4f..694348e31d 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -2085,7 +2085,14 @@ static void db_print_hash(int to, void *to_arg, int show, DbTable *tbl)
while(list != 0) {
if (list->hvalue == INVALID_HASH)
erts_print(to, to_arg, "*");
- erts_print(to, to_arg, "%T", make_tuple(list->dbterm.tpl));
+ if (tb->common.compress) {
+ Eterm key = GETKEY(tb, list->dbterm.tpl);
+ erts_print(to, to_arg, "key=%R", key, list->dbterm.tpl);
+ }
+ else {
+ Eterm obj = make_tuple_rel(list->dbterm.tpl,list->dbterm.tpl);
+ erts_print(to, to_arg, "%R", obj, list->dbterm.tpl);
+ }
if (list->next != 0)
erts_print(to, to_arg, ",");
list = list->next;
diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c
index a59c0c258d..eb77d1281a 100644
--- a/erts/emulator/beam/erl_db_tree.c
+++ b/erts/emulator/beam/erl_db_tree.c
@@ -179,7 +179,7 @@ static ERTS_INLINE TreeDbTerm* replace_dbterm(DbTableTree *tb, TreeDbTerm* old,
static TreeDbTerm *traverse_until(TreeDbTerm *t, int *current, int to);
static void check_slot_pos(DbTableTree *tb);
static void check_saved_stack(DbTableTree *tb);
-static int check_table_tree(TreeDbTerm *t);
+static int check_table_tree(DbTableTree* tb, TreeDbTerm *t);
#define TREE_DEBUG
#endif
@@ -194,8 +194,8 @@ static int check_table_tree(TreeDbTerm *t);
** Debugging dump
*/
-static void do_dump_tree2(int to, void *to_arg, int show, TreeDbTerm *t,
- int offset);
+static void do_dump_tree2(DbTableTree*, int to, void *to_arg, int show,
+ TreeDbTerm *t, int offset);
#else
@@ -1730,6 +1730,7 @@ static int db_select_delete_tree(Process *p, DbTable *tbl,
** Other interface routines (not directly coupled to one bif)
*/
+
/* Display tree contents (for dump) */
static void db_print_tree(int to, void *to_arg,
int show,
@@ -1740,7 +1741,7 @@ static void db_print_tree(int to, void *to_arg,
if (show)
erts_print(to, to_arg, "\nTree data dump:\n"
"------------------------------------------------\n");
- do_dump_tree2(to, to_arg, show, tb->root, 0);
+ do_dump_tree2(&tbl->tree, to, to_arg, show, tb->root, 0);
if (show)
erts_print(to, to_arg, "\n"
"------------------------------------------------\n");
@@ -2694,7 +2695,7 @@ static Sint do_cmp_partly_bound(Eterm a, Eterm b, Eterm* b_base, int *done)
while (1) {
if ((j = do_cmp_partly_bound(*aa++, *bb++, b_base, done)) != 0 || *done)
return j;
- if (*aa==*bb)
+ if (is_same(*aa, NULL, *bb, b_base))
return 0;
if (is_not_list(*aa) || is_not_list(*bb))
return do_cmp_partly_bound(*aa, *bb, b_base, done);
@@ -2742,7 +2743,7 @@ static Sint cmp_partly_bound(Eterm partly_bound_key, Eterm bound_key, Eterm* bk_
erts_fprintf(stderr," > ");
else
erts_fprintf(stderr," == ");
- erts_fprintf(stderr,"%T\n",bound_key); // HALFWORD BUG: printing rterm
+ erts_fprintf(stderr,"%R\n", bound_key, bk_base);
#endif
return ret;
}
@@ -3084,19 +3085,28 @@ static int doit_select_delete(DbTableTree *tb, TreeDbTerm *this, void *ptr,
}
#ifdef TREE_DEBUG
-static void do_dump_tree2(int to, void *to_arg, int show, TreeDbTerm *t,
- int offset)
+static void do_dump_tree2(DbTableTree* tb, int to, void *to_arg, int show,
+ TreeDbTerm *t, int offset)
{
if (t == NULL)
- return 0;
- do_dump_tree2(to, to_arg, show, t->right, offset + 4);
+ return;
+ do_dump_tree2(tb, to, to_arg, show, t->right, offset + 4);
if (show) {
- erts_print(to, to_arg, "%*s%T (addr = %p, bal = %d)\n"
- offset, "", make_tuple(t->dbterm.tpl),
+ const char* prefix;
+ Eterm term;
+ if (tb->common.compress) {
+ prefix = "key=";
+ term = GETKEY(tb, t->dbterm.tpl);
+ }
+ else {
+ prefix = "";
+ term = make_tuple_rel(t->dbterm.tpl,t->dbterm.tpl);
+ }
+ erts_print(to, to_arg, "%*s%s%R (addr = %p, bal = %d)\n",
+ offset, "", prefix, term, t->dbterm.tpl,
t, t->balance);
}
- do_dump_tree2(to, to_arg, show, t->left, offset + 4);
- return sum;
+ do_dump_tree2(tb, to, to_arg, show, t->left, offset + 4);
}
#endif
@@ -3106,7 +3116,7 @@ static void do_dump_tree2(int to, void *to_arg, int show, TreeDbTerm *t,
void db_check_table_tree(DbTable *tbl)
{
DbTableTree *tb = &tbl->tree;
- check_table_tree(tb->root);
+ check_table_tree(tb, tb->root);
check_saved_stack(tb);
check_slot_pos(tb);
}
@@ -3137,7 +3147,7 @@ static void check_slot_pos(DbTableTree *tb)
"element position %d is really 0x%08X, when stack says "
"it's 0x%08X\n", tb->stack.slot, t,
tb->stack.array[tb->stack.pos - 1]);
- do_dump_tree2(ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
+ do_dump_tree2(tb, ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
}
}
@@ -3152,14 +3162,14 @@ static void check_saved_stack(DbTableTree *tb)
if (t != stack->array[0]) {
erts_fprintf(stderr,"tb->stack[0] is 0x%08X, should be 0x%08X\n",
stack->array[0], t);
- do_dump_tree2(ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
+ do_dump_tree2(tb, ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
return;
}
while (n < stack->pos) {
if (t == NULL) {
erts_fprintf(stderr, "NULL pointer in tree when stack not empty,"
" stack depth is %d\n", n);
- do_dump_tree2(ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
+ do_dump_tree2(tb, ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
return;
}
n++;
@@ -3173,28 +3183,26 @@ static void check_saved_stack(DbTableTree *tb)
"represent child pointer in tree!"
"(left == 0x%08X, right == 0x%08X\n",
n, tb->stack[n], t->left, t->right);
- do_dump_tree2(ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
+ do_dump_tree2(tb, ERTS_PRINT_STDERR, NULL, 1, tb->root, 0);
return;
}
}
}
}
-static int check_table_tree(TreeDbTerm *t)
+static int check_table_tree(DbTableTree* tb, TreeDbTerm *t)
{
int lh, rh;
if (t == NULL)
return 0;
- lh = check_table_tree(t->left);
- rh = check_table_tree(t->right);
+ lh = check_table_tree(tb, t->left);
+ rh = check_table_tree(tb, t->right);
if ((rh - lh) != t->balance) {
erts_fprintf(stderr, "Invalid tree balance for this node:\n");
- erts_fprintf(stderr,"balance = %d, left = 0x%08X, right = 0x%08X\n"
- "data = %T",
- t->balance, t->left, t->right,
- make_tuple(t->dbterm.tpl));
+ erts_fprintf(stderr,"balance = %d, left = 0x%08X, right = 0x%08X\n",
+ t->balance, t->left, t->right);
erts_fprintf(stderr,"\nDump:\n---------------------------------\n");
- do_dump_tree2(ERTS_PRINT_STDERR, NULL, 1, t, 0);
+ do_dump_tree2(tb, ERTS_PRINT_STDERR, NULL, 1, t, 0);
erts_fprintf(stderr,"\n---------------------------------\n");
}
return ((rh > lh) ? rh : lh) + 1;
diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c
index c30d67ac88..5edcd667e7 100644
--- a/erts/emulator/beam/erl_gc.c
+++ b/erts/emulator/beam/erl_gc.c
@@ -215,7 +215,7 @@ erts_next_heap_size(Uint size, Uint offset)
low = mid + 1;
}
}
- erl_exit(1, "no next heap size found: %d, offset %d\n", size, offset);
+ erl_exit(1, "no next heap size found: %lu, offset %lu\n", (unsigned long)size, (unsigned long)offset);
}
return 0;
}
diff --git a/erts/emulator/beam/erl_lock_check.c b/erts/emulator/beam/erl_lock_check.c
index 9e18997890..9180508a49 100644
--- a/erts/emulator/beam/erl_lock_check.c
+++ b/erts/emulator/beam/erl_lock_check.c
@@ -240,7 +240,7 @@ typedef struct erts_lc_locked_lock_t_ erts_lc_locked_lock_t;
struct erts_lc_locked_lock_t_ {
erts_lc_locked_lock_t *next;
erts_lc_locked_lock_t *prev;
- Eterm extra;
+ UWord extra;
Sint16 id;
Uint16 flags;
};
@@ -441,12 +441,12 @@ new_locked_lock(erts_lc_lock_t *lck, Uint16 op_flags)
}
static void
-print_lock2(char *prefix, Sint16 id, Eterm extra, Uint16 flags, char *suffix)
+print_lock2(char *prefix, Sint16 id, Wterm extra, Uint16 flags, char *suffix)
{
char *lname = (0 <= id && id < ERTS_LOCK_ORDER_SIZE
? erts_lock_order[id].name
: "unknown");
- if (is_boxed(extra))
+ if (is_not_immed(extra))
erts_fprintf(stderr,
"%s'%s:%p%s'%s%s",
prefix,
@@ -1260,7 +1260,8 @@ erts_lc_init_lock(erts_lc_lock_t *lck, char *name, Uint16 flags)
{
lck->id = erts_lc_get_lock_order_id(name);
- lck->extra = make_boxed(&lck->extra);
+ lck->extra = &lck->extra;
+ ASSERT(is_not_immed(lck->extra));
lck->flags = flags;
lck->inited = ERTS_LC_INITITALIZED;
}
@@ -1270,6 +1271,7 @@ erts_lc_init_lock_x(erts_lc_lock_t *lck, char *name, Uint16 flags, Eterm extra)
{
lck->id = erts_lc_get_lock_order_id(name);
lck->extra = extra;
+ ASSERT(is_immed(lck->extra));
lck->flags = flags;
lck->inited = ERTS_LC_INITITALIZED;
}
diff --git a/erts/emulator/beam/erl_lock_check.h b/erts/emulator/beam/erl_lock_check.h
index cdb06d4458..b67f36fa06 100644
--- a/erts/emulator/beam/erl_lock_check.h
+++ b/erts/emulator/beam/erl_lock_check.h
@@ -39,7 +39,7 @@ typedef struct {
int inited;
Sint16 id;
Uint16 flags;
- Eterm extra;
+ UWord extra;
} erts_lc_lock_t;
#define ERTS_LC_INITITALIZED 0x7f7f7f7f
diff --git a/erts/emulator/beam/erl_printf_term.c b/erts/emulator/beam/erl_printf_term.c
index b71404fd27..34da9cab84 100644
--- a/erts/emulator/beam/erl_printf_term.c
+++ b/erts/emulator/beam/erl_printf_term.c
@@ -114,13 +114,13 @@ do { \
/* return 0 if list is not a non-empty flat list of printable characters */
static int
-is_printable_string(Eterm list)
+is_printable_string(Eterm list, Eterm* base)
{
int len = 0;
int c;
while(is_list(list)) {
- Eterm* consp = list_val(list);
+ Eterm* consp = list_val_rel(list, base);
Eterm hd = CAR(consp);
if (!is_byte(hd))
@@ -226,17 +226,20 @@ static int print_atom_name(fmtfn_t fn, void* arg, Eterm atom, long *dcount)
#define PRT_LAST_ARRAY_ELEMENT ((Eterm) 7) /* Note! Must be last... */
static int
-print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
+print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
+ Eterm* obj_base) /* ignored if !HALFWORD_HEAP */
{
DECLARE_WSTACK(s);
int res;
int i;
Eterm val;
Uint32 *ref_num;
+ union {
+ UWord word;
+ Eterm* ptr;
+ }popped;
Eterm* nobj;
-#if HALFWORD_HEAP
- UWord wobj;
-#endif
+ Wterm wobj;
res = 0;
@@ -258,18 +261,17 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
PRINT_CHAR(res, fn, arg, '}');
goto L_outer_loop;
default:
-#if HALFWORD_HEAP
- obj = (Eterm) (wobj = WSTACK_POP(s));
-#else
- obj = WSTACK_POP(s);
-#endif
+ popped.word = WSTACK_POP(s);
+
switch (val) {
case PRT_TERM:
+ obj = (Eterm) popped.word;
break;
case PRT_ONE_CONS:
+ obj = (Eterm) popped.word;
L_print_one_cons:
{
- Eterm* cons = list_val(obj);
+ Eterm* cons = list_val_rel(obj, obj_base);
Eterm tl;
obj = CAR(cons);
@@ -288,27 +290,13 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
}
break;
case PRT_LAST_ARRAY_ELEMENT:
- {
-#if HALFWORD_HEAP
- Eterm* ptr = (Eterm *) wobj;
-#else
- Eterm* ptr = (Eterm *) obj;
-#endif
- obj = *ptr;
- }
+ obj = *popped.ptr;
break;
default: /* PRT_LAST_ARRAY_ELEMENT+1 and upwards */
- {
-#if HALFWORD_HEAP
- Eterm* ptr = (Eterm *) wobj;
-#else
- Eterm* ptr = (Eterm *) obj;
-#endif
- obj = *ptr++;
- WSTACK_PUSH(s, (UWord) ptr);
- WSTACK_PUSH(s, val-1);
- WSTACK_PUSH(s, PRT_COMMA);
- }
+ obj = *popped.ptr;
+ WSTACK_PUSH(s, (UWord) (popped.ptr + 1));
+ WSTACK_PUSH(s, val-1);
+ WSTACK_PUSH(s, PRT_COMMA);
break;
}
break;
@@ -325,8 +313,12 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
PRINT_CHAR(res, fn, arg, '>');
goto L_done;
}
-
- switch (tag_val_def(obj)) {
+#if HALFWORD_HEAP
+ wobj = is_immed(obj) ? (Wterm)obj : rterm2wterm(obj, obj_base);
+#else
+ wobj = (Wterm)obj;
+#endif
+ switch (tag_val_def(wobj)) {
case NIL_DEF:
PRINT_STRING(res, fn, arg, "[]");
break;
@@ -348,13 +340,13 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
int print_res;
char def_buf[64];
char *buf, *big_str;
- Uint sz = (Uint) big_decimal_estimate(obj);
+ Uint sz = (Uint) big_decimal_estimate(wobj);
sz++;
if (sz <= 64)
buf = &def_buf[0];
else
buf = erts_alloc(ERTS_ALC_T_TMP, sz);
- big_str = erts_big_to_string(obj, buf, sz);
+ big_str = erts_big_to_string(wobj, buf, sz);
print_res = erts_printf_string(fn, arg, big_str);
if (buf != &def_buf[0])
erts_free(ERTS_ALC_T_TMP, (void *) buf);
@@ -369,9 +361,9 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
case EXTERNAL_REF_DEF:
PRINT_STRING(res, fn, arg, "#Ref<");
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) ref_channel_no(obj));
- ref_num = ref_numbers(obj);
- for (i = ref_no_of_numbers(obj)-1; i >= 0; i--) {
+ (unsigned long) ref_channel_no(wobj));
+ ref_num = ref_numbers(wobj);
+ for (i = ref_no_of_numbers(wobj)-1; i >= 0; i--) {
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1, (unsigned long) ref_num[i]);
}
@@ -381,30 +373,30 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
case EXTERNAL_PID_DEF:
PRINT_CHAR(res, fn, arg, '<');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) pid_channel_no(obj));
+ (unsigned long) pid_channel_no(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) pid_number(obj));
+ (unsigned long) pid_number(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) pid_serial(obj));
+ (unsigned long) pid_serial(wobj));
PRINT_CHAR(res, fn, arg, '>');
break;
case PORT_DEF:
case EXTERNAL_PORT_DEF:
PRINT_STRING(res, fn, arg, "#Port<");
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) port_channel_no(obj));
+ (unsigned long) port_channel_no(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
- (unsigned long) port_number(obj));
+ (unsigned long) port_number(wobj));
PRINT_CHAR(res, fn, arg, '>');
break;
case LIST_DEF:
- if (is_printable_string(obj)) {
+ if (is_printable_string(obj, obj_base)) {
int c;
PRINT_CHAR(res, fn, arg, '"');
- nobj = list_val(obj);
+ nobj = list_val_rel(obj, obj_base);
while (1) {
if ((*dcount)-- <= 0)
goto L_done;
@@ -418,7 +410,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
}
if (is_not_list(*nobj))
break;
- nobj = list_val(*nobj);
+ nobj = list_val_rel(*nobj, obj_base);
}
PRINT_CHAR(res, fn, arg, '"');
} else {
@@ -428,7 +420,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
}
break;
case TUPLE_DEF:
- nobj = tuple_val(obj); /* pointer to arity */
+ nobj = tuple_val(wobj); /* pointer to arity */
i = arityval(*nobj); /* arity */
PRINT_CHAR(res, fn, arg, '{');
WSTACK_PUSH(s,PRT_CLOSE_TUPLE);
@@ -440,13 +432,13 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
break;
case FLOAT_DEF: {
FloatDef ff;
- GET_DOUBLE(obj, ff);
+ GET_DOUBLE(wobj, ff);
PRINT_DOUBLE(res, fn, arg, 'e', 6, 0, ff.fd);
}
break;
case BINARY_DEF:
{
- ProcBin* pb = (ProcBin *) binary_val(obj);
+ ProcBin* pb = (ProcBin *) binary_val(wobj);
if (pb->size == 1)
PRINT_STRING(res, fn, arg, "<<1 byte>>");
else {
@@ -458,7 +450,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
break;
case EXPORT_DEF:
{
- Export* ep = *((Export **) (export_val(obj) + 1));
+ Export* ep = *((Export **) (export_val(wobj) + 1));
Atom* module = atom_tab(atom_val(ep->code[0]));
Atom* name = atom_tab(atom_val(ep->code[1]));
@@ -474,7 +466,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
break;
case FUN_DEF:
{
- ErlFunThing *funp = (ErlFunThing *) fun_val(obj);
+ ErlFunThing *funp = (ErlFunThing *) fun_val(wobj);
Atom *ap = atom_tab(atom_val(funp->fe->module));
PRINT_STRING(res, fn, arg, "#Fun<");
@@ -490,7 +482,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
break;
default:
PRINT_STRING(res, fn, arg, "<unknown:");
- PRINT_POINTER(res, fn, arg, (UWord) obj);
+ PRINT_POINTER(res, fn, arg, wobj);
PRINT_CHAR(res, fn, arg, '>');
break;
}
@@ -503,9 +495,10 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount)
}
int
-erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision)
+erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision,
+ unsigned long* term_base)
{
- int res = print_term(fn, arg, (Uint) term, &precision);
+ int res = print_term(fn, arg, (Eterm)term, &precision, (Eterm*)term_base);
if (res < 0)
return res;
if (precision <= 0)
diff --git a/erts/emulator/beam/erl_printf_term.h b/erts/emulator/beam/erl_printf_term.h
index 4f76028396..4ba22f12de 100644
--- a/erts/emulator/beam/erl_printf_term.h
+++ b/erts/emulator/beam/erl_printf_term.h
@@ -21,6 +21,6 @@
#define ERL_PRINTF_TERM_H__
#include "erl_printf_format.h"
-int erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision);
-
+int erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision,
+ unsigned long* term_base);
#endif
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 31f23d3978..8a56976905 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -3887,21 +3887,9 @@ handle_pend_sync_suspend(Process *suspendee,
}
}
-/*
- * Like erts_pid2proc() but:
- *
- * * At least ERTS_PROC_LOCK_MAIN have to be held on c_p.
- * * At least ERTS_PROC_LOCK_MAIN have to be taken on pid.
- * * It also waits for proc to be in a state != running and garbing.
- * * If ERTS_PROC_LOCK_BUSY is returned, the calling process has to
- * yield (ERTS_BIF_YIELD[0-3]()). c_p might in this case have been
- * suspended.
- */
-
-
-Process *
-erts_pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
- Eterm pid, ErtsProcLocks pid_locks)
+static Process *
+pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
+ Eterm pid, ErtsProcLocks pid_locks, int suspend)
{
Process *rp;
int unlock_c_p_status;
@@ -3928,7 +3916,7 @@ erts_pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
c_p->suspendee = NIL;
ASSERT(c_p->flags & F_P2PNR_RESCHED);
c_p->flags &= ~F_P2PNR_RESCHED;
- if (rp)
+ if (!suspend && rp)
resume_process(rp);
}
else {
@@ -3992,6 +3980,8 @@ erts_pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
}
/* rp is not running and we got the locks we want... */
+ if (suspend)
+ suspend_process(rp_rq, rp);
}
erts_smp_runqs_unlock(cp_rq, rp_rq);
}
@@ -4004,6 +3994,35 @@ erts_pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
return rp;
}
+
+/*
+ * Like erts_pid2proc() but:
+ *
+ * * At least ERTS_PROC_LOCK_MAIN have to be held on c_p.
+ * * At least ERTS_PROC_LOCK_MAIN have to be taken on pid.
+ * * It also waits for proc to be in a state != running and garbing.
+ * * If ERTS_PROC_LOCK_BUSY is returned, the calling process has to
+ * yield (ERTS_BIF_YIELD[0-3]()). c_p might in this case have been
+ * suspended.
+ */
+Process *
+erts_pid2proc_not_running(Process *c_p, ErtsProcLocks c_p_locks,
+ Eterm pid, ErtsProcLocks pid_locks)
+{
+ return pid2proc_not_running(c_p, c_p_locks, pid, pid_locks, 0);
+}
+
+/*
+ * Like erts_pid2proc_not_running(), but hands over the process
+ * in a suspended state unless (c_p is looked up).
+ */
+Process *
+erts_pid2proc_suspend(Process *c_p, ErtsProcLocks c_p_locks,
+ Eterm pid, ErtsProcLocks pid_locks)
+{
+ return pid2proc_not_running(c_p, c_p_locks, pid, pid_locks, 1);
+}
+
/*
* erts_pid2proc_nropt() is normally the same as
* erts_pid2proc_not_running(). However it is only
@@ -4117,6 +4136,21 @@ handle_pend_bif_async_suspend(Process *suspendee,
}
}
+#else
+
+/*
+ * Non-smp version of erts_pid2proc_suspend().
+ */
+Process *
+erts_pid2proc_suspend(Process *c_p, ErtsProcLocks c_p_locks,
+ Eterm pid, ErtsProcLocks pid_locks)
+{
+ Process *rp = erts_pid2proc(c_p, c_p_locks, pid, pid_locks);
+ if (rp)
+ erts_suspend(rp, pid_locks, NULL);
+ return rp;
+}
+
#endif /* ERTS_SMP */
/*
@@ -4650,7 +4684,7 @@ internal_add_to_runq(ErtsRunQueue *runq, Process *p)
if (p->status_flags & ERTS_PROC_SFLG_INRUNQ)
return NULL;
else if (p->runq_flags & ERTS_PROC_RUNQ_FLG_RUNNING) {
- ASSERT(p->rcount == 0);
+ ASSERT(ERTS_PROC_IS_EXITING(p) || p->rcount == 0);
ERTS_DBG_CHK_PROCS_RUNQ_NOPROC(runq, p);
p->status_flags |= ERTS_PROC_SFLG_PENDADD2SCHEDQ;
return NULL;
@@ -4661,7 +4695,7 @@ internal_add_to_runq(ErtsRunQueue *runq, Process *p)
ERTS_DBG_CHK_PROCS_RUNQ_NOPROC(runq, p);
#ifndef ERTS_SMP
/* Never schedule a suspended process (ok in smp case) */
- ASSERT(p->rcount == 0);
+ ASSERT(ERTS_PROC_IS_EXITING(p) || p->rcount == 0);
add_runq = runq;
#else
ASSERT(!p->bound_runq || p->bound_runq == p->run_queue);
diff --git a/erts/emulator/beam/erl_process.h b/erts/emulator/beam/erl_process.h
index 334ae5573f..296acc7367 100644
--- a/erts/emulator/beam/erl_process.h
+++ b/erts/emulator/beam/erl_process.h
@@ -1535,6 +1535,10 @@ erts_get_atom_cache_map(Process *c_p)
}
#endif
+Process *erts_pid2proc_suspend(Process *,
+ ErtsProcLocks,
+ Eterm,
+ ErtsProcLocks);
#ifdef ERTS_SMP
Process *erts_pid2proc_not_running(Process *,
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index afea51c44b..a17de717bc 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -2705,7 +2705,7 @@ term_array: /* arrays in 'aa' and 'bb', length in 'i' */
while (--i) {
a = *aa++;
b = *bb++;
- if (a != b) {
+ if (!is_same(a,a_base, b,b_base)) {
if (is_atom(a) && is_atom(b)) {
if ((j = cmp_atoms(a, b)) != 0) {
goto not_equal;
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 59f4cfb9b4..aec456151c 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -490,7 +490,6 @@ static int my_strncasecmp(const char *s1, const char *s2, size_t n)
#define TCP_REQ_RECV 42
#define TCP_REQ_UNRECV 43
#define TCP_REQ_SHUTDOWN 44
-#define TCP_REQ_MULTI_OP 45
/* UDP and SCTP requests */
#define PACKET_REQ_RECV 60 /* Common for UDP and SCTP */
#define SCTP_REQ_LISTEN 61 /* Different from TCP; not for UDP */
@@ -1763,7 +1762,6 @@ send_async_error(ErlDrvPort port, ErlDrvTermData Port, int Ref,
LOAD_INT_CNT + 2*LOAD_TUPLE_CNT];
int i = 0;
- i = 0;
i = LOAD_ATOM(spec, i, am_inet_async);
i = LOAD_PORT(spec, i, Port);
i = LOAD_INT(spec, i, Ref);
diff --git a/erts/emulator/sys/common/erl_mseg.c b/erts/emulator/sys/common/erl_mseg.c
index ffa3a6328c..eaef6680dd 100644
--- a/erts/emulator/sys/common/erl_mseg.c
+++ b/erts/emulator/sys/common/erl_mseg.c
@@ -134,7 +134,16 @@ static int mmap_fd;
#define CAN_PARTLY_DESTROY 0
#endif
-static const ErtsMsegOpt_t default_opt = ERTS_MSEG_DEFAULT_OPT_INITIALIZER;
+const ErtsMsegOpt_t erts_mseg_default_opt = {
+ 1, /* Use cache */
+ 1, /* Preserv data */
+ 0, /* Absolute shrink threshold */
+ 0 /* Relative shrink threshold */
+#if HALFWORD_HEAP
+ ,0 /* need low memory */
+#endif
+};
+
typedef struct cache_desc_t_ {
void *seg;
@@ -605,18 +614,10 @@ mseg_clear_cache(MemKind* mk)
INC_CC(clear_cache);
}
-static ERTS_INLINE MemKind* type2mk(ErtsAlcType_t atype)
+static ERTS_INLINE MemKind* memkind(const ErtsMsegOpt_t *opt)
{
#if HALFWORD_HEAP
- switch (atype) {
- case ERTS_ALC_A_ETS:
- case ERTS_ALC_A_BINARY:
- case ERTS_ALC_A_FIXED_SIZE:
- case ERTS_ALC_A_DRIVER:
- return &hi_mem;
- default:
- return &low_mem;
- }
+ return opt->low_mem ? &low_mem : &hi_mem;
#else
return &the_mem;
#endif
@@ -628,7 +629,7 @@ mseg_alloc(ErtsAlcType_t atype, Uint *size_p, const ErtsMsegOpt_t *opt)
Uint max, min, diff_size, size;
cache_desc_t *cd, *cand_cd;
void *seg;
- MemKind* mk = type2mk(atype);
+ MemKind* mk = memkind(opt);
INC_CC(alloc);
@@ -742,7 +743,7 @@ static void
mseg_dealloc(ErtsAlcType_t atype, void *seg, Uint size,
const ErtsMsegOpt_t *opt)
{
- MemKind* mk = type2mk(atype);
+ MemKind* mk = memkind(opt);
cache_desc_t *cd;
ERTS_MSEG_DEALLOC_STAT(mk,size);
@@ -800,7 +801,7 @@ static void *
mseg_realloc(ErtsAlcType_t atype, void *seg, Uint old_size, Uint *new_size_p,
const ErtsMsegOpt_t *opt)
{
- MemKind* mk = type2mk(atype);
+ MemKind* mk = memkind(opt);
void *new_seg;
Uint new_size;
@@ -1372,7 +1373,7 @@ erts_mseg_alloc_opt(ErtsAlcType_t atype, Uint *size_p, const ErtsMsegOpt_t *opt)
void *
erts_mseg_alloc(ErtsAlcType_t atype, Uint *size_p)
{
- return erts_mseg_alloc_opt(atype, size_p, &default_opt);
+ return erts_mseg_alloc_opt(atype, size_p, &erts_mseg_default_opt);
}
void
@@ -1387,7 +1388,7 @@ erts_mseg_dealloc_opt(ErtsAlcType_t atype, void *seg, Uint size,
void
erts_mseg_dealloc(ErtsAlcType_t atype, void *seg, Uint size)
{
- erts_mseg_dealloc_opt(atype, seg, size, &default_opt);
+ erts_mseg_dealloc_opt(atype, seg, size, &erts_mseg_default_opt);
}
void *
@@ -1405,7 +1406,7 @@ void *
erts_mseg_realloc(ErtsAlcType_t atype, void *seg, Uint old_size,
Uint *new_size_p)
{
- return erts_mseg_realloc_opt(atype, seg, old_size, new_size_p, &default_opt);
+ return erts_mseg_realloc_opt(atype, seg, old_size, new_size_p, &erts_mseg_default_opt);
}
void
diff --git a/erts/emulator/sys/common/erl_mseg.h b/erts/emulator/sys/common/erl_mseg.h
index d8053eb0d9..fbb66ee33b 100644
--- a/erts/emulator/sys/common/erl_mseg.h
+++ b/erts/emulator/sys/common/erl_mseg.h
@@ -60,15 +60,12 @@ typedef struct {
int preserv;
UWord abs_shrink_th;
UWord rel_shrink_th;
+#if HALFWORD_HEAP
+ int low_mem;
+#endif
} ErtsMsegOpt_t;
-#define ERTS_MSEG_DEFAULT_OPT_INITIALIZER \
-{ \
- 1, /* Use cache */ \
- 1, /* Preserv data */ \
- 0, /* Absolute shrink threshold */ \
- 0 /* Relative shrink threshold */ \
-}
+extern const ErtsMsegOpt_t erts_mseg_default_opt;
void *erts_mseg_alloc(ErtsAlcType_t, Uint *);
void *erts_mseg_alloc_opt(ErtsAlcType_t, Uint *, const ErtsMsegOpt_t *);
diff --git a/erts/emulator/test/process_SUITE.erl b/erts/emulator/test/process_SUITE.erl
index 36bae908aa..f68e712268 100644
--- a/erts/emulator/test/process_SUITE.erl
+++ b/erts/emulator/test/process_SUITE.erl
@@ -50,7 +50,8 @@
processes_last_call_trap/1, processes_gc_trap/1,
processes_term_proc_list/1,
otp_7738_waiting/1, otp_7738_suspended/1,
- otp_7738_resume/1]).
+ otp_7738_resume/1,
+ garb_other_running/1]).
-export([prio_server/2, prio_client/2]).
-export([init_per_testcase/2, end_per_testcase/2]).
@@ -72,7 +73,7 @@ all() ->
bad_register, garbage_collect, process_info_messages,
process_flag_badarg, process_flag_heap_size,
spawn_opt_heap_size, otp_6237, {group, processes_bif},
- {group, otp_7738}].
+ {group, otp_7738}, garb_other_running].
groups() ->
[{t_exit_2, [],
@@ -2116,6 +2117,41 @@ otp_7738_test(Type) ->
end,
?line ok.
+gor(Reds, Stop) ->
+ receive
+ {From, reds} ->
+ From ! {reds, Reds, self()},
+ gor(Reds+1, Stop);
+ {From, Stop} ->
+ From ! {stopped, Stop, Reds, self()}
+ after 0 ->
+ gor(Reds+1, Stop)
+ end.
+
+garb_other_running(Config) when is_list(Config) ->
+ ?line Stop = make_ref(),
+ ?line {Pid, Mon} = spawn_monitor(fun () -> gor(0, Stop) end),
+ ?line Reds = lists:foldl(fun (_, OldReds) ->
+ ?line erlang:garbage_collect(Pid),
+ ?line receive after 1 -> ok end,
+ ?line Pid ! {self(), reds},
+ ?line receive
+ {reds, NewReds, Pid} ->
+ ?line true = (NewReds > OldReds),
+ ?line NewReds
+ end
+ end,
+ 0,
+ lists:seq(1, 10000)),
+ ?line receive after 1 -> ok end,
+ ?line Pid ! {self(), Stop},
+ ?line receive
+ {stopped, Stop, StopReds, Pid} ->
+ ?line true = (StopReds > Reds)
+ end,
+ ?line receive {'DOWN', Mon, process, Pid, normal} -> ok end,
+ ?line ok.
+
%% Internal functions
wait_until(Fun) ->
diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c
index e97cc14fab..8db8e09bee 100644
--- a/erts/etc/unix/run_erl.c
+++ b/erts/etc/unix/run_erl.c
@@ -991,9 +991,7 @@ static int open_pty_master(char **ptyslave)
static int open_pty_slave(char *name)
{
int sfd;
-#ifdef DEBUG
struct termios tty_rmode;
-#endif
if ((sfd = open(name, O_RDWR, 0)) < 0) {
return -1;
@@ -1019,6 +1017,25 @@ static int open_pty_slave(char *name)
}
#endif
+ if (getenv("RUN_ERL_DISABLE_FLOWCNTRL")) {
+ if (tcgetattr(sfd, &tty_rmode) < 0) {
+ fprintf(stderr, "Cannot get terminal's current mode\n");
+ exit(-1);
+ }
+
+ tty_rmode.c_iflag &= ~IXOFF;
+ if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) {
+ fprintf(stderr, "Cannot disable terminal's flow control on input\n");
+ exit(-1);
+ }
+
+ tty_rmode.c_iflag &= ~IXON;
+ if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) {
+ fprintf(stderr, "Cannot disable terminal's flow control on output\n");
+ exit(-1);
+ }
+ }
+
#ifdef DEBUG
if (tcgetattr(sfd, &tty_rmode) < 0) {
fprintf(stderr, "Cannot get terminals current mode\n");
diff --git a/erts/etc/win32/nsis/find_redist.sh b/erts/etc/win32/nsis/find_redist.sh
index 328811a0d7..bc4260ecba 100755
--- a/erts/etc/win32/nsis/find_redist.sh
+++ b/erts/etc/win32/nsis/find_redist.sh
@@ -139,8 +139,7 @@ fi
#echo $BPATH_LIST
for BP in $BPATH_LIST; do
- #echo "BP=$BP"
- for verdir in "sdk v2.0" "sdk v3.5" "v6.0A" "v7.0A" "v7.1"; do
+ for verdir in "sdk v2.0" "sdk v3.5" "v6.0A" "v7.0" "v7.0A" "v7.1"; do
BPATH=$BP
fail=false
allow_fail=false
@@ -171,6 +170,18 @@ for BP in $BPATH_LIST; do
fi
done
+# shortcut for locating vcredist_x86.exe is to put it into $ERL_TOP
+if [ -f $ERL_TOP/vcredist_x86.exe ]; then
+ echo $ERL_TOP/vcredist_x86.exe
+ exit 0
+fi
+
+# or $ERL_TOP/.. to share across multiple builds
+if [ -f $ERL_TOP/../vcredist_x86.exe ]; then
+ echo $ERL_TOP/../vcredist_x86.exe
+ exit 0
+fi
+
echo "Failed to locate vcredist_x86.exe because directory structure was unexpected" >&2
exit 3
diff --git a/erts/include/internal/erl_printf_format.h b/erts/include/internal/erl_printf_format.h
index 45818079ea..400cc7dafd 100644
--- a/erts/include/internal/erl_printf_format.h
+++ b/erts/include/internal/erl_printf_format.h
@@ -40,7 +40,7 @@ extern int erts_printf_ulong(fmtfn_t, void*, char, int, int, unsigned long);
extern int erts_printf_slong(fmtfn_t, void*, char, int, int, signed long);
extern int erts_printf_double(fmtfn_t, void *, char, int, int, double);
-extern int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long);
+extern int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long, unsigned long*);
#endif
diff --git a/erts/lib_src/common/erl_printf_format.c b/erts/lib_src/common/erl_printf_format.c
index 968d563325..fba3fd723c 100644
--- a/erts/lib_src/common/erl_printf_format.c
+++ b/erts/lib_src/common/erl_printf_format.c
@@ -25,7 +25,7 @@
* width: [0-9]+ | '*'
* precision: [0-9]+ | '*'
* length: hh | h | l | ll | L | j | t | b<sz>
- * conversion: d,i | o,u,x,X | e,E | f,F | g,G | a,A | c | s | T |
+ * conversion: d,i | o,u,x,X | e,E | f,F | g,G | a,A | c | s | T | R |
* p | n | %
* sz: 8 | 16 | 32 | 64 | p | e
*/
@@ -101,7 +101,7 @@
#endif
#define FMTC_d 0x0000
-#define FMTC_i 0x0001
+#define FMTC_R 0x0001
#define FMTC_o 0x0002
#define FMTC_u 0x0003
#define FMTC_x 0x0004
@@ -165,7 +165,7 @@ static char heX[] = "0123456789ABCDEF";
#define SIGN(X) ((X) > 0 ? 1 : ((X) < 0 ? -1 : 0))
#define USIGN(X) ((X) == 0 ? 0 : 1)
-int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long) = NULL;
+int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long, unsigned long*) = NULL;
static int
noop_fn(void *vfp, char* buf, size_t len)
@@ -183,8 +183,8 @@ static int fmt_fld(fmtfn_t fn,void* arg,
int len;
/* format the prefix */
- if ((sign || (fmt & (FMTF_sgn|FMTF_blk))) &&
- (((fmt & FMTC_MASK) == FMTC_d) || ((fmt & FMTC_MASK) == FMTC_i))) {
+ if ((sign || (fmt & (FMTF_sgn|FMTF_blk)))
+ && (fmt & FMTC_MASK) == FMTC_d) {
if (sign < 0)
*pp++ = '-';
else if ((fmt & FMTF_sgn))
@@ -245,7 +245,6 @@ static int fmt_long(fmtfn_t fn,void* arg,int sign,unsigned long uval,
switch(fmt & FMTC_MASK) {
case FMTC_d:
- case FMTC_i:
case FMTC_u:
break;
case FMTC_o:
@@ -298,7 +297,6 @@ static int fmt_long_long(fmtfn_t fn,void* arg,int sign,
switch(fmt & FMTC_MASK) {
case FMTC_d:
- case FMTC_i:
case FMTC_u:
break;
case FMTC_o:
@@ -622,7 +620,7 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
/* specifier */
switch(*ptr) {
case 'd': ptr++; fmt |= FMTC_d; break;
- case 'i': ptr++; fmt |= FMTC_i; break;
+ case 'i': ptr++; fmt |= FMTC_d; break;
case 'o': ptr++; fmt |= FMTC_o; break;
case 'u': ptr++; fmt |= FMTC_u; break;
case 'x': ptr++; fmt |= FMTC_x; break;
@@ -637,6 +635,7 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
case 'p': ptr++; fmt |= FMTC_p; break;
case 'n': ptr++; fmt |= FMTC_n; break;
case 'T': ptr++; fmt |= FMTC_T; break;
+ case 'R': ptr++; fmt |= FMTC_R; break;
case '%':
FMT(fn,arg,ptr,1,count);
ptr++;
@@ -650,7 +649,6 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
switch(fmt & FMTC_MASK) {
case FMTC_d:
- case FMTC_i:
switch(fmt & FMTL_MASK) {
case FMTL_hh: {
signed char tval = (signed char) va_arg(ap,int);
@@ -814,9 +812,12 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
default: *va_arg(ap,int*) = count; break;
}
break;
- case FMTC_T: {
+ case FMTC_T: /* Eterm */
+ case FMTC_R: { /* Eterm, Eterm* base (base ignored if !HALFWORD_HEAP) */
long prec;
unsigned long eterm;
+ unsigned long* eterm_base;
+
if (!erts_printf_eterm_func)
return -EINVAL;
if (precision < 0)
@@ -826,14 +827,16 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
else
prec = (long) precision;
eterm = va_arg(ap, unsigned long);
+ eterm_base = ((fmt & FMTC_MASK) == FMTC_R) ?
+ va_arg(ap, unsigned long*) : NULL;
if (width > 0 && !(fmt & FMTF_adj)) {
- res = (*erts_printf_eterm_func)(noop_fn, NULL, eterm, prec);
+ res = (*erts_printf_eterm_func)(noop_fn, NULL, eterm, prec, eterm_base);
if (res < 0)
return res;
if (width > res)
BLANKS(fn, arg, width - res, count);
}
- res = (*erts_printf_eterm_func)(fn, arg, eterm, prec);
+ res = (*erts_printf_eterm_func)(fn, arg, eterm, prec, eterm_base);
if (res < 0)
return res;
count += res;
@@ -924,7 +927,7 @@ erts_printf_slong(fmtfn_t fn, void *arg, char conv, int pad, int width,
unsigned long ul_val;
switch (conv) {
case 'd': fmt |= FMTC_d; break;
- case 'i': fmt |= FMTC_i; break;
+ case 'i': fmt |= FMTC_d; break;
case 'o': fmt |= FMTC_o; break;
case 'x': fmt |= FMTC_x; break;
case 'X': fmt |= FMTC_X; break;
diff --git a/erts/preloaded/ebin/prim_file.beam b/erts/preloaded/ebin/prim_file.beam
index c2ae01d0d5..bfb1e48365 100644
--- a/erts/preloaded/ebin/prim_file.beam
+++ b/erts/preloaded/ebin/prim_file.beam
Binary files differ
diff --git a/erts/preloaded/src/prim_file.erl b/erts/preloaded/src/prim_file.erl
index fb0aef8947..13e8e8fb5b 100644
--- a/erts/preloaded/src/prim_file.erl
+++ b/erts/preloaded/src/prim_file.erl
@@ -864,9 +864,9 @@ drv_command(Port, Command) ->
drv_command(Port, Command, R) when is_binary(Command) ->
drv_command(Port, Command, true, R);
drv_command(Port, Command, R) ->
- try erlang:iolist_to_binary(Command) of
- Bin ->
- drv_command(Port, Bin, true, R)
+ try erlang:iolist_size(Command) of
+ _ ->
+ drv_command(Port, Command, true, R)
catch
error:Reason ->
{error, Reason}