From e99a939ef606f6f25af3d8ea472a7de9b5479cf4 Mon Sep 17 00:00:00 2001
From: Graham Nelson
+typedef struct property_setting_bp_data { + struct wording property_pending_text; temp. version used until props created + struct property *set_property; asserting \(B(x, v)\) sets this prop. of \(x\) to \(v\) + CLASS_DEFINITION +} property_setting_bp_data; + binary_predicate *Properties::SettingRelations::make_set_property_BP(wording W) { binary_predicate *bp = BinaryPredicates::make_pair(property_setting_bp_family, BPTerms::new(Kinds::Knowledge::as_subject(K_object)), BPTerms::new(NULL), I"set-property", NULL, NULL, NULL, WordAssemblages::lit_0()); - bp->property_pending_text = W; - bp->reversal->property_pending_text = W; + property_setting_bp_data *PSD = CREATE(property_setting_bp_data); + PSD->property_pending_text = W; + bp->family_specific = STORE_POINTER_property_setting_bp_data(PSD); + bp->reversal->family_specific = STORE_POINTER_property_setting_bp_data(PSD); return bp; }+
§4. Meanwhile, we can't look up the BP with reference to the property, since the property may not exist yet; we have to use the text of the name of the property as a key, clumsy as that may seem. @@ -144,30 +157,38 @@ property as a key, clumsy as that may seem. binary_predicate *Properties::SettingRelations::find_set_property_BP(wording W) { binary_predicate *bp; LOOP_OVER(bp, binary_predicate) - if (Wordings::match(W, bp->property_pending_text)) - if (bp->right_way_round) - return bp; + if (bp->relation_family == property_setting_bp_family) + if (bp->right_way_round) { + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + if (Wordings::match(W, PSD->property_pending_text)) + return bp; + } return NULL; } -
§5. ...And now it's "later on". We fix these BPs in original-reversal pairs, so -that the two can never fall out of step. +
§5. ...And now it's "later on". Original-reversal pairs share the setting data, so +that the two can never fall out of step with each other.
void Properties::SettingRelations::fix_property_bp(binary_predicate *bp) { - binary_predicate *bpr = bp->reversal; - wording W = bp->property_pending_text; - if (Wordings::nonempty(W)) { - bp->property_pending_text = EMPTY_WORDING; - bpr->property_pending_text = EMPTY_WORDING; - current_sentence = bp->bp_created_at; - <relation-property-name>(W); - if (<<r>> == FALSE) return; a problem was issued - property *prn = <<rp>>; - bp->set_property = prn; bpr->set_property = prn; - if (bp->right_way_round) Properties::SettingRelations::set_property_BP_schemas(bp, prn); - else Properties::SettingRelations::set_property_BP_schemas(bpr, prn); + if (bp->relation_family == property_setting_bp_family) { + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + wording W = PSD->property_pending_text; + if (Wordings::nonempty(W)) { + PSD->property_pending_text = EMPTY_WORDING; + current_sentence = bp->bp_created_at; + <relation-property-name>(W); + if (<<r>> == FALSE) return; a problem was issued + property *prn = <<rp>>; + PSD->set_property = prn; + if (bp->right_way_round) + Properties::SettingRelations::set_property_BP_schemas(bp, prn); + else + Properties::SettingRelations::set_property_BP_schemas(bp->reversal, prn); + } } }@@ -215,8 +236,9 @@ Inform:
binary_predicate *Properties::SettingRelations::make_set_nameless_property_BP(property *prn) { binary_predicate *bp = Properties::SettingRelations::make_set_property_BP(EMPTY_WORDING); - binary_predicate *bpr = bp->reversal; - bp->set_property = prn; bpr->set_property = prn; + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + PSD->set_property = prn; Properties::SettingRelations::set_property_BP_schemas(bp, prn); return bp; } @@ -254,7 +276,9 @@ instance, but hasn't been yet.int Properties::SettingRelations::REL_typecheck(bp_family *self, binary_predicate *bp, kind **kinds_of_terms, kind **kinds_required, tc_problem_kit *tck) { - property *prn = bp->set_property; + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + property *prn = PSD->set_property; kind *val_kind = Properties::Valued::kind(prn); Require the value to be type-safe for storage in the property9.1; Require the subject to be able to have properties9.2; @@ -337,7 +361,9 @@ be caught later on Inform's run. int Properties::SettingRelations::REL_assert(bp_family *self, binary_predicate *bp, inference_subject *infs0, parse_node *spec0, inference_subject *infs1, parse_node *spec1) { - World::Inferences::draw_property(infs0, bp->set_property, spec1); + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + World::Inferences::draw_property(infs0, PSD->set_property, spec1); return TRUE; }@@ -351,7 +377,9 @@ be caught later on Inform's run. if (Kinds::Behaviour::is_object(K)) return FALSE; - property *prn = bp->set_property; + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + property *prn = PSD->set_property; switch (task) { case TEST_ATOM_TASK: Calculus::Schemas::modify(asch->schema, @@ -371,7 +399,8 @@ be caught later on Inform's run.int Properties::SettingRelations::bp_sets_a_property(binary_predicate *bp) { - if ((bp->set_property) || (Wordings::nonempty(bp->property_pending_text))) return TRUE; + if (bp->relation_family == property_setting_bp_family) return TRUE; + if ((bp->set_property) (Wordings::nonempty(bp->property_pending_text))) return TRUE; return FALSE; }diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index bc7aa7561..91bddfdd9 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,6 +1,6 @@ Total memory consumption was 256345K = 250 MB -62.4% was used for 1338291 objects, in 273494 frames in 200 x 800K = 160000K = 156 MB: +62.4% was used for 1338375 objects, in 273578 frames in 200 x 800K = 160000K = 156 MB: 9.8% inter_tree_node_array 36 x 8192 = 294912 objects, 25953408 bytes 5.5% text_stream_array 2567 x 100 = 256700 objects, 14457344 bytes @@ -41,7 +41,7 @@ Total memory consumption was 256345K = 250 MB 0.1% noun 2379 objects, 285480 bytes ---- action_name_list_array 3 x 1000 = 3000 objects, 240096 bytes ---- inter_annotation_array 1 x 8192 objects, 196640 bytes - ---- binary_predicate 321 objects, 192600 bytes + ---- binary_predicate 321 objects, 184896 bytes ---- inference 1703 objects, 177112 bytes ---- linked_list_item_array 10 x 1000 = 10000 objects, 160320 bytes ---- linguistic_stock_item 3315 objects, 159120 bytes @@ -111,13 +111,14 @@ Total memory consumption was 256345K = 250 MB ---- parsing_pp_data 96 objects, 4608 bytes ---- build_vertex 40 objects, 4480 bytes ---- hierarchy_attachment_point 48 objects, 4224 bytes - ---- stacked_variable_list_array 1 x 100 objects, 4032 bytes ---- placement_affecting_array 1 x 100 objects, 4032 bytes + ---- stacked_variable_list_array 1 x 100 objects, 4032 bytes ---- activity 35 objects, 3920 bytes ---- inbuild_edition 54 objects, 3888 bytes ---- parse_node_annotation_type 118 objects, 3776 bytes ---- inbuild_copy 35 objects, 3640 bytes ---- command_line_switch 43 objects, 3440 bytes + ---- property_setting_bp_data 84 objects, 3360 bytes ---- kind_constructor_comparison_schema_array 1 x 100 objects, 3232 bytes ---- instance_usage_array 1 x 200 objects, 3232 bytes ---- compatibility_specification 66 objects, 3168 bytes @@ -126,24 +127,24 @@ Total memory consumption was 256345K = 250 MB ---- property_of_value_storage 93 objects, 2976 bytes ---- submodule_request 72 objects, 2880 bytes ---- inter_construct 32 objects, 2560 bytes - ---- kind_constructor_casting_rule_array 1 x 100 objects, 2432 bytes ---- method_set 76 objects, 2432 bytes ---- kind_constructor_instance_array 1 x 100 objects, 2432 bytes + ---- kind_constructor_casting_rule_array 1 x 100 objects, 2432 bytes ---- equation_symbol 30 objects, 2400 bytes ---- semver_range 22 objects, 2288 bytes ---- use_option 29 objects, 1856 bytes ---- pronoun_usage 42 objects, 1680 bytes ---- table_contribution_array 1 x 100 objects, 1632 bytes - ---- plugin_call_array 1 x 100 objects, 1632 bytes ---- activity_crossref_array 1 x 100 objects, 1632 bytes + ---- plugin_call_array 1 x 100 objects, 1632 bytes ---- kind_interaction 39 objects, 1560 bytes ---- inter_annotation_form 37 objects, 1480 bytes ---- pipeline_step 12 objects, 1440 bytes ---- noun_filter_token 22 objects, 1408 bytes ---- scene 1 object, 1344 bytes ---- special_meaning_holder 33 objects, 1320 bytes - ---- build_script 40 objects, 1280 bytes ---- constant_phrase 20 objects, 1280 bytes + ---- build_script 40 objects, 1280 bytes ---- invocation_options_array 1 x 100 objects, 1224 bytes ---- hierarchy_metadatum 15 objects, 1200 bytes ---- quantifier 16 objects, 1024 bytes @@ -154,8 +155,8 @@ Total memory consumption was 256345K = 250 MB ---- cached_understanding 21 objects, 840 bytes ---- runtime_kind_structure 13 objects, 832 bytes ---- phrase_option_array 1 x 100 objects, 824 bytes - ---- pipeline_stage 17 objects, 816 bytes ---- target_vm 6 objects, 816 bytes + ---- pipeline_stage 17 objects, 816 bytes ---- generated_segment 25 objects, 800 bytes ---- inter_data_type 14 objects, 784 bytes ---- submodule_identity 23 objects, 736 bytes @@ -166,22 +167,22 @@ Total memory consumption was 256345K = 250 MB ---- inter_warehouse_room 10 objects, 640 bytes ---- I6T_intervention 8 objects, 640 bytes ---- nascent_array 7 objects, 616 bytes - ---- named_rulebook_outcome 15 objects, 600 bytes ---- inbuild_search_result 15 objects, 600 bytes + ---- named_rulebook_outcome 15 objects, 600 bytes ---- label_namespace 10 objects, 560 bytes ---- small_word_set 11 objects, 528 bytes ---- inform_kit 5 objects, 520 bytes - ---- i6_memory_setting 13 objects, 416 bytes ---- equation 4 objects, 416 bytes + ---- i6_memory_setting 13 objects, 416 bytes ---- module_package 10 objects, 400 bytes ---- dval_written 10 objects, 400 bytes ---- article_usage 8 objects, 384 bytes ---- source_file 5 objects, 360 bytes ---- bp_family 11 objects, 352 bytes ---- inbuild_genre 7 objects, 336 bytes + ---- pronoun 8 objects, 320 bytes ---- door_dir_notice 5 objects, 320 bytes ---- grammatical_category 8 objects, 320 bytes - ---- pronoun 8 objects, 320 bytes ---- up_family 9 objects, 288 bytes ---- build_step 4 objects, 288 bytes ---- door_to_notice 5 objects, 280 bytes @@ -193,26 +194,26 @@ Total memory consumption was 256345K = 250 MB ---- kit_dependency 4 objects, 192 bytes ---- plural_dictionary_entry 4 objects, 192 bytes ---- inform_project 1 object, 176 bytes - ---- inter_architecture 4 objects, 160 bytes + ---- pointer_allocation 2 objects, 160 bytes ---- link_instruction 4 objects, 160 bytes ---- code_generation_target 4 objects, 160 bytes - ---- pointer_allocation 2 objects, 160 bytes + ---- inter_architecture 4 objects, 160 bytes ---- codegen_pipeline 1 object, 128 bytes ---- element_activation 4 objects, 128 bytes ---- inbuild_nest 3 objects, 120 bytes ---- inform_kit_ittt 2 objects, 96 bytes ---- compile_task_data 1 object, 80 bytes - ---- article 2 objects, 80 bytes ---- list_together_routine 2 objects, 80 bytes + ---- article 2 objects, 80 bytes ---- build_methodology 1 object, 56 bytes ---- inter_warehouse 1 object, 56 bytes ---- star_invention 1 object, 48 bytes ---- HTML_file_state 1 object, 48 bytes ---- blorb_figure 1 object, 48 bytes - ---- parse_name_notice 1 object, 40 bytes ---- kind_template_definition 1 object, 40 bytes - ---- by_routine_bp_data 1 object, 40 bytes + ---- parse_name_notice 1 object, 40 bytes ---- loop_over_scope 1 object, 40 bytes + ---- by_routine_bp_data 1 object, 40 bytes 37.5% was used for memory not allocated for objects: @@ -233,5 +234,5 @@ Total memory consumption was 256345K = 250 MB ---- emitter array storage 14368 bytes in 8 claims ---- code generation workspace for objects 9200 bytes in 9 claims -20.0% was overhead - 52565656 bytes = 51333K = 50 MB +20.0% was overhead - 52570000 bytes = 51337K = 50 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 97decdf11..2645e5926 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,28 +1,28 @@ 100.0% in inform7 run - 66.2% in compilation to Inter - 25.2% in //Phrases::Manager::compile_first_block// + 67.1% in compilation to Inter + 25.6% in //Phrases::Manager::compile_first_block// 8.8% in //Phrases::Manager::compile_as_needed// - 6.8% in //Strings::compile_responses// - 6.3% in //World::Compile::compile// + 7.2% in //Strings::compile_responses// + 6.1% in //World::Compile::compile// 3.7% in //MajorNodes::pre_pass// 3.3% in //MajorNodes::pass_1// 2.1% in //Phrases::Manager::RulePrintingRule_routine// 1.9% in //Phrases::Manager::rulebooks_array// 1.0% in //RTVerbs::ConjugateVerb// 0.8% in //Phrases::Manager::traverse// - 0.5% in //Phrases::Manager::compile_rulebooks// 0.5% in //Phrases::Manager::parse_rule_parameters// 0.5% in //World::complete// 0.3% in //MajorNodes::pass_2// + 0.3% in //Phrases::Manager::compile_rulebooks// 0.3% in //RTRelations::compile_defined_relations// 0.1% in //Kinds::RunTime::compile_data_type_support_routines// 0.1% in //PL::Parsing::Verbs::compile_all// 0.1% in //Task::make_built_in_kind_constructors// - 3.0% not specifically accounted for - 31.2% in running Inter pipeline - 10.4% in step preparation - 9.7% in inter step 2/12: link - 7.7% in inter step 12/12: generate inform6 -> auto.inf + 3.5% not specifically accounted for + 30.5% in running Inter pipeline + 9.8% in inter step 2/12: link + 9.8% in step preparation + 7.0% in inter step 12/12: generate inform6 -> auto.inf 0.3% in inter step 9/12: make-identifiers-unique 0.1% in inter step 10/12: reconcile-verbs 0.1% in inter step 11/12: eliminate-redundant-labels @@ -31,6 +31,6 @@ 0.1% in inter step 6/12: assimilate 0.1% in inter step 7/12: resolve-external-symbols 0.1% in inter step 8/12: inspect-plugs - 1.7% not specifically accounted for + 2.1% not specifically accounted for 1.9% in supervisor - 0.6% not specifically accounted for + 0.4% not specifically accounted for diff --git a/inform7/core-module/Chapter 1/Class Predeclarations.w b/inform7/core-module/Chapter 1/Class Predeclarations.w index e4c4e56fc..f419860fa 100644 --- a/inform7/core-module/Chapter 1/Class Predeclarations.w +++ b/inform7/core-module/Chapter 1/Class Predeclarations.w @@ -97,6 +97,7 @@ DECLARE_CLASS(text_substitution) @e property_CLASS @e property_permission_CLASS @e property_of_value_storage_CLASS +@e property_setting_bp_data_CLASS @e rule_CLASS @e rulebook_CLASS @e rulebook_outcome_CLASS @@ -121,6 +122,7 @@ DECLARE_CLASS_ALLOCATED_IN_ARRAYS(placement_affecting, 100) DECLARE_CLASS(property_of_value_storage) DECLARE_CLASS(property_permission) DECLARE_CLASS(property) +DECLARE_CLASS(property_setting_bp_data) DECLARE_CLASS(rule) DECLARE_CLASS(rulebook) DECLARE_CLASS(rulebook_outcome) diff --git a/inform7/knowledge-module/Chapter 2/Setting Property Relation.w b/inform7/knowledge-module/Chapter 2/Setting Property Relation.w index e2e5e2f31..3c0acbaf9 100644 --- a/inform7/knowledge-module/Chapter 2/Setting Property Relation.w +++ b/inform7/knowledge-module/Chapter 2/Setting Property Relation.w @@ -25,8 +25,12 @@ void Properties::SettingRelations::stock(bp_family *self, int n) { if (n == 2) { binary_predicate *bp; LOOP_OVER(bp, binary_predicate) - if (Wordings::nonempty(bp->property_pending_text)) - Properties::SettingRelations::fix_property_bp(bp); + if (bp->relation_family == property_setting_bp_family) { + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + if (Wordings::nonempty(PSD->property_pending_text)) + Properties::SettingRelations::fix_property_bp(bp); + } } } @@ -38,13 +42,21 @@ therefore store the text of the property name (say, "weight") in |property_pending_text| and come back to it later on. = +typedef struct property_setting_bp_data { + struct wording property_pending_text; /* temp. version used until props created */ + struct property *set_property; /* asserting $B(x, v)$ sets this prop. of $x$ to $v$ */ + CLASS_DEFINITION +} property_setting_bp_data; + binary_predicate *Properties::SettingRelations::make_set_property_BP(wording W) { binary_predicate *bp = BinaryPredicates::make_pair(property_setting_bp_family, BPTerms::new(Kinds::Knowledge::as_subject(K_object)), BPTerms::new(NULL), I"set-property", NULL, NULL, NULL, WordAssemblages::lit_0()); - bp->property_pending_text = W; - bp->reversal->property_pending_text = W; + property_setting_bp_data *PSD = CREATE(property_setting_bp_data); + PSD->property_pending_text = W; + bp->family_specific = STORE_POINTER_property_setting_bp_data(PSD); + bp->reversal->family_specific = STORE_POINTER_property_setting_bp_data(PSD); return bp; } @@ -56,29 +68,37 @@ property as a key, clumsy as that may seem. binary_predicate *Properties::SettingRelations::find_set_property_BP(wording W) { binary_predicate *bp; LOOP_OVER(bp, binary_predicate) - if (Wordings::match(W, bp->property_pending_text)) - if (bp->right_way_round) - return bp; + if (bp->relation_family == property_setting_bp_family) + if (bp->right_way_round) { + property_setting_bp_data *PSD = + RETRIEVE_POINTER_property_setting_bp_data(bp->family_specific); + if (Wordings::match(W, PSD->property_pending_text)) + return bp; + } return NULL; } -@ ...And now it's "later on". We fix these BPs in original-reversal pairs, so -that the two can never fall out of step. +@ ...And now it's "later on". Original-reversal pairs share the setting data, so +that the two can never fall out of step with each other. = void Properties::SettingRelations::fix_property_bp(binary_predicate *bp) { - binary_predicate *bpr = bp->reversal; - wording W = bp->property_pending_text; - if (Wordings::nonempty(W)) { - bp->property_pending_text = EMPTY_WORDING; - bpr->property_pending_text = EMPTY_WORDING; - current_sentence = bp->bp_created_at; -(W); - if (< > == FALSE) return; /* a problem was issued */ - property *prn = <