diff options
author | Sverker Eriksson <sverker@erlang.org> | 2019-11-12 15:28:07 +0100 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2020-01-14 15:20:17 +0100 |
commit | fc309a039a4d817725d7b9887a36d2c501a83679 (patch) | |
tree | 1039453d07d003d1881166357aa2e519c1a247e1 /erts/emulator/beam | |
parent | 69d79d8cee4bb0f492209b1cf0d830b402319b03 (diff) | |
download | erlang-fc309a039a4d817725d7b9887a36d2c501a83679.tar.gz |
Improve distribution handshake
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/bif.tab | 8 | ||||
-rw-r--r-- | erts/emulator/beam/dist.c | 174 | ||||
-rw-r--r-- | erts/emulator/beam/dist.h | 71 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_info.c | 6 | ||||
-rw-r--r-- | erts/emulator/beam/erl_node_tables.c | 13 | ||||
-rw-r--r-- | erts/emulator/beam/erl_node_tables.h | 5 | ||||
-rw-r--r-- | erts/emulator/beam/external.c | 136 | ||||
-rw-r--r-- | erts/emulator/beam/external.h | 8 |
8 files changed, 242 insertions, 179 deletions
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab index 7e36cf925a..3c52716fae 100644 --- a/erts/emulator/beam/bif.tab +++ b/erts/emulator/beam/bif.tab @@ -196,7 +196,7 @@ bif erts_internal:scheduler_wall_time/1 bif erts_internal:dirty_process_handle_signals/1 -bif erts_internal:create_dist_channel/4 +bif erts_internal:create_dist_channel/3 bif erts_internal:ets_super_user/1 @@ -764,3 +764,9 @@ bif erts_internal:ets_raw_next/2 bif erts_internal:abort_pending_connection/2 + +# +# New in 23 +# + +bif erts_internal:get_creation/0 diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c index f411da3f36..03e2e0b116 100644 --- a/erts/emulator/beam/dist.c +++ b/erts/emulator/beam/dist.c @@ -961,7 +961,7 @@ int erts_do_net_exits(DistEntry *dep, Eterm reason) ErtsAtomCache *cache; ErtsProcList *suspendees; ErtsDistOutputBuf *obuf; - Uint32 flags; + Uint64 flags; erts_atomic_set_mb(&dep->dist_cmd_scheduled, 1); erts_de_rwlock(dep); @@ -991,7 +991,7 @@ int erts_do_net_exits(DistEntry *dep, Eterm reason) dep->sequences = NULL; nodename = dep->sysname; - flags = dep->flags; + flags = dep->dflags; erts_atomic_set_nob(&dep->input_handler, (erts_aint_t) NIL); cache = dep->cache; @@ -1081,14 +1081,27 @@ void init_dist(void) am_erts_internal, am_spawn_request_yield, 3, spawn_request_yield_3); { - Eterm* hp = erts_alloc(ERTS_ALC_T_LITERAL, (1+6)*sizeof(Eterm)); - erts_dflags_record = TUPLE6(hp, am_erts_dflags, - make_small(DFLAG_DIST_DEFAULT), - make_small(DFLAG_DIST_MANDATORY), - make_small(DFLAG_DIST_ADDABLE), - make_small(DFLAG_DIST_REJECTABLE), - make_small(DFLAG_DIST_STRICT_ORDER)); - erts_set_literal_tag(&erts_dflags_record, hp, (1+6)); + Eterm *hp_start, *hp, **hpp = NULL; + Uint sz = 0, *szp = &sz; + while (1) { + erts_dflags_record = + erts_bld_tuple(hpp, szp, 6, + am_erts_dflags, + erts_bld_uint64(hpp, szp, DFLAG_DIST_DEFAULT), + erts_bld_uint64(hpp, szp, DFLAG_DIST_MANDATORY), + erts_bld_uint64(hpp, szp, DFLAG_DIST_ADDABLE), + erts_bld_uint64(hpp, szp, DFLAG_DIST_REJECTABLE), + erts_bld_uint64(hpp, szp, DFLAG_DIST_STRICT_ORDER)); + if (hpp) { + ASSERT(is_value(erts_dflags_record)); + ASSERT(hp == hp_start + sz); + erts_set_literal_tag(&erts_dflags_record, hp_start, sz); + break; + } + hp = hp_start = erts_alloc(ERTS_ALC_T_LITERAL, sz*sizeof(Eterm)); + hpp = &hp; + szp = NULL; + } } } @@ -1305,14 +1318,14 @@ erts_dsig_send_m_exit(ErtsDSigSendContext *ctx, Eterm watcher, Eterm watched, { Eterm ctl, msg; - if (~ctx->flags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { + if (~ctx->dflags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { /* * Receiver does not support DOP_MONITOR_P_EXIT (see dsig_send_monitor) */ return ERTS_DSIG_SEND_OK; } - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) { + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) { ctl = TUPLE4(&ctx->ctl_heap[0], make_small(DOP_PAYLOAD_MONITOR_P_EXIT), watched, watcher, ref); msg = reason; @@ -1334,7 +1347,7 @@ erts_dsig_send_monitor(ErtsDSigSendContext *ctx, Eterm watcher, Eterm watched, { Eterm ctl; - if (~ctx->flags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { + if (~ctx->dflags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { /* * Receiver does not support DOP_MONITOR_P. * Just avoid sending it and by doing that reduce this monitor @@ -1360,7 +1373,7 @@ erts_dsig_send_demonitor(ErtsDSigSendContext *ctx, Eterm watcher, { Eterm ctl; - if (~ctx->flags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { + if (~ctx->dflags & (DFLAG_DIST_MONITOR | DFLAG_DIST_MONITOR_NAME)) { /* * Receiver does not support DOP_DEMONITOR_P (see dsig_send_monitor) */ @@ -1377,7 +1390,7 @@ erts_dsig_send_demonitor(ErtsDSigSendContext *ctx, Eterm watcher, static int can_send_seqtrace_token(ErtsDSigSendContext* ctx, Eterm token) { Eterm label; - if (ctx->flags & DFLAG_BIG_SEQTRACE_LABELS) { + if (ctx->dflags & DFLAG_BIG_SEQTRACE_LABELS) { /* The other end is capable of handling arbitrary seq_trace labels. */ return 1; } @@ -1438,7 +1451,7 @@ erts_dsig_send_msg(ErtsDSigSendContext* ctx, Eterm remote, Eterm message) send_token = (token != NIL && can_send_seqtrace_token(ctx, token)); - if (ctx->flags & DFLAG_SEND_SENDER) { + if (ctx->dflags & DFLAG_SEND_SENDER) { dist_op = make_small(send_token ? DOP_SEND_SENDER_TT : DOP_SEND_SENDER); @@ -1540,20 +1553,20 @@ erts_dsig_send_exit_tt(ErtsDSigSendContext *ctx, Eterm local, Eterm remote, DTRACE_CHARBUF(reason_str, 128); #endif - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) msg = reason; if (have_seqtrace(token)) { seq_trace_update_serial(ctx->c_p); seq_trace_output_exit(token, reason, SEQ_TRACE_SEND, remote, local); - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) { + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) { ctl = TUPLE4(&ctx->ctl_heap[0], make_small(DOP_PAYLOAD_EXIT_TT), local, remote, token); } else ctl = TUPLE5(&ctx->ctl_heap[0], make_small(DOP_EXIT_TT), local, remote, token, reason); } else { - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) ctl = TUPLE3(&ctx->ctl_heap[0], make_small(DOP_PAYLOAD_EXIT), local, remote); else ctl = TUPLE4(&ctx->ctl_heap[0], make_small(DOP_EXIT), local, remote, reason); @@ -1584,9 +1597,9 @@ erts_dsig_send_exit_tt(ErtsDSigSendContext *ctx, Eterm local, Eterm remote, int erts_dsig_send_exit(ErtsDSigSendContext *ctx, Eterm local, Eterm remote, Eterm reason) { - Eterm ctl, msg = ctx->dep->flags & DFLAG_EXIT_PAYLOAD ? reason : THE_NON_VALUE; + Eterm ctl, msg = ctx->dep->dflags & DFLAG_EXIT_PAYLOAD ? reason : THE_NON_VALUE; - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) { + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) { ctl = TUPLE3(&ctx->ctl_heap[0], make_small(DOP_PAYLOAD_EXIT), local, remote); msg = reason; } else { @@ -1601,7 +1614,7 @@ erts_dsig_send_exit2(ErtsDSigSendContext *ctx, Eterm local, Eterm remote, Eterm { Eterm ctl, msg; - if (ctx->dep->flags & DFLAG_EXIT_PAYLOAD) { + if (ctx->dep->dflags & DFLAG_EXIT_PAYLOAD) { ctl = TUPLE3(&ctx->ctl_heap[0], make_small(DOP_PAYLOAD_EXIT2), local, remote); msg = reason; @@ -2249,7 +2262,7 @@ int erts_net_message(Port *prt, * the atom '' (empty cookie). */ ASSERT((type == DOP_SEND_SENDER || type == DOP_SEND_SENDER_TT) - ? (is_pid(tuple[2]) && (dep->flags & DFLAG_SEND_SENDER)) + ? (is_pid(tuple[2]) && (dep->dflags & DFLAG_SEND_SENDER)) : tuple[2] == am_Empty); #ifdef ERTS_DIST_MSG_DBG @@ -2859,7 +2872,7 @@ retry: ctx->connection_id = dep->connection_id; ctx->no_suspend = no_suspend; ctx->no_trap = no_trap; - ctx->flags = dep->flags; + ctx->dflags = dep->dflags; ctx->return_term = am_true; ctx->phase = ERTS_DSIG_SEND_PHASE_INIT; ctx->from = proc ? proc->common.id : am_undefined; @@ -2926,7 +2939,7 @@ erts_dsig_send(ErtsDSigSendContext *ctx) if (!erts_is_alive) return ERTS_DSIG_SEND_OK; - if (ctx->flags & DFLAG_DIST_HDR_ATOM_CACHE) { + if (ctx->dflags & DFLAG_DIST_HDR_ATOM_CACHE) { ctx->acmp = erts_get_atom_cache_map(ctx->c_p); } else { @@ -2944,7 +2957,7 @@ erts_dsig_send(ErtsDSigSendContext *ctx) ctx->data_size = 0; erts_reset_atom_cache_map(ctx->acmp); - ERTS_INIT_TTBSizeContext(&ctx->u.sc, ctx->flags); + ERTS_INIT_TTBSizeContext(&ctx->u.sc, ctx->dflags); while (1) { ErtsExtSzRes sz_res; @@ -3010,9 +3023,9 @@ erts_dsig_send(ErtsDSigSendContext *ctx) } case ERTS_DSIG_SEND_PHASE_ALLOC: { - erts_finalize_atom_cache_map(ctx->acmp, ctx->flags); + erts_finalize_atom_cache_map(ctx->acmp, ctx->dflags); - ERTS_INIT_TTBEncodeContext(&ctx->u.ec, ctx->flags); + ERTS_INIT_TTBEncodeContext(&ctx->u.ec, ctx->dflags); ctx->dhdr_ext_size = erts_encode_ext_dist_header_size(&ctx->u.ec, ctx->acmp, ctx->fragments); @@ -3037,7 +3050,7 @@ erts_dsig_send(ErtsDSigSendContext *ctx) Sint reds = CONTEXT_REDS; /* Encode control message */ int res = erts_encode_dist_ext(ctx->ctl, &ctx->extp, - ctx->flags, ctx->acmp, + ctx->dflags, ctx->acmp, &ctx->u.ec, &ctx->fragments, &reds); ctx->reds -= CONTEXT_REDS - reds; @@ -3062,7 +3075,7 @@ erts_dsig_send(ErtsDSigSendContext *ctx) } while (1) { int res = erts_encode_dist_ext(ctx->msg, &ctx->extp, - ctx->flags, ctx->acmp, + ctx->dflags, ctx->acmp, &ctx->u.ec, &ctx->fragments, redsp); @@ -3493,7 +3506,7 @@ erts_dist_command(Port *prt, int initial_reds) { Sint reds = initial_reds - ERTS_PORT_REDS_DIST_CMD_START; enum dist_entry_state state; - Uint32 flags; + Uint64 flags; Sint qsize, obufsize = 0; ErtsDistOutputQueue oq, foq; DistEntry *dep = (DistEntry*) erts_prtsd_get(prt, ERTS_PRTSD_DIST_ENTRY); @@ -3506,7 +3519,7 @@ erts_dist_command(Port *prt, int initial_reds) erts_atomic_set_mb(&dep->dist_cmd_scheduled, 0); erts_de_rlock(dep); - flags = dep->flags; + flags = dep->dflags; state = dep->state; send = dep->send; erts_de_runlock(dep); @@ -4131,7 +4144,7 @@ dist_ctrl_get_data_1(BIF_ALIST_1) obuf = dep->tmp_out_queue.first; obufsize += size_obuf(obuf); - reds = erts_encode_ext_dist_header_finalize(obuf, dep, dep->flags, reds); + reds = erts_encode_ext_dist_header_finalize(obuf, dep, dep->dflags, reds); obufsize -= size_obuf(obuf); if (reds < 0) { /* finalize needs to be restarted... */ erts_de_runlock(dep); @@ -4528,6 +4541,7 @@ BIF_RETTYPE setnode_2(BIF_ALIST_2) if (success) { inc_no_nodes(); erts_set_this_node(BIF_ARG_1, (Uint32) creation); + erts_this_dist_entry->creation = creation; erts_is_alive = 1; send_nodes_mon_msgs(NULL, am_nodeup, BIF_ARG_1, am_visible, NIL); erts_proc_lock(net_kernel, ERTS_PROC_LOCKS_ALL); @@ -4569,7 +4583,8 @@ BIF_RETTYPE setnode_2(BIF_ALIST_2) typedef struct { DistEntry *dep; int de_locked; - Uint flags; + Uint64 dflags; + Uint32 creation; Uint version; Eterm setup_pid; Process *net_kernel; @@ -4577,24 +4592,26 @@ typedef struct { static int setup_connection_epiloge_rwunlock(Process *c_p, DistEntry *dep, - Eterm ctrlr, Uint flags, - Uint version, Eterm setup_pid, + Eterm ctrlr, Uint64 flags, + Uint32 creation, Eterm setup_pid, Process *net_kernel); static Eterm setup_connection_distctrl(Process *c_p, void *arg, int *redsp, ErlHeapFragment **bpp); -BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) +BIF_RETTYPE erts_internal_create_dist_channel_3(BIF_ALIST_3) { BIF_RETTYPE ret; - Uint flags; + Uint64 flags; Uint version; + Uint32 creation; Eterm *hp, res_tag = THE_NON_VALUE, res = THE_NON_VALUE; DistEntry *dep = NULL; int de_locked = 0; Port *pp = NULL; int true_nk; + Eterm *tpl; Process *net_kernel = erts_whereis_process(BIF_P, ERTS_PROC_LOCK_MAIN, am_net_kernel, ERTS_PROC_LOCK_STATUS, @@ -4620,19 +4637,27 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) if (!is_internal_port(BIF_ARG_2) && !is_internal_pid(BIF_ARG_2)) goto badarg; + if (!is_tuple_arity(BIF_ARG_3, 3)) + goto badarg; + + tpl = tuple_val(BIF_ARG_3); + /* Dist flags... */ - if (!is_small(BIF_ARG_3)) + if (!term_to_Uint64(tpl[1], &flags)) goto badarg; - flags = unsigned_val(BIF_ARG_3); /* Version... */ - if (!is_small(BIF_ARG_4)) + if (!is_small(tpl[2])) goto badarg; - version = unsigned_val(BIF_ARG_4); + version = unsigned_val(tpl[2]); if (version == 0) goto badarg; + /* Creation... */ + if (!term_to_Uint32(tpl[3], &creation)) + goto badarg; + if (~flags & DFLAG_DIST_MANDATORY) { erts_dsprintf_buf_t *dsbufp = erts_create_logger_dsbuf(); erts_dsprintf(dsbufp, "%T", BIF_P->common.id); @@ -4673,7 +4698,8 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) scdc.dep = dep; scdc.de_locked = 1; - scdc.flags = flags; + scdc.dflags = flags; + scdc.creation = creation; scdc.version = version; scdc.setup_pid = BIF_P->common.id; scdc.net_kernel = net_kernel; @@ -4702,7 +4728,8 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) scdcp->dep = dep; scdcp->de_locked = 0; - scdcp->flags = flags; + scdcp->dflags = flags; + scdcp->creation = creation; scdcp->version = version; scdcp->setup_pid = BIF_P->common.id; scdcp->net_kernel = net_kernel; @@ -4777,7 +4804,7 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) conn_id = dep->connection_id; set_res = setup_connection_epiloge_rwunlock(BIF_P, dep, BIF_ARG_2, flags, - version, BIF_P->common.id, + creation, BIF_P->common.id, net_kernel); /* Dec of refc on net_kernel by setup_connection_epiloge_rwunlock() */ net_kernel = NULL; @@ -4823,9 +4850,9 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) dep->suspended_nodeup = BIF_P; erts_proc_inc_refc(BIF_P); erts_suspend(BIF_P, ERTS_PROC_LOCK_MAIN, NULL); - ERTS_BIF_PREP_YIELD4(ret, - &bif_trap_export[BIF_erts_internal_create_dist_channel_4], - BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3, BIF_ARG_4); + ERTS_BIF_PREP_YIELD3(ret, + &bif_trap_export[BIF_erts_internal_create_dist_channel_3], + BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3); goto done; badarg: @@ -4839,8 +4866,8 @@ BIF_RETTYPE erts_internal_create_dist_channel_4(BIF_ALIST_4) static int setup_connection_epiloge_rwunlock(Process *c_p, DistEntry *dep, - Eterm ctrlr, Uint flags, - Uint version, Eterm setup_pid, + Eterm ctrlr, Uint64 flags, + Uint32 creation, Eterm setup_pid, Process *net_kernel) { Eterm notify_proc = NIL; @@ -4869,8 +4896,7 @@ setup_connection_epiloge_rwunlock(Process *c_p, DistEntry *dep, if (!success) return 0; - dep->version = version; - dep->creation = 0; + dep->creation = creation; ASSERT(is_internal_port(ctrlr) || is_internal_pid(ctrlr)); ASSERT(dep->state == ERTS_DE_STATE_PENDING); @@ -4956,7 +4982,7 @@ setup_connection_distctrl(Process *c_p, void *arg, int *redsp, ErlHeapFragment * *redsp = 5; if (!setup_connection_epiloge_rwunlock(c_p, dep, c_p->common.id, - scdcp->flags, scdcp->version, + scdcp->dflags, scdcp->creation, scdcp->setup_pid, scdcp->net_kernel)) { erts_proc_lock(c_p, ERTS_PROC_LOCKS_ALL_MINOR); @@ -4999,18 +5025,40 @@ BIF_RETTYPE erts_internal_get_dflags_0(BIF_ALIST_0) { if (erts_dflags_test_remove_hopefull_flags) { /* For internal emulator tests only! */ - Eterm *hp = HAlloc(BIF_P, 1+6); - return TUPLE6(hp, am_erts_dflags, - make_small(DFLAG_DIST_DEFAULT & ~DFLAG_DIST_HOPEFULLY), - make_small(DFLAG_DIST_MANDATORY & ~DFLAG_DIST_HOPEFULLY), - make_small(DFLAG_DIST_ADDABLE & ~DFLAG_DIST_HOPEFULLY), - make_small(DFLAG_DIST_REJECTABLE & ~DFLAG_DIST_HOPEFULLY), - make_small(DFLAG_DIST_STRICT_ORDER & ~DFLAG_DIST_HOPEFULLY)); + Eterm *hp, **hpp = NULL; + Uint sz = 0, *szp = &sz; + Eterm res; + while (1) { + res = erts_bld_tuple(hpp, szp, 6, + am_erts_dflags, + erts_bld_uint64(hpp, szp, DFLAG_DIST_DEFAULT & ~DFLAG_DIST_HOPEFULLY), + erts_bld_uint64(hpp, szp, DFLAG_DIST_MANDATORY & ~DFLAG_DIST_HOPEFULLY), + erts_bld_uint64(hpp, szp, DFLAG_DIST_ADDABLE & ~DFLAG_DIST_HOPEFULLY), + erts_bld_uint64(hpp, szp, DFLAG_DIST_REJECTABLE & ~DFLAG_DIST_HOPEFULLY), + erts_bld_uint64(hpp, szp, DFLAG_DIST_STRICT_ORDER & ~DFLAG_DIST_HOPEFULLY)); + if (hpp) { + ASSERT(is_value(res)); + return res; + } + hp = HAlloc(BIF_P, sz); + hpp = &hp; + szp = NULL; + } } return erts_dflags_record; } +BIF_RETTYPE erts_internal_get_creation_0(BIF_ALIST_0) +{ + Eterm *hp; + Uint hsz = 0; + + erts_bld_uint(NULL, &hsz, erts_this_dist_entry->creation); + hp = HAlloc(BIF_P, hsz); + return erts_bld_uint(&hp, NULL, erts_this_dist_entry->creation); +} + BIF_RETTYPE erts_internal_new_connection_1(BIF_ALIST_1) { DistEntry* dep; @@ -5432,7 +5480,7 @@ BIF_RETTYPE erts_internal_dist_spawn_request_4(BIF_ALIST_4) goto noconnection; case ERTS_DSIG_PREP_CONNECTED: - if (!(dep->flags & DFLAG_SPAWN)) { + if (!(dep->dflags & DFLAG_SPAWN)) { erts_de_runlock(dep); goto notsup; } @@ -5896,7 +5944,7 @@ BIF_RETTYPE monitor_node_2(BIF_ALIST_2) BIF_RETTYPE net_kernel_dflag_unicode_io_1(BIF_ALIST_1) { DistEntry *de; - Uint32 f; + Uint64 f; if (is_not_pid(BIF_ARG_1)) { BIF_ERROR(BIF_P,BADARG); } @@ -5906,7 +5954,7 @@ BIF_RETTYPE net_kernel_dflag_unicode_io_1(BIF_ALIST_1) BIF_RET(am_true); } erts_de_rlock(de); - f = de->flags; + f = de->dflags; erts_de_runlock(de); BIF_RET(((f & DFLAG_UNICODE_IO) ? am_true : am_false)); } diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index b0fbfe96f9..65c29caeb3 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -25,31 +25,39 @@ #include "erl_node_tables.h" #include "zlib.h" -#define DFLAG_PUBLISHED 0x01 -#define DFLAG_ATOM_CACHE 0x02 -#define DFLAG_EXTENDED_REFERENCES 0x04 -#define DFLAG_DIST_MONITOR 0x08 -#define DFLAG_FUN_TAGS 0x10 -#define DFLAG_DIST_MONITOR_NAME 0x20 -#define DFLAG_HIDDEN_ATOM_CACHE 0x40 -#define DFLAG_NEW_FUN_TAGS 0x80 -#define DFLAG_EXTENDED_PIDS_PORTS 0x100 -#define DFLAG_EXPORT_PTR_TAG 0x200 -#define DFLAG_BIT_BINARIES 0x400 -#define DFLAG_NEW_FLOATS 0x800 -#define DFLAG_UNICODE_IO 0x1000 -#define DFLAG_DIST_HDR_ATOM_CACHE 0x2000 -#define DFLAG_SMALL_ATOM_TAGS 0x4000 -#define DFLAG_INTERNAL_TAGS 0x8000 /* used by ETS 'compressed' option */ -#define DFLAG_UTF8_ATOMS 0x10000 -#define DFLAG_MAP_TAG 0x20000 -#define DFLAG_BIG_CREATION 0x40000 -#define DFLAG_SEND_SENDER 0x80000 -#define DFLAG_BIG_SEQTRACE_LABELS 0x100000 -#define DFLAG_PENDING_CONNECT 0x200000 /* internal for pending connection */ -#define DFLAG_EXIT_PAYLOAD 0x400000 -#define DFLAG_FRAGMENTS 0x800000 -#define DFLAG_SPAWN 0x1000000 +#define DFLAG_PUBLISHED ((Uint64)0x01) +#define DFLAG_ATOM_CACHE ((Uint64)0x02) +#define DFLAG_EXTENDED_REFERENCES ((Uint64)0x04) +#define DFLAG_DIST_MONITOR ((Uint64)0x08) +#define DFLAG_FUN_TAGS ((Uint64)0x10) +#define DFLAG_DIST_MONITOR_NAME ((Uint64)0x20) +#define DFLAG_HIDDEN_ATOM_CACHE ((Uint64)0x40) +#define DFLAG_NEW_FUN_TAGS ((Uint64)0x80) +#define DFLAG_EXTENDED_PIDS_PORTS ((Uint64)0x100) +#define DFLAG_EXPORT_PTR_TAG ((Uint64)0x200) +#define DFLAG_BIT_BINARIES ((Uint64)0x400) +#define DFLAG_NEW_FLOATS ((Uint64)0x800) +#define DFLAG_UNICODE_IO ((Uint64)0x1000) +#define DFLAG_DIST_HDR_ATOM_CACHE ((Uint64)0x2000) +#define DFLAG_SMALL_ATOM_TAGS ((Uint64)0x4000) +#define DFLAG_ETS_COMPRESSED ((Uint64)0x8000) /* internal */ +#define DFLAG_UTF8_ATOMS ((Uint64)0x10000) +#define DFLAG_MAP_TAG ((Uint64)0x20000) +#define DFLAG_BIG_CREATION ((Uint64)0x40000) +#define DFLAG_SEND_SENDER ((Uint64)0x80000) +#define DFLAG_BIG_SEQTRACE_LABELS ((Uint64)0x100000) +#define DFLAG_PENDING_CONNECT ((Uint64)0x200000) /* internal */ +#define DFLAG_EXIT_PAYLOAD ((Uint64)0x400000) +#define DFLAG_FRAGMENTS ((Uint64)0x800000) +#define DFLAG_HANDSHAKE_23 ((Uint64)0x1000000) +#define DFLAG_RESERVED 0xfe000000 +/* + * As the old handshake only support 32 flag bits, we reserve the remainding + * bits in the lower 32 for changes in the handshake protocol or potentially + * new capabilities that we also want to backport to OTP-22 or older. + */ +#define DFLAG_SPAWN ((Uint64)0x100000000) + /* Mandatory flags for distribution */ #define DFLAG_DIST_MANDATORY (DFLAG_EXTENDED_REFERENCES \ @@ -82,6 +90,7 @@ | DFLAG_BIG_SEQTRACE_LABELS \ | DFLAG_EXIT_PAYLOAD \ | DFLAG_FRAGMENTS \ + | DFLAG_HANDSHAKE_23 \ | DFLAG_SPAWN) /* Flags addable by local distr implementations */ @@ -208,7 +217,7 @@ extern int erts_dflags_test_remove_hopefull_flags; typedef enum { TTBSize, TTBEncode, TTBCompress } TTBState; typedef struct TTBSizeContext_ { - Uint flags; + Uint64 dflags; int level; Sint vlen; int iovec; @@ -223,7 +232,7 @@ typedef struct TTBSizeContext_ { #define ERTS_INIT_TTBSizeContext(Ctx, Flags) \ do { \ (Ctx)->wstack.wstart = NULL; \ - (Ctx)->flags = (Flags); \ + (Ctx)->dflags = (Flags); \ (Ctx)->level = 0; \ (Ctx)->vlen = -1; \ (Ctx)->fragment_size = ~((Uint) 0); \ @@ -232,8 +241,8 @@ typedef struct TTBSizeContext_ { } while (0) typedef struct TTBEncodeContext_ { - Uint flags; - Uint hopefull_flags; + Uint64 dflags; + Uint64 hopefull_flags; byte *hopefull_flagsp; int level; byte* ep; @@ -261,7 +270,7 @@ typedef struct TTBEncodeContext_ { #define ERTS_INIT_TTBEncodeContext(Ctx, Flags) \ do { \ (Ctx)->wstack.wstart = NULL; \ - (Ctx)->flags = (Flags); \ + (Ctx)->dflags = (Flags); \ (Ctx)->level = 0; \ (Ctx)->vlen = 0; \ (Ctx)->size = 0; \ @@ -331,7 +340,7 @@ typedef struct erts_dsig_send_context { ErtsDistOutputBuf *obuf; Uint alloced_fragments, fragments; Sint vlen; - Uint32 flags; + Uint64 dflags; Process *c_p; union { TTBSizeContext sc; diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c index 23df37b597..5945bf48d9 100644 --- a/erts/emulator/beam/erl_bif_info.c +++ b/erts/emulator/beam/erl_bif_info.c @@ -4284,9 +4284,9 @@ BIF_RETTYPE erts_debug_get_internal_state_1(BIF_ALIST_1) } } else if (ERTS_IS_ATOM_STR("term_to_binary_tuple_fallbacks", tp[1])) { - Uint dflags = (TERM_TO_BINARY_DFLAGS - & ~DFLAG_EXPORT_PTR_TAG - & ~DFLAG_BIT_BINARIES); + Uint64 dflags = (TERM_TO_BINARY_DFLAGS + & ~DFLAG_EXPORT_PTR_TAG + & ~DFLAG_BIT_BINARIES); Eterm res = erts_term_to_binary(BIF_P, tp[2], 0, dflags); if (is_value(res)) BIF_RET(res); diff --git a/erts/emulator/beam/erl_node_tables.c b/erts/emulator/beam/erl_node_tables.c index 213983b0fd..0f30f71a0a 100644 --- a/erts/emulator/beam/erl_node_tables.c +++ b/erts/emulator/beam/erl_node_tables.c @@ -178,9 +178,8 @@ dist_table_alloc(void *dep_tmpl) dep->state = ERTS_DE_STATE_IDLE; dep->pending_nodedown = 0; dep->suspended_nodeup = NULL; - dep->flags = 0; + dep->dflags = 0; dep->opts = 0; - dep->version = 0; dep->mld = NULL; @@ -635,7 +634,7 @@ erts_set_dist_entry_not_connected(DistEntry *dep) else { ASSERT(dep->state != ERTS_DE_STATE_IDLE); ASSERT(is_internal_port(dep->cid) || is_internal_pid(dep->cid)); - if (dep->flags & DFLAG_PUBLISHED) { + if (dep->dflags & DFLAG_PUBLISHED) { ASSERT(erts_no_of_visible_dist_entries > 0); erts_no_of_visible_dist_entries--; head = &erts_visible_dist_entries; @@ -659,7 +658,7 @@ erts_set_dist_entry_not_connected(DistEntry *dep) dep->next->prev = dep->prev; dep->state = ERTS_DE_STATE_IDLE; - dep->flags = 0; + dep->dflags = 0; dep->opts = 0; dep->prev = NULL; dep->cid = NIL; @@ -701,7 +700,7 @@ erts_set_dist_entry_pending(DistEntry *dep) erts_no_of_not_connected_dist_entries--; dep->state = ERTS_DE_STATE_PENDING; - dep->flags = (DFLAG_DIST_MANDATORY | DFLAG_DIST_HOPEFULLY | DFLAG_PENDING_CONNECT); + dep->dflags = (DFLAG_DIST_MANDATORY | DFLAG_DIST_HOPEFULLY | DFLAG_PENDING_CONNECT); dep->connection_id = (dep->connection_id + 1) & ERTS_DIST_CON_ID_MASK; ASSERT(!dep->mld); @@ -720,7 +719,7 @@ erts_set_dist_entry_pending(DistEntry *dep) } void -erts_set_dist_entry_connected(DistEntry *dep, Eterm cid, Uint flags) +erts_set_dist_entry_connected(DistEntry *dep, Eterm cid, Uint64 flags) { erts_aint32_t set_qflgs; @@ -751,7 +750,7 @@ erts_set_dist_entry_connected(DistEntry *dep, Eterm cid, Uint flags) erts_no_of_pending_dist_entries--; dep->state = ERTS_DE_STATE_CONNECTED; - dep->flags = flags & ~DFLAG_PENDING_CONNECT; + dep->dflags = flags & ~DFLAG_PENDING_CONNECT; dep->cid = cid; erts_atomic_set_nob(&dep->input_handler, (erts_aint_t) cid); diff --git a/erts/emulator/beam/erl_node_tables.h b/erts/emulator/beam/erl_node_tables.h index 49708ccc67..f426f46d53 100644 --- a/erts/emulator/beam/erl_node_tables.h +++ b/erts/emulator/beam/erl_node_tables.h @@ -145,10 +145,9 @@ struct dist_entry_ { enum dist_entry_state state; int pending_nodedown; Process* suspended_nodeup; - Uint32 flags; /* Distribution flags, like hidden, + Uint64 dflags; /* Distribution flags, like hidden, atom cache etc. */ Uint32 opts; - unsigned long version; /* Protocol version */ ErtsMonLnkDist *mld; /* Monitors and links */ @@ -257,7 +256,7 @@ Uint erts_dist_table_size(void); void erts_dist_table_info(fmtfn_t, void *); void erts_set_dist_entry_not_connected(DistEntry *); void erts_set_dist_entry_pending(DistEntry *); -void erts_set_dist_entry_connected(DistEntry *, Eterm, Uint); +void erts_set_dist_entry_connected(DistEntry *, Eterm, Uint64); ErlNode *erts_find_or_insert_node(Eterm, Uint32, Eterm); void erts_schedule_delete_node(ErlNode *); void erts_set_this_node(Eterm, Uint32); diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c index d9587fe11e..5d91c1b2cb 100644 --- a/erts/emulator/beam/external.c +++ b/erts/emulator/beam/external.c @@ -101,13 +101,13 @@ static Export term_to_binary_trap_export; -static byte* enc_term(ErtsAtomCacheMap *, Eterm, byte*, Uint32, struct erl_off_heap_header** off_heap); +static byte* enc_term(ErtsAtomCacheMap *, Eterm, byte*, Uint64, struct erl_off_heap_header** off_heap); struct TTBEncodeContext_; -static int enc_term_int(struct TTBEncodeContext_*,ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint32 dflags, +static int enc_term_int(struct TTBEncodeContext_*,ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint64 dflags, struct erl_off_heap_header** off_heap, Sint *reds, byte **res); static int is_external_string(Eterm obj, Uint* lenp); -static byte* enc_atom(ErtsAtomCacheMap *, Eterm, byte*, Uint32); -static byte* enc_pid(ErtsAtomCacheMap *, Eterm, byte*, Uint32); +static byte* enc_atom(ErtsAtomCacheMap *, Eterm, byte*, Uint64); +static byte* enc_pid(ErtsAtomCacheMap *, Eterm, byte*, Uint64); struct B2TContext_t; static byte* dec_term(ErtsDistExternal*, ErtsHeapFactory*, byte*, Eterm*, struct B2TContext_t*, int); static byte* dec_atom(ErtsDistExternal *, byte*, Eterm*); @@ -116,16 +116,16 @@ static Sint decoded_size(byte *ep, byte* endp, int internal_tags, struct B2TCont static BIF_RETTYPE term_to_binary_trap_1(BIF_ALIST_1); static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm opts, int level, - Uint flags, Binary *context_b, int iovec, + Uint64 dflags, Binary *context_b, int iovec, Uint fragment_size); -static Uint encode_size_struct2(ErtsAtomCacheMap *, Eterm, unsigned); +static Uint encode_size_struct2(ErtsAtomCacheMap *, Eterm, Uint64); static ErtsExtSzRes encode_size_struct_int(TTBSizeContext*, ErtsAtomCacheMap *acmp, - Eterm obj, unsigned dflags, Sint *reds, Uint *res); + Eterm obj, Uint64 dflags, Sint *reds, Uint *res); static Export binary_to_term_trap_export; static BIF_RETTYPE binary_to_term_trap_1(BIF_ALIST_1); -static Sint transcode_dist_obuf(ErtsDistOutputBuf*, DistEntry*, Uint32 dflags, Sint reds); +static Sint transcode_dist_obuf(ErtsDistOutputBuf*, DistEntry*, Uint64 dflags, Sint reds); static byte *hopefull_bit_binary(TTBEncodeContext* ctx, byte **epp, Binary *pb_val, Eterm pb_term, byte *bytes, byte bitoffs, byte bitsize, Uint sz); static void hopefull_export(TTBEncodeContext* ctx, byte **epp, Export* exp, Uint32 dflags, @@ -228,7 +228,7 @@ erts_destroy_atom_cache_map(ErtsAtomCacheMap *acmp) } static ERTS_INLINE void -insert_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint32 dflags) +insert_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint64 dflags) { if (acmp && acmp->sz < ERTS_MAX_INTERNAL_ATOM_CACHE_ENTRIES) { int ix; @@ -244,7 +244,7 @@ insert_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint32 dflags) } static ERTS_INLINE int -get_iix_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint32 dflags) +get_iix_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint64 dflags) { if (!acmp) return -1; @@ -264,7 +264,7 @@ get_iix_acache_map(ErtsAtomCacheMap *acmp, Eterm atom, Uint32 dflags) } void -erts_finalize_atom_cache_map(ErtsAtomCacheMap *acmp, Uint32 dflags) +erts_finalize_atom_cache_map(ErtsAtomCacheMap *acmp, Uint64 dflags) { if (acmp) { int long_atoms = 0; /* !0 if one or more atoms are longer than 255. */ @@ -306,12 +306,11 @@ erts_encode_ext_dist_header_size(TTBEncodeContext *ctx, ErtsAtomCacheMap *acmp, Uint fragments) { - - if (ctx->flags & DFLAG_PENDING_CONNECT) { + if (ctx->dflags & DFLAG_PENDING_CONNECT) { /* HOPEFUL_DATA + hopefull flags + hopefull ix + payload ix */ - return 1 + 4 + 4 + 4; + return 1 + 8 + 4 + 4; } - else if (!acmp && !(ctx->flags & DFLAG_FRAGMENTS)) + else if (!acmp && !(ctx->dflags & DFLAG_FRAGMENTS)) return 1; /* pass through */ else { int fix_sz @@ -329,7 +328,7 @@ erts_encode_ext_dist_header_size(TTBEncodeContext *ctx, ASSERT(acmp->hdr_sz >= 0); fix_sz += acmp->hdr_sz; } else { - ASSERT(ctx->flags & DFLAG_FRAGMENTS); + ASSERT(ctx->dflags & DFLAG_FRAGMENTS); } return fix_sz; @@ -342,7 +341,7 @@ byte *erts_encode_ext_dist_header_setup(TTBEncodeContext *ctx, { /* Maximum number of atom must be less than the maximum of a 32 bits unsigned integer. Check is done in erl_init.c, erl_start function. */ - if (ctx->flags & DFLAG_PENDING_CONNECT) { + if (ctx->dflags & DFLAG_PENDING_CONNECT) { byte *ep = ctl_ext; ep -= 4; ctx->payload_ixp = ep; @@ -350,13 +349,13 @@ byte *erts_encode_ext_dist_header_setup(TTBEncodeContext *ctx, ep -= 4; ctx->hopefull_ixp = ep; put_int32(ERTS_NO_HIX, ep); - ep -= 4; + ep -= 8; ctx->hopefull_flagsp = ep; - put_int32(0, ep); + put_int64(0, ep); *--ep = HOPEFUL_DATA; return ep; } - else if (!acmp && !(ctx->flags & DFLAG_FRAGMENTS)) { + else if (!acmp && !(ctx->dflags & DFLAG_FRAGMENTS)) { byte *ep = ctl_ext; *--ep = PASS_THROUGH; return ep; @@ -390,7 +389,7 @@ byte *erts_encode_ext_dist_header_setup(TTBEncodeContext *ctx, --ep; put_int8(acmp->sz, ep); } else { - ASSERT(ctx->flags & DFLAG_FRAGMENTS); + ASSERT(ctx->dflags & DFLAG_FRAGMENTS); /* If we don't have an atom cache but are using a dist header we just put 0 in the atom cache size slot */ --ep; @@ -432,7 +431,7 @@ byte *erts_encode_ext_dist_header_fragment(byte **hdrpp, Sint erts_encode_ext_dist_header_finalize(ErtsDistOutputBuf* ob, DistEntry* dep, - Uint32 dflags, + Uint64 dflags, Sint reds) { byte *ip; @@ -643,18 +642,18 @@ erts_encode_dist_ext_size(Eterm term, if (ctx->vlen < 0) { /* First term as well */ ctx->vlen = 0; - if (ctx->flags & DFLAG_FRAGMENTS) + if (ctx->dflags & DFLAG_FRAGMENTS) ctx->fragment_size = ERTS_DIST_FRAGMENT_SIZE; } #ifndef ERTS_DEBUG_USE_DIST_SEP - if (!(ctx->flags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS))) + if (!(ctx->dflags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS))) #endif sz++ /* VERSION_MAGIC */; } - res = encode_size_struct_int(ctx, acmp, term, ctx->flags, redsp, &sz); + res = encode_size_struct_int(ctx, acmp, term, ctx->dflags, redsp, &sz); if (res == ERTS_EXT_SZ_OK) { Uint total_size, fragments; @@ -692,11 +691,12 @@ ErtsExtSzRes erts_encode_ext_size(Eterm term, Uint *szp) Uint erts_encode_ext_size_ets(Eterm term) { - return encode_size_struct2(NULL, term, TERM_TO_BINARY_DFLAGS|DFLAG_INTERNAL_TAGS); + return encode_size_struct2(NULL, term, + TERM_TO_BINARY_DFLAGS|DFLAG_ETS_COMPRESSED); } -int erts_encode_dist_ext(Eterm term, byte **ext, Uint32 flags, ErtsAtomCacheMap *acmp, +int erts_encode_dist_ext(Eterm term, byte **ext, Uint64 flags, ErtsAtomCacheMap *acmp, TTBEncodeContext* ctx, Uint *fragmentsp, Sint* reds) { int res; @@ -726,7 +726,7 @@ int erts_encode_dist_ext(Eterm term, byte **ext, Uint32 flags, ErtsAtomCacheMap *fragmentsp = res == 0 ? ctx->frag_ix + 1 : ctx->frag_ix; if (flags & DFLAG_PENDING_CONNECT) { ASSERT(ctx->hopefull_flagsp); - put_int32(ctx->hopefull_flags, ctx->hopefull_flagsp); + put_int64(ctx->hopefull_flags, ctx->hopefull_flagsp); } return res; } @@ -745,7 +745,7 @@ void erts_encode_ext(Eterm term, byte **ext) byte* erts_encode_ext_ets(Eterm term, byte *ep, struct erl_off_heap_header** off_heap) { - return enc_term(NULL, term, ep, TERM_TO_BINARY_DFLAGS|DFLAG_INTERNAL_TAGS, + return enc_term(NULL, term, ep, TERM_TO_BINARY_DFLAGS|DFLAG_ETS_COMPRESSED, off_heap); } @@ -850,7 +850,7 @@ erts_prepare_dist_ext(ErtsDistExternal *edep, ASSERT(dep); erts_de_rlock(dep); - ASSERT(dep->flags & DFLAG_UTF8_ATOMS); + ASSERT(dep->dflags & DFLAG_UTF8_ATOMS); if ((dep->state != ERTS_DE_STATE_CONNECTED && @@ -860,7 +860,7 @@ erts_prepare_dist_ext(ErtsDistExternal *edep, return ERTS_PREP_DIST_EXT_CLOSED; } - if (!(dep->flags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS))) { + if (!(dep->dflags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS))) { /* Skip PASS_THROUGH */ ext++; size--; @@ -890,7 +890,7 @@ erts_prepare_dist_ext(ErtsDistExternal *edep, edep->data->seq_id = 0; edep->data->frag_id = 1; - if (dep->flags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS)) + if (dep->dflags & (DFLAG_DIST_HDR_ATOM_CACHE|DFLAG_FRAGMENTS)) edep->flags |= ERTS_DIST_EXT_DFLAG_HDR; if (ep[1] != DIST_HEADER && ep[1] != DIST_FRAG_HEADER && ep[1] != DIST_FRAG_CONT) { @@ -900,7 +900,7 @@ erts_prepare_dist_ext(ErtsDistExternal *edep, edep->data->extp = ext; } else if (ep[1] == DIST_FRAG_CONT) { - if (!(dep->flags & DFLAG_FRAGMENTS)) + if (!(dep->dflags & DFLAG_FRAGMENTS)) goto bad_hdr; edep->attab.size = 0; edep->data->extp = ext + 1 + 1 + 8 + 8; @@ -917,7 +917,7 @@ erts_prepare_dist_ext(ErtsDistExternal *edep, goto bad_hdr; if (ep[1] == DIST_FRAG_HEADER) { - if (!(dep->flags & DFLAG_FRAGMENTS)) + if (!(dep->dflags & DFLAG_FRAGMENTS)) goto bad_hdr; edep->data->seq_id = get_int64(&ep[2]); edep->data->frag_id = get_int64(&ep[2+8]); @@ -2189,7 +2189,7 @@ external_size_2(BIF_ALIST_2) } static Eterm -erts_term_to_binary_simple(Process* p, Eterm Term, Uint size, int level, Uint flags) +erts_term_to_binary_simple(Process* p, Eterm Term, Uint size, int level, Uint64 dflags) { Eterm bin; size_t real_size; @@ -2205,7 +2205,7 @@ erts_term_to_binary_simple(Process* p, Eterm Term, Uint size, int level, Uint fl bytes = erts_alloc(ERTS_ALC_T_TMP, size); } - if ((endp = enc_term(NULL, Term, bytes, flags, NULL)) + if ((endp = enc_term(NULL, Term, bytes, dflags, NULL)) == NULL) { erts_exit(ERTS_ERROR_EXIT, "%s, line %d: bad term: %x\n", __FILE__, __LINE__, Term); @@ -2250,7 +2250,7 @@ erts_term_to_binary_simple(Process* p, Eterm Term, Uint size, int level, Uint fl bin = new_binary(p, (byte *)NULL, size); bytes = binary_bytes(bin); bytes[0] = VERSION_MAGIC; - if ((endp = enc_term(NULL, Term, bytes+1, flags, NULL)) + if ((endp = enc_term(NULL, Term, bytes+1, dflags, NULL)) == NULL) { erts_exit(ERTS_ERROR_EXIT, "%s, line %d: bad term: %x\n", __FILE__, __LINE__, Term); @@ -2265,7 +2265,7 @@ erts_term_to_binary_simple(Process* p, Eterm Term, Uint size, int level, Uint fl } Eterm -erts_term_to_binary(Process* p, Eterm Term, int level, Uint flags) { +erts_term_to_binary(Process* p, Eterm Term, int level, Uint64 flags) { Uint size = 0; switch (encode_size_struct_int(NULL, NULL, Term, flags, NULL, &size)) { case ERTS_EXT_SZ_SYSTEM_LIMIT: @@ -2396,7 +2396,7 @@ erts_ttb_iov_init(TTBEncodeContext *ctx, int use_termv, char *ptr, } static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm opts, - int level, Uint flags, Binary *context_b, + int level, Uint64 dflags, Binary *context_b, int iovec, Uint fragment_size) { Eterm *hp; @@ -2438,7 +2438,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm /* Setup enough to get started */ context->state = TTBSize; context->alive = 1; - ERTS_INIT_TTBSizeContext(&context->s.sc, flags); + ERTS_INIT_TTBSizeContext(&context->s.sc, dflags); context->s.sc.level = level; context->s.sc.fragment_size = fragment_size; if (!level) { @@ -2458,7 +2458,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm switch (context->state) { case TTBSize: { - Uint size, flags, fragments = 1; + Uint size, fragments = 1; Binary *result_bin; int level = context->s.sc.level; Sint vlen; @@ -2466,7 +2466,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm fragment_size = context->s.sc.fragment_size; size = 1; /* VERSION_MAGIC */ switch (encode_size_struct_int(&context->s.sc, NULL, Term, - context->s.sc.flags, &reds, + context->s.sc.dflags, &reds, &size)) { case ERTS_EXT_SZ_SYSTEM_LIMIT: BUMP_REDS(p, (initial_reds - reds) / TERM_TO_BINARY_LOOP_FACTOR); @@ -2479,7 +2479,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm break; } /* Move these to next state */ - flags = context->s.sc.flags; + dflags = context->s.sc.dflags; vlen = context->s.sc.vlen; if (vlen >= 0) { Uint total_size = size + context->s.sc.extra_size; @@ -2490,7 +2490,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm else if (size <= ERL_ONHEAP_BIN_LIMIT) { /* Finish in one go */ res = erts_term_to_binary_simple(p, Term, size, - level, flags); + level, dflags); if (iovec) { Eterm *hp = HAlloc(p, 2); res = CONS(hp, res, NIL); @@ -2503,7 +2503,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm result_bin->orig_bytes[0] = (byte)VERSION_MAGIC; /* Next state immediately, no need to export context */ context->state = TTBEncode; - ERTS_INIT_TTBEncodeContext(&context->s.ec, flags); + ERTS_INIT_TTBEncodeContext(&context->s.ec, dflags); context->s.ec.level = level; context->s.ec.result_bin = result_bin; context->s.ec.iovec = iovec; @@ -2525,8 +2525,8 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm Sint realloc_offset; Uint fragments; - flags = context->s.ec.flags; - if (enc_term_int(&context->s.ec, NULL,Term, bytes+1, flags, + dflags = context->s.ec.dflags; + if (enc_term_int(&context->s.ec, NULL,Term, bytes+1, dflags, NULL, &reds, &endp) < 0) { EXPORT_CONTEXT(); RETURN_STATE(); @@ -2769,7 +2769,7 @@ static Eterm erts_term_to_binary_int(Process* p, Sint bif_ix, Eterm Term, Eterm */ static byte* -enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint32 dflags) +enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint64 dflags) { int iix; int len; @@ -2777,7 +2777,7 @@ enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint32 dflags) ASSERT(is_atom(atom)); - if (dflags & DFLAG_INTERNAL_TAGS) { + if (dflags & DFLAG_ETS_COMPRESSED) { Uint aval = atom_val(atom); ASSERT(aval < (1<<24)); if (aval >= (1 << 16)) { @@ -2854,16 +2854,16 @@ enc_atom(ErtsAtomCacheMap *acmp, Eterm atom, byte *ep, Uint32 dflags) /* * We use this atom as sysname in local pid/port/refs - * for the ETS compressed format (DFLAG_INTERNAL_TAGS). + * for the ETS compressed format * */ #define INTERNAL_LOCAL_SYSNAME am_ErtsSecretAtom static byte* -enc_pid(ErtsAtomCacheMap *acmp, Eterm pid, byte* ep, Uint32 dflags) +enc_pid(ErtsAtomCacheMap *acmp, Eterm pid, byte* ep, Uint64 dflags) { Uint on, os; - Eterm sysname = ((is_internal_pid(pid) && (dflags & DFLAG_INTERNAL_TAGS)) + Eterm sysname = ((is_internal_pid(pid) && (dflags & DFLAG_ETS_COMPRESSED)) ? INTERNAL_LOCAL_SYSNAME : pid_node_name(pid)); Uint32 creation = pid_creation(pid); @@ -3044,7 +3044,7 @@ dec_pid(ErtsDistExternal *edep, ErtsHeapFactory* factory, byte* ep, #define ENC_LAST_ARRAY_ELEMENT ((Eterm) 6) static byte* -enc_term(ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint32 dflags, +enc_term(ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint64 dflags, struct erl_off_heap_header** off_heap) { byte *res; @@ -3053,7 +3053,8 @@ enc_term(ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint32 dflags, } static int -enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, Uint32 dflags, +enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, + Uint64 dflags, struct erl_off_heap_header** off_heap, Sint *reds, byte **res) { DECLARE_WSTACK(s); @@ -3260,7 +3261,7 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, case REF_DEF: case EXTERNAL_REF_DEF: { Uint32 *ref_num; - Eterm sysname = (((dflags & DFLAG_INTERNAL_TAGS) && is_internal_ref(obj)) + Eterm sysname = (((dflags & DFLAG_ETS_COMPRESSED) && is_internal_ref(obj)) ? INTERNAL_LOCAL_SYSNAME : ref_node_name(obj)); Uint32 creation = ref_creation(obj); @@ -3284,7 +3285,7 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, } case PORT_DEF: case EXTERNAL_PORT_DEF: { - Eterm sysname = (((dflags & DFLAG_INTERNAL_TAGS) && is_internal_port(obj)) + Eterm sysname = (((dflags & DFLAG_ETS_COMPRESSED) && is_internal_port(obj)) ? INTERNAL_LOCAL_SYSNAME : port_node_name(obj)); Uint32 creation = port_creation(obj); @@ -3458,7 +3459,7 @@ enc_term_int(TTBEncodeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, byte* ep, } } } - else if (dflags & DFLAG_INTERNAL_TAGS) { + else if (dflags & DFLAG_ETS_COMPRESSED) { ProcBin* pb = (ProcBin*) binary_val(obj); Uint bytesize = pb->size; if (pb->thing_word == HEADER_SUB_BIN) { @@ -4963,7 +4964,7 @@ error_hamt: (except for cached atoms) */ static Uint encode_size_struct2(ErtsAtomCacheMap *acmp, Eterm obj, - unsigned dflags) { + Uint64 dflags) { Uint size = 0; ErtsExtSzRes res = encode_size_struct_int(NULL, acmp, obj, dflags, NULL, @@ -4978,7 +4979,7 @@ static Uint encode_size_struct2(ErtsAtomCacheMap *acmp, static ErtsExtSzRes encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, - unsigned dflags, Sint *reds, Uint *res) + Uint64 dflags, Sint *reds, Uint *res) { DECLARE_WSTACK(s); Uint m, i, arity; @@ -5022,7 +5023,7 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, result++; break; case ATOM_DEF: - if (dflags & DFLAG_INTERNAL_TAGS) { + if (dflags & DFLAG_ETS_COMPRESSED) { if (atom_val(obj) >= (1<<16)) { result += 1 + 3; } @@ -5187,7 +5188,7 @@ encode_size_struct_int(TTBSizeContext* ctx, ErtsAtomCacheMap *acmp, Eterm obj, Uint bin_size = pb->size; byte bitoffs = 0; byte bitsize = 0; - if (dflags & DFLAG_INTERNAL_TAGS) { + if (dflags & DFLAG_ETS_COMPRESSED) { ProcBin* pb = (ProcBin*) binary_val(obj); Uint sub_extra = 0; if (pb->thing_word == HEADER_SUB_BIN) { @@ -5749,13 +5750,14 @@ error: Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, DistEntry* dep, - Uint32 dflags, + Uint64 dflags, Sint reds) { ErlIOVec* eiov = ob->eiov; SysIOVec* iov = eiov->iov; byte *hdr; - Uint32 hopefull_flags, hopefull_ix, payload_ix; + Uint64 hopefull_flags; + Uint32 hopefull_ix, payload_ix; Sint start_r, r; Uint new_len; byte *ep; @@ -5770,7 +5772,7 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, * +---+--------------+-----------+----------+ * |'H'|Hopefull Flags|Hopefull IX|Payload IX| * +---+--------------+-----------+----------+ - * 1 4 4 4 + * 1 8 4 4 * * Hopefull flags: Flags corresponding to actual * hopefull encodings in this @@ -5788,7 +5790,7 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, hdr = (byte *) iov[1].iov_base; ASSERT(HOPEFUL_DATA == *((byte *)iov[1].iov_base)); - ASSERT(iov[1].iov_len == 13); + ASSERT(iov[1].iov_len == 1+8+4+4); /* Control message always begin in vector element 2 */ ep = iov[2].iov_base; @@ -5812,9 +5814,9 @@ Sint transcode_dist_obuf(ErtsDistOutputBuf* ob, } hdr++; - hopefull_flags = get_int32(hdr); + hopefull_flags = get_int64(hdr); - hdr += 4; + hdr += 8; hopefull_ix = get_int32(hdr); if ((~dflags & DFLAG_SPAWN) diff --git a/erts/emulator/beam/external.h b/erts/emulator/beam/external.h index f6330473d6..bc006f83e2 100644 --- a/erts/emulator/beam/external.h +++ b/erts/emulator/beam/external.h @@ -162,13 +162,13 @@ struct TTBEncodeContext_; void erts_init_atom_cache_map(ErtsAtomCacheMap *); void erts_reset_atom_cache_map(ErtsAtomCacheMap *); void erts_destroy_atom_cache_map(ErtsAtomCacheMap *); -void erts_finalize_atom_cache_map(ErtsAtomCacheMap *, Uint32); +void erts_finalize_atom_cache_map(ErtsAtomCacheMap *, Uint64); Uint erts_encode_ext_dist_header_size(struct TTBEncodeContext_ *ctx, ErtsAtomCacheMap *, Uint); byte *erts_encode_ext_dist_header_setup(struct TTBEncodeContext_ *ctx, byte *, ErtsAtomCacheMap *, Uint, Eterm); byte *erts_encode_ext_dist_header_fragment(byte **, Uint, Eterm); -Sint erts_encode_ext_dist_header_finalize(ErtsDistOutputBuf*, DistEntry *, Uint32 dflags, Sint reds); +Sint erts_encode_ext_dist_header_finalize(ErtsDistOutputBuf*, DistEntry *, Uint64 dflags, Sint reds); struct erts_dsig_send_context; typedef enum { @@ -181,7 +181,7 @@ ErtsExtSzRes erts_encode_dist_ext_size(Eterm term, ErtsAtomCacheMap *acmp, struct TTBSizeContext_ *ctx, Uint* szp, Sint *redsp, Sint *vlenp, Uint *fragments); -int erts_encode_dist_ext(Eterm, byte **, Uint32, ErtsAtomCacheMap *, +int erts_encode_dist_ext(Eterm, byte **, Uint64, ErtsAtomCacheMap *, struct TTBEncodeContext_ *, Uint *, Sint *); ErtsExtSzRes erts_encode_ext_size(Eterm, Uint *szp); @@ -214,7 +214,7 @@ Sint erts_decode_ext_size_ets(byte*, Uint); Eterm erts_decode_ext(ErtsHeapFactory*, byte**, Uint32 flags); Eterm erts_decode_ext_ets(ErtsHeapFactory*, byte*); -Eterm erts_term_to_binary(Process* p, Eterm Term, int level, Uint flags); +Eterm erts_term_to_binary(Process* p, Eterm Term, int level, Uint64 flags); Eterm erts_debug_term_to_binary(Process *p, Eterm term, Eterm opts); Sint erts_binary2term_prepare(ErtsBinary2TermState *, byte *, Sint); |