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

Side by Side Diff: src/hydrogen.cc

Issue 6905166: Change heuristics for deciding phi-representation types to use int32 more frequently. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 7 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 | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 int double_count = use_count[Representation::kDouble]; 1568 int double_count = use_count[Representation::kDouble];
1569 int int32_count = use_count[Representation::kInteger32]; 1569 int int32_count = use_count[Representation::kInteger32];
1570 int non_tagged_count = double_count + int32_count; 1570 int non_tagged_count = double_count + int32_count;
1571 1571
1572 // If a non-loop phi has tagged uses, don't convert it to untagged. 1572 // If a non-loop phi has tagged uses, don't convert it to untagged.
1573 if (value->IsPhi() && !value->block()->IsLoopHeader()) { 1573 if (value->IsPhi() && !value->block()->IsLoopHeader()) {
1574 if (tagged_count > 0) return Representation::None(); 1574 if (tagged_count > 0) return Representation::None();
1575 } 1575 }
1576 1576
1577 if (non_tagged_count >= tagged_count) { 1577 if (non_tagged_count >= tagged_count) {
1578 // More untagged than tagged. 1578 if (int32_count > 0 && value->IsPhi()) {
Kevin Millikin (Chromium) 2011/05/03 07:58:32 if (int32_count > 0) { if (!value->IsPhi() || va
1579 if (double_count > 0) { 1579 HPhi* phi = HPhi::cast(value);
1580 // There is at least one usage that is a double => guess that the 1580 if (phi->IsConvertibleToInteger()) return Representation::Integer32();
1581 // correct representation is double.
1582 return Representation::Double();
1583 } else if (int32_count > 0) { 1581 } else if (int32_count > 0) {
1584 return Representation::Integer32(); 1582 return Representation::Integer32();
1585 } 1583 }
1584 if (double_count > 0) return Representation::Double();
1586 } 1585 }
1587 return Representation::None(); 1586 return Representation::None();
1588 } 1587 }
1589 1588
1590 1589
1591 void HInferRepresentation::Analyze() { 1590 void HInferRepresentation::Analyze() {
1592 HPhase phase("Infer representations", graph_); 1591 HPhase phase("Infer representations", graph_);
1593 1592
1594 // (1) Initialize bit vectors and count real uses. Each phi gets a 1593 // (1) Initialize bit vectors and count real uses. Each phi gets a
1595 // bit-vector of length <number of phis>. 1594 // bit-vector of length <number of phis>.
1596 const ZoneList<HPhi*>* phi_list = graph_->phi_list(); 1595 const ZoneList<HPhi*>* phi_list = graph_->phi_list();
1597 int phi_count = phi_list->length(); 1596 int phi_count = phi_list->length();
1598 ScopedVector<BitVector*> connected_phis(phi_count); 1597 ZoneList<BitVector*> connected_phis(phi_count);
1599 for (int i = 0; i < phi_count; ++i) { 1598 for (int i = 0; i < phi_count; ++i) {
1600 phi_list->at(i)->InitRealUses(i); 1599 phi_list->at(i)->InitRealUses(i);
1601 connected_phis[i] = new(zone()) BitVector(phi_count); 1600 connected_phis[i] = new(zone()) BitVector(phi_count);
1602 connected_phis[i]->Add(i); 1601 connected_phis[i]->Add(i);
1603 } 1602 }
1604 1603
1605 // (2) Do a fixed point iteration to find the set of connected phis. A 1604 // (2) Do a fixed point iteration to find the set of connected phis. A
1606 // phi is connected to another phi if its value is used either directly or 1605 // phi is connected to another phi if its value is used either directly or
1607 // indirectly through a transitive closure of the def-use relation. 1606 // indirectly through a transitive closure of the def-use relation.
1608 bool change = true; 1607 bool change = true;
(...skipping 20 matching lines...) Expand all
1629 !it.Done(); 1628 !it.Done();
1630 it.Advance()) { 1629 it.Advance()) {
1631 int index = it.Current(); 1630 int index = it.Current();
1632 if (index != i) { 1631 if (index != i) {
1633 HPhi* it_use = phi_list->at(it.Current()); 1632 HPhi* it_use = phi_list->at(it.Current());
1634 phi->AddNonPhiUsesFrom(it_use); 1633 phi->AddNonPhiUsesFrom(it_use);
1635 } 1634 }
1636 } 1635 }
1637 } 1636 }
1638 1637
1638 // (4) Compute phis that definitely can't be converted to integer
1639 // without deoptimization and mark them to avoid unnecessary deoptimization.
1640 change = true;
1641 while (change) {
1642 change = false;
1643 for (int i = 0; i < phi_count; i++) {
Kevin Millikin (Chromium) 2011/05/03 07:58:32 All the other loops in this function use new-schoo
1644 HPhi* phi = phi_list->at(i);
1645 for (int i = 0; i < phi->OperandCount(); i++) {
Kevin Millikin (Chromium) 2011/05/03 07:58:32 Please don't shadow the outer loop index even if y
1646 if (phi->IsConvertibleToInteger() &&
1647 !phi->OperandAt(i)->IsConvertibleToInteger()) {
1648 phi->set_is_convertible_to_integer(false);
1649 change = true;
1650 break;
1651 }
1652 }
1653 }
1654 }
1655
1656
1639 for (int i = 0; i < graph_->blocks()->length(); ++i) { 1657 for (int i = 0; i < graph_->blocks()->length(); ++i) {
1640 HBasicBlock* block = graph_->blocks()->at(i); 1658 HBasicBlock* block = graph_->blocks()->at(i);
1641 const ZoneList<HPhi*>* phis = block->phis(); 1659 const ZoneList<HPhi*>* phis = block->phis();
1642 for (int j = 0; j < phis->length(); ++j) { 1660 for (int j = 0; j < phis->length(); ++j) {
1643 AddToWorklist(phis->at(j)); 1661 AddToWorklist(phis->at(j));
1644 } 1662 }
1645 1663
1646 HInstruction* current = block->first(); 1664 HInstruction* current = block->first();
1647 while (current != NULL) { 1665 while (current != NULL) {
1648 AddToWorklist(current); 1666 AddToWorklist(current);
(...skipping 4428 matching lines...) Expand 10 before | Expand all | Expand 10 after
6077 } 6095 }
6078 } 6096 }
6079 6097
6080 #ifdef DEBUG 6098 #ifdef DEBUG
6081 if (graph_ != NULL) graph_->Verify(); 6099 if (graph_ != NULL) graph_->Verify();
6082 if (allocator_ != NULL) allocator_->Verify(); 6100 if (allocator_ != NULL) allocator_->Verify();
6083 #endif 6101 #endif
6084 } 6102 }
6085 6103
6086 } } // namespace v8::internal 6104 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698