OLD | NEW |
| (Empty) |
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/hydrogen-mark-deoptimize.h" | |
6 | |
7 namespace v8 { | |
8 namespace internal { | |
9 | |
10 void HMarkDeoptimizeOnUndefinedPhase::Run() { | |
11 const ZoneList<HPhi*>* phi_list = graph()->phi_list(); | |
12 for (int i = 0; i < phi_list->length(); i++) { | |
13 HPhi* phi = phi_list->at(i); | |
14 if (phi->CheckFlag(HValue::kAllowUndefinedAsNaN) && | |
15 !phi->CheckUsesForFlag(HValue::kAllowUndefinedAsNaN)) { | |
16 ProcessPhi(phi); | |
17 } | |
18 } | |
19 } | |
20 | |
21 | |
22 void HMarkDeoptimizeOnUndefinedPhase::ProcessPhi(HPhi* phi) { | |
23 DCHECK(phi->CheckFlag(HValue::kAllowUndefinedAsNaN)); | |
24 DCHECK(worklist_.is_empty()); | |
25 | |
26 // Push the phi onto the worklist | |
27 phi->ClearFlag(HValue::kAllowUndefinedAsNaN); | |
28 worklist_.Add(phi, zone()); | |
29 | |
30 // Process all phis that can reach this phi | |
31 while (!worklist_.is_empty()) { | |
32 phi = worklist_.RemoveLast(); | |
33 for (int i = phi->OperandCount() - 1; i >= 0; --i) { | |
34 HValue* input = phi->OperandAt(i); | |
35 if (input->IsPhi() && input->CheckFlag(HValue::kAllowUndefinedAsNaN)) { | |
36 input->ClearFlag(HValue::kAllowUndefinedAsNaN); | |
37 worklist_.Add(HPhi::cast(input), zone()); | |
38 } | |
39 } | |
40 } | |
41 } | |
42 | |
43 | |
44 void HComputeChangeUndefinedToNaN::Run() { | |
45 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); | |
46 for (int i = 0; i < blocks->length(); ++i) { | |
47 const HBasicBlock* block(blocks->at(i)); | |
48 for (HInstruction* current = block->first(); current != NULL; ) { | |
49 HInstruction* next = current->next(); | |
50 if (current->IsChange()) { | |
51 if (HChange::cast(current)->can_convert_undefined_to_nan()) { | |
52 current->SetFlag(HValue::kAllowUndefinedAsNaN); | |
53 } | |
54 } | |
55 current = next; | |
56 } | |
57 } | |
58 } | |
59 | |
60 | |
61 } // namespace internal | |
62 } // namespace v8 | |
OLD | NEW |