Files
mercury/tests/invalid/errors2.err_exp
Zoltan Somogyi b72243cadf Lookups in the map from type_ctors to their definitions are relatively
Estimated hours taken: 6
Branches: main

Lookups in the map from type_ctors to their definitions are relatively
expensive, due to the cost of repeatedly comparing type_ctors, comparisons
that are relatively expensive. This diff replaces that direct map
with a two-stage map, the first stage being a map on the type constructor name
(a plain string), and the second stage being a map of the full type_ctor.
Most of the job of searching is done by the first map, since the second map
can be expected to have only one entry most of the time.

An earlier diff yielded a reduction of 1.1% in compilation time, as measured
by a version of tools/speedtest which compiles six modules in grade hlc.gc.
The speedup when compiling in grade asm_fast.gc was 0.6%. (The MLDS code
generator does more lookups of type definitions than the LLDS code generator.)
This diff also has some more changes that led to some further speedups, but
I don't have the original basis for comparison anymore.

Note that making the type table's type abstract leads to a slowdown,
but the faster data structure more than compensates for it.

compiler/hlds_data.m:
	Make the type table an abstract type, and change its representation
	as described above. Provide the operations on it that are needed
	by the other modules of the compiler.

compiler/*.m:
	Use the operations provided by hlds_data.m instead of operations on
	maps to access the type table.

	In several cases replace old code that iterated on keys and looked up
	the associated values in the map, with new code that iterates on an
	association list that puts the value right next to its key (a list
	that the old code just threw away).

	In other cases, change code that iterated on a list of the keys
	to iterating on the whole assoc_list instead, paying attention only
	to the keys. This is faster, since it avoids allocating memory
	for the list of keys.

compiler/type_ctor_info.m:
	This module used to use a roundabout method of generating
	type_ctor_gen_infos for the builtin types conceptually defined
	in builtin.m. It used to add their type_ctors to the list of
	user-defined type_ctors it processed, and the code that processed
	each type_ctor would check whether it was one of these, and if yes,
	handle them specially.

	This diff makes the code handle these builtin type_ctors and
	user-defined type_ctors separately, avoiding a whole bunch of tests.

compiler/typecheck_errors.m:
	Sort lists of types shown in error messages. The new data type table
	would naturally lead to slightly different orders of types in error
	messages than the old one; this change neutralizes such effects
	for the future.

tests/invalid/ambiguous_overloading.err_exp:
tests/invalid/errors2.err_exp:
tests/warnings/ambiguous_overloading.exp:
	Expect sorted types in error messages.
2009-09-04 02:28:10 +00:00

129 lines
5.9 KiB
Plaintext

errors2.m:001: Warning: interface for module `errors2' does not export
errors2.m:001: anything.
errors2.m:001: To be useful, a module should export something. A file should
errors2.m:001: contain at least one declaration other than `:- import_module'
errors2.m:001: in its interface section(s). This would normally be a
errors2.m:001: `:- pred', `:- func', `:- type', `:- inst' or `:- mode'
errors2.m:001: declaration.
errors2.m:007: Error: no clauses for predicate `bind_type_param'/2.
errors2.m:009: Error: clause for predicate `errors2.bind_type_param'/1
errors2.m:009: without preceding `pred' declaration.
errors2.m:009: Inferred :- pred bind_type_param(int).
errors2.m:023: Error: no clauses for predicate `produce_string'/1.
errors2.m:025: Error: no clauses for predicate `expect_int'/1.
errors2.m:031: In clause for predicate `type_error'/0:
errors2.m:031: in argument 1 of call to predicate `expect_int'/1:
errors2.m:031: type error: variable `X' has type `string',
errors2.m:031: expected type was `int'.
errors2.m:031: The partial type assignment was:
errors2.m:031: X_1: string
errors2.m:037: In clause for predicate `type_error_2'/0:
errors2.m:037: type error in unification of variable `X'
errors2.m:037: and variable `Y'.
errors2.m:037: `X' has type `string',
errors2.m:037: `Y' has type `int'.
errors2.m:037: The partial type assignment was:
errors2.m:037: X_1: string
errors2.m:037: Y_2: int
errors2.m:043: In clause for predicate `type_error_3'/0:
errors2.m:043: in argument 1 of call to predicate `expect_int'/1:
errors2.m:043: type error: variable `Y' has type `string',
errors2.m:043: expected type was `int'.
errors2.m:043: The partial type assignment was:
errors2.m:043: X_1: string
errors2.m:043: Y_2: string
errors2.m:052: In clause for predicate `type_error_4'/0:
errors2.m:052: in argument 3 of functor `foo_functor/3':
errors2.m:052: type error in unification of argument
errors2.m:052: and constant `1.0'.
errors2.m:052: argument has type `string',
errors2.m:052: constant `1.0' has type `float'.
errors2.m:052: The partial type assignment was:
errors2.m:052: Y_1: int
errors2.m:052: X_2: errors2.foo_type
errors2.m:052: V_3: character
errors2.m:052: V_4: string
errors2.m:052: In clause for predicate `errors2.type_error_4'/0:
errors2.m:052: warning: variable `X' occurs only once in this scope.
errors2.m:059: In clause for predicate `type_error_5'/0:
errors2.m:059: in argument 3 of functor `foo_functor/3':
errors2.m:059: type error in unification of argument
errors2.m:059: and constant `1.0'.
errors2.m:059: argument has type `string',
errors2.m:059: constant `1.0' has type `float'.
errors2.m:059: The partial type assignment was:
errors2.m:059: Y_1: character
errors2.m:059: X_2: errors2.foo_type
errors2.m:059: V_3: int
errors2.m:059: V_4: string
errors2.m:059: In clause for predicate `errors2.type_error_5'/0:
errors2.m:059: warning: variable `X' occurs only once in this scope.
errors2.m:065: In clause for predicate `type_error_6'/0:
errors2.m:065: in argument 3 of functor `bar_functor/3':
errors2.m:065: type error in unification of argument
errors2.m:065: and constant `1.0'.
errors2.m:065: argument has type `string',
errors2.m:065: constant `1.0' has type `float'.
errors2.m:065: The partial type assignment was:
errors2.m:065: Y_1: character
errors2.m:065: X_2: errors2.bar_1_type
errors2.m:065: V_3: int
errors2.m:065: V_4: string
errors2.m:065: In clause for predicate `errors2.type_error_6'/0:
errors2.m:065: warning: variable `X' occurs only once in this scope.
errors2.m:070: In clause for predicate `errors2.type_error_7'/0:
errors2.m:070: warning: variable `Y' occurs only once in this scope.
errors2.m:071: In clause for predicate `errors2.type_error_7'/0:
errors2.m:071: warning: variables `A, B, Z' occur only once in this scope.
errors2.m:072: In clause for predicate `type_error_7'/0:
errors2.m:072: in argument 1 of call to predicate `expect_int'/1:
errors2.m:072: type error: variable `C' has type `string',
errors2.m:072: expected type was `int'.
errors2.m:072: The possible partial type assignments were:
errors2.m:072: Type assignment 1:
errors2.m:072: Y_1: errors2.foo
errors2.m:072: Z_2: errors2.bar_1_type
errors2.m:072: A_3: int
errors2.m:072: B_4: character
errors2.m:072: C_5: string
errors2.m:072:
errors2.m:072: Type assignment 2:
errors2.m:072: Y_1: character
errors2.m:072: Z_2: errors2.bar_1_type
errors2.m:072: A_3: int
errors2.m:072: B_4: character
errors2.m:072: C_5: string
errors2.m:072:
errors2.m:072: Type assignment 3:
errors2.m:072: Y_1: errors2.foo
errors2.m:072: Z_2: errors2.bar_2_type
errors2.m:072: A_3: character
errors2.m:072: B_4: int
errors2.m:072: C_5: string
errors2.m:072:
errors2.m:072: Type assignment 4:
errors2.m:072: Y_1: character
errors2.m:072: Z_2: errors2.bar_2_type
errors2.m:072: A_3: character
errors2.m:072: B_4: int
errors2.m:072: C_5: string
errors2.m:078: In clause for predicate `type_error_8'/0:
errors2.m:078: error: undefined predicate `from_char_list'/2.
errors2.m:078: In clause for predicate `type_error_8'/0:
errors2.m:078: in argument 1 of call to predicate `from_char_list'/2:
errors2.m:078: error: undefined symbol `[]/0'.
errors2.m:085: In clause for predicate `type_error_9'/0:
errors2.m:085: type error in unification of variable `X'
errors2.m:085: and variable `Y'.
errors2.m:085: `X' has type `{int, string, character}',
errors2.m:085: `Y' has type `{string, character, int}'.
errors2.m:085: The partial type assignment was:
errors2.m:085: X_1: {int, string, character}
errors2.m:085: Y_2: {string, character, int}
errors2.m:085: V_3: int
errors2.m:085: V_4: string
errors2.m:085: V_5: character
errors2.m:085: V_6: string
errors2.m:085: V_7: character
errors2.m:085: V_8: int