Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
dart::Place Class Reference
Inheritance diagram for dart::Place:
dart::ValueObject

Public Types

enum  Kind {
  kNone , kStaticField , kInstanceField , kIndexed ,
  kConstantIndexed
}
 
enum  ElementSize {
  kNoSize , k1Byte , k2Bytes , k4Bytes ,
  k8Bytes , k16Bytes , kLargestElementSize = k16Bytes
}
 

Public Member Functions

 Place (const Place &other)
 
 Place (Instruction *instr, bool *is_load, bool *is_store)
 
 Place (AllocationInstr *alloc, intptr_t input_pos)
 
Place ToAlias () const
 
bool DependsOnInstance () const
 
Place CopyWithoutInstance () const
 
Place CopyWithoutIndex () const
 
Place ToLargerElement (ElementSize to) const
 
Place ToSmallerElement (ElementSize to, intptr_t index) const
 
intptr_t id () const
 
Kind kind () const
 
Representation representation () const
 
Definitioninstance () const
 
void set_instance (Definition *def)
 
const Fieldstatic_field () const
 
const Slotinstance_field () const
 
Definitionindex () const
 
ElementSize element_size () const
 
intptr_t index_constant () const
 
const char * ToCString () const
 
bool IsImmutableField () const
 
uword Hash () const
 
bool Equals (const Place &other) const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static PlaceCreateAnyInstanceAnyIndexAlias (Zone *zone, intptr_t id)
 
static const char * DefinitionName (Definition *def)
 
static PlaceWrap (Zone *zone, const Place &place, intptr_t id)
 
static bool IsAllocation (Definition *defn)
 
static bool IsTypedDataViewAllocation (Definition *defn)
 

Detailed Description

Definition at line 163 of file redundancy_elimination.cc.

Member Enumeration Documentation

◆ ElementSize

Enumerator
kNoSize 
k1Byte 
k2Bytes 
k4Bytes 
k8Bytes 
k16Bytes 
kLargestElementSize 

Definition at line 186 of file redundancy_elimination.cc.

186 {
187 // If indexed access is not a TypedData access then element size is not
188 // important because there is only a single possible access size depending
189 // on the receiver - X[C] aliases X[K] if and only if C == K.
190 // This is the size set for Array, ImmutableArray, OneByteString and
191 // TwoByteString accesses.
192 kNoSize,
193
194 // 1 byte (Int8List, Uint8List, Uint8ClampedList).
195 k1Byte,
196
197 // 2 bytes (Int16List, Uint16List).
198 k2Bytes,
199
200 // 4 bytes (Int32List, Uint32List, Float32List).
201 k4Bytes,
202
203 // 8 bytes (Int64List, Uint64List, Float64List).
204 k8Bytes,
205
206 // 16 bytes (Int32x4List, Float32x4List, Float64x2List).
207 k16Bytes,
208
210 };

◆ Kind

Enumerator
kNone 
kStaticField 
kInstanceField 
kIndexed 
kConstantIndexed 

Definition at line 165 of file redundancy_elimination.cc.

165 {
166 kNone,
167
168 // Static field location. Is represented as a Field object with a
169 // nullptr instance.
171
172 // Instance field location. It is represented by a pair of instance
173 // and a Slot.
175
176 // Indexed location with a non-constant index.
177 kIndexed,
178
179 // Indexed location with a constant index.
181 };

Constructor & Destructor Documentation

◆ Place() [1/3]

dart::Place::Place ( const Place other)
inline

Definition at line 212 of file redundancy_elimination.cc.

213 : ValueObject(),
214 flags_(other.flags_),
215 instance_(other.instance_),
216 raw_selector_(other.raw_selector_),
217 id_(other.id_) {}

◆ Place() [2/3]

dart::Place::Place ( Instruction instr,
bool *  is_load,
bool *  is_store 
)
inline

Definition at line 221 of file redundancy_elimination.cc.

