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

Side by Side Diff: src/hydrogen.cc

Issue 6260035: Fix a bug in the placement of minus-zero checks and in GVN.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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') | src/hydrogen-instructions.cc » ('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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1806
1807 current = current->EnsureAndPropagateNotMinusZero(visited); 1807 current = current->EnsureAndPropagateNotMinusZero(visited);
1808 } 1808 }
1809 } 1809 }
1810 1810
1811 1811
1812 void HGraph::InsertRepresentationChangeForUse(HValue* value, 1812 void HGraph::InsertRepresentationChangeForUse(HValue* value,
1813 HValue* use, 1813 HValue* use,
1814 Representation to, 1814 Representation to,
1815 bool is_truncating) { 1815 bool is_truncating) {
1816 // Propagate flags for negative zero checks upwards from conversions
1817 // int32-to-tagged and int32-to-double.
1818 Representation from = value->representation();
1819 if (from.IsInteger32()) {
1820 ASSERT(to.IsTagged() || to.IsDouble());
1821 BitVector visited(GetMaximumValueID());
1822 PropagateMinusZeroChecks(value, &visited);
1823 }
1824
1825 // Insert the representation change right before its use. For phi-uses we 1816 // Insert the representation change right before its use. For phi-uses we
1826 // insert at the end of the corresponding predecessor. 1817 // insert at the end of the corresponding predecessor.
1827 HBasicBlock* insert_block = use->block(); 1818 HBasicBlock* insert_block = use->block();
1828 if (use->IsPhi()) { 1819 if (use->IsPhi()) {
1829 int index = 0; 1820 int index = 0;
1830 while (use->OperandAt(index) != value) ++index; 1821 while (use->OperandAt(index) != value) ++index;
1831 insert_block = insert_block->predecessors()->at(index); 1822 insert_block = insert_block->predecessors()->at(index);
1832 } 1823 }
1833 1824
1834 HInstruction* next = (insert_block == use->block()) 1825 HInstruction* next = (insert_block == use->block())
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 // Process normal instructions. 1968 // Process normal instructions.
1978 HInstruction* current = blocks_[i]->first(); 1969 HInstruction* current = blocks_[i]->first();
1979 while (current != NULL) { 1970 while (current != NULL) {
1980 InsertRepresentationChanges(current); 1971 InsertRepresentationChanges(current);
1981 current = current->next(); 1972 current = current->next();
1982 } 1973 }
1983 } 1974 }
1984 } 1975 }
1985 1976
1986 1977
1978 void HGraph::ComputeMinusZeroChecks() {
1979 BitVector visited(GetMaximumValueID());
1980 for (int i = 0; i < blocks_.length(); ++i) {
1981 for (HInstruction* current = blocks_[i]->first();
1982 current != NULL;
1983 current = current->next()) {
1984 if (current->IsChange()) {
1985 HChange* change = HChange::cast(current);
1986 // Propagate flags for negative zero checks upwards from conversions
1987 // int32-to-tagged and int32-to-double.
1988 Representation from = change->value()->representation();
1989 ASSERT(from.Equals(change->from()));
1990 if (from.IsInteger32()) {
1991 ASSERT(change->to().IsTagged() || change->to().IsDouble());
1992 ASSERT(visited.IsEmpty());
1993 PropagateMinusZeroChecks(change->value(), &visited);
1994 visited.Clear();
1995 }
1996 }
1997 }
1998 }
1999 }
2000
2001
1987 // Implementation of utility classes to represent an expression's context in 2002 // Implementation of utility classes to represent an expression's context in
1988 // the AST. 2003 // the AST.
1989 AstContext::AstContext(HGraphBuilder* owner, Expression::Context kind) 2004 AstContext::AstContext(HGraphBuilder* owner, Expression::Context kind)
1990 : owner_(owner), kind_(kind), outer_(owner->ast_context()) { 2005 : owner_(owner), kind_(kind), outer_(owner->ast_context()) {
1991 owner->set_ast_context(this); // Push. 2006 owner->set_ast_context(this); // Push.
1992 #ifdef DEBUG 2007 #ifdef DEBUG
1993 original_length_ = owner->environment()->length(); 2008 original_length_ = owner->environment()->length();
1994 #endif 2009 #endif
1995 } 2010 }
1996 2011
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 rep.Analyze(); 2251 rep.Analyze();
2237 2252
2238 if (FLAG_use_range) { 2253 if (FLAG_use_range) {
2239 HRangeAnalysis rangeAnalysis(graph_); 2254 HRangeAnalysis rangeAnalysis(graph_);
2240 rangeAnalysis.Analyze(); 2255 rangeAnalysis.Analyze();
2241 } 2256 }
2242 2257
2243 graph_->InitializeInferredTypes(); 2258 graph_->InitializeInferredTypes();
2244 graph_->Canonicalize(); 2259 graph_->Canonicalize();
2245 graph_->InsertRepresentationChanges(); 2260 graph_->InsertRepresentationChanges();
2261 graph_->ComputeMinusZeroChecks();
2246 2262
2247 // Eliminate redundant stack checks on backwards branches. 2263 // Eliminate redundant stack checks on backwards branches.
2248 HStackCheckEliminator sce(graph_); 2264 HStackCheckEliminator sce(graph_);
2249 sce.Process(); 2265 sce.Process();
2250 2266
2251 // Perform common subexpression elimination and loop-invariant code motion. 2267 // Perform common subexpression elimination and loop-invariant code motion.
2252 if (FLAG_use_gvn) { 2268 if (FLAG_use_gvn) {
2253 HPhase phase("Global value numbering", graph_); 2269 HPhase phase("Global value numbering", graph_);
2254 HGlobalValueNumberer gvn(graph_); 2270 HGlobalValueNumberer gvn(graph_);
2255 gvn.Analyze(); 2271 gvn.Analyze();
(...skipping 3622 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 } 5894 }
5879 } 5895 }
5880 5896
5881 #ifdef DEBUG 5897 #ifdef DEBUG
5882 if (graph_ != NULL) graph_->Verify(); 5898 if (graph_ != NULL) graph_->Verify();
5883 if (allocator_ != NULL) allocator_->Verify(); 5899 if (allocator_ != NULL) allocator_->Verify();
5884 #endif 5900 #endif
5885 } 5901 }
5886 5902
5887 } } // namespace v8::internal 5903 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698