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

#include <type_testing_stubs.h>

Inheritance diagram for dart::TypeUsageInfo:
dart::ThreadStackResource dart::StackResource

Public Member Functions

 TypeUsageInfo (Thread *thread)
 
 ~TypeUsageInfo ()
 
void UseTypeInAssertAssignable (const AbstractType &type)
 
void UseTypeArgumentsInInstanceCreation (const Class &klass, const TypeArguments &ta)
 
void BuildTypeUsageInformation ()
 
bool IsUsedInTypeTest (const AbstractType &type)
 
- Public Member Functions inherited from dart::ThreadStackResource
 ThreadStackResource (Thread *T)
 
 ~ThreadStackResource ()
 
Threadthread () const
 
Isolateisolate () const
 
IsolateGroupisolate_group () const
 
- Public Member Functions inherited from dart::StackResource
 StackResource (ThreadState *thread)
 
virtual ~StackResource ()
 
ThreadStatethread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from dart::StackResource
static void Unwind (ThreadState *thread)
 
static void UnwindAbove (ThreadState *thread, StackResource *new_top)
 

Detailed Description

Definition at line 184 of file type_testing_stubs.h.

Constructor & Destructor Documentation

◆ TypeUsageInfo()

dart::TypeUsageInfo::TypeUsageInfo ( Thread thread)
explicit

Definition at line 1373 of file type_testing_stubs.cc.

1375 zone_(thread->zone()),
1376 assert_assignable_types_(),
1377 instance_creation_arguments_(
1378 new TypeArgumentsSet
1380 klass_(Class::Handle(zone_)) {
1382}
intptr_t NumCids() const
ClassTable * class_table() const
Definition isolate.h:491
static Object & Handle()
Definition object.h:407
Zone * zone() const
void set_type_usage_info(TypeUsageInfo *value)
Definition thread.h:605
IsolateGroup * isolate_group() const
Definition thread.h:540

◆ ~TypeUsageInfo()

dart::TypeUsageInfo::~TypeUsageInfo ( )

Definition at line 1384 of file type_testing_stubs.cc.

1384 {
1385 thread()->set_type_usage_info(nullptr);
1386 delete[] instance_creation_arguments_;
1387}

Member Function Documentation

◆ BuildTypeUsageInformation()

void dart::TypeUsageInfo::BuildTypeUsageInformation ( )

Definition at line 1432 of file type_testing_stubs.cc.

1432 {
1433 ClassTable* class_table = thread()->isolate_group()->class_table();
1434 const intptr_t cid_count = class_table->NumCids();
1435
1436 // Step 1) Collect the type parameters we're interested in.
1437 TypeParameterSet parameters_tested_against;
1438 CollectTypeParametersUsedInAssertAssignable(&parameters_tested_against);
1439
1440 // Step 2) Add all types which flow into a type parameter we test against to
1441 // the set of types tested against.
1442 UpdateAssertAssignableTypes(class_table, cid_count,
1443 &parameters_tested_against);
1444}

◆ IsUsedInTypeTest()

bool dart::TypeUsageInfo::IsUsedInTypeTest ( const AbstractType type)

Definition at line 1519 of file type_testing_stubs.cc.

1519 {
1520 if (type.IsFinalized()) {
1521 return assert_assignable_types_.HasKey(&type);
1522 }
1523 return false;
1524}
bool HasKey(typename KeyValueTrait::Key key) const
Definition hash_map.h:52

◆ UseTypeArgumentsInInstanceCreation()

void dart::TypeUsageInfo::UseTypeArgumentsInInstanceCreation ( const Class klass,
const TypeArguments ta 
)

Definition at line 1395 of file type_testing_stubs.cc.

1397 {
1398 if (ta.IsNull() || ta.IsCanonical()) {
1399 // The Dart VM performs an optimization where it re-uses type argument
1400 // vectors if the use-site needs a prefix of an already-existent type
1401 // arguments vector.
1402 //
1403 // For example:
1404 //
1405 // class Foo<K, V> {
1406 // foo() => new Bar<K>();
1407 // }
1408 //
1409 // So the length of the type arguments vector can be longer than the number
1410 // of type arguments the class expects.
1411 ASSERT(ta.IsNull() || klass.NumTypeArguments() <= ta.Length());
1412
1413 // If this is a non-instantiated [TypeArguments] object, then it refers to
1414 // type parameters. We need to ensure the type parameters in [ta] only
1415 // refer to type parameters in the class.
1416 if (!ta.IsNull() && !ta.IsInstantiated()) {
1417 return;
1418 }
1419
1420 klass_ = klass.ptr();
1421 while (klass_.NumTypeArguments() > 0) {
1422 const intptr_t cid = klass_.id();
1423 TypeArgumentsSet& set = instance_creation_arguments_[cid];
1424 if (!set.HasKey(&ta)) {
1425 set.Insert(&TypeArguments::ZoneHandle(zone_, ta.ptr()));
1426 }
1427 klass_ = klass_.SuperClass();
1428 }
1429 }
1430}
intptr_t id() const
Definition object.h:1235
intptr_t NumTypeArguments() const
Definition object.cc:3690
ClassPtr SuperClass(ClassTable *class_table=nullptr) const
Definition object.cc:3715
ObjectPtr ptr() const
Definition object.h:332
static Object & ZoneHandle()
Definition object.h:419
#define ASSERT(E)
const intptr_t cid
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition switches.h:76

◆ UseTypeInAssertAssignable()

void dart::TypeUsageInfo::UseTypeInAssertAssignable ( const AbstractType type)

Definition at line 1389 of file type_testing_stubs.cc.

1389 {
1390 if (!assert_assignable_types_.HasKey(&type)) {
1391 AddTypeToSet(&assert_assignable_types_, &type);
1392 }
1393}

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