Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: src/hydrogen-infer-types.cc

Issue 18568007: Turn infer types into proper HPhase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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::InitializeInferredTypes(int from_inclusive,
34 int to_inclusive) {
35 for (int i = from_inclusive; i <= to_inclusive; ++i) {
36 HBasicBlock* block = graph()->blocks()->at(i);
37
38 const ZoneList<HPhi*>* phis = block->phis();
39 for (int j = 0; j < phis->length(); j++) {
40 phis->at(j)->UpdateInferredType();
41 }
42
43 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
44 it.Current()->UpdateInferredType();
45 }
46
47 if (block->IsLoopHeader()) {
48 HBasicBlock* last_back_edge =
49 block->loop_information()->GetLastBackEdge();
50 InitializeInferredTypes(i + 1, last_back_edge->block_id());
51 // Skip all blocks already processed by the recursive call.
52 i = last_back_edge->block_id();
53 // Update phis of the loop header now after the whole loop body is
54 // guaranteed to be processed.
55 for (int j = 0; j < block->phis()->length(); ++j) {
56 HPhi* phi = block->phis()->at(j);
57 worklist_.Add(phi, zone());
58 in_worklist_.Add(phi->id());
59 }
60 while (!worklist_.is_empty()) {
61 HValue* current = worklist_.RemoveLast();
62 in_worklist_.Remove(current->id());
63 if (current->UpdateInferredType()) {
64 for (HUseIterator it(current->uses()); !it.Done(); it.Advance()) {
65 HValue* use = it.value();
66 if (!in_worklist_.Contains(use->id())) {
67 in_worklist_.Add(use->id());
68 worklist_.Add(use, zone());
69 }
70 }
71 }
72 }
73 ASSERT(in_worklist_.IsEmpty());
74 }
75 }
76 }
77
78 } } // namespace v8::internal
OLDNEW
« src/hydrogen-infer-types.h ('K') | « src/hydrogen-infer-types.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698