Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: src/hydrogen-representation-changes.cc

Issue 303263010: Remove forced type changes when they can't deopt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove ForceRepresentation in representation change phase. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/hydrogen-representation-changes.h" 5 #include "src/hydrogen-representation-changes.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 9
10 void HRepresentationChangesPhase::InsertRepresentationChangeForUse( 10 void HRepresentationChangesPhase::InsertRepresentationChangeForUse(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ASSERT(!FLAG_hydrogen_track_positions || 44 ASSERT(!FLAG_hydrogen_track_positions ||
45 !graph()->info()->IsOptimizing()); 45 !graph()->info()->IsOptimizing());
46 } 46 }
47 } 47 }
48 48
49 new_value->InsertBefore(next); 49 new_value->InsertBefore(next);
50 use_value->SetOperandAt(use_index, new_value); 50 use_value->SetOperandAt(use_index, new_value);
51 } 51 }
52 52
53 53
54 static bool HChangeCanDeoptForUse(HChange* change, HValue* use, int use_index) {
Jakob Kummerow 2014/06/12 10:16:49 I don't like that this function's name doesn't mat
55 Representation change_rep = change->RequiredInputRepresentation(0);
Jakob Kummerow 2014/06/12 10:16:49 It's cleaner to use change->from()...
56 Representation use_rep = use->RequiredInputRepresentation(use_index);
Jakob Kummerow 2014/06/12 10:16:49 ...and change->to().
57 if (change_rep.IsSmiOrInteger32() && use_rep.IsSmiOrInteger32() &&
58 (change->CheckFlag(HValue::kUint32) == use->CheckFlag(HValue::kUint32)) &&
Jakob Kummerow 2014/06/12 10:16:49 Representation changes are inserted before the uin
59 SmiValuesAre32Bits()) {
60 return false;
61 }
62 return true;
63 }
64
65
54 void HRepresentationChangesPhase::InsertRepresentationChangesForValue( 66 void HRepresentationChangesPhase::InsertRepresentationChangesForValue(
55 HValue* value) { 67 HValue* value) {
56 Representation r = value->representation(); 68 Representation r = value->representation();
57 if (r.IsNone()) return; 69 if (r.IsNone()) return;
58 if (value->HasNoUses()) { 70 if (value->HasNoUses()) {
59 if (value->IsForceRepresentation()) value->DeleteAndReplaceWith(NULL); 71 if (value->IsForceRepresentation()) value->DeleteAndReplaceWith(NULL);
60 return; 72 return;
61 } 73 }
62 74
63 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) { 75 for (HUseIterator it(value->uses()); !it.Done(); it.Advance()) {
64 HValue* use_value = it.value(); 76 HValue* use_value = it.value();
65 int use_index = it.index(); 77 int use_index = it.index();
66 Representation req = use_value->RequiredInputRepresentation(use_index); 78 Representation req = use_value->RequiredInputRepresentation(use_index);
67 if (req.IsNone() || req.Equals(r)) continue; 79 if (req.IsNone() || req.Equals(r)) continue;
80
81 // If this is an HForceRepresentation instruction, and an HChange has been
82 // inserted above it, examine the input representation of the HChange to see
83 // if it satisfies any of the HForceRepresentation's uses. If so, and the
84 // HChange can't deopt, set the input of the use to the input of the
85 // HChange.
86 if (value->IsForceRepresentation()) {
87 HValue* parent = HForceRepresentation::cast(value)->value();
Jakob Kummerow 2014/06/12 10:16:49 nit: we don't use "parent" for instructions (they
88 if (parent->IsChange() &&
89 parent->RequiredInputRepresentation(0).Equals(req) &&
Jakob Kummerow 2014/06/12 10:16:49 again, s/parent->RequiredInputRepresentation(0)/HC
90 !HChangeCanDeoptForUse(HChange::cast(parent), value, 0)) {
91 use_value->SetOperandAt(use_index, HChange::cast(parent)->value());
92 continue;
93 }
94 }
68 InsertRepresentationChangeForUse(value, use_value, use_index, req); 95 InsertRepresentationChangeForUse(value, use_value, use_index, req);
69 } 96 }
70 if (value->HasNoUses()) { 97 if (value->HasNoUses()) {
71 ASSERT(value->IsConstant()); 98 ASSERT(value->IsConstant() || value->IsForceRepresentation());
72 value->DeleteAndReplaceWith(NULL); 99 value->DeleteAndReplaceWith(NULL);
73 } 100 } else {
74 101 // The only purpose of a HForceRepresentation is to represent the value
75 // The only purpose of a HForceRepresentation is to represent the value 102 // after the (possible) HChange instruction. We make it disappear.
76 // after the (possible) HChange instruction. We make it disappear. 103 if (value->IsForceRepresentation()) {
77 if (value->IsForceRepresentation()) { 104 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value());
78 value->DeleteAndReplaceWith(HForceRepresentation::cast(value)->value()); 105 }
79 } 106 }
80 } 107 }
81 108
82 109
83 void HRepresentationChangesPhase::Run() { 110 void HRepresentationChangesPhase::Run() {
84 // Compute truncation flag for phis: Initially assume that all 111 // Compute truncation flag for phis: Initially assume that all
85 // int32-phis allow truncation and iteratively remove the ones that 112 // int32-phis allow truncation and iteratively remove the ones that
86 // are used in an operation that does not allow a truncating 113 // are used in an operation that does not allow a truncating
87 // conversion. 114 // conversion.
88 ZoneList<HPhi*> int_worklist(8, zone()); 115 ZoneList<HPhi*> int_worklist(8, zone());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Process normal instructions. 196 // Process normal instructions.
170 for (HInstruction* current = block->first(); current != NULL; ) { 197 for (HInstruction* current = block->first(); current != NULL; ) {
171 HInstruction* next = current->next(); 198 HInstruction* next = current->next();
172 InsertRepresentationChangesForValue(current); 199 InsertRepresentationChangesForValue(current);
173 current = next; 200 current = next;
174 } 201 }
175 } 202 }
176 } 203 }
177 204
178 } } // namespace v8::internal 205 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698