#include "global.h"#include "main.h"#include "object.h"#include "mapping.h"#include "svalue.h"#include "array.h"#include "pike_macros.h"#include "pike_error.h"#include "pike_memory.h"#include "dynamic_buffer.h"#include "interpret.h"#include "las.h"#include "gc.h"#include "stralloc.h"#include "pike_security.h"#include "block_alloc.h"#include "opcodes.h"#include "stuff.h"Defines | |
| #define | AVG_LINK_LENGTH 4 |
| #define | MIN_LINK_LENGTH 1 |
| #define | MAP_SLOTS(X) ((X)?((X)+((X)>>4)+8):0) |
| #define | unlink_mapping_data(M) |
| #define | MAPPING_DATA_SIZE(HSIZE, KEYPAIRS) PTR_TO_INT(MD_KEYPAIRS(0, HSIZE) + KEYPAIRS) |
| #define | EXIT_BLOCK(m) |
| #define | COUNT_OTHER() |
| #define | FREE_KEYPAIR(md, k) |
| #define | LOW_RELOC(X) X= (void *) ((char *)(X) + off); |
| #define | RELOC(X) if(X) LOW_RELOC(X) |
| #define | MAPPING_DATA_IN_USE(MD) ((MD)->refs != (MD)->hardlinks + 1) |
| #define | LOW_FIND(FUN, KEY, FOUND, NOT_FOUND) |
| #define | LOW_FIND2(FUN, KEY, FOUND, NOT_FOUND) |
| #define | SAME_DATA(SAME, NOT_SAME) |
| #define | FIND() |
| #define | COPYMAP2() |
| #define | PREPARE_FOR_DATA_CHANGE2() if(md->valrefs) COPYMAP2() |
| #define | PREPARE_FOR_INDEX_CHANGE2() if(md->refs>1) COPYMAP2() |
| #define | PROPAGATE() |
| #define | COPYMAP() |
| #define | PREPARE_FOR_DATA_CHANGE() if(md->valrefs) COPYMAP() |
| #define | PREPARE_FOR_INDEX_CHANGE() if(md->refs>1) COPYMAP() |
| #define | mapping_insert(M, KEY, VAL) low_mapping_insert ((M), (KEY), (VAL), 1) |
| #define | DO_IF_MAPPING_SIZE_DEBUG(x) |
| #define | GC_RECURSE_MD_IN_USE(MD, RECURSE_FN, IND_TYPES, VAL_TYPES) |
| #define | GC_RECURSE(M, MD, REC_KEYPAIR, TYPE, IND_TYPES, VAL_TYPES) |
| #define | GC_REC_KP(REMOVE, N_REC, W_REC, N_TST, W_TST) |
| #define | GC_REC_KP_IND(REMOVE, N_REC, W_REC, N_TST, W_TST) |
| #define | GC_REC_KP_VAL(REMOVE, N_REC, W_REC, N_TST, W_TST) |
| #define | GC_REC_KP_BOTH(REMOVE, N_REC, W_REC, N_TST, W_TST) |
Functions | |
| PMOD_EXPORT struct mapping * | debug_allocate_mapping (int size) |
| PMOD_EXPORT void | really_free_mapping_data (struct mapping_data *md) |
| PMOD_EXPORT void | do_free_mapping (struct mapping *m) |
| mapping_data * | copy_mapping_data (struct mapping_data *md) |
| PMOD_EXPORT void | mapping_fix_type_field (struct mapping *m) |
| PMOD_EXPORT void | mapping_set_flags (struct mapping *m, int flags) |
| PMOD_EXPORT void | low_mapping_insert (struct mapping *m, const struct svalue *key, const struct svalue *val, int overwrite) |
| PMOD_EXPORT void | mapping_insert (struct mapping *m, const struct svalue *key, const struct svalue *val) |
| PMOD_EXPORT union anything * | mapping_get_item_ptr (struct mapping *m, struct svalue *key, TYPE_T t) |
| PMOD_EXPORT void | map_delete_no_free (struct mapping *m, struct svalue *key, struct svalue *to) |
| PMOD_EXPORT void | check_mapping_for_destruct (struct mapping *m) |
| PMOD_EXPORT struct svalue * | low_mapping_lookup (struct mapping *m, const struct svalue *key) |
| PMOD_EXPORT struct svalue * | low_mapping_string_lookup (struct mapping *m, struct pike_string *p) |
| PMOD_EXPORT void | mapping_string_insert (struct mapping *m, struct pike_string *p, struct svalue *val) |
| PMOD_EXPORT void | mapping_string_insert_string (struct mapping *m, struct pike_string *p, struct pike_string *val) |
| PMOD_EXPORT struct svalue * | simple_mapping_string_lookup (struct mapping *m, const char *p) |
| PMOD_EXPORT struct svalue * | mapping_mapping_lookup (struct mapping *m, struct svalue *key1, struct svalue *key2, int create) |
| PMOD_EXPORT struct svalue * | mapping_mapping_string_lookup (struct mapping *m, struct pike_string *key1, struct pike_string *key2, int create) |
| PMOD_EXPORT void | mapping_index_no_free (struct svalue *dest, struct mapping *m, struct svalue *key) |
| PMOD_EXPORT struct array * | mapping_indices (struct mapping *m) |
| PMOD_EXPORT struct array * | mapping_values (struct mapping *m) |
| PMOD_EXPORT struct array * | mapping_to_array (struct mapping *m) |
| PMOD_EXPORT void | mapping_replace (struct mapping *m, struct svalue *from, struct svalue *to) |
| PMOD_EXPORT struct mapping * | mkmapping (struct array *ind, struct array *val) |
| PMOD_EXPORT struct mapping * | copy_mapping (struct mapping *m) |
| PMOD_EXPORT struct mapping * | merge_mappings (struct mapping *a, struct mapping *b, INT32 op) |
| PMOD_EXPORT struct mapping * | merge_mapping_array_ordered (struct mapping *a, struct array *b, INT32 op) |
| PMOD_EXPORT struct mapping * | merge_mapping_array_unordered (struct mapping *a, struct array *b, INT32 op) |
| PMOD_EXPORT struct mapping * | add_mappings (struct svalue *argp, INT32 args) |
| PMOD_EXPORT int | mapping_equal_p (struct mapping *a, struct mapping *b, struct processing *p) |
| void | describe_mapping (struct mapping *m, struct processing *p, int indent) |
| node * | make_node_from_mapping (struct mapping *m) |
| PMOD_EXPORT void | f_aggregate_mapping (INT32 args) |
| PMOD_EXPORT struct mapping * | copy_mapping_recursively (struct mapping *m, struct mapping *p) |
| PMOD_EXPORT void | mapping_search_no_free (struct svalue *to, struct mapping *m, struct svalue *look_for, struct svalue *key) |
| void | gc_mark_mapping_as_referenced (struct mapping *m) |
| void | real_gc_cycle_check_mapping (struct mapping *m, int weak) |
| unsigned | gc_touch_all_mappings (void) |
| void | gc_check_all_mappings (void) |
| void | gc_mark_all_mappings (void) |
| void | gc_cycle_check_all_mappings (void) |
| void | gc_zap_ext_weak_refs_in_mappings (void) |
| size_t | gc_free_all_unreferenced_mappings (void) |
| int | mapping_is_constant (struct mapping *m, struct processing *p) |
Variables | |
| mapping * | first_mapping |
| mapping * | gc_internal_mapping = 0 |
|
|
|
|
|
Value: do { \ ptrdiff_t off; \ m->data=copy_mapping_data(m->data); \ debug_malloc_touch(m->data); \ off=((char *)m->data)-((char *)md); \ LOW_RELOC(k); \ free_mapping_data(md); \ md=m->data; \ add_ref(md); \ }while(0) |
|
|
Value: do { \ ptrdiff_t off; \ m->data=copy_mapping_data(m->data); \ debug_malloc_touch(m->data); \ DO_IF_DEBUG( if(d_flag>1) check_mapping(m); ) \ off=((char *)m->data)-((char *)md); \ LOW_RELOC(k); \ LOW_RELOC(prev); \ md=m->data; \ }while(0) |
|
|
Value: do{ \ struct mapping *m; \ double datasize = 0.0; \ for(m=first_mapping;m;m=m->next) \ { \ datasize+=MAPPING_DATA_SIZE(m->data->hashsize, m->data->num_keypairs) / \ (double) m->data->refs; \ } \ size += (INT32) datasize; \ }while(0) |
|
|
|
|
|
Value: do{ \ DO_IF_DEBUG( \ if(m->refs) { \ DO_IF_DMALLOC(describe_something(m, T_MAPPING, 0,2,0, NULL)); \ Pike_fatal("really free mapping on mapping with %d refs.\n", m->refs); \ } \ ) \ \ FREE_PROT(m); \ \ unlink_mapping_data(m->data); \ \ DOUBLEUNLINK(first_mapping, m); \ \ GC_FREE(m); \ }while(0) |
|
|
Value: do{ \ LOW_FIND(is_eq, key, \ omd=md; \ SAME_DATA( break, \ struct svalue *tmp=&k->ind; \ LOW_FIND(is_identical, tmp, break, ;); \ free_mapping_data(omd)), \ break); \ free_mapping_data(md); \ }while(0) |
|
|
Value: do { \ k->next = md->free_list; \ md->free_list = k; \ } while(0) |
|
|
Value: do { \ if ((REMOVE = N_REC(&k->ind, 1))) \ gc_free_svalue(&k->val); \ else \ N_REC(&k->val, 1); \ } while (0) |
|
|
Value: do { \ if ((REMOVE = W_TST(&k->ind))) /* Don't recurse now. */ \ gc_free_svalue(&k->val); \ else if ((REMOVE = W_REC(&k->val, 1))) \ gc_free_svalue(&k->ind); \ else \ W_REC(&k->ind, 1); /* Now we can recurse the index. */ \ } while (0) |
|
|
Value: do { \ if ((REMOVE = W_REC(&k->ind, 1))) \ gc_free_svalue(&k->val); \ else \ N_REC(&k->val, 1); \ } while (0) |
|
|
Value: do { \ if ((REMOVE = N_TST(&k->ind))) /* Don't recurse now. */ \ gc_free_svalue(&k->val); \ else if ((REMOVE = W_REC(&k->val, 1))) \ gc_free_svalue(&k->ind); \ else \ N_REC(&k->ind, 1); /* Now we can recurse the index. */ \ } while (0) |
|
|
|
|
|
Value: do { \ INT32 e; \ struct keypair *k; \ IND_TYPES = MD->ind_types; \ NEW_MAPPING_LOOP(MD) { \ if (!IS_DESTRUCTED(&k->ind) && RECURSE_FN(&k->ind, 1)) { \ DO_IF_DEBUG(Pike_fatal("Didn't expect an svalue zapping now.\n")); \ } \ RECURSE_FN(&k->val, 1); \ VAL_TYPES |= 1 << k->val.type; \ } \ } while (0) |
|
|
Value: do { \ md=m->data; \ add_ref(md); \ if(md->hashsize) \ { \ h=h2 % md->hashsize; \ DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \ if(md->ind_types & ((1 << key->type) | BIT_OBJECT)) \ { \ for(prev= md->hash + h;(k=*prev);prev=&k->next) \ { \ if(h2 == k->hval && FUN(& k->ind, KEY)) \ { \ FOUND; \ } \ } \ } \ } \ NOT_FOUND; \ }while(0) |
|
|
Value: do { \ struct keypair *k2; \ md=m->data; \ add_ref(md); \ if(md->hashsize) \ { \ h=h2 % md->hashsize; \ DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \ if(md->ind_types & ((1 << key->type) | BIT_OBJECT)) \ { \ k2=omd->hash[h2 % omd->hashsize]; \ prev= md->hash + h; \ for(;(k=*prev) && k2;(prev=&k->next),(k2=k2->next)) \ if(!(h2 == k->hval && is_identical(&k2->ind, &k->ind))) \ break; \ for(;(k=*prev);prev=&k->next) \ { \ if(FUN(& k->ind, KEY)) \ { \ FOUND; \ } \ } \ } \ } \ NOT_FOUND; \ }while(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: do { \ if(md->refs==1) \ { \ h=h2 % md->hashsize; \ *prev=k->next; \ k->next=md->hash[h]; \ md->hash[h]=k; \ } \ }while(0) |
|
|
|
|
|
Value: if(m->data == md) \ { \ SAME; \ }else{ \ NOT_SAME; \ } |
|
|
Value: do{ \ struct mapping_data *md_=(M); \ if(md_->hardlinks) { md_->hardlinks--; md_->valrefs--; } \ free_mapping_data(M); \ }while(0) |
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
1.3.9.1