Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Merge branch 'sverk/map-merge-trap'
Browse files Browse the repository at this point in the history
* sverk/map-merge-trap:
  erts: Optimize maps:merge
  erts: Yield in maps:merge
  erts: Refactor arg swapping for maps:merge
  erts: Add save/restore for PSTACK
  erts: Fix magic binary alignment on 32-bit
  erts: Add maps to send_term_SUITE
  erts: Fix calculation of reclaimed data during full gc
  erts: Fix warning about const pointer to make_boxed and make_list
  erts: Fix typo in etp-carrier-blocks
  • Loading branch information
sverker committed Jun 15, 2015
2 parents b130093 + f7ef9fb commit 0aa4393
Show file tree
Hide file tree
Showing 14 changed files with 492 additions and 247 deletions.
1 change: 1 addition & 0 deletions erts/emulator/beam/atom.names
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ atom message
atom message_binary
atom message_queue_len
atom messages
atom merge_trap
atom meta
atom meta_match_spec
atom micro_seconds
Expand Down
18 changes: 15 additions & 3 deletions erts/emulator/beam/erl_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ ERTS_GLB_INLINE Binary *erts_bin_nrml_alloc(Uint size);
ERTS_GLB_INLINE Binary *erts_bin_realloc_fnf(Binary *bp, Uint size);
ERTS_GLB_INLINE Binary *erts_bin_realloc(Binary *bp, Uint size);
ERTS_GLB_INLINE void erts_bin_free(Binary *bp);
ERTS_GLB_INLINE Binary *erts_create_magic_binary_x(Uint size,
void (*destructor)(Binary *),
int unaligned);
ERTS_GLB_INLINE Binary *erts_create_magic_binary(Uint size,
void (*destructor)(Binary *));

Expand Down Expand Up @@ -332,21 +335,30 @@ erts_bin_free(Binary *bp)
}

ERTS_GLB_INLINE Binary *
erts_create_magic_binary(Uint size, void (*destructor)(Binary *))
erts_create_magic_binary_x(Uint size, void (*destructor)(Binary *),
int unaligned)
{
Uint bsize = ERTS_MAGIC_BIN_SIZE(size);
Uint bsize = unaligned ? ERTS_MAGIC_BIN_UNALIGNED_SIZE(size)
: ERTS_MAGIC_BIN_SIZE(size);
Binary* bptr = erts_alloc_fnf(ERTS_ALC_T_BINARY, bsize);
ASSERT(bsize > size);
if (!bptr)
erts_alloc_n_enomem(ERTS_ALC_T2N(ERTS_ALC_T_BINARY), bsize);
ERTS_CHK_BIN_ALIGNMENT(bptr);
bptr->flags = BIN_FLAG_MAGIC;
bptr->orig_size = ERTS_MAGIC_BIN_ORIG_SIZE(size);
bptr->orig_size = unaligned ? ERTS_MAGIC_BIN_UNALIGNED_ORIG_SIZE(size)
: ERTS_MAGIC_BIN_ORIG_SIZE(size);
erts_refc_init(&bptr->refc, 0);
ERTS_MAGIC_BIN_DESTRUCTOR(bptr) = destructor;
return bptr;
}

ERTS_GLB_INLINE Binary *
erts_create_magic_binary(Uint size, void (*destructor)(Binary *))
{
return erts_create_magic_binary_x(size, destructor, 0);
}

#endif /* #if ERTS_GLB_INLINE_INCL_FUNC_DEF */

#endif /* !__ERL_BINARY_H */
8 changes: 8 additions & 0 deletions erts/emulator/beam/erl_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ erts_bits_destroy_state(ERL_BITS_PROTO_0)
void
erts_init_bits(void)
{
ERTS_CT_ASSERT(offsetof(Binary,orig_bytes) % 8 == 0);
ERTS_CT_ASSERT(offsetof(ErtsMagicBinary,u.aligned.data) % 8 == 0);
ERTS_CT_ASSERT(ERTS_MAGIC_BIN_BYTES_TO_ALIGN ==
(offsetof(ErtsMagicBinary,u.aligned.data)
- offsetof(ErtsMagicBinary,u.unaligned.data)));
ERTS_CT_ASSERT(offsetof(ErtsBinary,driver.binary.orig_bytes)
== offsetof(Binary,orig_bytes));

erts_smp_atomic_init_nob(&bits_bufs_size, 0);
#if defined(ERTS_SMP)
/* erl_process.c calls erts_bits_init_state() on all state instances */
Expand Down
3 changes: 2 additions & 1 deletion erts/emulator/beam/erl_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,8 @@ major_collection(Process* p, int need, Eterm* objv, int nobj, Uint *recl)
Uint new_sz;
Uint fragments = MBUF_SIZE(p) + combined_message_size(p);

size_before = fragments + (HEAP_TOP(p) - HEAP_START(p));
size_before = fragments + (HEAP_TOP(p) - HEAP_START(p))
+ (OLD_HTOP(p) - OLD_HEAP(p));

/*
* Do a fullsweep GC. First figure out the size of the heap
Expand Down
1 change: 1 addition & 0 deletions erts/emulator/beam/erl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ erl_init(int ncpu,
erts_init_bif_re();
erts_init_unicode(); /* after RE to get access to PCRE unicode */
erts_init_external();
erts_init_map();
erts_delay_trap = erts_export_put(am_erlang, am_delay_trap, 2);
erts_late_init_process();
#if HAVE_ERTS_MSEG
Expand Down
Loading

0 comments on commit 0aa4393

Please sign in to comment.