Skip to content

Commit

Permalink
Fix for Jira bug I7-1939
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed May 18, 2022
1 parent d4065df commit ef072e6
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 75 deletions.
50 changes: 41 additions & 9 deletions docs/imperative-module/4-cdp.html

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions inform7/Figures/memory-diagnostics.txt
@@ -1,47 +1,47 @@
Total memory consumption was 123376K = 120 MB
Total memory consumption was 129459K = 126 MB

---- was used for 2044965 objects, in 362888 frames in 0 x 800K = 0K = 0 MB:

33.0% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes
20.5% text_stream_array 4605 x 100 = 460500 objects, 25935360 bytes
19.2% linked_list 43461 objects, 24338160 bytes
11.1% inter_symbol_array 132 x 1024 = 135168 objects, 14061696 bytes
10.4% inter_error_stash_array 101 x 1024 = 103424 objects, 13241504 bytes
8.2% parse_node 129722 objects, 10377760 bytes
5.8% verb_conjugation 160 objects, 7425280 bytes
4.3% parse_node_annotation_array 346 x 500 = 173000 objects, 5547072 bytes
2.6% pcalc_prop_array 25 x 1000 = 25000 objects, 3400800 bytes
2.5% inter_name_array 67 x 1000 = 67000 objects, 3218144 bytes
2.0% kind_array 66 x 1000 = 66000 objects, 2642112 bytes
1.6% inter_name_generator_array 51 x 1000 = 51000 objects, 2041632 bytes
31.5% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes
19.5% text_stream_array 4605 x 100 = 460500 objects, 25935360 bytes
18.3% linked_list 43461 objects, 24338160 bytes
10.6% inter_symbol_array 132 x 1024 = 135168 objects, 14061696 bytes
9.9% inter_error_stash_array 101 x 1024 = 103424 objects, 13241504 bytes
7.8% parse_node 129722 objects, 10377760 bytes
5.6% verb_conjugation 160 objects, 7425280 bytes
4.1% parse_node_annotation_array 346 x 500 = 173000 objects, 5547072 bytes
2.5% pcalc_prop_array 25 x 1000 = 25000 objects, 3400800 bytes
2.4% inter_name_array 67 x 1000 = 67000 objects, 3218144 bytes
1.9% 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 13969 objects, 2011536 bytes
1.4% package_request 21153 objects, 1861464 bytes
1.4% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes
1.2% dict_entry_array 470 x 100 = 47000 objects, 1519040 bytes
1.3% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes
1.1% dict_entry_array 470 x 100 = 47000 objects, 1519040 bytes
1.1% match_trie_array 11 x 1000 = 11000 objects, 1496352 bytes
1.1% inter_symbols_table 26592 objects, 1489152 bytes
1.0% i6_schema_array 23 x 100 = 2300 objects, 1380736 bytes
1.0% scan_directory 314 objects, 1296192 bytes
1.0% inter_package 26592 objects, 1276416 bytes
0.9% scan_directory 314 objects, 1296192 bytes
0.9% inter_package 26592 objects, 1276416 bytes
0.8% map_data 671 objects, 1127280 bytes
0.8% id_body 942 objects, 1077648 bytes
0.7% adjective_meaning 202 objects, 1000304 bytes
0.7% excerpt_meaning 3102 objects, 967824 bytes
0.7% production 3878 objects, 899696 bytes
0.6% production 3878 objects, 899696 bytes
0.6% ptoken 8397 objects, 873288 bytes
0.6% grammatical_usage 3613 objects, 867120 bytes
0.6% individual_form 2563 objects, 861168 bytes
0.6% inter_schema_node 8920 objects, 856320 bytes
0.5% unary_predicate_array 16 x 1000 = 16000 objects, 640512 bytes
0.4% unary_predicate_array 16 x 1000 = 16000 objects, 640512 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 470 objects, 368480 bytes
0.2% dictionary 7521 objects, 361008 bytes
0.2% verb_form 386 objects, 348944 bytes
0.2% noun 2382 objects, 285840 bytes
0.2% compilation_subtask 3355 objects, 268400 bytes
0.2% inter_annotation_array 2 x 8192 = 16384 objects, 262208 bytes
0.2% inference_subject 666 objects, 261072 bytes
0.1% inter_annotation_array 2 x 8192 = 16384 objects, 262208 bytes
0.1% inference_subject 666 objects, 261072 bytes
0.1% vanilla_function 3683 objects, 235712 bytes
0.1% binary_predicate 322 objects, 170016 bytes
0.1% hierarchy_location 1122 objects, 161568 bytes
Expand Down Expand Up @@ -237,23 +237,23 @@ Total memory consumption was 123376K = 120 MB

