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

#include <il.h>

Inheritance diagram for dart::UnboxInstr:
dart::TemplateDefinition< 1, NoThrow, Pure > dart::UnboxIntegerInstr dart::UnboxInt64Instr dart::UnboxInteger32Instr dart::UnboxInt32Instr dart::UnboxUint32Instr

Public Member Functions

Valuevalue () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual SpeculativeMode SpeculativeModeOfInput (intptr_t index) const
 
virtual Representation representation () const
 
virtual bool AttributesEqual (const Instruction &other) const
 
DefinitionCanonicalize (FlowGraph *flow_graph)
 
virtual intptr_t DeoptimizationTarget () const
 
virtual TokenPosition token_pos () const
 
 DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS (UnboxInstr, TemplateDefinition, FIELD_LIST) protected
 
void set_speculative_mode (SpeculativeMode value)
 
- Public Member Functions inherited from dart::TemplateDefinition< 1, NoThrow, Pure >
 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
 

Static Public Member Functions

static UnboxInstrCreate (Representation to, Value *value, intptr_t deopt_id, SpeculativeMode speculative_mode=kGuardInputs)
 

Additional Inherited Members

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

Detailed Description

Definition at line 8623 of file il.h.

Member Function Documentation

◆ AttributesEqual()

virtual bool dart::UnboxInstr::AttributesEqual ( const Instruction other) const
inlinevirtual

Reimplemented in dart::UnboxIntegerInstr.

Definition at line 8659 of file il.h.

8659 {
8660 auto const other_unbox = other.AsUnbox();
8661 return (representation() == other_unbox->representation()) &&
8662 (speculative_mode_ == other_unbox->speculative_mode_);
8663 }
virtual Representation representation() const
Definition il.h:8655

◆ Canonicalize()

Definition * dart::UnboxInstr::Canonicalize ( FlowGraph flow_graph)

Definition at line 3303 of file il.cc.

3303 {
3304 if (!HasUses() && !CanDeoptimize()) return nullptr;
3305
3306 // Fold away Unbox<rep>(v) if v has a target representation already.
3307 Definition* value_defn = value()->definition();
3308 if (value_defn->representation() == representation()) {
3309 return value_defn;
3310 }
3311
3312 BoxInstr* box_defn = value()->definition()->AsBox();
3313 if (box_defn != nullptr) {
3314 // Fold away Unbox<rep>(Box<rep>(v)).
3315 if (box_defn->from_representation() == representation()) {
3316 return box_defn->value()->definition();
3317 }
3318
3319 if ((box_defn->from_representation() == kUnboxedDouble) &&
3320 (representation() == kUnboxedFloat)) {
3321 Definition* replacement = new DoubleToFloatInstr(
3322 box_defn->value()->CopyWithType(), DeoptId::kNone);
3323 flow_graph->InsertBefore(this, replacement, NULL, FlowGraph::kValue);
3324 return replacement;
3325 }
3326
3327 if ((box_defn->from_representation() == kUnboxedFloat) &&
3328 (representation() == kUnboxedDouble)) {
3329 Definition* replacement = new FloatToDoubleInstr(
3330 box_defn->value()->CopyWithType(), DeoptId::kNone);
3331 flow_graph->InsertBefore(this, replacement, NULL, FlowGraph::kValue);
3332 return replacement;
3333 }
3334 }
3335
3336 if (representation() == kUnboxedDouble && value()->BindsToConstant()) {
3337 const Object& val = value()->BoundConstant();
3338 if (val.IsInteger()) {
3339 const Double& double_val = Double::ZoneHandle(
3340 flow_graph->zone(),
3341 Double::NewCanonical(Integer::Cast(val).AsDoubleValue()));
3342 return flow_graph->GetConstant(double_val, kUnboxedDouble);
3343 } else if (val.IsDouble()) {
3344 return flow_graph->GetConstant(val, kUnboxedDouble);
3345 }
3346 }
3347
3348 if (representation() == kUnboxedFloat && value()->BindsToConstant()) {
3349 const Object& val = value()->BoundConstant();
3350 if (val.IsInteger()) {
3351 double narrowed_val =
3352 static_cast<float>(Integer::Cast(val).AsDoubleValue());
3353 return flow_graph->GetConstant(
3355 kUnboxedFloat);
3356 } else if (val.IsDouble()) {
3357 double narrowed_val = static_cast<float>(Double::Cast(val).value());
3358 return flow_graph->GetConstant(
3360 kUnboxedFloat);
3361 }
3362 }
3363
3364 return this;
3365}
static constexpr intptr_t kNone
Definition deopt_id.h:27
static DoublePtr NewCanonical(double d)
Definition object.cc:23497
static Object & ZoneHandle()
Definition object.h:419
Value * value() const
Definition il.h:8630
const Object & BoundConstant() const
Definition il.cc:1199
Definition * definition() const
Definition il.h:103

