Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Merge branch 'dev' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
proxyles committed Aug 25, 2011
2 parents 48eb259 + d48eaa0 commit 756a93c
Show file tree
Hide file tree
Showing 84 changed files with 686 additions and 384 deletions.
4 changes: 2 additions & 2 deletions INSTALL.md
Expand Up @@ -418,7 +418,7 @@ as before, but the build process will take a much longer time.
### Building in Git ###

When building in a Git working directory you also have to have a GNU `autoconf`
of at least version 2.59 on your system. This since you need to generate the
of at least version 2.59 on your system, because you need to generate the
`configure` scripts before you can start building.

The `configure` scripts are generated by invoking `./otp_build autoconf` in
Expand All @@ -430,7 +430,7 @@ when checking out a branch. Regenerated `configure` scripts imply that you
have to run `configure` and build again.

> *NOTE*: Running `./otp_build autoconf` is **not** needed when building
> an unmodified version the released source.
> an unmodified version of the released source.
Other useful information can be found at our github wiki:
<http://wiki.github.com/erlang/otp>
Expand Down
40 changes: 24 additions & 16 deletions erts/emulator/beam/erl_gc.c
Expand Up @@ -100,14 +100,14 @@ static Uint combined_message_size(Process* p);
static void remove_message_buffers(Process* p);
static int major_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl);
static int minor_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl);
static void do_minor(Process *p, int new_sz, Eterm* objv, int nobj);
static void do_minor(Process *p, Uint new_sz, Eterm* objv, int nobj);
static Eterm* sweep_rootset(Rootset *rootset, Eterm* htop, char* src, Uint src_size);
static Eterm* sweep_one_area(Eterm* n_hp, Eterm* n_htop, char* src, Uint src_size);
static Eterm* sweep_one_heap(Eterm* heap_ptr, Eterm* heap_end, Eterm* htop,
char* src, Uint src_size);
static Eterm* collect_heap_frags(Process* p, Eterm* heap,
Eterm* htop, Eterm* objv, int nobj);
static Uint adjust_after_fullsweep(Process *p, int size_before,
static Uint adjust_after_fullsweep(Process *p, Uint size_before,
int need, Eterm *objv, int nobj);
static void shrink_new_heap(Process *p, Uint new_sz, Eterm *objv, int nobj);
static void grow_new_heap(Process *p, Uint new_sz, Eterm* objv, int nobj);
Expand Down Expand Up @@ -441,7 +441,15 @@ erts_garbage_collect(Process* p, int need, Eterm* objv, int nobj)
p->last_old_htop = p->old_htop;
#endif

return ((int) (HEAP_TOP(p) - HEAP_START(p)) / 10);
/* FIXME: This function should really return an Sint, i.e., a possibly
64 bit wide signed integer, but that requires updating all the code
that calls it. For now, we just return INT_MAX if the result is too
large for an int. */
{
Sint result = (HEAP_TOP(p) - HEAP_START(p)) / 10;
if (result >= INT_MAX) return INT_MAX;
else return (int) result;
}
}

/*
Expand Down Expand Up @@ -599,7 +607,7 @@ erts_garbage_collect_literals(Process* p, Eterm* literals, Uint lit_size)
char* area;
Uint area_size;
Eterm* old_htop;
int n;
Uint n;

/*
* Set GC state.
Expand Down Expand Up @@ -731,7 +739,7 @@ minor_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl)
* This improved Estone by more than 1200 estones on my computer
* (Ultra Sparc 10).
*/
size_t new_sz = erts_next_heap_size(HEAP_TOP(p) - HEAP_START(p), 1);
Uint new_sz = erts_next_heap_size(HEAP_TOP(p) - HEAP_START(p), 1);

/* Create new, empty old_heap */
n_old = (Eterm *) ERTS_HEAP_ALLOC(ERTS_ALC_T_OLD_HEAP,
Expand Down Expand Up @@ -871,12 +879,12 @@ minor_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl)
#endif /* HIPE */

static void
do_minor(Process *p, int new_sz, Eterm* objv, int nobj)
do_minor(Process *p, Uint new_sz, Eterm* objv, int nobj)
{
Rootset rootset; /* Rootset for GC (stack, dictionary, etc). */
Roots* roots;
Eterm* n_htop;
int n;
Uint n;
Eterm* ptr;
Eterm val;
Eterm gval;
Expand Down Expand Up @@ -1079,14 +1087,14 @@ major_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl)
{
Rootset rootset;
Roots* roots;
int size_before;
Uint size_before;
Eterm* n_heap;
Eterm* n_htop;
char* src = (char *) HEAP_START(p);
Uint src_size = (char *) HEAP_TOP(p) - src;
char* oh = (char *) OLD_HEAP(p);
Uint oh_size = (char *) OLD_HTOP(p) - oh;
int n;
Uint n;
Uint new_sz;
Uint fragments = MBUF_SIZE(p) + combined_message_size(p);
ErlMessage *msgp;
Expand Down Expand Up @@ -1312,10 +1320,10 @@ major_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl)
}

