From c562bb5796c955914482cde6235d3e9be80787c8 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 27 Feb 2014 16:21:47 -0500 Subject: [PATCH] rta: store real types in live_cast_type 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 --- src/global_compiler.nit | 5 +---- src/metrics/rta_metrics.nit | 2 ++ src/rapid_type_analysis.nit | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/global_compiler.nit b/src/global_compiler.nit index 9b05fe5..ecd7265 100644 --- a/src/global_compiler.nit +++ b/src/global_compiler.nit @@ -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 diff --git a/src/metrics/rta_metrics.nit b/src/metrics/rta_metrics.nit index 4752396..03d9a8a 100644 --- a/src/metrics/rta_metrics.nit +++ b/src/metrics/rta_metrics.nit @@ -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 diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index db88025..d2121e5 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -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 -- 1.7.9.5