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

Side by Side Diff: src/hydrogen.cc

Issue 7974009: Fix a bug with uninitialized const variables in the optimizing compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 3 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 | « src/hydrogen.h ('k') | test/mjsunit/compiler/regress-96989.js » ('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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 HPhi* phi = phi_list[i]; 845 HPhi* phi = phi_list[i];
846 if (!phi->is_live()) { 846 if (!phi->is_live()) {
847 HBasicBlock* block = phi->block(); 847 HBasicBlock* block = phi->block();
848 block->RemovePhi(phi); 848 block->RemovePhi(phi);
849 block->RecordDeletedPhi(phi->merged_index()); 849 block->RecordDeletedPhi(phi->merged_index());
850 } 850 }
851 } 851 }
852 } 852 }
853 853
854 854
855 bool HGraph::CheckPhis() { 855 bool HGraph::CheckArgumentsPhiUses() {
856 int block_count = blocks_.length(); 856 int block_count = blocks_.length();
857 for (int i = 0; i < block_count; ++i) { 857 for (int i = 0; i < block_count; ++i) {
858 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { 858 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
859 HPhi* phi = blocks_[i]->phis()->at(j); 859 HPhi* phi = blocks_[i]->phis()->at(j);
860 // We don't support phi uses of arguments for now. 860 // We don't support phi uses of arguments for now.
861 if (phi->CheckFlag(HValue::kIsArguments)) return false; 861 if (phi->CheckFlag(HValue::kIsArguments)) return false;
862 } 862 }
863 } 863 }
864 return true; 864 return true;
865 } 865 }
866 866
867 867
868 bool HGraph::CollectPhis() { 868 bool HGraph::CheckConstPhiUses() {
869 int block_count = blocks_.length(); 869 int block_count = blocks_.length();
870 phi_list_ = new ZoneList<HPhi*>(block_count);
871 for (int i = 0; i < block_count; ++i) { 870 for (int i = 0; i < block_count; ++i) {
872 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { 871 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
873 HPhi* phi = blocks_[i]->phis()->at(j); 872 HPhi* phi = blocks_[i]->phis()->at(j);
874 phi_list_->Add(phi);
875 // Check for the hole value (from an uninitialized const). 873 // Check for the hole value (from an uninitialized const).
876 for (int k = 0; k < phi->OperandCount(); k++) { 874 for (int k = 0; k < phi->OperandCount(); k++) {
877 if (phi->OperandAt(k) == GetConstantHole()) return false; 875 if (phi->OperandAt(k) == GetConstantHole()) return false;
878 } 876 }
879 } 877 }
880 } 878 }
881 return true; 879 return true;
882 } 880 }
883 881
884 882
883 void HGraph::CollectPhis() {
884 int block_count = blocks_.length();
885 phi_list_ = new ZoneList<HPhi*>(block_count);
886 for (int i = 0; i < block_count; ++i) {
887 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
888 HPhi* phi = blocks_[i]->phis()->at(j);
889 phi_list_->Add(phi);
890 }
891 }
892 }
893
894
885 void HGraph::InferTypes(ZoneList<HValue*>* worklist) { 895 void HGraph::InferTypes(ZoneList<HValue*>* worklist) {
886 BitVector in_worklist(GetMaximumValueID()); 896 BitVector in_worklist(GetMaximumValueID());
887 for (int i = 0; i < worklist->length(); ++i) { 897 for (int i = 0; i < worklist->length(); ++i) {
888 ASSERT(!in_worklist.Contains(worklist->at(i)->id())); 898 ASSERT(!in_worklist.Contains(worklist->at(i)->id()));
889 in_worklist.Add(worklist->at(i)->id()); 899 in_worklist.Add(worklist->at(i)->id());
890 } 900 }
891 901
892 while (!worklist->is_empty()) { 902 while (!worklist->is_empty()) {
893 HValue* current = worklist->RemoveLast(); 903 HValue* current = worklist->RemoveLast();
894 in_worklist.Remove(current->id()); 904 in_worklist.Remove(current->id());
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 2332
2323 graph()->OrderBlocks(); 2333 graph()->OrderBlocks();
2324 graph()->AssignDominators(); 2334 graph()->AssignDominators();
2325 2335
2326 #ifdef DEBUG 2336 #ifdef DEBUG
2327 // Do a full verify after building the graph and computing dominators. 2337 // Do a full verify after building the graph and computing dominators.
2328 graph()->Verify(true); 2338 graph()->Verify(true);
2329 #endif 2339 #endif
2330 2340
2331 graph()->PropagateDeoptimizingMark(); 2341 graph()->PropagateDeoptimizingMark();
2342 if (!graph()->CheckConstPhiUses()) {
2343 Bailout("Unsupported phi use of const variable");
2344 return NULL;
2345 }
2332 graph()->EliminateRedundantPhis(); 2346 graph()->EliminateRedundantPhis();
2333 if (!graph()->CheckPhis()) { 2347 if (!graph()->CheckArgumentsPhiUses()) {
2334 Bailout("Unsupported phi use of arguments object"); 2348 Bailout("Unsupported phi use of arguments");
2335 return NULL; 2349 return NULL;
2336 } 2350 }
2337 if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis(); 2351 if (FLAG_eliminate_dead_phis) graph()->EliminateUnreachablePhis();
2338 if (!graph()->CollectPhis()) { 2352 graph()->CollectPhis();
2339 Bailout("Unsupported phi use of uninitialized constant");
2340 return NULL;
2341 }
2342 2353
2343 HInferRepresentation rep(graph()); 2354 HInferRepresentation rep(graph());
2344 rep.Analyze(); 2355 rep.Analyze();
2345 2356
2346 graph()->MarkDeoptimizeOnUndefined(); 2357 graph()->MarkDeoptimizeOnUndefined();
2347 graph()->InsertRepresentationChanges(); 2358 graph()->InsertRepresentationChanges();
2348 2359
2349 graph()->InitializeInferredTypes(); 2360 graph()->InitializeInferredTypes();
2350 graph()->Canonicalize(); 2361 graph()->Canonicalize();
2351 2362
(...skipping 4475 matching lines...) Expand 10 before | Expand all | Expand 10 after
6827 } 6838 }
6828 } 6839 }
6829 6840
6830 #ifdef DEBUG 6841 #ifdef DEBUG
6831 if (graph_ != NULL) graph_->Verify(false); // No full verify. 6842 if (graph_ != NULL) graph_->Verify(false); // No full verify.
6832 if (allocator_ != NULL) allocator_->Verify(); 6843 if (allocator_ != NULL) allocator_->Verify();
6833 #endif 6844 #endif
6834 } 6845 }
6835 6846
6836 } } // namespace v8::internal 6847 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/compiler/regress-96989.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698