diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index 8058b284e7..4be8288b7c 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,20 +1,20 @@ -Total memory consumption was 126309K = 123 MB +Total memory consumption was 126314K = 123 MB - ---- was used for 2008042 objects, in 360817 frames in 0 x 800K = 0K = 0 MB: + ---- was used for 2008185 objects, in 360861 frames in 0 x 800K = 0K = 0 MB: 32.3% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes - 18.9% text_stream_array 4342 x 100 = 434200 objects, 24454144 bytes + 18.9% text_stream_array 4343 x 100 = 434300 objects, 24459776 bytes 18.7% linked_list 43280 objects, 24236800 bytes 10.8% inter_symbol_array 132 x 1024 = 135168 objects, 14061696 bytes 10.2% inter_error_stash_array 101 x 1024 = 103424 objects, 13241504 bytes - 8.0% parse_node 129462 objects, 10356960 bytes + 8.0% parse_node 129463 objects, 10357040 bytes 5.7% verb_conjugation 160 objects, 7425280 bytes 4.2% parse_node_annotation_array 345 x 500 = 172500 objects, 5531040 bytes 2.6% pcalc_prop_array 25 x 1000 = 25000 objects, 3400800 bytes 2.4% inter_name_array 67 x 1000 = 67000 objects, 3218144 bytes 2.0% kind_array 66 x 1000 = 66000 objects, 2642112 bytes 1.5% inter_name_generator_array 51 x 1000 = 51000 objects, 2041632 bytes - 1.5% inter_schema_token 13937 objects, 2006928 bytes + 1.5% inter_schema_token 13959 objects, 2010096 bytes 1.4% package_request 21137 objects, 1860056 bytes 1.3% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes 1.1% match_trie_array 11 x 1000 = 11000 objects, 1496352 bytes @@ -30,11 +30,11 @@ Total memory consumption was 126309K = 123 MB 0.6% ptoken 8397 objects, 873288 bytes 0.6% grammatical_usage 3611 objects, 866640 bytes 0.6% individual_form 2561 objects, 860496 bytes - 0.6% inter_schema_node 8896 objects, 854016 bytes + 0.6% inter_schema_node 8914 objects, 855744 bytes 0.4% unary_predicate_array 16 x 1000 = 16000 objects, 640512 bytes 0.3% scan_directory 112 objects, 462336 bytes 0.3% local_variable_array 47 x 100 = 4700 objects, 452704 bytes - 0.3% verb_usage 1128 objects, 388032 bytes + 0.2% verb_usage 1128 objects, 388032 bytes 0.2% rule 469 objects, 367696 bytes 0.2% verb_form 386 objects, 348944 bytes 0.2% dictionary 6619 objects, 317712 bytes @@ -55,7 +55,7 @@ Total memory consumption was 126309K = 123 MB ---- noun_usage 2402 objects, 96080 bytes ---- anl_entry_array 2 x 1000 = 2000 objects, 96064 bytes ---- preposition 273 objects, 87360 bytes - ---- inter_schema 1508 objects, 84448 bytes + ---- inter_schema 1510 objects, 84560 bytes ---- lexical_cluster 2517 objects, 80544 bytes ---- pcalc_term_array 2 x 1000 = 2000 objects, 80064 bytes ---- kind_variable_declaration 1652 objects, 79296 bytes @@ -237,7 +237,7 @@ Total memory consumption was 126309K = 123 MB 100.0% was used for memory not allocated for objects: - 59.2% text stream storage 76627344 bytes in 452212 claims + 59.2% text stream storage 76632712 bytes in 452254 claims 3.5% dictionary storage 4544512 bytes in 6619 claims ---- sorting 744 bytes in 3 claims 5.5% source text 7200000 bytes in 3 claims @@ -246,7 +246,7 @@ Total memory consumption was 126309K = 123 MB ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims 3.4% inter symbols storage 4523040 bytes in 27924 claims - 12.9% inter bytecode storage 16767472 bytes in 14 claims + 12.9% inter bytecode storage 16767432 bytes in 14 claims 4.8% inter links storage 6222976 bytes in 11 claims 0.1% inter tree location list storage 191232 bytes in 32 claims 1.3% instance-of-kind counting 1695204 bytes in 1 claim @@ -255,5 +255,5 @@ Total memory consumption was 126309K = 123 MB ---- code generation workspace for objects 1336 bytes in 4 claims 0.2% emitter array storage 279776 bytes in 1995 claims --140.-5% was overhead - -181852072 bytes = -177589K = -173 MB +-140.-6% was overhead - -181862792 bytes = -177600K = -173 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 277e39266c..dbaa0fcae4 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,8 +1,8 @@ 100.0% in inform7 run - 68.2% in compilation to Inter - 47.9% in //Sequence::undertake_queued_tasks// - 4.6% in //MajorNodes::pre_pass// - 3.2% in //MajorNodes::pass_1// + 68.5% in compilation to Inter + 48.2% in //Sequence::undertake_queued_tasks// + 4.5% in //MajorNodes::pre_pass// + 3.3% in //MajorNodes::pass_1// 2.3% in //RTPhrasebook::compile_entries// 1.8% in //ImperativeDefinitions::assess_all// 1.5% in //RTKindConstructors::compile// @@ -18,15 +18,15 @@ 0.1% in //Task::make_built_in_kind_constructors// 0.1% in //Understand::traverse// 0.1% in //World::stages_II_and_III// - 2.1% not specifically accounted for - 29.1% in running Inter pipeline - 10.2% in step 14/15: generate inform6 -> auto.inf - 7.5% in step 5/15: load-binary-kits - 6.7% in step 6/15: make-synoptic-module + 2.0% not specifically accounted for + 28.8% in running Inter pipeline + 10.1% in step 14/15: generate inform6 -> auto.inf + 7.6% in step 5/15: load-binary-kits + 6.6% in step 6/15: make-synoptic-module 1.5% in step 9/15: make-identifiers-unique 0.4% in step 12/15: eliminate-redundant-operations 0.4% in step 4/15: compile-splats - 0.4% in step 7/15: shorten-wiring + 0.3% in step 7/15: shorten-wiring 0.3% in step 8/15: detect-indirect-calls 0.2% in step 11/15: eliminate-redundant-labels 0.1% in step 10/15: reconcile-verbs diff --git a/inform7/imperative-module/Chapter 4/Compile Deferred Propositions.w b/inform7/imperative-module/Chapter 4/Compile Deferred Propositions.w index a0077230c4..4966ceb853 100644 --- a/inform7/imperative-module/Chapter 4/Compile Deferred Propositions.w +++ b/inform7/imperative-module/Chapter 4/Compile Deferred Propositions.w @@ -23,6 +23,8 @@ void DeferredPropositions::compile_comment_about_deferral_reason(int reason) { EmitCode::comment(I"How many x satisfy this?"); break; case TOTAL_DEFER: EmitCode::comment(I"Find a total property value over all x satisfying:"); break; + case TOTAL_REAL_DEFER: + EmitCode::comment(I"Find a total real property value over all x satisfying:"); break; case RANDOM_OF_DEFER: EmitCode::comment(I"Find a random x satisfying:"); break; case MULTIPURPOSE_DEFER: @@ -243,8 +245,12 @@ possibility. case NUMBER_OF_DUSAGE: reason = NUMBER_OF_DEFER; break; case RANDOM_OF_DUSAGE: reason = RANDOM_OF_DEFER; break; case TOTAL_DUSAGE: reason = TOTAL_DEFER; break; + case TOTAL_REAL_DUSAGE: reason = TOTAL_REAL_DEFER; break; case EXTREMAL_DUSAGE: reason = EXTREMAL_DEFER; break; } + if ((use == TOTAL_REAL_DUSAGE) && + (TargetVMs::supports_floating_point(Task::vm()) == FALSE)) + continue; EmitCode::inv(CASE_BIP); EmitCode::down(); EmitCode::val_number((inter_ti) use); @@ -285,6 +291,7 @@ and at the end of the search it performs |return counter|. case NUMBER_OF_DEFER: @; break; case LIST_OF_DEFER: @; break; case TOTAL_DEFER: @; break; + case TOTAL_REAL_DEFER: @; break; case RANDOM_OF_DEFER: @; break; } @; @@ -302,6 +309,7 @@ and at the end of the search it performs |return counter|. case NUMBER_OF_DEFER: @; break; case LIST_OF_DEFER: @; break; case TOTAL_DEFER: @; break; + case TOTAL_REAL_DEFER: @; break; case RANDOM_OF_DEFER: @; break; } @@ -486,6 +494,7 @@ example. (See below.) case NUMBER_OF_DEFER: @; break; case LIST_OF_DEFER: @; break; case TOTAL_DEFER: @; break; + case TOTAL_REAL_DEFER: @; break; case RANDOM_OF_DEFER: @; break; } @@ -893,6 +902,9 @@ In some of the cases, additional local variables are needed within the case TOTAL_DEFER: total_s = LocalVariables::new_internal_as_symbol(I"total"); break; + case TOTAL_REAL_DEFER: + total_s = LocalVariables::new_internal_as_symbol(I"total"); + break; case LIST_OF_DEFER: counter_s = LocalVariables::new_internal_as_symbol(I"counter"); total_s = LocalVariables::new_internal_as_symbol(I"total"); @@ -1215,6 +1227,10 @@ in the domain $\lbrace x\mid \phi(x)\rbrace$. proposition = DeferredPropositions::compile_loop_header(0, var_ix_lv[0], proposition, FALSE, FALSE, pdef); +@ = + proposition = DeferredPropositions::compile_loop_header(0, var_ix_lv[0], + proposition, FALSE, FALSE, pdef); + @ The only wrinkle here is the way the compiled code knows which property it should be totalling. If we know that ourselves, we can compile in a direct reference. But if we are compiling a multipurpose deferred proposition, then @@ -1246,12 +1262,42 @@ which until runtime -- when its identity will be found in the Inter variable @; +@ = + EmitCode::inv(STORE_BIP); + EmitCode::down(); + EmitCode::ref_symbol(K_value, total_s); + EmitCode::call(Hierarchy::find(REAL_NUMBER_TY_PLUS_HL)); + EmitCode::down(); + EmitCode::val_symbol(K_value, total_s); + EmitCode::inv(PROPERTYVALUE_BIP); + EmitCode::down(); + EmitCode::val_iname(K_value, RTKindIDs::weak_iname(K_object)); + EmitCode::val_symbol(K_value, var_s[0]); + if (multipurpose_function) { + EmitCode::val_iname(K_value, + Hierarchy::find(PROPERTY_TO_BE_TOTALLED_HL)); + } else { + prn = RETRIEVE_POINTER_property(pdef->defn_ref); + EmitCode::val_iname(K_value, RTProperties::iname(prn)); + } + EmitCode::up(); + EmitCode::up(); + EmitCode::up(); + + @; + @ = EmitCode::inv(RETURN_BIP); EmitCode::down(); EmitCode::val_symbol(K_value, total_s); EmitCode::up(); +@ = + EmitCode::inv(RETURN_BIP); + EmitCode::down(); + EmitCode::val_symbol(K_value, total_s); + EmitCode::up(); + @h Adaptation to EXTREMAL. This is rather similar. We find the member of $\lbrace x\mid \phi(x)\rbrace$ which either minimises, or maximises, the value of some property $P$. We use diff --git a/inform7/imperative-module/Chapter 4/Deciding to Defer.w b/inform7/imperative-module/Chapter 4/Deciding to Defer.w index 11b18ac3d6..db4d499c46 100644 --- a/inform7/imperative-module/Chapter 4/Deciding to Defer.w +++ b/inform7/imperative-module/Chapter 4/Deciding to Defer.w @@ -16,8 +16,9 @@ at runtime. @d LOOP_DOMAIN_DEFER 4 /* "repeat with I running through X" */ @d NUMBER_OF_DEFER 5 /* "the number of X" */ @d TOTAL_DEFER 6 /* "the total P of X" */ -@d RANDOM_OF_DEFER 7 /* "a random X" */ -@d LIST_OF_DEFER 8 /* "the list of X" */ +@d TOTAL_REAL_DEFER 7 /* "the total P of X" */ +@d RANDOM_OF_DEFER 8 /* "a random X" */ +@d LIST_OF_DEFER 9 /* "the list of X" */ @d MULTIPURPOSE_DEFER 100 /* potentially any of the above */ @@ -378,8 +379,9 @@ states, times of day, and so on). @d NUMBER_OF_DUSAGE -3 /* return the number of $w$ such that $\phi(w)$ */ @d RANDOM_OF_DUSAGE -4 /* return a random $w$ such that $\phi(w)$, or 0 if none exists */ @d TOTAL_DUSAGE -5 /* return the total value of a property among $w$ such that $\phi(w)$ */ -@d EXTREMAL_DUSAGE -6 /* return the maximal property value among such $w$ */ -@d LIST_OF_DUSAGE -7 /* return the list of $w$ such that $\phi(w)$ */ +@d TOTAL_REAL_DUSAGE -6 /* the same, but using real arithmetic */ +@d EXTREMAL_DUSAGE -7 /* return the maximal property value among such $w$ */ +@d LIST_OF_DUSAGE -8 /* return the list of $w$ such that $\phi(w)$ */ @ Multi-purpose description routines are pretty dandy, then, but they have one big drawback: they can't be passed cinders, because they might be called @@ -553,6 +555,15 @@ int Deferrals::has_finite_domain(kind *K) { = int Deferrals::defer_total_of_matches(property *prn, parse_node *spec) { if (prn == NULL) internal_error("total of on non-property"); + kind *K = ValueProperties::kind(prn); + int reason, usage; + if (Kinds::FloatingPoint::uses_floating_point(K)) { + reason = TOTAL_REAL_DEFER; + usage = TOTAL_REAL_DUSAGE; + } else { + reason = TOTAL_DEFER; + usage = TOTAL_DUSAGE; + } if (Deferrals::spec_is_variable_of_kind_description(spec)) { EmitCode::inv(SEQUENTIAL_BIP); EmitCode::down(); @@ -565,15 +576,14 @@ int Deferrals::defer_total_of_matches(property *prn, parse_node *spec) { EmitCode::inv(INDIRECT1_BIP); EmitCode::down(); CompileValues::to_code_val(spec); - EmitCode::val_number((inter_ti) TOTAL_DUSAGE); + EmitCode::val_number((inter_ti) usage); EmitCode::up(); EmitCode::up(); } else { pcalc_prop *prop = SentencePropositions::from_spec(spec); CompilePropositions::verify_descriptive(prop, "a total property value for things matching a description", spec); - Deferrals::call_deferred_fn(prop, TOTAL_DEFER, - STORE_POINTER_property(prn), NULL); + Deferrals::call_deferred_fn(prop, reason, STORE_POINTER_property(prn), NULL); } return TRUE; }