100.0% was used for memory not allocated for objects:

57.7% text stream storage 72935668 bytes in 478024 claims
4.1% dictionary storage 5229056 bytes in 7521 claims
59.7% text stream storage 79164708 bytes in 478474 claims
3.9% dictionary storage 5229056 bytes in 7521 claims
---- sorting 1448 bytes in 149 claims
5.6% source text 7200000 bytes in 3 claims
8.5% source text details 10800000 bytes in 2 claims
0.2% documentation fragments 262144 bytes in 1 claim
5.4% source text 7200000 bytes in 3 claims
8.1% source text details 10800000 bytes in 2 claims
0.1% documentation fragments 262144 bytes in 1 claim
---- linguistic stock array 81920 bytes in 2 claims
---- small word set array 105600 bytes in 22 claims
3.5% inter symbols storage 4520272 bytes in 27949 claims
13.2% inter bytecode storage 16767680 bytes in 14 claims
4.9% inter links storage 6222976 bytes in 11 claims
3.4% inter symbols storage 4520272 bytes in 27949 claims
12.6% inter bytecode storage 16767680 bytes in 14 claims
4.6% 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 1700416 bytes in 1 claim
1.2% instance-of-kind counting 1700416 bytes in 1 claim
---- compilation workspace for objects 21896 bytes in 25 claims
---- lists for type-checking invocations 16000 bytes in 1 claim
---- code generation workspace for objects 1336 bytes in 4 claims
0.2% emitter array storage 280288 bytes in 1999 claims

-146.-1% was overhead - -184656968 bytes = -180329K = -176 MB
-139.-2% was overhead - -184656968 bytes = -180329K = -176 MB

59 changes: 30 additions & 29 deletions inform7/Figures/timings-diagnostics.txt
@@ -1,32 +1,33 @@
100.0% in inform7 run
71.9% in compilation to Inter
72.2% in compilation to Inter
51.2% in //Sequence::undertake_queued_tasks//
4.6% in //MajorNodes::pre_pass//
3.4% in //MajorNodes::pass_1//
2.0% in //RTPhrasebook::compile_entries//
1.8% in //ImperativeDefinitions::assess_all//
1.4% in //RTKindConstructors::compile//
1.2% in //Sequence::lint_inter//
0.6% in //MajorNodes::pass_2//
0.6% in //Sequence::undertake_queued_tasks//
0.6% in //World::stage_V//
0.4% in //ImperativeDefinitions::compile_first_block//
0.4% in //Sequence::undertake_queued_tasks//
0.2% in //CompletionModule::compile//
0.2% in //InferenceSubjects::emit_all//
0.2% in //RTKindConstructors::compile_permissions//
0.2% in //Task::make_built_in_kind_constructors//
2.6% not specifically accounted for
25.4% in running Inter pipeline
9.9% in step 14/15: generate inform6 -> auto.inf
5.6% in step 5/15: load-binary-kits
4.5% in //MajorNodes::pre_pass//
3.3% in //MajorNodes::pass_1//
2.3% in //RTPhrasebook::compile_entries//
1.7% in //ImperativeDefinitions::assess_all//
1.5% in //RTKindConstructors::compile//
0.9% in //Sequence::lint_inter//
0.5% in //ImperativeDefinitions::compile_first_block//
0.5% in //MajorNodes::pass_2//
0.5% in //Sequence::undertake_queued_tasks//
0.5% in //World::stage_V//
0.3% in //Sequence::undertake_queued_tasks//
0.1% in //CompletionModule::compile//
0.1% in //InferenceSubjects::emit_all//
0.1% in //RTKindConstructors::compile_permissions//
0.1% in //Task::make_built_in_kind_constructors//
0.1% in //World::stages_II_and_III//
2.8% not specifically accounted for
25.0% in running Inter pipeline
9.7% in step 14/15: generate inform6 -> auto.inf
5.4% in step 5/15: load-binary-kits
5.2% in step 6/15: make-synoptic-module
1.4% 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.2% in step 11/15: eliminate-redundant-labels
0.2% in step 8/15: detect-indirect-calls
1.5% not specifically accounted for
2.2% in supervisor
0.5% not specifically accounted for
1.3% in step 9/15: make-identifiers-unique
0.5% in step 4/15: compile-splats
0.3% in step 12/15: eliminate-redundant-operations
0.3% in step 7/15: shorten-wiring
0.3% in step 8/15: detect-indirect-calls
0.1% in step 11/15: eliminate-redundant-labels
1.2% not specifically accounted for
2.3% in supervisor
0.4% not specifically accounted for
5 changes: 5 additions & 0 deletions inform7/Tests/Test Cases/CountInnerExistential.txt
@@ -0,0 +1,5 @@
Foo is a room.
Blob is a person in Foo.
When play begins:
if every room encloses a person, say "hooray.";
if every room encloses two people, say "yowza.";
13 changes: 13 additions & 0 deletions inform7/Tests/Test Cases/_Results_Ideal/CountInnerExistential.txt
@@ -0,0 +1,13 @@
Foo
hooray.
yowza.

