34 bool HUint32AnalysisPhase::IsSafeUint32Use(HValue* val, HValue* use) {
36 if (use->IsBitwise() || use->IsShl() || use->IsSar() || use->IsShr()) {
38 }
else if (use->IsSimulate()) {
41 }
else if (use->IsChange()) {
46 ASSERT(HChange::cast(use)->to().IsDouble() ||
47 HChange::cast(use)->to().IsSmi() ||
48 HChange::cast(use)->to().IsTagged());
50 }
else if (use->IsStoreKeyed()) {
51 HStoreKeyed* store = HStoreKeyed::cast(use);
52 if (store->is_external()) {
55 if (store->value() == val) {
76 bool HUint32AnalysisPhase::Uint32UsesAreSafe(HValue* uint32val) {
77 bool collect_phi_uses =
false;
78 for (HUseIterator it(uint32val->uses()); !it.Done(); it.Advance()) {
79 HValue* use = it.value();
85 collect_phi_uses =
true;
92 if (!IsSafeUint32Use(uint32val, use)) {
97 if (collect_phi_uses) {
98 for (HUseIterator it(uint32val->uses()); !it.Done(); it.Advance()) {
99 HValue* use = it.value();
105 phis_.
Add(HPhi::cast(use), zone());
115 bool HUint32AnalysisPhase::CheckPhiOperands(HPhi* phi) {
121 for (
int j = 0; j < phi->OperandCount(); j++) {
122 HValue* operand = phi->OperandAt(j);
125 if (operand->IsInteger32Constant() &&
126 operand->GetInteger32Constant() >= 0) {
143 void HUint32AnalysisPhase::UnmarkPhi(HPhi* phi, ZoneList<HPhi*>* worklist) {
145 for (
int j = 0; j < phi->OperandCount(); j++) {
146 HValue* operand = phi->OperandAt(j);
149 if (operand->IsPhi()) {
150 worklist->Add(HPhi::cast(operand), zone());
157 void HUint32AnalysisPhase::UnmarkUnsafePhis() {
159 if (phis_.length() == 0)
return;
163 ZoneList<HPhi*> worklist(phis_.length(), zone());
175 for (
int i = 0; i < phis_.length(); i++) {
176 HPhi* phi = phis_[i];
178 if (CheckPhiOperands(phi) && Uint32UsesAreSafe(phi)) {
179 phis_[phi_count++] = phi;
181 UnmarkPhi(phi, &worklist);
189 while (!worklist.is_empty()) {
190 while (!worklist.is_empty()) {
191 HPhi* phi = worklist.RemoveLast();
192 UnmarkPhi(phi, &worklist);
198 int new_phi_count = 0;
199 for (
int i = 0; i < phi_count; i++) {
200 HPhi* phi = phis_[i];
202 if (CheckPhiOperands(phi)) {
203 phis_[new_phi_count++] = phi;
205 UnmarkPhi(phi, &worklist);
208 phi_count = new_phi_count;
214 if (!
graph()->has_uint32_instructions())
return;
217 for (
int i = 0; i < uint32_instructions->length(); ++i) {
223 Uint32UsesAreSafe(current)) {
#define ASSERT(condition)
Representation representation() const
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())