more tricks in ConditionalEliminationPhase

Garcia Gutierrez Miguel Alfredo miguelalfredo.garcia at epfl.ch
Sun Feb 9 12:34:04 PST 2014


Currently ConditionalElimination gives a definitive answer for InstanceOfNode in two cases (as per snippet below)
  (a) object() is known to be null
  (b) the type of object() is known to conform in IsInstanceOf.

                if (condition instanceof InstanceOfNode) {
                    InstanceOfNode instanceOf = (InstanceOfNode) condition;
                    ValueNode object = instanceOf.object();
                    if (state.isNull(object)) {
                        metricInstanceOfRemoved.increment();
                        return falseValue;
                    } else if (state.isNonNull(object)) {
                        ResolvedJavaType type = state.getNodeType(object);
                        if (type != null && instanceOf.type().isAssignableFrom(type)) {
                            metricInstanceOfRemoved.increment();
                            return trueValue;
                        }
                    }
                } else ...


What about the following case? A definitive answer is also possible:
  (c) the type of object() is known *not* to conform in InstanceOfNode

It's clear "the type of object()" (as inferred by ConditionalElimination) is an approximation (the runtime type might be more precise).

Yes, but still. In those cases where "the type of object()" is

  - an exact class-type (in particular due to final-class)

  - a non-exact class-type, AND the InstanceOfNode.type() is a class-type

then a definitive answer can be obtained via isAssignableFrom


Comments are welcome!

--
Miguel Garcia
Swiss Federal Institute of Technology
EPFL - IC - LAMP1 - INR 328 - Station 14
CH-1015 Lausanne - Switzerland
http://lamp.epfl.ch/~magarcia/


More information about the graal-dev mailing list