222 : flags_(0), instance_(nullptr), raw_selector_(0), id_(0) {
223 switch (instr->tag()) {
224 case Instruction::kLoadField: {
225 LoadFieldInstr* load_field = instr->AsLoadField();
226 set_representation(load_field->representation());
227 instance_ = load_field->instance()->definition()->OriginalDefinition();
228 set_kind(kInstanceField);
229 instance_field_ = &load_field->slot();
230 *is_load = true;
231 break;
232 }
233
234 case Instruction::kStoreField: {
235 StoreFieldInstr* store = instr->AsStoreField();
236 set_representation(
237 store->RequiredInputRepresentation(StoreFieldInstr::kValuePos));
238 instance_ = store->instance()->definition()->OriginalDefinition();
239 set_kind(kInstanceField);
240 instance_field_ = &store->slot();
241 *is_store = true;
242 break;
243 }
244
245 case Instruction::kLoadStaticField:
246 set_kind(kStaticField);
247 set_representation(instr->AsLoadStaticField()->representation());
248 static_field_ = &instr->AsLoadStaticField()->field();
249 *is_load = true;
250 break;
251
252 case Instruction::kStoreStaticField:
253 set_kind(kStaticField);
254 set_representation(
255 instr->AsStoreStaticField()->RequiredInputRepresentation(
257 static_field_ = &instr->AsStoreStaticField()->field();
258 *is_store = true;
259 break;
260
261 case Instruction::kLoadIndexed: {
262 LoadIndexedInstr* load_indexed = instr->AsLoadIndexed();
263 // Since the same returned representation is used for arrays with small
264 // elements, use the array element representation instead.
265 //
266 // For example, loads from signed and unsigned byte views of the same
267 // array share the same place if the returned representation is used,
268 // which means a load which sign extends the byte to the native word
269 // size might be replaced with an load that zero extends the byte
270 // instead and vice versa.
272 load_indexed->class_id()));
273 instance_ = load_indexed->array()->definition()->OriginalDefinition();
274 SetIndex(load_indexed->index()->definition()->OriginalDefinition(),
275 load_indexed->index_scale(), load_indexed->class_id());
276 *is_load = true;
277 break;
278 }
279
280 case Instruction::kStoreIndexed: {
281 StoreIndexedInstr* store_indexed = instr->AsStoreIndexed();
282 // Use the array element representation instead of the value
283 // representation for the same reasons as for LoadIndexed above.
285 store_indexed->class_id()));
286 instance_ = store_indexed->array()->definition()->OriginalDefinition();
287 SetIndex(store_indexed->index()->definition()->OriginalDefinition(),
288 store_indexed->index_scale(), store_indexed->class_id());
289 *is_store = true;
290 break;
291 }
292
293 default:
294 break;
295 }
296 }
SI void store(P *ptr, const T &val)
Definition * OriginalDefinition()
Definition: il.cc:532
const Field * static_field_
const Slot * instance_field_
static Representation RepresentationOfArrayElement(classid_t cid)
Definition: locations.cc:79

◆ Place() [3/3]

dart::Place::Place ( AllocationInstr alloc,
intptr_t  input_pos 
)
inline

Definition at line 301 of file redundancy_elimination.cc.

302 : flags_(0), instance_(nullptr), raw_selector_(0), id_(0) {
303 if (const Slot* slot = alloc->SlotForInput(input_pos)) {
304 set_representation(alloc->RequiredInputRepresentation(input_pos));
305 instance_ = alloc;
306 set_kind(kInstanceField);
307 instance_field_ = slot;
308 }
309 }

Member Function Documentation

◆ CopyWithoutIndex()

Place dart::Place::CopyWithoutIndex ( ) const
inline

Definition at line 369 of file redundancy_elimination.cc.

369 {
371 return Place(EncodeFlags(kIndexed, kNoRepresentation, kNoSize), instance_,
372 0);
373 }
Place(const Place &other)
#define ASSERT(E)

◆ CopyWithoutInstance()

Place dart::Place::CopyWithoutInstance ( ) const
inline

Definition at line 363 of file redundancy_elimination.cc.

363 {
365 return Place(flags_, nullptr, raw_selector_);
366 }
bool DependsOnInstance() const

◆ CreateAnyInstanceAnyIndexAlias()

static Place * dart::Place::CreateAnyInstanceAnyIndexAlias ( Zone zone,
intptr_t  id 
)
inlinestatic

Definition at line 312 of file redundancy_elimination.cc.

312 {
313 return Wrap(
314 zone,
315 Place(EncodeFlags(kIndexed, kNoRepresentation, kNoSize), nullptr, 0),
316 id);
317 }
static Place * Wrap(Zone *zone, const Place &place, intptr_t id)

◆ DefinitionName()

static const char * dart::Place::DefinitionName ( Definition def)
inlinestatic

