static Eterm do_info(Process* c_p, TrapData* trap_data) { HashTable* hash_table; Uint remaining; Uint idx; Uint max_iter; hash_table = trap_data->table; idx = trap_data->idx; #if defined(DEBUG) || defined(VALGRIND) max_iter = 50; #else max_iter = ERTS_BIF_REDS_LEFT(c_p); #endif remaining = trap_data->remaining < max_iter ? trap_data->remaining : max_iter; trap_data->remaining -= remaining; while (remaining != 0) { if (is_boxed(hash_table->term[idx])) { ErtsLiteralArea* area; area = term_to_area(hash_table->term[idx]); trap_data->memory += sizeof(ErtsLiteralArea) + sizeof(Eterm) * (area->end - area->start - 1); remaining--; } idx++; } trap_data->idx = idx; if (trap_data->remaining > 0) { return am_ok; /* Dummy return value */ } else { Eterm* hp; Eterm count_term; Eterm memory_term; Eterm res; Uint memory; Uint hsz = MAP_SZ(2); memory = sizeof(HashTable) + (trap_data->table->allocated-1) * sizeof(Eterm) + trap_data->memory; (void) erts_bld_uint(NULL, &hsz, hash_table->num_entries); (void) erts_bld_uint(NULL, &hsz, memory); hp = HAlloc(c_p, hsz); count_term = erts_bld_uint(&hp, NULL, hash_table->num_entries); memory_term = erts_bld_uint(&hp, NULL, memory); res = MAP2(hp, am_count, count_term, am_memory, memory_term); return res; } }
static void insert_offheap(ErlOffHeap *oh, int type, Eterm id) { union erl_off_heap_ptr u; struct insert_offheap2_arg a; a.type = BIN_REF; for (u.hdr = oh->first; u.hdr; u.hdr = u.hdr->next) { switch (thing_subtag(u.hdr->thing_word)) { case REFC_BINARY_SUBTAG: if(IsMatchProgBinary(u.pb->val)) { InsertedBin *ib; int insert_bin = 1; for (ib = inserted_bins; ib; ib = ib->next) if(ib->bin_val == u.pb->val) { insert_bin = 0; break; } if (insert_bin) { #if HALFWORD_HEAP UWord val = (UWord) u.pb->val; DeclareTmpHeapNoproc(id_heap,BIG_UINT_HEAP_SIZE*2); /* extra place allocated */ #else DeclareTmpHeapNoproc(id_heap,BIG_UINT_HEAP_SIZE); #endif Uint *hp = &id_heap[0]; InsertedBin *nib; #if HALFWORD_HEAP int actual_need = BIG_UWORD_HEAP_SIZE(val); ASSERT(actual_need <= (BIG_UINT_HEAP_SIZE*2)); UseTmpHeapNoproc(actual_need); a.id = erts_bld_uword(&hp, NULL, (UWord) val); #else UseTmpHeapNoproc(BIG_UINT_HEAP_SIZE); a.id = erts_bld_uint(&hp, NULL, (Uint) u.pb->val); #endif erts_match_prog_foreach_offheap(u.pb->val, insert_offheap2, (void *) &a); nib = erts_alloc(ERTS_ALC_T_NC_TMP, sizeof(InsertedBin)); nib->bin_val = u.pb->val; nib->next = inserted_bins; inserted_bins = nib; #if HALFWORD_HEAP UnUseTmpHeapNoproc(actual_need); #else UnUseTmpHeapNoproc(BIG_UINT_HEAP_SIZE); #endif } } break; case FUN_SUBTAG: break; /* No need to */ default: ASSERT(is_external_header(u.hdr->thing_word)); insert_node(u.ext->node, type, id); break; } } }
static void insert_offheap(ErlOffHeap *oh, int type, Eterm id) { if(oh->externals) { ExternalThing *etp = oh->externals; while (etp) { insert_node(etp->node, type, id); etp = etp->next; } } if(oh->mso) { ProcBin *pb; struct insert_offheap2_arg a; a.type = BIN_REF; for(pb = oh->mso; pb; pb = pb->next) { if(IsMatchProgBinary(pb->val)) { InsertedBin *ib; int insert_bin = 1; for (ib = inserted_bins; ib; ib = ib->next) if(ib->bin_val == pb->val) { insert_bin = 0; break; } if (insert_bin) { Uint id_heap[BIG_UINT_HEAP_SIZE]; Uint *hp = &id_heap[0]; InsertedBin *nib; a.id = erts_bld_uint(&hp, NULL, (Uint) pb->val); erts_match_prog_foreach_offheap(pb->val, insert_offheap2, (void *) &a); nib = erts_alloc(ERTS_ALC_T_NC_TMP, sizeof(InsertedBin)); nib->bin_val = pb->val; nib->next = inserted_bins; inserted_bins = nib; } } } } #if 0 if(oh->funs) { /* No need to */ } #endif }