Line data Source code
1 : // Copyright 2013 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/crankshaft/hydrogen-infer-types.h"
6 : #include "src/objects-inl.h"
7 :
8 : namespace v8 {
9 : namespace internal {
10 :
11 343653 : void HInferTypesPhase::InferTypes(int from_inclusive, int to_inclusive) {
12 4855237 : for (int i = from_inclusive; i <= to_inclusive; ++i) {
13 9023172 : HBasicBlock* block = graph()->blocks()->at(i);
14 :
15 : const ZoneList<HPhi*>* phis = block->phis();
16 9656826 : for (int j = 0; j < phis->length(); j++) {
17 5145238 : phis->at(j)->UpdateInferredType();
18 : }
19 :
20 33549280 : for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
21 29037696 : it.Current()->UpdateInferredType();
22 : }
23 :
24 4511584 : if (block->IsLoopHeader()) {
25 119844 : HBasicBlock* last_back_edge =
26 59922 : block->loop_information()->GetLastBackEdge();
27 59922 : InferTypes(i + 1, last_back_edge->block_id());
28 : // Skip all blocks already processed by the recursive call.
29 : i = last_back_edge->block_id();
30 : // Update phis of the loop header now after the whole loop body is
31 : // guaranteed to be processed.
32 166109 : for (int j = 0; j < block->phis()->length(); ++j) {
33 106187 : HPhi* phi = block->phis()->at(j);
34 106187 : worklist_.Add(phi, zone());
35 244622 : in_worklist_.Add(phi->id());
36 : }
37 181172 : while (!worklist_.is_empty()) {
38 426352 : HValue* current = worklist_.RemoveLast();
39 : in_worklist_.Remove(current->id());
40 121250 : if (current->UpdateInferredType()) {
41 17185 : for (HUseIterator it(current->uses()); !it.Done(); it.Advance()) {
42 17185 : HValue* use = it.value();
43 34370 : if (!in_worklist_.Contains(use->id())) {
44 : in_worklist_.Add(use->id());
45 15063 : worklist_.Add(use, zone());
46 : }
47 : }
48 : }
49 : }
50 : DCHECK(in_worklist_.IsEmpty());
51 : }
52 : }
53 343651 : }
54 :
55 : } // namespace internal
56 : } // namespace v8
|