Definition at line 448 of file redundancy_elimination.cc.

448 {
449 if (def == nullptr) {
450 return "*";
451 } else {
452 return Thread::Current()->zone()->PrintToString("v%" Pd,
453 def->ssa_temp_index());
454 }
455 }
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
char * PrintToString(const char *format,...) PRINTF_ATTRIBUTE(2
Definition: zone.cc:313
#define Pd
Definition: globals.h:408

◆ DependsOnInstance()

bool dart::Place::DependsOnInstance ( ) const
inline

Definition at line 345 of file redundancy_elimination.cc.

345 {
346 switch (kind()) {
347 case kInstanceField:
348 case kIndexed:
349 case kConstantIndexed:
350 return true;
351
352 case kStaticField:
353 case kNone:
354 return false;
355 }
356
357 UNREACHABLE();
358 return false;
359 }
#define UNREACHABLE()
Definition: assert.h:248

◆ element_size()

ElementSize dart::Place::element_size ( ) const
inline

Definition at line 441 of file redundancy_elimination.cc.

441{ return ElementSizeBits::decode(flags_); }
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124

◆ Equals()

bool dart::Place::Equals ( const Place other) const
inline

Definition at line 509 of file redundancy_elimination.cc.

509 {
510 return (flags_ == other.flags_) && (instance_ == other.instance_) &&
511 SameField(other);
512 }

◆ Hash()

uword dart::Place::Hash ( ) const
inline

Definition at line 503 of file redundancy_elimination.cc.

503 {
504 return FinalizeHash(
505 CombineHashes(flags_, reinterpret_cast<uword>(instance_)),
506 kBitsPerInt32 - 1);
507 }
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition: hash.h:12
uintptr_t uword
Definition: globals.h:501
constexpr intptr_t kBitsPerInt32
Definition: globals.h:466
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition: hash.h:20

◆ id()

intptr_t dart::Place::id ( ) const
inline

Definition at line 407 of file redundancy_elimination.cc.

407{ return id_; }

◆ index()

Definition * dart::Place::index ( ) const
inline

Definition at line 436 of file redundancy_elimination.cc.

436 {
437 ASSERT(kind() == kIndexed);
438 return index_;
439 }

◆ index_constant()

intptr_t dart::Place::index_constant ( ) const
inline

Definition at line 443 of file redundancy_elimination.cc.

443 {
445 return index_constant_;
446 }

◆ instance()

Definition * dart::Place::instance ( ) const
inline

Definition at line 415 of file redundancy_elimination.cc.

415 {
417 return instance_;
418 }

◆ instance_field()

const Slot & dart::Place::instance_field ( ) const
inline

Definition at line 431 of file redundancy_elimination.cc.

431 {
433 return *instance_field_;
434 }

◆ IsAllocation()

static bool dart::Place::IsAllocation ( Definition defn)
inlinestatic

Definition at line 517 of file redundancy_elimination.cc.

517 {
518 return (defn != nullptr) && (defn->IsAllocation() ||
519 (defn->IsStaticCall() &&
520 defn->AsStaticCall()->IsRecognizedFactory()));
521 }

◆ IsImmutableField()

bool dart::Place::IsImmutableField ( ) const
inline

Definition at line 494 of file redundancy_elimination.cc.

494 {
495 switch (kind()) {
496 case kInstanceField:
497 return instance_field().is_immutable();
498 default:
499 return false;
500 }
501 }
const Slot & instance_field() const
bool is_immutable() const
Definition: slot.h:521

◆ IsTypedDataViewAllocation()

static bool dart::Place::IsTypedDataViewAllocation ( Definition defn)
inlinestatic

Definition at line 523 of file redundancy_elimination.cc.

523 {
524 if (defn != nullptr) {
525 if (auto* alloc = defn->AsAllocateObject()) {
526 auto const cid = alloc->cls().id();
527 return IsTypedDataViewClassId(cid) ||
529 }
530 }
531 return false;
532 }
bool IsTypedDataViewClassId(intptr_t index)
Definition: class_id.h:439
bool IsUnmodifiableTypedDataViewClassId(intptr_t index)
Definition: class_id.h:453
const intptr_t cid

◆ kind()

Kind dart::Place::kind ( ) const
inline

Definition at line 409 of file redundancy_elimination.cc.

409{ return KindBits::decode(flags_); }

◆ representation()

Representation dart::Place::representation ( ) const
inline

Definition at line 411 of file redundancy_elimination.cc.

411 {
412 return RepresentationBits::decode(flags_);
413 }

◆ set_instance()

void dart::Place::set_instance ( Definition def)
inline

Definition at line 420 of file redundancy_elimination.cc.

420 {
422 instance_ = def->OriginalDefinition();
423 }

◆ static_field()

const Field & dart::Place::static_field ( ) const
inline

Definition at line 425 of file redundancy_elimination.cc.

425 {
428 return *static_field_;
429 }
bool is_static() const
Definition: object.h:4440

◆ ToAlias()

Place dart::Place::ToAlias ( ) const
inline

Definition at line 335 of file redundancy_elimination.cc.

335 {
336 Definition* alias_instance = nullptr;
339 alias_instance = instance();
340 }
341 return Place(RepresentationBits::update(kNoRepresentation, flags_),
342 alias_instance, (kind() == kIndexed) ? 0 : raw_selector_);
343 }
static bool IsTypedDataViewAllocation(Definition *defn)
Definition * instance() const
static bool IsAllocation(Definition *defn)