Welcome
An Interactive Fiction
Release 1 / Serial number 160428 / Inform 7 v10.1.0 / D

Foo
You can see Blob here.

> > Foo
> Are you sure you want to quit?
Expand Up @@ -410,6 +410,7 @@ typedef struct q_stack_data {
int parameter; /* its parameter, e.g., 9 for "more than nine" */
int C_stack_level; /* at the point this occurs */
int L_stack_level;
int existential; /* just one solution is needed */
} q_stack_data;

typedef struct c_stack_data {
Expand Down Expand Up @@ -520,7 +521,10 @@ Inter code as we go, but preserving the Invariant.
if (R_stack[R_sp-1].parity == FALSE) negated_quantifier_found = TRUE;
quantifier *quant = pl->quant;
int param = Atoms::get_quantification_parameter(pl);
if (quant != exists_quantifier) @<Push the Q-stack@>;
if (quant == exists_quantifier)
@<Mark the Q-stack to show an inner existential quantifier is in play@>
else
@<Push the Q-stack@>;
@<Compile a loop through possible values of the variable quantified@>;
break;
case DOMAIN_OPEN_ATOM:
Expand Down Expand Up @@ -709,6 +713,7 @@ because the |DOMAIN_OPEN| atom does it.
Q_stack[Q_sp].parameter = param;
Q_stack[Q_sp].L_stack_level = L_sp;
Q_stack[Q_sp].C_stack_level = C_sp;
Q_stack[Q_sp].existential = FALSE;
EmitCode::inv(STORE_BIP);
EmitCode::down();
EmitCode::ref_symbol(K_value, qcy_s[Q_sp]);
Expand All @@ -722,6 +727,13 @@ because the |DOMAIN_OPEN| atom does it.

Q_sp++;

@ Existential quantifiers are not pushed to the Q-stack, because they are
by definition about finding the first solution, not counting solutions. But
we need to record their presence anyway:

@<Mark the Q-stack to show an inner existential quantifier is in play@> =
if (Q_sp > 0) Q_stack[Q_sp-1].existential = TRUE;

@ It is always true that $\not\exists x: \psi(x)$ is equivalent to $\forall x:
\lnot(\phi(x))$, so the following seems pointless. We do this, in the case
of "now" only, in order to make $\not\exists$ legal in a "now", which
Expand Down Expand Up @@ -773,10 +785,7 @@ thing works, or doesn't, and is more like testing a single |if|.
@<Pop the Q-stack@> =
if (Q_sp <= 0) internal_error("Q stack underflow");
Q_sp--;
EmitCode::inv(POSTINCREMENT_BIP);
EmitCode::down();
EmitCode::ref_symbol(K_value, qcy_s[Q_sp]);
EmitCode::up();
@<Count this as a success@>;

while (C_sp > Q_stack[Q_sp].C_stack_level)
@<Pop the C-stack@>;
Expand All @@ -789,6 +798,19 @@ thing works, or doesn't, and is more like testing a single |if|.
Quantifiers::emit_test(Q_stack[Q_sp].quant, Q_stack[Q_sp].parameter, qcy_s[Q_sp], qcn_s[Q_sp]);
@<Open a block in the Inter code compiled to perform the search, if variant@>;

@ Note that if there is an existential quantifier inside the quantifier we
are counting solutions for, then we halt the search as soon as a solution is found;
we don't want to rack up |qcy_s[Q_sp]| to artificially high levels by finding
multiple solutions. See test case |CountInnerExistential|.

@<Count this as a success@> =
EmitCode::inv(POSTINCREMENT_BIP);
EmitCode::down();
EmitCode::ref_symbol(K_value, qcy_s[Q_sp]);
EmitCode::up();
if (Q_stack[Q_sp].existential)
EmitCode::inv(BREAK_BIP);

@h The C-stack.
When a CALLED atom in the proposition gives a name to a variable, we have to
transcribe that to the stash of callings for the benefit of the code
Expand Down

0 comments on commit ef072e6

Please sign in to comment.