Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 >

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 Attributes

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

Static Public Attributes

static constexpr intptr_t kNotFunctionParameter = -1
 

Additional Inherited Members

- Public Types inherited from dart::TemplateDefinition< 0, NoThrow >
using BaseClass = typename NoCSE< Definition, PureDefinition >::Base
 
- Protected Attributes inherited from dart::TemplateDefinition< 0, NoThrow >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 2900 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 2906 of file il.h.

2911 : env_index_(env_index),
2912 param_index_(param_index),
2913 representation_(representation),
2914 block_(block),
2915 location_(loc) {}
intptr_t param_index() const
Definition il.h:2926
DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(ParameterInstr, TemplateDefinition, FIELD_LIST) DECLARE_EXTRA_SERIALIZATION private Location location_
Definition il.h:2959
virtual Representation representation() const
Definition il.h:2934

Member Function Documentation

◆ ComputeCanDeoptimize()

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

Definition at line 2941 of file il.h.

2941{ return false; }

◆ ComputeType()

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

Definition at line 1195 of file type_propagator.cc.

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

2921 { return env_index_; }

◆ DISALLOW_COPY_AND_ASSIGN()

dart::ParameterInstr::DISALLOW_COPY_AND_ASSIGN ( ParameterInstr  )

◆ GetBlock()

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

Definition at line 2931 of file il.h.

2931{ return block_; }

◆ Hash()

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

Definition at line 2945 of file il.h.

2945 {
2946 UNREACHABLE();
2947 return 0;
2948 }

◆ HasUnknownSideEffects()

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

Definition at line 2943 of file il.h.

2943{ return false; }

◆ index()

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

Definition at line 2922 of file il.h.

2922{ return env_index(); }

◆ location()

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

Definition at line 2928 of file il.h.

2928{ return location_; }

◆ param_index()

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

Definition at line 2926 of file il.h.

2926{ return param_index_; }

◆ representation()

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

Definition at line 2934 of file il.h.

2934{ return representation_; }

◆ RequiredInputRepresentation()

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

Definition at line 2936 of file il.h.

2936 {
2937 UNREACHABLE();
2938 return kTagged;
2939 }

◆ set_block()

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

Definition at line 2932 of file il.h.

2932{ block_ = block; }

Member Data Documentation

◆ kNotFunctionParameter

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

Definition at line 2904 of file il.h.

◆ location_

Definition at line 2967 of file il.h.


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