Soar Kernel
9.3.2 08-06-12
|
#include "chunk.h"
#include "kernel.h"
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | cons_struct |
struct | dl_cons_struct |
struct | hash_table_struct |
struct | item_in_hash_table_struct |
struct | memory_pool_struct |
Macros | |
#define | decrement_used_count(p) { } |
#define | fast_remove_from_dll(header, item, typename, next_field_name, prev_field_name) |
#define | fill_with_garbage(block, size) { } |
#define | HASH_TABLE_MEM_USAGE 1 |
#define | increment_used_count(p) { } |
#define | insert_at_head_of_dll(header, item, next_field_name, prev_field_name) |
#define | MAX_POOL_NAME_LENGTH 15 |
#define | MISCELLANEOUS_MEM_USAGE 0 |
#define | NUM_MEM_USAGE_CODES 5 |
#define | POOL_MEM_USAGE 3 |
#define | remove_from_dll(header, item, next_field_name, prev_field_name) |
#define | STATS_OVERHEAD_MEM_USAGE 4 |
#define | STRING_MEM_USAGE 2 |
Typedefs | |
typedef char | Bool |
typedef item_in_hash_table * | bucket_array |
typedef struct cons_struct | cons |
typedef Bool(* | cons_test_fn )(agent *thisAgent, cons *c, void *data) |
typedef struct dl_cons_struct | dl_cons |
typedef Bool(* | dl_cons_test_fn )(dl_cons *dc, agent *thisAgent) |
typedef dl_cons | dl_list |
typedef void * | growable_string |
typedef struct hash_table_struct | hash_table |
typedef Bool(* | hash_table_callback_fn )(void *item) |
typedef Bool(* | hash_table_callback_fn2 )(agent *thisAgent, void *item, void *f) |
typedef struct item_in_hash_table_struct | item_in_hash_table |
typedef cons | list |
typedef struct memory_pool_struct | memory_pool |
Variables | |
uint32_t | masks_for_n_low_order_bits [33] |
#define fast_remove_from_dll | ( | header, | |
item, | |||
typename, | |||
next_field_name, | |||
prev_field_name | |||
) |
Definition at line 418 of file mem.h.
Referenced by elaborate_gds(), remove_token_and_subtree(), remove_token_from_left_ht(), and remove_wme_from_wm().
#define fill_with_garbage | ( | block, | |
size | |||
) | { } |
Definition at line 174 of file mem.h.
Referenced by allocate_memory(), and free_memory().
#define HASH_TABLE_MEM_USAGE 1 |
Definition at line 179 of file mem.h.
Referenced by destroy_soar_agent(), free_hash_table(), init_rete(), make_hash_table(), print_memory_statistics(), and resize_hash_table().
#define insert_at_head_of_dll | ( | header, | |
item, | |||
next_field_name, | |||
prev_field_name | |||
) |
Definition at line 376 of file mem.h.
Referenced by _epmem_process_buffered_wme_list(), _smem_process_buffered_wme_list(), add_impasse_wme(), add_input_wme(), soar_module::add_module_wme(), add_preference_to_tm(), add_production_to_rete(), add_to_chunk_cond_set(), add_wme_to_alpha_mem(), add_wme_to_gds(), add_wme_to_rete(), assert_new_preferences(), cn_partner_node_left_addition(), create_instantiation(), decide_context_slot(), decide_non_context_slot(), do_acceptable_preference_wme_changes_for_slot(), do_demotion(), fill_in_new_instantiation_stuff(), insert_token_into_left_ht(), make_clones_of_results(), soar_module::make_fake_instantiation(), make_fake_preference_for_goal_item(), make_production(), make_slot(), mark_context_slot_as_acceptable_preference_changed(), mark_id_and_tc_as_unknown_level(), mark_slot_as_changed(), negative_node_left_addition(), negative_node_right_addition(), new_left_token(), p_node_left_addition(), p_node_left_removal(), parse_value_test_star(), post_link_removal(), postpone_assertion(), reorder_simplified_conditions(), restore_postponed_assertions(), reteload_node_and_children(), unhashed_negative_node_left_addition(), unhashed_negative_node_right_addition(), and update_for_top_state_wme_addition().
#define MAX_POOL_NAME_LENGTH 15 |
Definition at line 242 of file mem.h.
Referenced by init_memory_pool().
#define MISCELLANEOUS_MEM_USAGE 0 |
Definition at line 178 of file mem.h.
Referenced by add_rhs_function(), add_trace_format(), deallocate_trace_format_list(), destroy_soar_agent(), init_rete(), parse_item_from_format_string(), print_match_set(), print_memory_statistics(), remove_rhs_function(), remove_trace_format(), reteload_all_symbols(), reteload_alpha_memories(), reteload_free_am_table(), reteload_free_symbol_table(), start_lex_from_file(), stop_lex_from_file(), update_max_rhs_unbound_variables(), and xml_match_set().
#define NUM_MEM_USAGE_CODES 5 |
Definition at line 184 of file mem.h.
Referenced by init_memory_utilities(), and print_memory_statistics().
#define POOL_MEM_USAGE 3 |
Definition at line 181 of file mem.h.
Referenced by add_block_to_memory_pool(), free_memory_pool(), and print_memory_statistics().
#define remove_from_dll | ( | header, | |
item, | |||
next_field_name, | |||
prev_field_name | |||
) |
Definition at line 394 of file mem.h.
Referenced by add_production_to_rete(), consume_last_postponed_assertion(), deallocate_instantiation(), deallocate_preference(), decide_non_context_slot(), do_acceptable_preference_wme_changes_for_slot(), do_demotion(), do_output_cycle(), excise_production(), extract_dl_list_elements(), get_next_nil_goal_retraction(), get_next_retraction(), p_node_left_addition(), p_node_left_removal(), post_link_removal(), postpone_assertion(), print_action_list(), print_condition_list(), remove_existing_context_and_descendents(), remove_from_chunk_cond_set(), remove_garbage_slots(), remove_input_wme(), soar_module::remove_module_wme(), remove_output_function(), remove_preference_from_tm(), remove_wme_from_alpha_mem(), remove_wme_from_rete(), reorder_simplified_conditions(), restore_postponed_assertions(), retract_instantiation(), update_impasse_items(), walk_and_update_levels(), and xml_condition_list().
#define STATS_OVERHEAD_MEM_USAGE 4 |
Definition at line 182 of file mem.h.
Referenced by allocate_memory(), free_memory(), and print_memory_statistics().
#define STRING_MEM_USAGE 2 |
Definition at line 180 of file mem.h.
Referenced by add_to_growable_string(), free_growable_string(), free_memory_block_for_string(), make_blank_growable_string(), make_memory_block_for_string(), print_memory_statistics(), and read_rest_of_floating_point_number().
typedef item_in_hash_table* bucket_array |
typedef struct cons_struct cons |
typedef struct dl_cons_struct dl_cons |
typedef void* growable_string |
typedef struct hash_table_struct hash_table |
typedef struct item_in_hash_table_struct item_in_hash_table |
typedef struct memory_pool_struct memory_pool |
void add_block_to_memory_pool | ( | agent * | thisAgent, |
memory_pool * | p | ||
) |
Definition at line 224 of file mem.cpp.
References allocate_memory(), DEFAULT_INTERLEAVE_FACTOR, memory_pool_struct::first_block, memory_pool_struct::free_list, memory_pool_struct::item_size, memory_pool_struct::items_per_block, memory_pool_struct::num_blocks, and POOL_MEM_USAGE.
void add_to_growable_string | ( | agent * | thisAgent, |
growable_string * | gs, | ||
const char * | string_to_add | ||
) |
Definition at line 170 of file mem.cpp.
References allocate_memory(), free_memory(), length_of_growable_string(), memsize_of_growable_string(), STRING_MEM_USAGE, and text_of_growable_string().
Referenced by add_trace_for_attribute_path(), add_trace_for_wme(), add_values_of_attribute_path(), calculate_support_for_instantiation_preferences(), collect_root_variables(), object_to_trace_string(), p_node_left_addition(), parse_head_of_conds_for_one_id(), print_action_list(), print_condition_list(), reorder_simplified_conditions(), restore_and_deallocate_saved_tests(), trace_format_list_to_string(), and write_rhs_function_code().
void add_to_hash_table | ( | agent * | thisAgent, |
struct hash_table_struct * | ht, | ||
void * | item | ||
) |
Definition at line 581 of file mem.cpp.
References hash_table_struct::buckets, hash_table_struct::count, hash_table_struct::h, hash_table_struct::log2size, item_in_hash_table_struct::next, resize_hash_table(), hash_table_struct::size, and uint32_t().
Referenced by add_trace_format(), find_or_make_alpha_mem(), make_float_constant(), make_int_constant(), make_new_identifier(), make_sym_constant(), and make_variable().
Definition at line 44 of file mem.cpp.
References abort_with_fatal_error(), BUFFER_MSG_SIZE, fill_with_garbage, agent_struct::memory_for_usage, and STATS_OVERHEAD_MEM_USAGE.
Referenced by add_block_to_memory_pool(), add_rhs_function(), add_to_growable_string(), add_trace_format(), allocate_memory_and_zerofill(), make_blank_growable_string(), make_hash_table(), make_memory_block_for_string(), parse_item_from_format_string(), print_match_set(), read_rest_of_floating_point_number(), reteload_all_symbols(), reteload_alpha_memories(), start_lex_from_file(), and xml_match_set().
Definition at line 73 of file mem.cpp.
References allocate_memory().
Referenced by init_rete(), make_hash_table(), resize_hash_table(), and update_max_rhs_unbound_variables().
Definition at line 453 of file mem.cpp.
References cons_struct::first.
Referenced by remove_existing_context_and_descendents().
void do_for_all_items_in_hash_bucket | ( | struct hash_table_struct * | ht, |
hash_table_callback_fn | f, | ||
uint32_t | hash_value | ||
) |
Definition at line 610 of file mem.cpp.
References hash_table_struct::buckets, hash_table_struct::log2size, masks_for_n_low_order_bits, item_in_hash_table_struct::next, and NIL.
void do_for_all_items_in_hash_table | ( | agent * | thisAgent, |
struct hash_table_struct * | ht, | ||
hash_table_callback_fn2 | f, | ||
void * | userdata | ||
) |
Definition at line 595 of file mem.cpp.
References hash_table_struct::buckets, item_in_hash_table_struct::next, NIL, hash_table_struct::size, and uint32_t().
Referenced by print_all_trace_formats(), print_all_trace_formats_tcl(), print_internal_symbols(), reset_id_and_variable_tc_numbers(), reset_id_counters(), reset_variable_gensym_numbers(), retesave_alpha_memories(), and retesave_symbol_table().
dl_list* extract_dl_list_elements | ( | agent * | thisAgent, |
dl_list ** | header, | ||
dl_cons_test_fn | f | ||
) |
Definition at line 419 of file mem.cpp.
References dl_cons_struct::next, NIL, dl_cons_struct::prev, and remove_from_dll.
Referenced by print_action_list(), print_condition_list(), and xml_condition_list().
void free_growable_string | ( | agent * | thisAgent, |
growable_string | gs | ||
) |
Definition at line 191 of file mem.cpp.
References free_memory(), and STRING_MEM_USAGE.
Referenced by add_trace_for_attribute_path(), add_trace_for_wme(), add_values_of_attribute_path(), calculate_support_for_instantiation_preferences(), collect_root_variables(), p_node_left_addition(), parse_head_of_conds_for_one_id(), print_action_list(), print_condition_list(), print_object_trace(), print_object_trace_using_provided_format_string(), print_stack_trace(), reorder_simplified_conditions(), restore_and_deallocate_saved_tests(), trace_format_list_to_string(), and write_rhs_function_code().
void free_hash_table | ( | agent * | thisAgent, |
struct hash_table_struct * | ht | ||
) |
Definition at line 548 of file mem.cpp.
References hash_table_struct::buckets, free_memory(), and HASH_TABLE_MEM_USAGE.
Referenced by destroy_soar_agent().
Definition at line 81 of file mem.cpp.
References fill_with_garbage, agent_struct::memory_for_usage, and STATS_OVERHEAD_MEM_USAGE.
Referenced by add_to_growable_string(), deallocate_trace_format_list(), destroy_soar_agent(), free_growable_string(), free_hash_table(), free_memory_block_for_string(), free_memory_pool(), print_match_set(), remove_rhs_function(), remove_trace_format(), resize_hash_table(), reteload_free_am_table(), reteload_free_symbol_table(), stop_lex_from_file(), update_max_rhs_unbound_variables(), and xml_match_set().
void free_memory_block_for_string | ( | agent * | thisAgent, |
char * | p | ||
) |
Definition at line 153 of file mem.cpp.
References free_memory(), and STRING_MEM_USAGE.
Referenced by deallocate_production(), deallocate_symbol(), deallocate_trace_format_list(), destroy_soar_agent(), parse_production(), read_rest_of_floating_point_number(), rl_perform_update(), and stop_lex_from_file().
void free_memory_pool | ( | agent * | , |
memory_pool * | p | ||
) |
Definition at line 274 of file mem.cpp.
References memory_pool_struct::first_block, free_memory(), memory_pool_struct::num_blocks, and POOL_MEM_USAGE.
Referenced by destroy_soar_agent().
void init_memory_pool | ( | agent * | thisAgent, |
memory_pool * | p, | ||
size_t | item_size, | ||
const char * | name | ||
) |
Definition at line 287 of file mem.cpp.
References abort_with_fatal_error(), DEFAULT_BLOCK_SIZE, memory_pool_struct::first_block, memory_pool_struct::free_list, memory_pool_struct::item_size, memory_pool_struct::items_per_block, MAX_POOL_NAME_LENGTH, agent_struct::memory_pools_in_use, memory_pool_struct::name, memory_pool_struct::next, NIL, memory_pool_struct::num_blocks, and memory_pool_struct::used_count.
Referenced by soar_module::get_memory_pool(), init_chunker(), init_decider(), init_firer(), init_memory_utilities(), init_production_utilities(), init_reorderer(), init_rete(), init_soar_agent(), init_soar_io(), and init_symbol_tables().
void init_memory_utilities | ( | agent * | thisAgent | ) |
Definition at line 629 of file mem.cpp.
References agent_struct::cons_cell_pool, agent_struct::dl_cons_pool, init_memory_pool(), agent_struct::memory_for_usage, and NUM_MEM_USAGE_CODES.
Referenced by create_soar_agent().
|
inline |
Definition at line 222 of file mem.h.
Referenced by add_to_growable_string(), add_trace_for_attribute_path(), make_blank_growable_string(), and trace_format_list_to_string().
growable_string make_blank_growable_string | ( | agent * | thisAgent | ) |
Definition at line 159 of file mem.cpp.
References allocate_memory(), INITIAL_GROWABLE_STRING_SIZE, length_of_growable_string(), memsize_of_growable_string(), STRING_MEM_USAGE, and text_of_growable_string().
Referenced by add_trace_for_attribute_path(), calculate_support_for_instantiation_preferences(), collect_root_variables(), object_to_trace_string(), p_node_left_addition(), parse_head_of_conds_for_one_id(), print_action_list(), print_condition_list(), reorder_simplified_conditions(), restore_and_deallocate_saved_tests(), selection_to_trace_string(), trace_format_list_to_string(), and write_rhs_function_code().
|
read |
Definition at line 502 of file mem.cpp.
References allocate_memory(), allocate_memory_and_zerofill(), hash_table_struct::buckets, hash_table_struct::count, hash_table_struct::h, HASH_TABLE_MEM_USAGE, hash_table_struct::log2size, hash_table_struct::minimum_log2size, hash_table_struct::size, and uint32_t().
Referenced by init_rete(), init_symbol_tables(), and init_tracing().
char* make_memory_block_for_string | ( | agent * | thisAgent, |
char const * | s | ||
) |
Definition at line 142 of file mem.cpp.
References allocate_memory(), and STRING_MEM_USAGE.
Referenced by make_sym_constant(), make_variable(), parse_item_from_format_string(), parse_production(), reteload_node_and_children(), rl_perform_update(), and start_lex_from_file().
|
inline |
Definition at line 217 of file mem.h.
Referenced by add_to_growable_string(), and make_blank_growable_string().
void print_memory_statistics | ( | agent * | thisAgent | ) |
Definition at line 96 of file mem.cpp.
References HASH_TABLE_MEM_USAGE, agent_struct::memory_for_usage, MISCELLANEOUS_MEM_USAGE, NUM_MEM_USAGE_CODES, POOL_MEM_USAGE, print(), STATS_OVERHEAD_MEM_USAGE, and STRING_MEM_USAGE.
void remove_from_hash_table | ( | agent * | thisAgent, |
struct hash_table_struct * | ht, | ||
void * | item | ||
) |
Definition at line 553 of file mem.cpp.
References hash_table_struct::buckets, hash_table_struct::count, hash_table_struct::h, hash_table_struct::log2size, hash_table_struct::minimum_log2size, item_in_hash_table_struct::next, NIL, resize_hash_table(), hash_table_struct::size, and uint32_t().
Referenced by deallocate_symbol(), remove_ref_to_alpha_mem(), and remove_trace_format().
|
inline |
Definition at line 212 of file mem.h.
Referenced by capitalize_symbol_rhs_function_code(), create_soar_agent(), and trim_rhs_function_code().
|
inline |
Definition at line 227 of file mem.h.
Referenced by add_to_growable_string(), add_trace_for_attribute_path(), add_trace_for_wme(), add_values_of_attribute_path(), calculate_support_for_instantiation_preferences(), collect_root_variables(), make_blank_growable_string(), p_node_left_addition(), parse_head_of_conds_for_one_id(), print_action_list(), print_condition_list(), print_object_trace(), print_object_trace_using_provided_format_string(), print_stack_trace(), reorder_simplified_conditions(), restore_and_deallocate_saved_tests(), trace_format_list_to_string(), and write_rhs_function_code().
typedef uint32_t | ( | (*)(void *item, short num_bits) | hash_function | ) |
Referenced by add_to_hash_table(), add_wme_to_alpha_mem(), add_wme_to_rete(), beta_memory_node_left_addition(), canonical_cond_greater(), cn_node_left_addition(), cn_partner_node_left_addition(), compress(), do_for_all_items_in_hash_table(), exploration_get_highest_q_value_pref(), exploration_randomly_select(), find_alpha_mem(), find_float_constant(), find_identifier(), find_int_constant(), find_sym_constant(), find_variable(), MTRand::hash(), hash_condition(), hash_string(), hash_test(), MTRand::initialize(), MTRand::load(), lookup_trace_format(), make_chunk_cond_for_condition(), make_hash_table(), mp_node_left_addition(), mp_node_right_addition(), negative_node_left_addition(), negative_node_right_addition(), operator<<(), operator>>(), positive_node_left_addition(), positive_node_right_addition(), predict_srand_store_snapshot(), MTRand::rand53(), MTRand::randInt(), MTRand::reload(), remove_from_hash_table(), remove_trace_format(), remove_wme_from_alpha_mem(), resize_hash_table(), reteload_four_bytes(), MTRand::save(), MTRand::seed(), unhashed_beta_memory_node_left_addition(), unhashed_mp_node_left_addition(), unhashed_mp_node_right_addition(), unhashed_negative_node_left_addition(), unhashed_negative_node_right_addition(), and unhashed_positive_node_right_addition().
uint32_t masks_for_n_low_order_bits[33] |
Definition at line 492 of file mem.cpp.
Referenced by add_wme_to_aht(), alpha_hash_value(), compress(), do_for_all_items_in_hash_bucket(), hash_name_restriction(), and make_chunk_cond_for_condition().