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

#include <il.h>

Inheritance diagram for dart::CheckClassInstr:
dart::TemplateInstruction< 1, NoThrow >

Public Member Functions

 CheckClassInstr (Value *value, intptr_t deopt_id, const Cids &cids, const InstructionSource &source)
 
virtual bool ComputeCanDeoptimize () const
 
virtual TokenPosition token_pos () const
 
Valuevalue () const
 
const Cidscids () const
 
virtual InstructionCanonicalize (FlowGraph *flow_graph)
 
bool IsNullCheck () const
 
bool IsDeoptIfNull () const
 
bool IsDeoptIfNotNull () const
 
bool IsBitTest () const
 
intptr_t ComputeCidMask () const
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const
 
virtual bool AttributesEqual (const Instruction &other) const
 
DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(CheckClassInstr, TemplateInstruction, FIELD_LIST) private void EmitBitTest (FlowGraphCompiler *compiler, intptr_t min, intptr_t max, intptr_t mask, compiler::Label *deopt)
 
void EmitNullCheck (FlowGraphCompiler *compiler, compiler::Label *deopt)
 
 DISALLOW_COPY_AND_ASSIGN (CheckClassInstr)
 
- Public Member Functions inherited from dart::TemplateInstruction< 1, NoThrow >
 TemplateInstruction (intptr_t deopt_id=DeoptId::kNone)
 
 TemplateInstruction (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 bool IsCompactCidRange (const Cids &cids)
 

Additional Inherited Members

- Public Types inherited from dart::TemplateInstruction< 1, NoThrow >
using BaseClass = typename NoCSE< Instruction, PureInstruction >::Base
 
- Protected Attributes inherited from dart::TemplateInstruction< 1, NoThrow >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 10527 of file il.h.

Constructor & Destructor Documentation

◆ CheckClassInstr()

dart::CheckClassInstr::CheckClassInstr ( Value value,
intptr_t  deopt_id,
const Cids cids,
const InstructionSource source 
)

Definition at line 838 of file il.cc.

842 : TemplateInstruction(source, deopt_id),
843 cids_(cids),
844 is_bit_test_(IsCompactCidRange(cids)),
845 token_pos_(source.token_pos) {
846 // Expected useful check data.
847 const intptr_t number_of_checks = cids.length();
848 ASSERT(number_of_checks > 0);
849 SetInputAt(0, value);
850 // Otherwise use CheckSmiInstr.
851 ASSERT(number_of_checks != 1 || !cids[0].IsSingleCid() ||
852 cids[0].cid_start != kSmiCid);
853}
Value * value() const
Definition il.h:10540
const Cids & cids() const
Definition il.h:10542
static bool IsCompactCidRange(const Cids &cids)
Definition il.cc:883
intptr_t length() const
Definition il.h:752
TemplateInstruction(intptr_t deopt_id=DeoptId::kNone)
Definition il.h:1501
#define ASSERT(E)
SkBitmap source
Definition examples.cpp:28

Member Function Documentation

◆ AllowsCSE()

virtual bool dart::CheckClassInstr::AllowsCSE ( ) const
inlinevirtual

Definition at line 10555 of file il.h.

10555{ return true; }

◆ AttributesEqual()

bool dart::CheckClassInstr::AttributesEqual ( const Instruction other) const
virtual

Definition at line 855 of file il.cc.

855 {
856 auto const other_check = other.AsCheckClass();
857 ASSERT(other_check != nullptr);
858 return cids().Equals(other_check->cids());
859}
bool Equals(const Cids &other) const
Definition il.cc:653

◆ Canonicalize()

Instruction * dart::CheckClassInstr::Canonicalize ( FlowGraph flow_graph)
virtual

Definition at line 3802 of file il.cc.

3802 {
3803 const intptr_t value_cid = value()->Type()->ToCid();
3804 if (value_cid == kDynamicCid) {
3805 return this;
3806 }
3807
3808 return cids().HasClassId(value_cid) ? nullptr : this;
3809}
bool HasClassId(intptr_t cid) const
Definition il.cc:680
CompileType * Type()
@ kDynamicCid
Definition class_id.h:253

◆ cids()

const Cids & dart::CheckClassInstr::cids ( ) const
inline

Definition at line 10542 of file il.h.

10542{ return cids_; }

◆ ComputeCanDeoptimize()

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

Definition at line 10536 of file il.h.

10536{ return true; }

◆ ComputeCidMask()

intptr_t dart::CheckClassInstr::ComputeCidMask ( ) const

Definition at line 901 of file il.cc.

901 {
902 ASSERT(IsBitTest());
903 const uintptr_t one = 1;
904 intptr_t min = cids_.ComputeLowestCid();
905 intptr_t mask = 0;
906 for (intptr_t i = 0; i < cids_.length(); ++i) {
907 uintptr_t run;
908 uintptr_t range = one + cids_[i].Extent();
909 if (range >= static_cast<uintptr_t>(compiler::target::kBitsPerWord)) {
910 run = -1;
911 } else {
912 run = (one << range) - 1;
913 }
914 mask |= run << (cids_[i].cid_start - min);
915 }
916 return mask;
917}
bool IsBitTest() const
Definition il.cc:897
static float min(float r, float g, float b)
Definition hsl.cpp:48
Definition run.py:1

◆ DISALLOW_COPY_AND_ASSIGN()

dart::CheckClassInstr::DISALLOW_COPY_AND_ASSIGN ( CheckClassInstr  )

◆ EmitBitTest()

DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(CheckClassInstr, TemplateInstruction, FIELD_LIST) private void dart::CheckClassInstr::EmitBitTest ( FlowGraphCompiler compiler,
intptr_t  min,
intptr_t  max,
intptr_t  mask,
compiler::Label deopt 
)

◆ EmitNullCheck()

void dart::CheckClassInstr::EmitNullCheck ( FlowGraphCompiler compiler,
compiler::Label deopt 
)

◆ HasUnknownSideEffects()

virtual bool dart::CheckClassInstr::HasUnknownSideEffects ( ) const
inlinevirtual

Definition at line 10556 of file il.h.

10556{ return false; }

◆ IsBitTest()

bool dart::CheckClassInstr::IsBitTest ( ) const

Definition at line 897 of file il.cc.

897 {
898 return is_bit_test_;
899}

◆ IsCompactCidRange()

bool dart::CheckClassInstr::IsCompactCidRange ( const Cids cids)
static

Definition at line 883 of file il.cc.

883 {
884 const intptr_t number_of_checks = cids.length();
885 // If there are only two checks, the extra register pressure needed for the
886 // dense-cid-range code is not justified.
887 if (number_of_checks <= 2) return false;
888
889 // TODO(fschneider): Support smis in dense cid checks.
890 if (cids.HasClassId(kSmiCid)) return false;
891
892 intptr_t min = cids.ComputeLowestCid();
893 intptr_t max = cids.ComputeHighestCid();
894 return (max - min) < compiler::target::kBitsPerWord;
895}
intptr_t ComputeLowestCid() const
Definition il.cc:664
intptr_t ComputeHighestCid() const
Definition il.cc:672
static float max(float r, float g, float b)
Definition hsl.cpp:49

◆ IsDeoptIfNotNull()

bool dart::CheckClassInstr::IsDeoptIfNotNull ( ) const

Definition at line 875 of file il.cc.

875 {
876 if (!cids().IsMonomorphic()) {
877 return false;
878 }
879 const intptr_t cid = cids().MonomorphicReceiverCid();
880 return cid == kNullCid;
881}
intptr_t MonomorphicReceiverCid() const
Definition il.cc:804
@ kNullCid
Definition class_id.h:252
const intptr_t cid

◆ IsDeoptIfNull()

bool dart::CheckClassInstr::IsDeoptIfNull ( ) const

Definition at line 861 of file il.cc.

861 {
862 if (!cids().IsMonomorphic()) {
863 return false;
864 }
865 CompileType* in_type = value()->Type();
866 const intptr_t cid = cids().MonomorphicReceiverCid();
867 // Performance check: use CheckSmiInstr instead.
868 ASSERT(cid != kSmiCid);
869 return in_type->is_nullable() && (in_type->ToNullableCid() == cid);
870}

◆ IsNullCheck()

bool dart::CheckClassInstr::IsNullCheck ( ) const
inline

Definition at line 10546 of file il.h.

10546{ return IsDeoptIfNull() || IsDeoptIfNotNull(); }
bool IsDeoptIfNull() const
Definition il.cc:861
bool IsDeoptIfNotNull() const
Definition il.cc:875

◆ token_pos()

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

Definition at line 10538 of file il.h.

10538{ return token_pos_; }

◆ value()

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

Definition at line 10540 of file il.h.

10540{ return inputs_[0]; }
EmbeddedArray< Value *, N > inputs_
Definition il.h:1516

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