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

Side by Side Diff: src/hydrogen.cc

Issue 13950013: Use worklist to find out Phis that could not be truncated to int32 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 8 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3699 matching lines...) Expand 10 before | Expand all | Expand 10 after
3710 } 3710 }
3711 3711
3712 3712
3713 void HGraph::InsertRepresentationChanges() { 3713 void HGraph::InsertRepresentationChanges() {
3714 HPhase phase("H_Representation changes", this); 3714 HPhase phase("H_Representation changes", this);
3715 3715
3716 // Compute truncation flag for phis: Initially assume that all 3716 // Compute truncation flag for phis: Initially assume that all
3717 // int32-phis allow truncation and iteratively remove the ones that 3717 // int32-phis allow truncation and iteratively remove the ones that
3718 // are used in an operation that does not allow a truncating 3718 // are used in an operation that does not allow a truncating
3719 // conversion. 3719 // conversion.
3720 // TODO(fschneider): Replace this with a worklist-based iteration. 3720 ZoneList<HPhi*> worklist(8, zone());
3721
3721 for (int i = 0; i < phi_list()->length(); i++) { 3722 for (int i = 0; i < phi_list()->length(); i++) {
3722 HPhi* phi = phi_list()->at(i); 3723 HPhi* phi = phi_list()->at(i);
3723 if (phi->representation().IsInteger32()) { 3724 if (phi->representation().IsInteger32()) {
3724 phi->SetFlag(HValue::kTruncatingToInt32); 3725 phi->SetFlag(HValue::kTruncatingToInt32);
3725 } 3726 }
3726 } 3727 }
3727 bool change = true; 3728
3728 while (change) { 3729 for (int i = 0; i < phi_list()->length(); i++) {
3729 change = false; 3730 HPhi* phi = phi_list()->at(i);
3730 for (int i = 0; i < phi_list()->length(); i++) { 3731 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
3731 HPhi* phi = phi_list()->at(i); 3732 // If a Phi is used as a non-truncating int32 or as a double,
3732 if (!phi->CheckFlag(HValue::kTruncatingToInt32)) continue; 3733 // clear its "truncating" flag.
3733 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { 3734 HValue* use = it.value();
3734 // If a Phi is used as a non-truncating int32 or as a double, 3735 Representation input_representation =
3735 // clear its "truncating" flag. 3736 use->RequiredInputRepresentation(it.index());
3736 HValue* use = it.value(); 3737 if ((input_representation.IsInteger32() &&
3737 Representation input_representation = 3738 !use->CheckFlag(HValue::kTruncatingToInt32)) ||
3738 use->RequiredInputRepresentation(it.index()); 3739 input_representation.IsDouble()) {
3739 if ((input_representation.IsInteger32() && 3740 if (FLAG_trace_representation) {
3740 !use->CheckFlag(HValue::kTruncatingToInt32)) || 3741 PrintF("#%d Phi is not truncating because of #%d %s\n",
3741 input_representation.IsDouble()) { 3742 phi->id(), it.value()->id(), it.value()->Mnemonic());
3742 if (FLAG_trace_representation) {
3743 PrintF("#%d Phi is not truncating because of #%d %s\n",
3744 phi->id(), it.value()->id(), it.value()->Mnemonic());
3745 }
3746 phi->ClearFlag(HValue::kTruncatingToInt32);
3747 change = true;
3748 break;
3749 } 3743 }
3744 phi->ClearFlag(HValue::kTruncatingToInt32);
3745 worklist.Add(phi, zone());
Jakob Kummerow 2013/04/25 16:32:36 I think you may want to prevent duplicate entries
haitao.feng 2013/04/26 04:38:13 Thanks for the review. It seems that we do not ne
3746 break;
3747 }
3748 }
3749 }
3750
3751 while (!worklist.is_empty()) {
3752 HPhi* current = worklist.RemoveLast();
3753 for (int i = 0; i < current->OperandCount(); ++i) {
3754 HValue* input = current->OperandAt(i);
3755 if (input->IsPhi() &&
3756 input->representation().IsInteger32() &&
3757 input->CheckFlag(HValue::kTruncatingToInt32)) {
3758 if (FLAG_trace_representation) {
3759 PrintF("#%d Phi is not truncating because of #%d %s\n",
3760 input->id(), current->id(), current->Mnemonic());
3761 }
3762 input->ClearFlag(HValue::kTruncatingToInt32);
3763 worklist.Add(HPhi::cast(input), zone());
3750 } 3764 }
3751 } 3765 }
3752 } 3766 }
3753 3767
3754 for (int i = 0; i < blocks_.length(); ++i) { 3768 for (int i = 0; i < blocks_.length(); ++i) {
3755 // Process phi instructions first. 3769 // Process phi instructions first.
3756 const ZoneList<HPhi*>* phis = blocks_[i]->phis(); 3770 const ZoneList<HPhi*>* phis = blocks_[i]->phis();
3757 for (int j = 0; j < phis->length(); j++) { 3771 for (int j = 0; j < phis->length(); j++) {
3758 InsertRepresentationChangesForValue(phis->at(j)); 3772 InsertRepresentationChangesForValue(phis->at(j));
3759 } 3773 }
(...skipping 8049 matching lines...) Expand 10 before | Expand all | Expand 10 after
11809 } 11823 }
11810 } 11824 }
11811 11825
11812 #ifdef DEBUG 11826 #ifdef DEBUG
11813 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11827 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11814 if (allocator_ != NULL) allocator_->Verify(); 11828 if (allocator_ != NULL) allocator_->Verify();
11815 #endif 11829 #endif
11816 } 11830 }
11817 11831
11818 } } // namespace v8::internal 11832 } } // 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