| Index: runtime/vm/intermediate_language.h
|
| ===================================================================
|
| --- runtime/vm/intermediate_language.h (revision 10474)
|
| +++ runtime/vm/intermediate_language.h (working copy)
|
| @@ -147,8 +147,9 @@
|
| // Returns true, if this computation can deoptimize.
|
| virtual bool CanDeoptimize() const = 0;
|
|
|
| - // Static type of the computation.
|
| - virtual RawAbstractType* StaticType() const = 0;
|
| + // Compile time type of the computation, which typically depends on the
|
| + // compile time types (and possibly propagated types) of its inputs.
|
| + virtual RawAbstractType* CompileType() const = 0;
|
|
|
| // Mutate assigned_vars to add the local variable index for all
|
| // frame-allocated locals assigned to by the computation.
|
| @@ -183,16 +184,16 @@
|
|
|
| static LocationSummary* MakeCallSummary();
|
|
|
| - // Declare an enum value used to define type-test predicates.
|
| - enum ComputationType {
|
| -#define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName,
|
| + // Declare an enum value used to define kind-test predicates.
|
| + enum ComputationKind {
|
| +#define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName,
|
|
|
| - FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE)
|
| + FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND)
|
|
|
| -#undef DECLARE_COMPUTATION_TYPE
|
| +#undef DECLARE_COMPUTATION_KIND
|
| };
|
|
|
| - virtual ComputationType computation_type() const = 0;
|
| + virtual ComputationKind computation_kind() const = 0;
|
|
|
| // Declare predicate for each computation.
|
| #define DECLARE_PREDICATE(ShortName, ClassName) \
|
| @@ -278,7 +279,7 @@
|
| public:
|
| Value() { }
|
|
|
| - bool StaticTypeIsMoreSpecificThan(const AbstractType& dst_type) const;
|
| + bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const;
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(Value);
|
| @@ -288,12 +289,12 @@
|
| // Functions defined in all concrete computation classes.
|
| #define DECLARE_COMPUTATION(ShortName) \
|
| virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \
|
| - virtual ComputationType computation_type() const { \
|
| + virtual ComputationKind computation_kind() const { \
|
| return Computation::k##ShortName; \
|
| } \
|
| virtual intptr_t ArgumentCount() const { return 0; } \
|
| virtual const char* DebugName() const { return #ShortName; } \
|
| - virtual RawAbstractType* StaticType() const; \
|
| + virtual RawAbstractType* CompileType() const; \
|
| virtual LocationSummary* MakeLocationSummary() const; \
|
| virtual void EmitNativeCode(FlowGraphCompiler* compiler);
|
|
|
| @@ -306,11 +307,11 @@
|
| // Function defined in all call computation classes.
|
| #define DECLARE_CALL_COMPUTATION(ShortName) \
|
| virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \
|
| - virtual ComputationType computation_type() const { \
|
| + virtual ComputationKind computation_kind() const { \
|
| return Computation::k##ShortName; \
|
| } \
|
| virtual const char* DebugName() const { return #ShortName; } \
|
| - virtual RawAbstractType* StaticType() const; \
|
| + virtual RawAbstractType* CompileType() const; \
|
| virtual LocationSummary* MakeLocationSummary() const; \
|
| virtual void EmitNativeCode(FlowGraphCompiler* compiler);
|
|
|
| @@ -373,7 +374,8 @@
|
| : token_pos_(token_pos),
|
| try_index_(try_index),
|
| dst_type_(dst_type),
|
| - dst_name_(dst_name) {
|
| + dst_name_(dst_name),
|
| + eliminated_(false) {
|
| ASSERT(value != NULL);
|
| ASSERT(instantiator != NULL);
|
| ASSERT(instantiator_type_arguments != NULL);
|
| @@ -395,6 +397,14 @@
|
| const AbstractType& dst_type() const { return dst_type_; }
|
| const String& dst_name() const { return dst_name_; }
|
|
|
| + bool IsEliminated() const {
|
| + return eliminated_;
|
| + }
|
| + void Eliminate() {
|
| + ASSERT(!eliminated_);
|
| + eliminated_ = true;
|
| + }
|
| +
|
| virtual void PrintOperandsTo(BufferFormatter* f) const;
|
|
|
| virtual bool CanDeoptimize() const { return false; }
|
| @@ -404,6 +414,7 @@
|
| const intptr_t try_index_;
|
| const AbstractType& dst_type_;
|
| const String& dst_name_;
|
| + bool eliminated_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp);
|
| };
|
| @@ -1677,7 +1688,7 @@
|
| // Implementation of type testers and cast functins.
|
| #define DEFINE_PREDICATE(ShortName, ClassName) \
|
| bool Computation::Is##ShortName() const { \
|
| - return computation_type() == k##ShortName; \
|
| + return computation_kind() == k##ShortName; \
|
| } \
|
| const ClassName* Computation::As##ShortName() const { \
|
| if (!Is##ShortName()) return NULL; \
|
| @@ -2274,7 +2285,10 @@
|
| // Abstract super-class of all instructions that define a value (Bind, Phi).
|
| class Definition : public Instruction {
|
| public:
|
| - Definition() : temp_index_(-1), ssa_temp_index_(-1) { }
|
| + Definition()
|
| + : temp_index_(-1),
|
| + ssa_temp_index_(-1),
|
| + propagated_type_(AbstractType::Handle()) { }
|
|
|
| virtual bool IsDefinition() const { return true; }
|
| virtual Definition* AsDefinition() { return this; }
|
| @@ -2289,12 +2303,35 @@
|
| }
|
| bool HasSSATemp() const { return ssa_temp_index_ >= 0; }
|
|
|
| - // Static type of the definition.
|
| - virtual RawAbstractType* StaticType() const = 0;
|
| + // Compile time type of the definition, which may be requested before type
|
| + // propagation during graph building.
|
| + virtual RawAbstractType* CompileType() const = 0;
|
|
|
| + bool HasPropagatedType() const {
|
| + return !propagated_type_.IsNull();
|
| + }
|
| + RawAbstractType* PropagatedType() const {
|
| + ASSERT(HasPropagatedType());
|
| + return propagated_type_.raw();
|
| + }
|
| + // Returns true if the propagated type has changed.
|
| + bool SetPropagatedType(const AbstractType& propagated_type) {
|
| + if (propagated_type.IsNull()) {
|
| + // Not a typed definition, e.g. access to a VM field.
|
| + return false;
|
| + }
|
| + const bool changed =
|
| + propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_);
|
| + propagated_type_ = propagated_type.raw();
|
| + return changed;
|
| + }
|
| +
|
| private:
|
| intptr_t temp_index_;
|
| intptr_t ssa_temp_index_;
|
| + // TODO(regis): GrowableArray<const AbstractType*> propagated_types_;
|
| + // For now:
|
| + AbstractType& propagated_type_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(Definition);
|
| };
|
| @@ -2335,10 +2372,7 @@
|
| void set_computation(Computation* value) { computation_ = value; }
|
| bool is_used() const { return is_used_; }
|
|
|
| - // Static type of the underlying computation.
|
| - virtual RawAbstractType* StaticType() const {
|
| - return computation()->StaticType();
|
| - }
|
| + virtual RawAbstractType* CompileType() const;
|
|
|
| virtual void RecordAssignedVars(BitVector* assigned_vars,
|
| intptr_t fixed_parameter_count);
|
| @@ -2366,8 +2400,7 @@
|
| }
|
| }
|
|
|
| - // Least upper bound of the static types of the inputs.
|
| - virtual RawAbstractType* StaticType() const;
|
| + virtual RawAbstractType* CompileType() const;
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
| @@ -2379,6 +2412,9 @@
|
|
|
| virtual bool CanDeoptimize() const { return false; }
|
|
|
| + // TODO(regis): This helper will be removed once we support type sets.
|
| + RawAbstractType* LeastSpecificInputType() const;
|
| +
|
| // Phi is alive if it reaches a non-environment use.
|
| bool is_alive() const { return is_alive_; }
|
| void mark_alive() { is_alive_ = true; }
|
| @@ -2401,8 +2437,8 @@
|
|
|
| intptr_t index() const { return index_; }
|
|
|
| - // Static type of the passed-in parameter.
|
| - virtual RawAbstractType* StaticType() const;
|
| + // Compile type of the passed-in parameter.
|
| + virtual RawAbstractType* CompileType() const;
|
|
|
| virtual intptr_t ArgumentCount() const { return 0; }
|
|
|
|
|