OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } | 1110 } |
1111 | 1111 |
1112 // The direction of the count operation must agree with the start and the end | 1112 // The direction of the count operation must agree with the start and the end |
1113 // value. We currently do not allow the initial value to be the same as the | 1113 // value. We currently do not allow the initial value to be the same as the |
1114 // terminal value. This _would_ be ok as long as the loop body never executes | 1114 // terminal value. This _would_ be ok as long as the loop body never executes |
1115 // or executes exactly one time. | 1115 // or executes exactly one time. |
1116 if (init_value == term_value) return NULL; | 1116 if (init_value == term_value) return NULL; |
1117 if (init_value < term_value && update->op() != Token::INC) return NULL; | 1117 if (init_value < term_value && update->op() != Token::INC) return NULL; |
1118 if (init_value > term_value && update->op() != Token::DEC) return NULL; | 1118 if (init_value > term_value && update->op() != Token::DEC) return NULL; |
1119 | 1119 |
| 1120 // Check that the update operation cannot overflow the smi range. This can |
| 1121 // occur in the two cases where the loop bound is equal to the largest or |
| 1122 // smallest smi. |
| 1123 if (update->op() == Token::INC && term_value == Smi::kMaxValue) return NULL; |
| 1124 if (update->op() == Token::DEC && term_value == Smi::kMinValue) return NULL; |
| 1125 |
1120 // Found a smi loop variable. | 1126 // Found a smi loop variable. |
1121 return loop_var; | 1127 return loop_var; |
1122 } | 1128 } |
1123 | 1129 |
1124 int AssignedVariablesAnalyzer::BitIndex(Variable* var) { | 1130 int AssignedVariablesAnalyzer::BitIndex(Variable* var) { |
1125 ASSERT(var != NULL); | 1131 ASSERT(var != NULL); |
1126 ASSERT(var->IsStackAllocated()); | 1132 ASSERT(var->IsStackAllocated()); |
1127 Slot* slot = var->slot(); | 1133 Slot* slot = var->slot(); |
1128 if (slot->type() == Slot::PARAMETER) { | 1134 if (slot->type() == Slot::PARAMETER) { |
1129 return slot->index(); | 1135 return slot->index(); |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 | 2205 |
2200 // Step 4: Based on RD_in for block nodes, propagate reaching definitions | 2206 // Step 4: Based on RD_in for block nodes, propagate reaching definitions |
2201 // to all variable uses in the block. | 2207 // to all variable uses in the block. |
2202 for (int i = 0; i < node_count; i++) { | 2208 for (int i = 0; i < node_count; i++) { |
2203 postorder_->at(i)->PropagateReachingDefinitions(&variables_); | 2209 postorder_->at(i)->PropagateReachingDefinitions(&variables_); |
2204 } | 2210 } |
2205 } | 2211 } |
2206 | 2212 |
2207 | 2213 |
2208 } } // namespace v8::internal | 2214 } } // namespace v8::internal |
OLD | NEW |