static Uint
adjust_after_fullsweep(Process *p, int size_before, int need, Eterm *objv, int nobj)
adjust_after_fullsweep(Process *p, Uint size_before, int need, Eterm *objv, int nobj)
{
int wanted, sz, size_after, need_after;
int stack_size = STACK_SZ_ON_HEAP(p);
Uint wanted, sz, size_after, need_after;
Uint stack_size = STACK_SZ_ON_HEAP(p);
Uint reclaimed_now;

size_after = (HEAP_TOP(p) - HEAP_START(p));
Expand Down Expand Up @@ -1915,8 +1923,8 @@ static void
grow_new_heap(Process *p, Uint new_sz, Eterm* objv, int nobj)
{
Eterm* new_heap;
int heap_size = HEAP_TOP(p) - HEAP_START(p);
int stack_size = p->hend - p->stop;
Uint heap_size = HEAP_TOP(p) - HEAP_START(p);
Uint stack_size = p->hend - p->stop;
Sint offs;

ASSERT(HEAP_SIZE(p) < new_sz);
Expand Down Expand Up @@ -1954,10 +1962,10 @@ static void
shrink_new_heap(Process *p, Uint new_sz, Eterm *objv, int nobj)
{
Eterm* new_heap;
int heap_size = HEAP_TOP(p) - HEAP_START(p);
Uint heap_size = HEAP_TOP(p) - HEAP_START(p);
Sint offs;

int stack_size = p->hend - p->stop;
Uint stack_size = p->hend - p->stop;

ASSERT(new_sz < p->heap_sz);
sys_memmove(p->heap + new_sz - stack_size, p->stop, stack_size *
Expand Down
46 changes: 26 additions & 20 deletions erts/emulator/test/mtx_SUITE_data/mtx_SUITE.c
Expand Up @@ -552,13 +552,19 @@ create_rwlock(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
static ERL_NIF_TERM
rwlock_op(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
rwlock_resource_t *rwlr;
/*
* Use a union for pointer type conversion to avoid compiler warnings
* about strict-aliasing violations with gcc-4.1. gcc >= 4.2 does not
* emit the warning.
* TODO: Reconsider use of union once gcc-4.1 is obsolete?
*/
union { void* vp; rwlock_resource_t *p; } rwlr;
int blocking, write, wait_locked, wait_unlocked;

if (argc != 5)
goto badarg;

if (!enif_get_resource(env, argv[0], enif_priv_data(env), (void **) &rwlr))
if (!enif_get_resource(env, argv[0], enif_priv_data(env), &rwlr.vp))
goto badarg;

blocking = get_bool(env, argv[1]);
Expand All @@ -581,41 +587,41 @@ rwlock_op(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])

if (write) {
if (blocking)
RWMUTEX_WLOCK(rwlr->rwlock);
RWMUTEX_WLOCK(rwlr.p->rwlock);
else
while (EBUSY == RWMUTEX_TRYWLOCK(rwlr->rwlock));
if (rwlr->lock_check) {
ASSERT(!ATOMIC_READ(&rwlr->is_locked));
ATOMIC_SET(&rwlr->is_locked, -1);
while (EBUSY == RWMUTEX_TRYWLOCK(rwlr.p->rwlock));
if (rwlr.p->lock_check) {
ASSERT(!ATOMIC_READ(&rwlr.p->is_locked));
ATOMIC_SET(&rwlr.p->is_locked, -1);
}
}
else {
if (blocking)
RWMUTEX_RLOCK(rwlr->rwlock);
RWMUTEX_RLOCK(rwlr.p->rwlock);
else
while (EBUSY == RWMUTEX_TRYRLOCK(rwlr->rwlock));
if (rwlr->lock_check) {
ASSERT(ATOMIC_READ(&rwlr->is_locked) >= 0);
ATOMIC_INC(&rwlr->is_locked);
while (EBUSY == RWMUTEX_TRYRLOCK(rwlr.p->rwlock));
if (rwlr.p->lock_check) {
ASSERT(ATOMIC_READ(&rwlr.p->is_locked) >= 0);
ATOMIC_INC(&rwlr.p->is_locked);
}
}

if (wait_locked)
milli_sleep(wait_locked);

if (write) {
if (rwlr->lock_check) {
ASSERT(ATOMIC_READ(&rwlr->is_locked) == -1);
ATOMIC_SET(&rwlr->is_locked, 0);
if (rwlr.p->lock_check) {
ASSERT(ATOMIC_READ(&rwlr.p->is_locked) == -1);
ATOMIC_SET(&rwlr.p->is_locked, 0);
}
RWMUTEX_WUNLOCK(rwlr->rwlock);
RWMUTEX_WUNLOCK(rwlr.p->rwlock);
}
else {
if (rwlr->lock_check) {
ASSERT(ATOMIC_READ(&rwlr->is_locked) > 0);
ATOMIC_DEC(&rwlr->is_locked);
if (rwlr.p->lock_check) {
ASSERT(ATOMIC_READ(&rwlr.p->is_locked) > 0);
ATOMIC_DEC(&rwlr.p->is_locked);
}
RWMUTEX_RUNLOCK(rwlr->rwlock);
RWMUTEX_RUNLOCK(rwlr.p->rwlock);
}

if (wait_unlocked)
Expand Down
38 changes: 23 additions & 15 deletions erts/emulator/test/nif_SUITE_data/nif_SUITE.c
Expand Up @@ -41,7 +41,18 @@ typedef struct
CallInfo* call_history;
NifModPrivData* nif_mod;
union { ErlNifResourceType* t; long l; } rt_arr[2];
}PrivData;
} PrivData;

/*
* Use a union for pointer type conversion to avoid compiler warnings
* about strict-aliasing violations with gcc-4.1. gcc >= 4.2 does not
* emit the warning.
* TODO: Reconsider use of union once gcc-4.1 is obsolete?
*/
typedef union {
void* vp;
struct make_term_info* p;
} mti_t;

void add_call(ErlNifEnv* env, PrivData* data, const char* func_name)
{
Expand Down Expand Up @@ -707,7 +718,7 @@ static ERL_NIF_TERM get_resource_type(ErlNifEnv* env, int argc, const ERL_NIF_TE
static ERL_NIF_TERM alloc_resource(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
ErlNifBinary data_bin;
union { ErlNifResourceType* t; long l;} type;
union { ErlNifResourceType* t; long l; } type;
union { void* p; long l;} data;
if (!enif_get_long(env, argv[0], &type.l)
|| !enif_inspect_binary(env, argv[1], &data_bin)
Expand All @@ -731,7 +742,7 @@ static ERL_NIF_TERM make_resource(ErlNifEnv* env, int argc, const ERL_NIF_TERM a
static ERL_NIF_TERM make_new_resource(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
ErlNifBinary data_bin;
union { ErlNifResourceType* t; long l;} type;
union { ErlNifResourceType* t; long l; } type;
void* data;
ERL_NIF_TERM ret;
if (!enif_get_long(env, argv[0], &type.l)
Expand All @@ -749,7 +760,7 @@ static ERL_NIF_TERM make_new_resource(ErlNifEnv* env, int argc, const ERL_NIF_TE
static ERL_NIF_TERM make_new_resource_binary(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
ErlNifBinary data_bin;
union { struct binary_resource* p; void* vp; long l;} br;
union { struct binary_resource* p; void* vp; long l; } br;
void* buf;
ERL_NIF_TERM ret;
if (!enif_inspect_binary(env, argv[0], &data_bin)
Expand Down Expand Up @@ -1269,10 +1280,7 @@ static void msgenv_dtor(ErlNifEnv* env, void* obj)

static ERL_NIF_TERM clear_msgenv(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union {
void* vp;
struct make_term_info* p;
}mti;
mti_t mti;
if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)) {
return enif_make_badarg(env);
}
Expand All @@ -1285,7 +1293,7 @@ static ERL_NIF_TERM clear_msgenv(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar

static ERL_NIF_TERM grow_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
ERL_NIF_TERM term;
if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)
|| (argc>2 && !enif_get_uint(env,argv[2], &mti.p->n))) {
Expand All @@ -1301,7 +1309,7 @@ static ERL_NIF_TERM grow_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[

static ERL_NIF_TERM send_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
ErlNifPid to;
ERL_NIF_TERM copy;
int res;
Expand All @@ -1316,7 +1324,7 @@ static ERL_NIF_TERM send_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[

static ERL_NIF_TERM send3_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
ErlNifPid to;
ERL_NIF_TERM copy;
int res;
Expand All @@ -1334,7 +1342,7 @@ static ERL_NIF_TERM send3_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv
void* threaded_sender(void *arg)
{

union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
mti.vp = arg;

enif_mutex_lock(mti.p->mtx);
Expand All @@ -1349,7 +1357,7 @@ void* threaded_sender(void *arg)

static ERL_NIF_TERM send_blob_thread(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
ERL_NIF_TERM copy;
if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)
|| !enif_get_local_pid(env,argv[1], &mti.p->to_pid)) {
Expand All @@ -1375,7 +1383,7 @@ static ERL_NIF_TERM send_blob_thread(ErlNifEnv* env, int argc, const ERL_NIF_TER

static ERL_NIF_TERM join_send_thread(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
int err;
if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)) {
return enif_make_badarg(env);
Expand All @@ -1392,7 +1400,7 @@ static ERL_NIF_TERM join_send_thread(ErlNifEnv* env, int argc, const ERL_NIF_TER

static ERL_NIF_TERM copy_blob(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
union { void* vp; struct make_term_info* p; }mti;
mti_t mti;
if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)) {
return enif_make_badarg(env);
}
Expand Down

0 comments on commit 756a93c

Please sign in to comment.