OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 | 43 |
44 void HRangeAnalysisPhase::Analyze(HBasicBlock* block) { | 44 void HRangeAnalysisPhase::Analyze(HBasicBlock* block) { |
45 TraceRange("Analyzing block B%d\n", block->block_id()); | 45 TraceRange("Analyzing block B%d\n", block->block_id()); |
46 | 46 |
47 int last_changed_range = changed_ranges_.length() - 1; | 47 int last_changed_range = changed_ranges_.length() - 1; |
48 | 48 |
49 // Infer range based on control flow. | 49 // Infer range based on control flow. |
50 if (block->predecessors()->length() == 1) { | 50 if (block->predecessors()->length() == 1) { |
51 HBasicBlock* pred = block->predecessors()->first(); | 51 HBasicBlock* pred = block->predecessors()->first(); |
52 if (pred->end()->IsCompareIDAndBranch()) { | 52 if (pred->end()->IsCompareNumericAndBranch()) { |
53 InferControlFlowRange(HCompareIDAndBranch::cast(pred->end()), block); | 53 InferControlFlowRange(HCompareNumericAndBranch::cast(pred->end()), |
| 54 block); |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 // Process phi instructions. | 58 // Process phi instructions. |
58 for (int i = 0; i < block->phis()->length(); ++i) { | 59 for (int i = 0; i < block->phis()->length(); ++i) { |
59 HPhi* phi = block->phis()->at(i); | 60 HPhi* phi = block->phis()->at(i); |
60 InferRange(phi); | 61 InferRange(phi); |
61 } | 62 } |
62 | 63 |
63 // Go through all instructions of the current block. | 64 // Go through all instructions of the current block. |
64 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 65 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
65 InferRange(it.Current()); | 66 InferRange(it.Current()); |
66 } | 67 } |
67 | 68 |
68 // Continue analysis in all dominated blocks. | 69 // Continue analysis in all dominated blocks. |
69 for (int i = 0; i < block->dominated_blocks()->length(); ++i) { | 70 for (int i = 0; i < block->dominated_blocks()->length(); ++i) { |
70 Analyze(block->dominated_blocks()->at(i)); | 71 Analyze(block->dominated_blocks()->at(i)); |
71 } | 72 } |
72 | 73 |
73 RollBackTo(last_changed_range); | 74 RollBackTo(last_changed_range); |
74 } | 75 } |
75 | 76 |
76 | 77 |
77 void HRangeAnalysisPhase::InferControlFlowRange(HCompareIDAndBranch* test, | 78 void HRangeAnalysisPhase::InferControlFlowRange(HCompareNumericAndBranch* test, |
78 HBasicBlock* dest) { | 79 HBasicBlock* dest) { |
79 ASSERT((test->FirstSuccessor() == dest) == (test->SecondSuccessor() != dest)); | 80 ASSERT((test->FirstSuccessor() == dest) == (test->SecondSuccessor() != dest)); |
80 if (test->representation().IsSmiOrInteger32()) { | 81 if (test->representation().IsSmiOrInteger32()) { |
81 Token::Value op = test->token(); | 82 Token::Value op = test->token(); |
82 if (test->SecondSuccessor() == dest) { | 83 if (test->SecondSuccessor() == dest) { |
83 op = Token::NegateCompareOp(op); | 84 op = Token::NegateCompareOp(op); |
84 } | 85 } |
85 Token::Value inverted_op = Token::ReverseCompareOp(op); | 86 Token::Value inverted_op = Token::ReverseCompareOp(op); |
86 UpdateControlFlowRange(op, test->left(), test->right()); | 87 UpdateControlFlowRange(op, test->left(), test->right()); |
87 UpdateControlFlowRange(inverted_op, test->right(), test->left()); | 88 UpdateControlFlowRange(inverted_op, test->right(), test->left()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 original_range->lower(), | 161 original_range->lower(), |
161 original_range->upper()); | 162 original_range->upper()); |
162 } | 163 } |
163 TraceRange("New information was [%d,%d]\n", | 164 TraceRange("New information was [%d,%d]\n", |
164 range->lower(), | 165 range->lower(), |
165 range->upper()); | 166 range->upper()); |
166 } | 167 } |
167 | 168 |
168 | 169 |
169 } } // namespace v8::internal | 170 } } // namespace v8::internal |
OLD | NEW |