OLD | NEW |
---|---|
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...) Loading... | |
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...) Loading... | |
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 for (int i = 0; i < blocks_.length(); ++i) { | |
1980 for (HInstruction* current = blocks_[i]->first(); | |
1981 current != NULL; | |
1982 current = current->next()) { | |
1983 if (current->IsChange()) { | |
1984 HChange* change = HChange::cast(current); | |
1985 // Propagate flags for negative zero checks upwards from conversions | |
1986 // int32-to-tagged and int32-to-double. | |
1987 Representation from = change->value()->representation(); | |
1988 ASSERT(from.Equals(change->from())); | |
1989 if (from.IsInteger32()) { | |
1990 ASSERT(change->to().IsTagged() || change->to().IsDouble()); | |
1991 BitVector visited(GetMaximumValueID()); | |
William Hesse
2011/01/31 12:22:54
Is this allocation a problem? Can you reuse one?
fschneider
2011/01/31 12:34:44
Good point. Done.
| |
1992 PropagateMinusZeroChecks(change->value(), &visited); | |
1993 } | |
1994 } | |
1995 } | |
1996 } | |
1997 } | |
1998 | |
1999 | |
1987 // Implementation of utility classes to represent an expression's context in | 2000 // Implementation of utility classes to represent an expression's context in |
1988 // the AST. | 2001 // the AST. |
1989 AstContext::AstContext(HGraphBuilder* owner, Expression::Context kind) | 2002 AstContext::AstContext(HGraphBuilder* owner, Expression::Context kind) |
1990 : owner_(owner), kind_(kind), outer_(owner->ast_context()) { | 2003 : owner_(owner), kind_(kind), outer_(owner->ast_context()) { |
1991 owner->set_ast_context(this); // Push. | 2004 owner->set_ast_context(this); // Push. |
1992 #ifdef DEBUG | 2005 #ifdef DEBUG |
1993 original_length_ = owner->environment()->length(); | 2006 original_length_ = owner->environment()->length(); |
1994 #endif | 2007 #endif |
1995 } | 2008 } |
1996 | 2009 |
(...skipping 239 matching lines...) Loading... | |
2236 rep.Analyze(); | 2249 rep.Analyze(); |
2237 | 2250 |
2238 if (FLAG_use_range) { | 2251 if (FLAG_use_range) { |
2239 HRangeAnalysis rangeAnalysis(graph_); | 2252 HRangeAnalysis rangeAnalysis(graph_); |
2240 rangeAnalysis.Analyze(); | 2253 rangeAnalysis.Analyze(); |
2241 } | 2254 } |
2242 | 2255 |
2243 graph_->InitializeInferredTypes(); | 2256 graph_->InitializeInferredTypes(); |
2244 graph_->Canonicalize(); | 2257 graph_->Canonicalize(); |
2245 graph_->InsertRepresentationChanges(); | 2258 graph_->InsertRepresentationChanges(); |
2259 graph_->ComputeMinusZeroChecks(); | |
2246 | 2260 |
2247 // Eliminate redundant stack checks on backwards branches. | 2261 // Eliminate redundant stack checks on backwards branches. |
2248 HStackCheckEliminator sce(graph_); | 2262 HStackCheckEliminator sce(graph_); |
2249 sce.Process(); | 2263 sce.Process(); |
2250 | 2264 |
2251 // Perform common subexpression elimination and loop-invariant code motion. | 2265 // Perform common subexpression elimination and loop-invariant code motion. |
2252 if (FLAG_use_gvn) { | 2266 if (FLAG_use_gvn) { |
2253 HPhase phase("Global value numbering", graph_); | 2267 HPhase phase("Global value numbering", graph_); |
2254 HGlobalValueNumberer gvn(graph_); | 2268 HGlobalValueNumberer gvn(graph_); |
2255 gvn.Analyze(); | 2269 gvn.Analyze(); |
(...skipping 3622 matching lines...) Loading... | |
5878 } | 5892 } |
5879 } | 5893 } |
5880 | 5894 |
5881 #ifdef DEBUG | 5895 #ifdef DEBUG |
5882 if (graph_ != NULL) graph_->Verify(); | 5896 if (graph_ != NULL) graph_->Verify(); |
5883 if (allocator_ != NULL) allocator_->Verify(); | 5897 if (allocator_ != NULL) allocator_->Verify(); |
5884 #endif | 5898 #endif |
5885 } | 5899 } |
5886 | 5900 |
5887 } } // namespace v8::internal | 5901 } } // namespace v8::internal |
OLD | NEW |