◆ ComputeCanDeoptimize()

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

Reimplemented in dart::UnboxIntegerInstr.

Definition at line 8632 of file il.h.

8632 {
8633 if (SpeculativeModeOfInputs() == kNotSpeculative) {
8634 return false;
8635 }
8636
8637 const intptr_t value_cid = value()->Type()->ToCid();
8638 const intptr_t box_cid = BoxCid();
8639
8640 if (value_cid == box_cid) {
8641 return false;
8642 }
8643
8644 if (CanConvertSmi() && (value_cid == kSmiCid)) {
8645 return false;
8646 }
8647
8648 return true;
8649 }
CompileType * Type()

◆ Create()

UnboxInstr * dart::UnboxInstr::Create ( Representation  to,
Value value,
intptr_t  deopt_id,
SpeculativeMode  speculative_mode = kGuardInputs 
)
static

Definition at line 4045 of file il.cc.

4048 {
4049 switch (to) {
4050 case kUnboxedInt32:
4051 // We must truncate if we can't deoptimize.
4052 return new UnboxInt32Instr(
4053 speculative_mode == SpeculativeMode::kNotSpeculative
4055 : UnboxInt32Instr::kNoTruncation,
4056 value, deopt_id, speculative_mode);
4057
4058 case kUnboxedUint32:
4059 return new UnboxUint32Instr(value, deopt_id, speculative_mode);
4060
4061 case kUnboxedInt64:
4062 return new UnboxInt64Instr(value, deopt_id, speculative_mode);
4063
4064 case kUnboxedDouble:
4065 case kUnboxedFloat:
4066 case kUnboxedFloat32x4:
4067 case kUnboxedFloat64x2:
4068 case kUnboxedInt32x4:
4070 return new UnboxInstr(to, value, deopt_id, speculative_mode);
4071
4072 default:
4073 UNREACHABLE();
4074 return nullptr;
4075 }
4076}
#define UNREACHABLE()
Definition assert.h:248
static bool SupportsUnboxedDoubles()
#define ASSERT(E)

◆ DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS()

dart::UnboxInstr::DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS ( UnboxInstr  ,
TemplateDefinition  ,
FIELD_LIST   
)
inline

Definition at line 8675 of file il.h.

8680 :
8681 UnboxInstr(Representation representation,
8682 Value* value,
8683 intptr_t deopt_id,
8684 SpeculativeMode speculative_mode)
8685 : TemplateDefinition(deopt_id),
8686 representation_(representation),
8687 speculative_mode_(speculative_mode) {
8688 // Unboxing doesn't currently handle non-native representations.
8690 SetInputAt(0, value);
8691 }
#define ASSERT_EQUAL(expected, actual)
Definition assert.h:309
TemplateDefinition(intptr_t deopt_id=DeoptId::kNone)
Definition il.h:2731
Representation
Definition locations.h:66
static constexpr Representation NativeRepresentation(Representation rep)
Definition il.h:8456

◆ DeoptimizationTarget()

virtual intptr_t dart::UnboxInstr::DeoptimizationTarget ( ) const
inlinevirtual

Definition at line 8667 of file il.h.

8667{ return GetDeoptId(); }

◆ representation()

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

Definition at line 8655 of file il.h.

8655{ return representation_; }

◆ set_speculative_mode()

void dart::UnboxInstr::set_speculative_mode ( SpeculativeMode  value)
inline

Definition at line 8693 of file il.h.

8693 {
8694 speculative_mode_ = value;
8695 }

◆ SpeculativeModeOfInput()

virtual SpeculativeMode dart::UnboxInstr::SpeculativeModeOfInput ( intptr_t  index) const
inlinevirtual

Definition at line 8651 of file il.h.

8651 {
8652 return speculative_mode_;
8653 }

◆ token_pos()

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

Definition at line 8669 of file il.h.

8669{ return TokenPosition::kBox; }

◆ value()

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

Definition at line 8630 of file il.h.

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

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