Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
dart::AssertAssignableInstr Class Reference

#include <il.h>

Inheritance diagram for dart::AssertAssignableInstr:
dart::TemplateDefinition< 4, Throws, Pure >

Public Types

enum  Kind { FOR_EACH_ASSERT_ASSIGNABLE_KIND =(KIND_DEFN) }
 
enum  {
  kInstancePos = 0 , kDstTypePos = 1 , kInstantiatorTAVPos = 2 , kFunctionTAVPos = 3 ,
  kNumInputs = 4
}
 
- Public Types inherited from dart::TemplateDefinition< 4, Throws, Pure >
using BaseClass = typename Pure< Definition, PureDefinition >::Base
 

Public Member Functions

 AssertAssignableInstr (const InstructionSource &source, Value *value, Value *dst_type, Value *instantiator_type_arguments, Value *function_type_arguments, const String &dst_name, intptr_t deopt_id, Kind kind=kUnknown)
 
virtual intptr_t statistics_tag () const
 
virtual CompileType ComputeType () const
 
virtual bool RecomputeType ()
 
Valuevalue () const
 
Valuedst_type () const
 
Valueinstantiator_type_arguments () const
 
Valuefunction_type_arguments () const
 
virtual TokenPosition token_pos () const
 
const Stringdst_name () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual bool ComputeCanDeoptimizeAfterCall () const
 
virtual intptr_t NumberOfInputsConsumedBeforeCall () const
 
virtual bool CanBecomeDeoptimizationTarget () const
 
virtual DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual bool AttributesEqual (const Instruction &other) const
 
virtual ValueRedefinedValue () const
 
virtual void InferRange (RangeAnalysis *analysis, Range *range)
 
