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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 void HStackCheckEliminator::Process() { | 1243 void HStackCheckEliminator::Process() { |
1244 // For each loop block walk the dominator tree from the backwards branch to | 1244 // For each loop block walk the dominator tree from the backwards branch to |
1245 // the loop header. If a call instruction is encountered the backwards branch | 1245 // the loop header. If a call instruction is encountered the backwards branch |
1246 // is dominated by a call and the stack check in the backwards branch can be | 1246 // is dominated by a call and the stack check in the backwards branch can be |
1247 // removed. | 1247 // removed. |
1248 for (int i = 0; i < graph_->blocks()->length(); i++) { | 1248 for (int i = 0; i < graph_->blocks()->length(); i++) { |
1249 HBasicBlock* block = graph_->blocks()->at(i); | 1249 HBasicBlock* block = graph_->blocks()->at(i); |
1250 if (block->IsLoopHeader()) { | 1250 if (block->IsLoopHeader()) { |
1251 HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge(); | 1251 HBasicBlock* back_edge = block->loop_information()->GetLastBackEdge(); |
1252 HBasicBlock* dominator = back_edge; | 1252 HBasicBlock* dominator = back_edge; |
1253 bool back_edge_dominated_by_call = false; | 1253 while (true) { |
1254 while (dominator != block && !back_edge_dominated_by_call) { | |
1255 HInstruction* instr = dominator->first(); | 1254 HInstruction* instr = dominator->first(); |
1256 while (instr != NULL && !back_edge_dominated_by_call) { | 1255 while (instr != NULL) { |
1257 if (instr->IsCall()) { | 1256 if (instr->IsCall()) { |
1258 RemoveStackCheck(back_edge); | 1257 RemoveStackCheck(back_edge); |
1259 back_edge_dominated_by_call = true; | 1258 break; |
1260 } | 1259 } |
1261 instr = instr->next(); | 1260 instr = instr->next(); |
1262 } | 1261 } |
| 1262 |
| 1263 // Done when the loop header is processed. |
| 1264 if (dominator == block) break; |
| 1265 |
| 1266 // Move up the dominator tree. |
1263 dominator = dominator->dominator(); | 1267 dominator = dominator->dominator(); |
1264 } | 1268 } |
1265 } | 1269 } |
1266 } | 1270 } |
1267 } | 1271 } |
1268 | 1272 |
1269 | 1273 |
1270 void HStackCheckEliminator::RemoveStackCheck(HBasicBlock* block) { | 1274 void HStackCheckEliminator::RemoveStackCheck(HBasicBlock* block) { |
1271 HInstruction* instr = block->first(); | 1275 HInstruction* instr = block->first(); |
1272 while (instr != NULL) { | 1276 while (instr != NULL) { |
(...skipping 5297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6570 } | 6574 } |
6571 } | 6575 } |
6572 | 6576 |
6573 #ifdef DEBUG | 6577 #ifdef DEBUG |
6574 if (graph_ != NULL) graph_->Verify(); | 6578 if (graph_ != NULL) graph_->Verify(); |
6575 if (allocator_ != NULL) allocator_->Verify(); | 6579 if (allocator_ != NULL) allocator_->Verify(); |
6576 #endif | 6580 #endif |
6577 } | 6581 } |
6578 | 6582 |
6579 } } // namespace v8::internal | 6583 } } // namespace v8::internal |
OLD | NEW |