Skip to content

Commit

Permalink
Mending halfword heap emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
sverker committed Jul 22, 2010
1 parent 9267b2d commit 78bb45a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion erts/emulator/beam/beam_bp.h
Expand Up @@ -123,7 +123,7 @@ typedef struct {
Uint ms;
Uint s;
Uint us;
Uint *pc;
BeamInstr *pc;
} process_breakpoint_time_t; /* used within psd */

extern erts_smp_spinlock_t erts_bp_lock;
Expand Down
10 changes: 5 additions & 5 deletions erts/emulator/beam/beam_emu.c
Expand Up @@ -4463,7 +4463,7 @@ void process_main(void)
E -= 2;
E[0] = make_cp(I);
E[1] = make_cp(c_p->cp); /* original return address */
c_p->cp = (BeamInstr *) make_cp(beam_return_time_trace);
c_p->cp = beam_return_time_trace;
}
}

Expand Down Expand Up @@ -4493,20 +4493,20 @@ void process_main(void)
BeamInstr real_I;
Uint32 flags;
Eterm tracer_pid;
BeamInstr *cpp;
Uint* cpp;
int return_to_trace = 0, need = 0;
flags = 0;
SWAPOUT;
reg[0] = r(0);

if (*(c_p->cp) == (BeamInstr) OpCode(return_trace)) {
cpp = (BeamInstr*)&E[2];
cpp = &E[2];
} else if (*(c_p->cp) == (BeamInstr) OpCode(i_return_to_trace)) {
return_to_trace = !0;
cpp = (BeamInstr*)&E[0];
cpp = &E[0];
} else if (*(c_p->cp) == (BeamInstr) OpCode(i_return_time_trace)) {
return_to_trace = !0;
cpp = (BeamInstr*)&E[0];
cpp = &E[0];
} else {
cpp = NULL;
}
Expand Down
9 changes: 6 additions & 3 deletions erts/emulator/beam/erl_gc.c
Expand Up @@ -146,6 +146,9 @@ erts_init_gc(void)
ASSERT(offsetof(ProcBin,thing_word) == offsetof(struct erl_off_heap_header,thing_word));
ASSERT(offsetof(ProcBin,thing_word) == offsetof(ErlFunThing,thing_word));
ASSERT(offsetof(ProcBin,thing_word) == offsetof(ExternalThing,header));
ASSERT(offsetof(ProcBin,size) == offsetof(struct erl_off_heap_header,size));
ASSERT(offsetof(ProcBin,size) == offsetof(ErlSubBin,size));
ASSERT(offsetof(ProcBin,size) == offsetof(ErlHeapBin,size));
ASSERT(offsetof(ProcBin,next) == offsetof(struct erl_off_heap_header,next));
ASSERT(offsetof(ProcBin,next) == offsetof(ErlFunThing,next));
ASSERT(offsetof(ProcBin,next) == offsetof(ExternalThing,next));
Expand Down Expand Up @@ -2111,9 +2114,9 @@ sweep_off_heap(Process *p, int fullsweep)
int to_new_heap = !in_area(ptr, oheap, oheap_sz);
ASSERT(to_new_heap == !seen_mature || (!to_new_heap && (seen_mature=1)));
if (to_new_heap) {
bin_vheap += ptr->u.size / sizeof(Eterm);
bin_vheap += ptr->size / sizeof(Eterm);
} else {
BIN_OLD_VHEAP(p) += ptr->u.size / sizeof(Eterm); /* for binary gc (words)*/
BIN_OLD_VHEAP(p) += ptr->size / sizeof(Eterm); /* for binary gc (words)*/
}
link_live_proc_bin(&shrink, &prev, &ptr, to_new_heap);
}
Expand Down Expand Up @@ -2157,7 +2160,7 @@ sweep_off_heap(Process *p, int fullsweep)
ASSERT(in_area(ptr, oheap, oheap_sz));
ASSERT(!IS_MOVED_BOXED(ptr->thing_word));
if (ptr->thing_word == HEADER_PROC_BIN) {
BIN_OLD_VHEAP(p) += ptr->u.size / sizeof(Eterm); /* for binary gc (words)*/
BIN_OLD_VHEAP(p) += ptr->size / sizeof(Eterm); /* for binary gc (words)*/
link_live_proc_bin(&shrink, &prev, &ptr, 0);
}
else {
Expand Down
8 changes: 4 additions & 4 deletions erts/emulator/beam/erl_message.h
Expand Up @@ -30,10 +30,10 @@ struct external_thing_;

struct erl_off_heap_header {
Eterm thing_word;
union {
Uint size;
void* ptr;
}u;
Uint size;
#if HALFWORD_HEAP
void* dummy_ptr_padding__;
#endif
struct erl_off_heap_header* next;
};

Expand Down
11 changes: 7 additions & 4 deletions erts/emulator/beam/erl_term.h
Expand Up @@ -821,10 +821,10 @@ _ET_DECLARE_CHECKED(struct erl_node_*,internal_ref_node,Eterm)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |A A A A A A A A A A A A A A A A A A A A A A A A A A|t t t t|0 0| Thing
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N| Next
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |E E E E E E E E E E E E E E E E E E E E E E E E E E E E E E E E| ErlNode
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N| Next
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X| Data 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* . . .
Expand All @@ -835,7 +835,7 @@ _ET_DECLARE_CHECKED(struct erl_node_*,internal_ref_node,Eterm)
* t : External pid thing tag (1100)
* t : External port thing tag (1101)
* t : External ref thing tag (1110)
* N : Next (external thing) pointer
* N : Next (off_heap) pointer
* E : ErlNode pointer
* X : Type specific data
*
Expand All @@ -852,8 +852,11 @@ _ET_DECLARE_CHECKED(struct erl_node_*,internal_ref_node,Eterm)
/* XXX:PaN - this structure is not perfect for halfword heap, it takes
a lot of memory due to padding, and the array will not begin at the end of the
structure, as otherwise expected. Be sure to access data.ui32 array and not try
to do pointer manipulation on an Eterm * to reach the actual data... */
to do pointer manipulation on an Eterm * to reach the actual data...
XXX:Sverk - Problem made worse by "one off-heap list" when 'next' pointer
must align with 'next' in ProcBin, erl_fun_thing and erl_off_heap_header.
*/
typedef struct external_thing_ {
/* ----+ */
Eterm header; /* | */
Expand Down
2 changes: 1 addition & 1 deletion erts/emulator/beam/global.h
Expand Up @@ -465,7 +465,7 @@ typedef struct proc_bin {
Eterm thing_word; /* Subtag REFC_BINARY_SUBTAG. */
Uint size; /* Binary size in bytes. */
#if HALFWORD_HEAP
char alignment__[SIZEOF_VOID_P - ERTS_SIZEOF_ETERM];
void* dummy_ptr_padding__;
#endif
struct erl_off_heap_header *next;
Binary *val; /* Pointer to Binary structure. */
Expand Down

0 comments on commit 78bb45a

Please sign in to comment.