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#ifndef V8_HYDROGEN_MARK_DEOPTIMIZE_H_ 6#define V8_HYDROGEN_MARK_DEOPTIMIZE_H_ 7 8#include "src/hydrogen.h" 9 10namespace v8 { 11namespace internal { 12 13 14// Compute DeoptimizeOnUndefined flag for phis. Any phi that can reach a use 15// with DeoptimizeOnUndefined set must have DeoptimizeOnUndefined set. 16// Currently only HCompareNumericAndBranch, with double input representation, 17// has this flag set. The flag is used by HChange tagged->double, which must 18// deoptimize if one of its uses has this flag set. 19class HMarkDeoptimizeOnUndefinedPhase : public HPhase { 20 public: 21 explicit HMarkDeoptimizeOnUndefinedPhase(HGraph* graph) 22 : HPhase("H_Mark deoptimize on undefined", graph), 23 worklist_(16, zone()) {} 24 25 void Run(); 26 27 private: 28 void ProcessPhi(HPhi* phi); 29 30 // Preallocated worklist used as an optimization so we don't have 31 // to allocate a new ZoneList for every ProcessPhi() invocation. 32 ZoneList<HPhi*> worklist_; 33 34 DISALLOW_COPY_AND_ASSIGN(HMarkDeoptimizeOnUndefinedPhase); 35}; 36 37 38class HComputeChangeUndefinedToNaN : public HPhase { 39 public: 40 explicit HComputeChangeUndefinedToNaN(HGraph* graph) 41 : HPhase("H_Compute change undefined to nan", graph) {} 42 43 void Run(); 44 45 private: 46 DISALLOW_COPY_AND_ASSIGN(HComputeChangeUndefinedToNaN); 47}; 48 49 50} } // namespace v8::internal 51 52#endif // V8_HYDROGEN_MARK_DEOPTIMIZE_H_ 53