◆ ToCString()

const char * dart::Place::ToCString ( ) const
inline

Definition at line 457 of file redundancy_elimination.cc.

457 {
458 switch (kind()) {
459 case kNone:
460 return "<none>";
461
462 case kStaticField: {
463 const char* field_name =
465 return Thread::Current()->zone()->PrintToString("<%s>", field_name);
466 }
467
468 case kInstanceField:
470 "<%s.%s[%p]>", DefinitionName(instance()), instance_field().Name(),
471 &instance_field());
472
473 case kIndexed:
475 "<%s[%s]>", DefinitionName(instance()), DefinitionName(index()));
476
477 case kConstantIndexed:
478 if (element_size() == kNoSize) {
480 "<%s[%" Pd "]>", DefinitionName(instance()), index_constant());
481 } else {
483 "<%s[%" Pd "|%" Pd "]>", DefinitionName(instance()),
484 index_constant(), ElementSizeMultiplier(element_size()));
485 }
486 }
487 UNREACHABLE();
488 return "<?>";
489 }
virtual const char * ToCString() const
Definition: object.h:366
static Object & Handle()
Definition: object.h:407
intptr_t index_constant() const
static const char * DefinitionName(Definition *def)
ElementSize element_size() const
const Field & static_field() const
Definition * index() const
ImplicitString Name
Definition: DMSrcSink.h:38
const char *const name

◆ ToLargerElement()

Place dart::Place::ToLargerElement ( ElementSize  to) const
inline

Definition at line 382 of file redundancy_elimination.cc.

382 {
385 ASSERT(element_size() < to);
386 return Place(ElementSizeBits::update(to, flags_), instance_,
387 RoundByteOffset(to, index_constant_));
388 }

◆ ToSmallerElement()

Place dart::Place::ToSmallerElement ( ElementSize  to,
intptr_t  index 
) const
inline

Definition at line 396 of file redundancy_elimination.cc.

396 {
399 ASSERT(element_size() > to);
400 ASSERT(index >= 0);
401 ASSERT(index <
402 ElementSizeMultiplier(element_size()) / ElementSizeMultiplier(to));
403 return Place(ElementSizeBits::update(to, flags_), instance_,
404 ByteOffsetToSmallerElement(to, index, index_constant_));
405 }

◆ Wrap()

Place * dart::Place::Wrap ( Zone zone,
const Place place,
intptr_t  id 
)
static

Definition at line 684 of file redundancy_elimination.cc.

684 {
685 Place* wrapped = (new (zone) ZonePlace(place))->place();
686 wrapped->id_ = id;
687 return wrapped;
688}
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
intptr_t id() const

Member Data Documentation

◆ index_

Definition* dart::Place::index_

Definition at line 668 of file redundancy_elimination.cc.

◆ index_constant_

intptr_t dart::Place::index_constant_

Definition at line 667 of file redundancy_elimination.cc.

◆ instance_field_

const Slot* dart::Place::instance_field_

Definition at line 666 of file redundancy_elimination.cc.

◆ raw_selector_

intptr_t dart::Place::raw_selector_

Definition at line 664 of file redundancy_elimination.cc.

◆ static_field_

const Field* dart::Place::static_field_

Definition at line 665 of file redundancy_elimination.cc.


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