OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "hydrogen-infer-types.h" |
| 29 |
| 30 namespace v8 { |
| 31 namespace internal { |
| 32 |
| 33 void HInferTypesPhase::InferTypes(int from_inclusive, int to_inclusive) { |
| 34 for (int i = from_inclusive; i <= to_inclusive; ++i) { |
| 35 HBasicBlock* block = graph()->blocks()->at(i); |
| 36 |
| 37 const ZoneList<HPhi*>* phis = block->phis(); |
| 38 for (int j = 0; j < phis->length(); j++) { |
| 39 phis->at(j)->UpdateInferredType(); |
| 40 } |
| 41 |
| 42 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 43 it.Current()->UpdateInferredType(); |
| 44 } |
| 45 |
| 46 if (block->IsLoopHeader()) { |
| 47 HBasicBlock* last_back_edge = |
| 48 block->loop_information()->GetLastBackEdge(); |
| 49 InferTypes(i + 1, last_back_edge->block_id()); |
| 50 // Skip all blocks already processed by the recursive call. |
| 51 i = last_back_edge->block_id(); |
| 52 // Update phis of the loop header now after the whole loop body is |
| 53 // guaranteed to be processed. |
| 54 for (int j = 0; j < block->phis()->length(); ++j) { |
| 55 HPhi* phi = block->phis()->at(j); |
| 56 worklist_.Add(phi, zone()); |
| 57 in_worklist_.Add(phi->id()); |
| 58 } |
| 59 while (!worklist_.is_empty()) { |
| 60 HValue* current = worklist_.RemoveLast(); |
| 61 in_worklist_.Remove(current->id()); |
| 62 if (current->UpdateInferredType()) { |
| 63 for (HUseIterator it(current->uses()); !it.Done(); it.Advance()) { |
| 64 HValue* use = it.value(); |
| 65 if (!in_worklist_.Contains(use->id())) { |
| 66 in_worklist_.Add(use->id()); |
| 67 worklist_.Add(use, zone()); |
| 68 } |
| 69 } |
| 70 } |
| 71 } |
| 72 ASSERT(in_worklist_.IsEmpty()); |
| 73 } |
| 74 } |
| 75 } |
| 76 |
| 77 } } // namespace v8::internal |
OLD | NEW |