Merge: Rewrite the coloration for properties and types.
authorJean Privat <jean@pryen.org>
Tue, 31 Mar 2015 03:21:57 +0000 (10:21 +0700)
committerJean Privat <jean@pryen.org>
Tue, 31 Mar 2015 03:21:57 +0000 (10:21 +0700)
commitbb979d4c4ad336340e67414ad5f0897e602ce211
tree9e34681e7b2d451c78369b0a819476e2c0c021f9
parenta6dddaaae40fa5e70d065f6870c9117a4090ee1b
parent8f4950f81c4347cde1e1eff1c5fa30b752c3d259
Merge: Rewrite the coloration for properties and types.

This introduce a new colorer, `POSetGroupColorer` that colors elements introduced by the classes in a class-hierarchy.
The advantage of this new colorer is that it uses conflict graphs of classes to colorize elements.
By comparison, the previously used colorers work with conflict graphs of elements; that are therefore much larger.

An other advantage is that only the introductions of elements are needed by the colorer, so filling the information from the model is far more easier.

The construction of the poset of types is also removed.
Instead, subtyping tables are computed with a more standard way:

* target cast types are grouped by classes: a map class->types is created
* the map is colored: a table layout by class is computed
* for each live type, the table layout of the associated class is used to build the type table

Results are so good that most of the time of the coloring is removed.

For nitc/nitc/nit

Before:

user: 0m6.044s
total: 15096 MIr
do_property_coloring: 1420 MIr
do_type_coloring: 2600 MIr

After:

user: 0m5.608s (-7%)
total: 12800 MIr (-15%)
do_property_coloring: 452 MIr (-68%)
do_type_coloring: 895 MIr (-65%)

note that in the previous numbers, most of the time is done in the model to inherit or resolve things.
Pure coloring algorithm is now negligible:

conflict_graph: 34 MIr (<1% of the total Ir)
coloring: 60 MIr (<1% of the total Ir)

Unfortunately, with types the coloring can degenerate and produce big tables. If this is an issue, the options `--type-poset` use the previous coloring method for types

Pull-Request: #1215
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
src/compiler/abstract_compiler.nit
src/compiler/separate_compiler.nit
src/compiler/separate_erasure_compiler.nit
src/model/model.nit