rta: store real types in live_cast_type
authorJean Privat <jean@pryen.org>
Thu, 27 Feb 2014 21:21:47 +0000 (16:21 -0500)
committerJean Privat <jean@pryen.org>
Fri, 28 Feb 2014 17:30:35 +0000 (12:30 -0500)
The separate compiler need to distinguish if the target is nullable or not.
So do not un-nullable cast types.

rta_metrics.nit is also updated to deal with the change of the static
type of the attribute.

nitg-g is also modified to use the new correct the RTA information
(this remove a workaround)

Signed-off-by: Jean Privat <jean@pryen.org>

src/global_compiler.nit
src/metrics/rta_metrics.nit
src/rapid_type_analysis.nit

index 9b05fe5..ecd7265 100644 (file)
@@ -708,10 +708,7 @@ class GlobalCompilerVisitor
        redef fun type_test(value, mtype, tag)
        do
                mtype = self.anchor(mtype)
-               var mclasstype = mtype
-               if mtype isa MNullableType then mclasstype = mtype.mtype
-               assert mclasstype isa MClassType
-               if not self.compiler.runtime_type_analysis.live_cast_types.has(mclasstype) then
+               if not self.compiler.runtime_type_analysis.live_cast_types.has(mtype) then
                        debug "problem: {mtype} was detected cast-dead"
                        abort
                end
index 4752396..03d9a8a 100644 (file)
@@ -103,6 +103,8 @@ do
        end
 
        for mtype in analysis.live_cast_types do
+               if mtype isa MNullableType then mtype = mtype.mtype
+               if not mtype isa MClassType then continue
                mtypes.add(mtype)
                nlct += 1
                mtype.mclass.nlct += 1
index db88025..d2121e5 100644 (file)
@@ -60,7 +60,7 @@ class RapidTypeAnalysis
        var live_classes = new HashSet[MClass]
 
        # The pool of types used to perform type checks (isa and as).
-       var live_cast_types = new HashSet[MClassType]
+       var live_cast_types = new HashSet[MType]
 
        # The pool of undesolved types used to perform type checks (isa and as).
        # They are globally resolved at the end of the analaysis
@@ -207,8 +207,6 @@ class RapidTypeAnalysis
                        for t in live_types do
                                if not ot.can_resolve_for(t, t, mainmodule) then continue
                                var rt = ot.anchor_to(mainmodule, t)
-                               if rt isa MNullableType then rt = rt.mtype
-                               assert rt isa MClassType
                                live_cast_types.add(rt)
                                #print "  {ot}/{t} -> {rt}"
                        end
@@ -261,11 +259,9 @@ class RapidTypeAnalysis
 
        fun add_cast(mtype: MType)
        do
-               if mtype isa MNullableType then mtype = mtype.mtype
                if mtype.need_anchor then
                        live_open_cast_types.add(mtype)
                else
-                       assert mtype isa MClassType
                        live_cast_types.add(mtype)
                end
        end