Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
dart::ParameterInstr Class Reference

#include <il.h>

Inheritance diagram for dart::ParameterInstr:
dart::TemplateDefinition< 0, NoThrow > dart::Instruction dart::ZoneAllocated

Public Member Functions

 ParameterInstr (BlockEntryInstr *block, intptr_t env_index, intptr_t param_index, const Location &loc, Representation representation)
 
 DECLARE_ATTRIBUTES_NAMED (("index", "location"),(index(), location())) intptr_t env_index() const
 
intptr_t index () const
 
intptr_t param_index () const
 
const Locationlocation () const
 
virtual BlockEntryInstrGetBlock ()
 
void set_block (BlockEntryInstr *block)
 
virtual Representation representation () const
 
virtual Representation RequiredInputRepresentation (intptr_t index) const
 
virtual bool ComputeCanDeoptimize () const
 
virtual bool HasUnknownSideEffects () const
 
virtual uword Hash () const
 
virtual CompileType ComputeType () const
 
 DISALLOW_COPY_AND_ASSIGN (ParameterInstr)
 
- Public Member Functions inherited from dart::TemplateDefinition< 0, NoThrow >
 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
 
- Public Member Functions inherited from dart::Instruction
 Instruction (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
 Instruction (intptr_t deopt_id=DeoptId::kNone)
 
virtual ~Instruction ()
 
virtual Tag tag () const =0
 
virtual intptr_t statistics_tag () const
 
intptr_t deopt_id () const
 
virtual TokenPosition token_pos () const
 
InstructionSource source () const
 
virtual intptr_t InputCount () const =0
 
virtual ValueInputAt (intptr_t i) const =0
 
void SetInputAt (intptr_t i, Value *value)
 
InputsIterable inputs ()
 
void UnuseAllInputs ()
 
virtual intptr_t ArgumentCount () const
 
ValueArgumentValueAt (intptr_t index) const
 
DefinitionArgumentAt (intptr_t index) const
 
virtual void SetMoveArguments (MoveArgumentsArray *move_arguments)
 
virtual MoveArgumentsArrayGetMoveArguments () const
 
virtual void ReplaceInputsWithMoveArguments (MoveArgumentsArray *move_arguments)
 
bool HasMoveArguments () const
 
void RepairArgumentUsesInEnvironment () const
 
virtual bool ComputeCanDeoptimize () const =0
 
virtual bool ComputeCanDeoptimizeAfterCall () const
 
bool CanDeoptimize () const
 
virtual void Accept (InstructionVisitor *visitor)=0
 
Instructionprevious () const
 
void set_previous (Instruction *instr)
 
Instructionnext () const
 
void set_next (Instruction *instr)
 
void LinkTo (Instruction *next)
 
InstructionRemoveFromGraph (bool return_previous=true)
 
virtual intptr_t SuccessorCount () const
 
virtual BlockEntryInstrSuccessorAt (intptr_t index) const
 
SuccessorsIterable successors () const
 
void Goto (JoinEntryInstr *entry)
 
virtual const char * DebugName () const =0
 
void CheckField (const Field &field) const
 
const char * ToCString () const
 
 DECLARE_INSTRUCTION_TYPE_CHECK (BlockEntryWithInitialDefs, BlockEntryWithInitialDefs) template< typename T > T *Cast()
 
template<typename T >
const TCast () const
 
LocationSummarylocs ()
 
bool HasLocs () const
 
virtual LocationSummaryMakeLocationSummary (Zone *zone, bool is_optimizing) const =0
 
void InitializeLocationSummary (Zone *zone, bool optimizing)
 
virtual void EmitNativeCode (FlowGraphCompiler *compiler)
 
Environmentenv () const
 
void SetEnvironment (Environment *deopt_env)
 
void RemoveEnvironment ()
 
void ReplaceInEnvironment (Definition *current, Definition *replacement)
 
virtual intptr_t NumberOfInputsConsumedBeforeCall () const
 
intptr_t GetPassSpecificId (CompilerPass::Id pass) const
 
void SetPassSpecificId (CompilerPass::Id pass, intptr_t id)
 
bool HasPassSpecificId (CompilerPass::Id pass) const
 
bool HasUnmatchedInputRepresentations () const
 
virtual Representation RequiredInputRepresentation (intptr_t idx) const
 
SpeculativeMode SpeculativeModeOfInputs () const
 
virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const
 
virtual Representation representation () const
 
bool WasEliminated () const
 
virtual intptr_t DeoptimizationTarget () const
 
virtual InstructionCanonicalize (FlowGraph *flow_graph)
 
void InsertBefore (Instruction *next)
 
void InsertAfter (Instruction *prev)
 
InstructionAppendInstruction (Instruction *tail)
 
virtual bool AllowsCSE () const
 
virtual bool HasUnknownSideEffects () const =0
 
virtual bool CanCallDart () const
 
virtual bool CanTriggerGC () const
 
virtual BlockEntryInstrGetBlock ()
 
virtual intptr_t inlining_id () const
 
virtual void set_inlining_id (intptr_t value)
 
virtual bool has_inlining_id () const
 
virtual uword Hash () const
 
bool Equals (const Instruction &other) const
 
virtual bool AttributesEqual (const Instruction &other) const
 
void InheritDeoptTarget (Zone *zone, Instruction *other)
 
bool NeedsEnvironment () const
 
virtual bool CanBecomeDeoptimizationTarget () const
 
void InheritDeoptTargetAfter (FlowGraph *flow_graph, Definition *call, Definition *result)
 
virtual bool MayThrow () const =0
 
virtual bool MayHaveVisibleEffect () const
 
virtual bool CanEliminate (const BlockEntryInstr *block) const
 
bool CanEliminate ()
 
bool IsDominatedBy (Instruction *dom)
 
void ClearEnv ()
 
void Unsupported (FlowGraphCompiler *compiler)
 
virtual bool UseSharedSlowPathStub (bool is_optimizing) const
 
Location::Kind RegisterKindForResult () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Public Attributes

DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(ParameterInstr, TemplateDefinition, FIELD_LIST) DECLARE_EXTRA_SERIALIZATION private Location location_
 

Static Public Attributes

static constexpr intptr_t kNotFunctionParameter = -1
 
- Static Public Attributes inherited from dart::Instruction
static const intptr_t kInstructionAttrs [kNumInstructions]
 

Additional Inherited Members

- Public Types inherited from dart::TemplateDefinition< 0, NoThrow >
using BaseClass = typename NoCSE< Definition, PureDefinition >::Base
 
- Public Types inherited from dart::Instruction
enum  Tag { FOR_EACH_INSTRUCTION =(DECLARE_TAG) kNumInstructions }
 
enum  SpeculativeMode { kGuardInputs , kNotSpeculative }
 
using InputsIterable = InstructionIndexedPropertyIterable< InputsTrait >
 
using SuccessorsIterable = InstructionIndexedPropertyIterable< SuccessorsTrait >
 
- Static Public Member Functions inherited from dart::Instruction
static const ICDataGetICData (const ZoneGrowableArray< const ICData * > &ic_data_array, intptr_t deopt_id, bool is_static_call)
 
static LocationSummaryMakeCallSummary (Zone *zone, const Instruction *instr, LocationSummary *locs=nullptr)
 
static bool SlowPathSharingSupported (bool is_optimizing)
 
- Protected Member Functions inherited from dart::Instruction
intptr_t GetDeoptId () const
 
virtual void CopyDeoptIdFrom (const Instruction &instr)
 
void WriteExtraWithoutInputs (FlowGraphSerializer *s)
 
void ReadExtraWithoutInputs (FlowGraphDeserializer *d)
 
- Protected Attributes inherited from dart::TemplateDefinition< 0, NoThrow >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 2918 of file il.h.

Constructor & Destructor Documentation

◆ ParameterInstr()

dart::ParameterInstr::ParameterInstr ( BlockEntryInstr block,
intptr_t  env_index,
intptr_t  param_index,
const Location loc,
Representation  representation 
)
inline

Definition at line 2924 of file il.h.

2929 : env_index_(env_index),
2930 param_index_(param_index),
2931 representation_(representation),
2932 block_(block),
2933 location_(loc) {}
intptr_t param_index() const
Definition: il.h:2944
DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(ParameterInstr, TemplateDefinition, FIELD_LIST) DECLARE_EXTRA_SERIALIZATION private Location location_
Definition: il.h:2977
virtual Representation representation() const
Definition: il.h:2952

Member Function Documentation

◆ ComputeCanDeoptimize()

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

Implements dart::Instruction.

Definition at line 2959 of file il.h.

2959{ return false; }

◆ ComputeType()

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

Definition at line 1194 of file type_propagator.cc.

1194 {
1195 // Note that returning the declared type of the formal parameter would be
1196 // incorrect, because ParameterInstr is used as input to the type check
1197 // verifying the run time type of the passed-in parameter and this check would
1198 // always be wrongly eliminated.
1199 // However there are parameters that are known to match their declared type:
1200 // for example receiver.
1201 GraphEntryInstr* graph_entry = block_->AsGraphEntry();
1202 if (graph_entry == nullptr) {
1203 if (auto function_entry = block_->AsFunctionEntry()) {
1204 graph_entry = function_entry->graph_entry();
1205 } else if (auto osr_entry = block_->AsOsrEntry()) {
1206 graph_entry = osr_entry->graph_entry();
1207 } else if (auto catch_entry = block_->AsCatchBlockEntry()) {
1208 graph_entry = catch_entry->graph_entry();
1209 } else {
1210 UNREACHABLE();
1211 }
1212 }
1213 // Parameters at OSR entries have type dynamic.
1214 //
1215 // TODO(kmillikin): Use the actual type of the parameter at OSR entry.
1216 // The code below is not safe for OSR because it doesn't necessarily use
1217 // the correct scope.
1218 if (graph_entry->IsCompiledForOsr()) {
1219 // Parameter at OSR entry may correspond to a late local variable.
1221 }
1222
1223 const ParsedFunction& pf = graph_entry->parsed_function();
1224 const Function& function = pf.function();
1225 if (function.IsIrregexpFunction()) {
1226 // In irregexp functions, types of input parameters are known and immutable.
1227 // Set parameter types here in order to prevent unnecessary CheckClassInstr
1228 // from being generated.
1229 switch (env_index()) {
1231 return CompileType::FromCid(kRegExpCid);
1233 return CompileType::FromCid(function.string_specialization_cid());
1235 return CompileType::FromCid(kSmiCid);
1236 default:
1237 UNREACHABLE();
1238 }
1239 UNREACHABLE();
1240 return CompileType::Dynamic();
1241 }
1242
1243 const intptr_t param_index = this->param_index();
1244 if (param_index >= 0) {
1245 // Parameter is the receiver.
1246 if ((param_index == 0) &&
1247 (function.IsDynamicFunction() || function.IsGenerativeConstructor())) {
1248 const AbstractType& type = pf.RawParameterVariable(0)->static_type();
1249 if (type.IsObjectType() || type.IsNullType()) {
1250 // Receiver can be null.
1251 return CompileType(CompileType::kCanBeNull,
1253 }
1254
1255 // Receiver can't be null but can be an instance of a subclass.
1256 intptr_t cid = kDynamicCid;
1257
1258 if (type.type_class_id() != kIllegalCid) {
1259 Thread* thread = Thread::Current();
1260 const Class& type_class = Class::Handle(type.type_class());
1261 if (!CHA::HasSubclasses(type_class)) {
1262 if (type_class.IsPrivate()) {
1263 // Private classes can never be subclassed by later loaded libs.
1264 cid = type_class.id();
1265 } else {
1266 if (FLAG_use_cha_deopt ||
1267 thread->isolate_group()->all_classes_finalized()) {
1268 if (FLAG_trace_cha) {
1269 THR_Print(
1270 " **(CHA) Computing exact type of receiver, "
1271 "no subclasses: %s\n",
1272 type_class.ToCString());
1273 }
1274 if (FLAG_use_cha_deopt) {
1275 thread->compiler_state()
1276 .cha()
1277 .AddToGuardedClassesForSubclassCount(type_class,
1278 /*subclass_count=*/0);
1279 }
1280 cid = type_class.id();
1281 }
1282 }
1283 }
1284 }
1285
1286 return CompileType(CompileType::kCannotBeNull,
1288 }
1289
1290 const bool is_unchecked_entry_param =
1291 graph_entry->unchecked_entry() == block_;
1292
1293 const LocalVariable* param = (pf.scope() != nullptr)
1294 ? pf.ParameterVariable(param_index)
1295 : pf.RawParameterVariable(param_index);
1296 ASSERT(param != nullptr);
1297
1298 CompileType* inferred_type = nullptr;
1299 intptr_t inferred_cid = kDynamicCid;
1300 bool inferred_nullable = true;
1301 if (!block_->IsCatchBlockEntry()) {
1302 inferred_type = param->inferred_arg_type();
1303
1304 if (inferred_type != nullptr) {
1305 // Use inferred type if it is an int.
1306 if (inferred_type->IsNullableInt()) {
1307 TraceStrongModeType(this, inferred_type);
1308 return *inferred_type;
1309 }
1310 // Otherwise use inferred cid and nullability.
1311 inferred_cid = inferred_type->ToNullableCid();
1312 inferred_nullable = inferred_type->is_nullable();
1313 }
1314 }
1315 // If parameter type was checked by caller, then use Dart type annotation,
1316 // plus non-nullability from inferred type if known.
1317 // Do not trust static parameter type of 'operator ==' as it is a
1318 // non-nullable Object but VM handles comparison with null in
1319 // the callee, so 'operator ==' can take null as an argument.
1320 if ((function.name() != Symbols::EqualOperator().ptr()) &&
1321 (param->was_type_checked_by_caller() ||
1322 (is_unchecked_entry_param &&
1323 !param->is_explicit_covariant_parameter()))) {
1324 const AbstractType& static_type = param->static_type();
1325 CompileType result(
1326 inferred_nullable && !static_type.IsStrictlyNonNullable(),
1327 block_->IsCatchBlockEntry() && param->is_late(),
1328 inferred_cid == kDynamicCid ? kIllegalCid : inferred_cid,
1329 &static_type);
1331 return result;
1332 }
1333 // Last resort: use inferred type as is.
1334 if (inferred_type != nullptr) {
1335 TraceStrongModeType(this, inferred_type);
1336 return *inferred_type;
1337 }
1338 }
1339
1340 if (block_->IsCatchBlockEntry()) {
1341 // Parameter of a catch block may correspond to a late local variable.
1343 }
1344
1345 return CompileType::Dynamic();
1346}
#define UNREACHABLE()
Definition: assert.h:248
GLenum type
static bool HasSubclasses(const Class &cls)
Definition: cha.cc:64
static CompileType FromCid(intptr_t cid)
static constexpr bool kCannotBeSentinel
Definition: compile_type.h:49
static CompileType DynamicOrSentinel()
static constexpr bool kCannotBeNull
Definition: compile_type.h:46
static constexpr bool kCanBeNull
Definition: compile_type.h:45
static CompileType Dynamic()
static Object & Handle()
Definition: object.h:407
static Thread * Current()
Definition: thread.h:362
#define THR_Print(format,...)
Definition: log.h:20
#define ASSERT(E)
GAsyncResult * result
Dart_NativeFunction function
Definition: fuchsia.cc:51
@ kIllegalCid
Definition: class_id.h:214
@ kDynamicCid
Definition: class_id.h:253
const intptr_t cid
static void TraceStrongModeType(const Instruction *instr, const AbstractType &type)

◆ DECLARE_ATTRIBUTES_NAMED()

dart::ParameterInstr::DECLARE_ATTRIBUTES_NAMED ( ("index", "location")  ,
(index(), location())   
) const
inline

Definition at line 2936 of file il.h.

2939 { return env_index_; }

◆ DISALLOW_COPY_AND_ASSIGN()

dart::ParameterInstr::DISALLOW_COPY_AND_ASSIGN ( ParameterInstr  )

◆ GetBlock()

virtual BlockEntryInstr * dart::ParameterInstr::GetBlock ( )
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 2949 of file il.h.

2949{ return block_; }

◆ Hash()

virtual uword dart::ParameterInstr::Hash ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 2963 of file il.h.

2963 {
2964 UNREACHABLE();
2965 return 0;
2966 }

◆ HasUnknownSideEffects()

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

Implements dart::Instruction.

Definition at line 2961 of file il.h.

2961{ return false; }

◆ index()

intptr_t dart::ParameterInstr::index ( ) const
inline

Definition at line 2940 of file il.h.

2940{ return env_index(); }

◆ location()

const Location & dart::ParameterInstr::location ( ) const
inline

Definition at line 2946 of file il.h.

2946{ return location_; }

◆ param_index()

intptr_t dart::ParameterInstr::param_index ( ) const
inline

Definition at line 2944 of file il.h.

2944{ return param_index_; }

◆ representation()

virtual Representation dart::ParameterInstr::representation ( ) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 2952 of file il.h.

2952{ return representation_; }

◆ RequiredInputRepresentation()

virtual Representation dart::ParameterInstr::RequiredInputRepresentation ( intptr_t  index) const
inlinevirtual

Reimplemented from dart::Instruction.

Definition at line 2954 of file il.h.

2954 {
2955 UNREACHABLE();
2956 return kTagged;
2957 }

◆ set_block()

void dart::ParameterInstr::set_block ( BlockEntryInstr block)
inline

Definition at line 2950 of file il.h.

2950{ block_ = block; }

Member Data Documentation

◆ kNotFunctionParameter

constexpr intptr_t dart::ParameterInstr::kNotFunctionParameter = -1
staticconstexpr

Definition at line 2922 of file il.h.

◆ location_

Definition at line 2985 of file il.h.


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