- Public Member Functions inherited from dart::TemplateDefinition< 4, Throws, Pure >
 TemplateDefinition (intptr_t deopt_id=DeoptId::kNone)
 
 TemplateDefinition (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t InputCount () const
 
virtual ValueInputAt (intptr_t i) const
 
virtual bool MayThrow () const
 

Static Public Member Functions

static const char * KindToCString (Kind kind)
 
static bool ParseKind (const char *str, Kind *out)
 

Additional Inherited Members

- Protected Attributes inherited from dart::TemplateDefinition< 4, Throws, Pure >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 4356 of file il.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kInstancePos 
kDstTypePos 
kInstantiatorTAVPos 
kFunctionTAVPos 
kNumInputs 

Definition at line 4371 of file il.h.

◆ Kind

Enumerator
FOR_EACH_ASSERT_ASSIGNABLE_KIND 

Definition at line 4365 of file il.h.

#define KIND_DEFN(name)
Definition il.h:4364

Constructor & Destructor Documentation

◆ AssertAssignableInstr()

dart::AssertAssignableInstr::AssertAssignableInstr ( const InstructionSource source,
Value value,
Value dst_type,
Value instantiator_type_arguments,
Value function_type_arguments,
const String dst_name,
intptr_t  deopt_id,
Kind  kind = kUnknown 
)
inline

Definition at line 4379 of file il.h.

4387 : TemplateDefinition(source, deopt_id),
4388 token_pos_(source.token_pos),
4389 dst_name_(dst_name),
4390 kind_(kind) {
4392 SetInputAt(kInstancePos, value);
4393 SetInputAt(kDstTypePos, dst_type);
4396 }
Value * dst_type() const
Definition il.h:4405
const String & dst_name() const
Definition il.h:4412
Value * value() const
Definition il.h:4404
Value * function_type_arguments() const
Definition il.h:4409
Value * instantiator_type_arguments() const
Definition il.h:4406
bool IsNull() const
Definition object.h:363
TemplateDefinition(intptr_t deopt_id=DeoptId::kNone)
Definition il.h:2731
#define ASSERT(E)
SkBitmap source
Definition examples.cpp:28

Member Function Documentation

◆ AttributesEqual()

virtual bool dart::AssertAssignableInstr::AttributesEqual ( const Instruction other) const
inlinevirtual

Definition at line 4438 of file il.h.

4438{ return true; }

◆ CanBecomeDeoptimizationTarget()

virtual bool dart::AssertAssignableInstr::CanBecomeDeoptimizationTarget ( ) const
inlinevirtual

Definition at line 4430 of file il.h.

4430 {
4431 // AssertAssignable instructions that are specialized by the optimizer
4432 // (e.g. replaced with CheckClass) need a deoptimization descriptor before.
4433 return true;
4434 }

◆ Canonicalize()

Definition * dart::AssertAssignableInstr::Canonicalize ( FlowGraph flow_graph)
virtual

Definition at line 3064 of file il.cc.

3064 {
3065 // We need dst_type() to be a constant AbstractType to perform any
3066 // canonicalization.
3067 if (!dst_type()->BindsToConstant()) return this;
3068 const auto& abs_type = AbstractType::Cast(dst_type()->BoundConstant());
3069
3070 if (abs_type.IsTopTypeForSubtyping() ||
3071 (FLAG_eliminate_type_checks &&
3072 value()->Type()->IsAssignableTo(abs_type))) {
3073 return value()->definition();
3074 }
3075 if (abs_type.IsInstantiated()) {
3076 return this;
3077 }
3078
3079 // For uninstantiated target types: If the instantiator and function
3080 // type arguments are constant, instantiate the target type here.
3081 // Note: these constant type arguments might not necessarily correspond
3082 // to the correct instantiator because AssertAssignable might
3083 // be located in the unreachable part of the graph (e.g.
3084 // it might be dominated by CheckClass that always fails).
3085 // This means that the code below must guard against such possibility.
3086 Thread* thread = Thread::Current();
3087 Zone* Z = thread->zone();
3088
3089 const TypeArguments* instantiator_type_args = nullptr;
3090 const TypeArguments* function_type_args = nullptr;
3091
3092 if (instantiator_type_arguments()->BindsToConstant()) {
3093 const Object& val = instantiator_type_arguments()->BoundConstant();
3094 instantiator_type_args = (val.ptr() == TypeArguments::null())
3095 ? &TypeArguments::null_type_arguments()
3096 : &TypeArguments::Cast(val);
3097 }
3098
3099 if (function_type_arguments()->BindsToConstant()) {
3100 const Object& val = function_type_arguments()->BoundConstant();
3101 function_type_args =
3102 (val.ptr() == TypeArguments::null())
3103 ? &TypeArguments::null_type_arguments()
3104 : &TypeArguments::Cast(function_type_arguments()->BoundConstant());
3105 }
3106
3107 // If instantiator_type_args are not constant try to match the pattern
3108 // obj.field.:type_arguments where field's static type exactness state
3109 // tells us that all values stored in the field have exact superclass.
3110 // In this case we know the prefix of the actual type arguments vector
3111 // and can try to instantiate the type using just the prefix.
3112 //
3113 // Note: TypeParameter::InstantiateFrom returns an error if we try
3114 // to instantiate it from a vector that is too short.
3115 if (instantiator_type_args == nullptr) {
3116 if (LoadFieldInstr* load_type_args =
3117 instantiator_type_arguments()->definition()->AsLoadField()) {
3118 if (load_type_args->slot().IsTypeArguments()) {
3119 if (LoadFieldInstr* load_field = load_type_args->instance()
3120 ->definition()
3121 ->OriginalDefinition()
3122 ->AsLoadField()) {
3123 if (load_field->slot().IsDartField() &&
3124 load_field->slot()
3125 .field()
3126 .static_type_exactness_state()
3127 .IsHasExactSuperClass()) {
3128 instantiator_type_args = &TypeArguments::Handle(
3129 Z, Type::Cast(AbstractType::Handle(
3130 Z, load_field->slot().field().type()))
3131 .GetInstanceTypeArguments(thread));
3132 }
3133 }
3134 }
3135 }
3136 }
3137
3138 if ((instantiator_type_args != nullptr) && (function_type_args != nullptr)) {
3139 AbstractType& new_dst_type = AbstractType::Handle(
3140 Z, abs_type.InstantiateFrom(*instantiator_type_args,
3141 *function_type_args, kAllFree, Heap::kOld));
3142 if (new_dst_type.IsNull()) {
3143 // Failed instantiation in dead code.
3144 return this;
3145 }
3146 new_dst_type = new_dst_type.Canonicalize(Thread::Current());
3147
3148 // Successfully instantiated destination type: update the type attached
3149 // to this instruction and set type arguments to null because we no
3150 // longer need them (the type was instantiated).
3151 dst_type()->BindTo(flow_graph->GetConstant(new_dst_type));
3152 instantiator_type_arguments()->BindTo(flow_graph->constant_null());
3153 function_type_arguments()->BindTo(flow_graph->constant_null());
3154
3155 if (new_dst_type.IsTopTypeForSubtyping() ||
3156 (FLAG_eliminate_type_checks &&
3157 value()->Type()->IsAssignableTo(new_dst_type))) {
3158 return value()->definition();
3159 }
3160 }
3161 return this;
3162}
#define Z
@ kOld
Definition heap.h:39
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
static Thread * Current()
Definition thread.h:361
const Object & BoundConstant() const
Definition il.cc:1199
Definition * definition() const
Definition il.h:103
void BindTo(Definition *definition)
Definition il.h:2700
@ kAllFree
Definition object.h:2920

◆ ComputeCanDeoptimize()

virtual bool dart::AssertAssignableInstr::ComputeCanDeoptimize ( ) const
inlinevirtual

Definition at line 4414 of file il.h.

4414{ return false; }

◆ ComputeCanDeoptimizeAfterCall()

virtual bool dart::AssertAssignableInstr::ComputeCanDeoptimizeAfterCall ( ) const
inlinevirtual

Definition at line 4415 of file il.h.

4415 {
4416 return !CompilerState::Current().is_aot();
4417 }
static CompilerState & Current()

◆ ComputeType()

CompileType dart::AssertAssignableInstr::ComputeType ( ) const
virtual

Definition at line 1374 of file type_propagator.cc.

1374 {
1375 CompileType* value_type = value()->Type();
1376
1377 const AbstractType* abs_type = &AbstractType::dynamic_type();
1378 if (dst_type()->BindsToConstant() &&
1379 dst_type()->BoundConstant().IsAbstractType()) {
1380 abs_type = &AbstractType::Cast(dst_type()->BoundConstant());
1381 if (value_type->IsSubtypeOf(*abs_type)) {
1382 return *value_type;
1383 }
1384 }
1385 return CompileType::FromAbstractType(*abs_type, value_type->is_nullable(),
1387}
static constexpr bool kCannotBeSentinel
static CompileType FromAbstractType(const AbstractType &type, bool can_be_null, bool can_be_sentinel)
CompileType * Type()

◆ dst_name()

const String & dart::AssertAssignableInstr::dst_name ( ) const
inline

Definition at line 4412 of file il.h.

4412{ return dst_name_; }

◆ dst_type()

Value * dart::AssertAssignableInstr::dst_type ( ) const
inline

Definition at line 4405 of file il.h.

4405{ return inputs_[kDstTypePos]; }
EmbeddedArray< Value *, N > inputs_
Definition il.h:2744

◆ function_type_arguments()

Value * dart::AssertAssignableInstr::function_type_arguments ( ) const
inline

Definition at line 4409 of file il.h.

4409{ return inputs_[kFunctionTAVPos]; }

◆ InferRange()

void dart::AssertAssignableInstr::InferRange ( RangeAnalysis analysis,
Range range 
)
virtual

Definition at line 3141 of file range_analysis.cc.

3141 {
3142 const Range* value_range = value()->definition()->range();
3143 if (!Range::IsUnknown(value_range)) {
3144 *range = *value_range;
3145 } else {
3147 }
3148}
Range * range() const
Definition il.h:2618
static bool IsUnknown(const Range *other)
static Range Full(RangeBoundary::RangeSize size)

◆ instantiator_type_arguments()

Value * dart::AssertAssignableInstr::instantiator_type_arguments ( ) const
inline

Definition at line 4406 of file il.h.

4406 {
4408 }

◆ KindToCString()

const char * dart::AssertAssignableInstr::KindToCString ( Kind  kind)
static

Definition at line 814 of file il.cc.

814 {
815 switch (kind) {
816#define KIND_CASE(name) \
817 case k##name: \
818 return #name;
820#undef KIND_CASE
821 default:
822 UNREACHABLE();
823 return nullptr;
824 }
825}
#define UNREACHABLE()
Definition assert.h:248
#define KIND_CASE(name)

◆ NumberOfInputsConsumedBeforeCall()

virtual intptr_t dart::AssertAssignableInstr::NumberOfInputsConsumedBeforeCall ( ) const
inlinevirtual

Definition at line 4418 of file il.h.

4418 {
4419#if !defined(TARGET_ARCH_IA32)
4420 return InputCount();
4421#else
4422 // The ia32 implementation calls the stub by pushing the input registers
4423 // in the same order onto the stack thereby making the deopt-env correct.
4424 // (Due to lack of registers we cannot use all-argument calling convention
4425 // as in other architectures.)
4426 return 0;
4427#endif
4428 }
virtual intptr_t InputCount() const
Definition il.h:2737

◆ ParseKind()

bool dart::AssertAssignableInstr::ParseKind ( const char *  str,
Kind out 
)
static

Definition at line 827 of file il.cc.

827 {
828#define KIND_CASE(name) \
829 if (strcmp(str, #name) == 0) { \
830 *out = Kind::k##name; \
831 return true; \
832 }
834#undef KIND_CASE
835 return false;
836}

◆ RecomputeType()

bool dart::AssertAssignableInstr::RecomputeType ( )
virtual

Definition at line 1389 of file type_propagator.cc.

1389 {
1390 return UpdateType(ComputeType());
1391}
virtual CompileType ComputeType() const

◆ RedefinedValue()

Value * dart::AssertAssignableInstr::RedefinedValue ( ) const
virtual

Definition at line 547 of file il.cc.

547 {
548 return value();
549}

◆ statistics_tag()

intptr_t dart::AssertAssignableInstr::statistics_tag ( ) const
virtual

Definition at line 6022 of file il.cc.

6022 {
6023 switch (kind_) {
6024 case kParameterCheck:
6026 case kInsertedByFrontend:
6028 case kFromSource:
6030 case kUnknown:
6031 break;
6032 }
6033
6034 return tag();
6035}

◆ token_pos()

virtual TokenPosition dart::AssertAssignableInstr::token_pos ( ) const
inlinevirtual

Definition at line 4411 of file il.h.

4411{ return token_pos_; }

◆ value()

Value * dart::AssertAssignableInstr::value ( ) const
inline

Definition at line 4404 of file il.h.

4404{ return inputs_[kInstancePos]; }

The documentation for this class was generated from the following files: