From 6d366f0ae53669a17de96db0094ef62217b60f1b Mon Sep 17 00:00:00 2001 From: happi Date: Fri, 3 May 2013 16:25:37 +0200 Subject: Make term_to_binary yield (trap). --- erts/emulator/beam/erl_gc.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'erts/emulator/beam/erl_gc.c') diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index 0d12e658d9..2c219ee87c 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -1964,6 +1964,15 @@ setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) ++n; } + // Check if a suspended bif has live working data. + // How do we know n is small enough to fit in roots[32?]? + if (p->extra_root != NULL) { + printf("GC with extra_root 0x%xl\n", p->extra_root); + roots[n].v = p->extra_root; + roots[n].sz = p->extra_root_sz; + ++n; + } + ASSERT((is_nil(p->seq_trace_token) || is_tuple(follow_moved(p->seq_trace_token)) || is_atom(p->seq_trace_token))); -- cgit v1.2.3 From 47d6fd3ccf35a4d921591dd0a9b5e69b9804b5b0 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Wed, 5 Jun 2013 12:02:11 +0200 Subject: Make all steps ofterm_to_binary work in chunks and yield Rewrite and extend of Happi's initial work Extra_root to process structure to enable GC of state - Changed the process structure to point to a separate struct, the struct also contains a destructor function to allow for proper cleanup. Rewrote encode_size_struct and enc_term to have internal versions with reduction counters which will result in interrupt for later restart when the counter reaches zero - removed the EWA_STACK from Happis version and directly save the ESTACK's and WSTACK's in the above mentioned struct (or array thereof) that are pointed out from the process structure. The destructor will take care of the deallocation in case of process death. Added ESTACK and WSTACK macros to save and restore stack and to change allocator, which makes the previously mentioned stack-save work. Rewrote enc_term to not store pointers on the stack, and use one WSTACK for commands etc and another ESTACK for Eterms - Slightly different than Happis version to make halfword code simpler. Rewrote encode_size_struct2 so that it does not store pointers on the stack, also switched to ESTACK instead of WSTACK, this also handles halfword correctly. Added interfaces for chunkwise compression, that are used from term_to_binary/2 when the compressed option is given. --- erts/emulator/beam/erl_gc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'erts/emulator/beam/erl_gc.c') diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index 2c219ee87c..da0f46e556 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -1964,15 +1964,20 @@ setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) ++n; } - // Check if a suspended bif has live working data. - // How do we know n is small enough to fit in roots[32?]? + /* + * A trapping BIF can add to rootset by setting the extra_root + * in the process_structure. + */ if (p->extra_root != NULL) { - printf("GC with extra_root 0x%xl\n", p->extra_root); - roots[n].v = p->extra_root; - roots[n].sz = p->extra_root_sz; - ++n; +#ifdef HARDDEBUG + erts_fprintf(stderr,"GC with extra root 0x%xl\n", p->extra_root->objv); +#endif + roots[n].v = p->extra_root->objv; + roots[n].sz = p->extra_root->sz; + ++n; } + ASSERT((is_nil(p->seq_trace_token) || is_tuple(follow_moved(p->seq_trace_token)) || is_atom(p->seq_trace_token))); -- cgit v1.2.3 From 2b4707d10b6ea5656242f5ae8506969c921ac841 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Thu, 6 Jun 2013 08:20:20 +0200 Subject: Teach erl_gc:offset_rootset about extra_root --- erts/emulator/beam/erl_gc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'erts/emulator/beam/erl_gc.c') diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index da0f46e556..7b463958d2 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -2555,6 +2555,12 @@ offset_one_rootset(Process *p, Sint offs, char* area, Uint area_size, p->dictionary->used, offs, area, area_size); } + if (p->extra_root != NULL) { + offset_heap_ptr(p->extra_root->objv, + p->extra_root->sz, + offs, area, area_size); + } + offset_heap_ptr(&p->fvalue, 1, offs, area, area_size); offset_heap_ptr(&p->ftrace, 1, offs, area, area_size); offset_heap_ptr(&p->seq_trace_token, 1, offs, area, area_size); -- cgit v1.2.3 From 6318211b480cec0b74170d4db962e7e9b374f895 Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Mon, 10 Jun 2013 14:48:37 +0200 Subject: term_to_binary: Remove debug code and set production trap levels --- erts/emulator/beam/erl_gc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'erts/emulator/beam/erl_gc.c') diff --git a/erts/emulator/beam/erl_gc.c b/erts/emulator/beam/erl_gc.c index 7b463958d2..8ba94d89e9 100644 --- a/erts/emulator/beam/erl_gc.c +++ b/erts/emulator/beam/erl_gc.c @@ -1969,9 +1969,6 @@ setup_rootset(Process *p, Eterm *objv, int nobj, Rootset *rootset) * in the process_structure. */ if (p->extra_root != NULL) { -#ifdef HARDDEBUG - erts_fprintf(stderr,"GC with extra root 0x%xl\n", p->extra_root->objv); -#endif roots[n].v = p->extra_root->objv; roots[n].sz = p->extra_root->sz; ++n; -- cgit v1.2.3