33 void HRepresentationChangesPhase::InsertRepresentationChangeForUse(
34 HValue* value, HValue* use_value,
int use_index, Representation to) {
37 HInstruction* next =
NULL;
38 if (use_value->IsPhi()) {
39 next = use_value->block()->predecessors()->at(use_index)->end();
47 HInstruction* new_value =
NULL;
50 if (value->IsConstant()) {
51 HConstant* constant = HConstant::cast(value);
53 if (is_truncating_to_int && to.IsInteger32()) {
54 Maybe<HConstant*> res = constant->CopyToTruncatedInt32(
graph()->zone());
55 if (res.has_value) new_value = res.value;
57 new_value = constant->CopyToRepresentation(to,
graph()->zone());
61 if (new_value ==
NULL) {
62 new_value =
new(
graph()->zone()) HChange(
63 value, to, is_truncating_to_smi, is_truncating_to_int);
64 if (!use_value->operand_position(use_index).IsUnknown()) {
65 new_value->set_position(use_value->operand_position(use_index));
67 ASSERT(!FLAG_hydrogen_track_positions ||
72 new_value->InsertBefore(next);
73 use_value->SetOperandAt(use_index, new_value);
77 void HRepresentationChangesPhase::InsertRepresentationChangesForValue(
79 Representation r = value->representation();
80 if (r.IsNone())
return;
81 if (value->HasNoUses()) {
82 if (value->IsForceRepresentation()) value->DeleteAndReplaceWith(
NULL);
86 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) {
87 HValue* use_value = it.value();
88 int use_index = it.index();
89 Representation req = use_value->RequiredInputRepresentation(use_index);
90 if (req.IsNone() || req.Equals(r))
continue;
91 InsertRepresentationChangeForUse(value, use_value, use_index, req);
93 if (value->HasNoUses()) {
94 ASSERT(value->IsConstant());
95 value->DeleteAndReplaceWith(
NULL);
100 if (value->IsForceRepresentation()) {
101 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value());
115 for (
int i = 0; i < phi_list->length(); i++) {
116 HPhi* phi = phi_list->
at(i);
117 if (phi->representation().IsInteger32()) {
119 }
else if (phi->representation().IsSmi()) {
125 for (
int i = 0; i < phi_list->length(); i++) {
126 HPhi* phi = phi_list->
at(i);
128 if (phi->representation().IsSmiOrInteger32() &&
130 int_worklist.
Add(phi, zone());
132 if (FLAG_trace_representation) {
133 PrintF(
"#%d Phi is not truncating Int32 because of #%d %s\n",
138 if (phi->representation().IsSmi() &&
140 smi_worklist.
Add(phi, zone());
142 if (FLAG_trace_representation) {
143 PrintF(
"#%d Phi is not truncating Smi because of #%d %s\n",
149 while (!int_worklist.is_empty()) {
150 HPhi* current = int_worklist.RemoveLast();
151 for (
int i = 0; i < current->OperandCount(); ++i) {
153 if (input->
IsPhi() &&
156 if (FLAG_trace_representation) {
157 PrintF(
"#%d Phi is not truncating Int32 because of #%d %s\n",
158 input->
id(), current->id(), current->Mnemonic());
161 int_worklist.
Add(HPhi::cast(input), zone());
166 while (!smi_worklist.is_empty()) {
167 HPhi* current = smi_worklist.RemoveLast();
168 for (
int i = 0; i < current->OperandCount(); ++i) {
170 if (input->
IsPhi() &&
173 if (FLAG_trace_representation) {
174 PrintF(
"#%d Phi is not truncating Smi because of #%d %s\n",
175 input->
id(), current->id(), current->Mnemonic());
178 smi_worklist.
Add(HPhi::cast(input), zone());
184 for (
int i = 0; i < blocks->length(); ++i) {
186 const HBasicBlock* block(blocks->
at(i));
188 for (
int j = 0; j < phis->length(); j++) {
189 InsertRepresentationChangesForValue(phis->at(j));
195 InsertRepresentationChangesForValue(current);
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void PrintF(const char *format,...)
#define ASSERT(condition)
Representation representation() const
bool IsSmiOrInteger32() const
HInstruction * next() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
bool CheckFlag(Flag f) const
virtual HValue * OperandAt(int index) const =0
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
const char * Mnemonic() const
static HValue * cast(HValue *value)