| Index: src/hydrogen.h | 
| diff --git a/src/hydrogen.h b/src/hydrogen.h | 
| index 7417fdd2de495e92ed9b40e3b37f1cb3bba3bf4a..8e53ef4153ae235d2aab62a40ff2dc580f72254b 100644 | 
| --- a/src/hydrogen.h | 
| +++ b/src/hydrogen.h | 
| @@ -263,6 +263,7 @@ class HGraph: public ZoneObject { | 
| void MarkDeoptimizeOnUndefined(); | 
| void ComputeMinusZeroChecks(); | 
| void ComputeSafeUint32Operations(); | 
| +  void GlobalValueNumbering(); | 
| bool ProcessArgumentsObject(); | 
| void EliminateRedundantPhis(); | 
| void EliminateUnreachablePhis(); | 
| @@ -291,6 +292,7 @@ class HGraph: public ZoneObject { | 
| undefined_constant_.set(constant); | 
| } | 
| HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } | 
| +  HConstant* GetConstant0(); | 
| HConstant* GetConstant1(); | 
| HConstant* GetConstantMinus1(); | 
| HConstant* GetConstantTrue(); | 
| @@ -409,6 +411,7 @@ class HGraph: public ZoneObject { | 
| ZoneList<HPhi*>* phi_list_; | 
| ZoneList<HInstruction*>* uint32_instructions_; | 
| SetOncePointer<HConstant> undefined_constant_; | 
| +  SetOncePointer<HConstant> constant_0_; | 
| SetOncePointer<HConstant> constant_1_; | 
| SetOncePointer<HConstant> constant_minus1_; | 
| SetOncePointer<HConstant> constant_true_; | 
| @@ -874,6 +877,9 @@ class HGraphBuilder { | 
| protected: | 
| virtual bool BuildGraph() = 0; | 
|  | 
| +  HBasicBlock* CreateBasicBlock(HEnvironment* env); | 
| +  HBasicBlock* CreateLoopHeaderBlock(); | 
| + | 
| // Building common constructs | 
| HInstruction* BuildExternalArrayElementAccess( | 
| HValue* external_elements, | 
| @@ -901,6 +907,81 @@ class HGraphBuilder { | 
| bool is_store, | 
| Representation checked_index_representation = Representation::None()); | 
|  | 
| + | 
| +  class IfBuilder { | 
| +   public: | 
| +    IfBuilder(HGraphBuilder* builder, | 
| +              BailoutId id = BailoutId::StubEntry()); | 
| +    ~IfBuilder() { | 
| +      if (!finished_) End(); | 
| +    } | 
| + | 
| +    void BeginTrue(HValue* left, HValue* right, Token::Value token); | 
| +    void BeginFalse(); | 
| +    void End(); | 
| + | 
| +   private: | 
| +    HGraphBuilder* builder_; | 
| +    bool finished_; | 
| +    HEnvironment* true_env_; | 
| +    HEnvironment* false_env_; | 
| +    HEnvironment* merge_env_; | 
| +    HBasicBlock* true_block_; | 
| +    HBasicBlock* false_block_; | 
| +    HBasicBlock* merge_block_; | 
| +    BailoutId id_; | 
| + | 
| +    Zone* zone() { return builder_->zone(); } | 
| +  }; | 
| + | 
| +  class LoopBuilder { | 
| +   public: | 
| +    enum Direction { | 
| +      kPreIncrement, | 
| +      kPostIncrement, | 
| +      kPreDecrement, | 
| +      kPostDecrement | 
| +    }; | 
| + | 
| +    LoopBuilder(HGraphBuilder* builder, | 
| +                HValue* context, | 
| +                Direction direction, | 
| +                BailoutId id = BailoutId::StubEntry()); | 
| +    ~LoopBuilder() { | 
| +      ASSERT(finished_); | 
| +    } | 
| + | 
| +    HValue* BeginBody(HValue* initial, HValue* terminating, Token::Value token); | 
| +    void EndBody(); | 
| + | 
| +   private: | 
| +    HGraphBuilder* builder_; | 
| +    HValue* context_; | 
| +    HInstruction* increment_; | 
| +    HPhi* phi_; | 
| +    HEnvironment* body_env_; | 
| +    HEnvironment* exit_env_; | 
| +    HBasicBlock* header_block_; | 
| +    HBasicBlock* body_block_; | 
| +    HBasicBlock* exit_block_; | 
| +    Direction direction_; | 
| +    BailoutId id_; | 
| +    bool finished_; | 
| + | 
| +    Zone* zone() { return builder_->zone(); } | 
| +  }; | 
| + | 
| +  HValue* BuildAllocateElements(HContext* context, | 
| +                                ElementsKind kind, | 
| +                                HValue* capacity); | 
| + | 
| +  void BuildCopyElements(HContext* context, | 
| +                         HValue* from_elements, | 
| +                         ElementsKind from_elements_kind, | 
| +                         HValue* to_elements, | 
| +                         ElementsKind to_elements_kind, | 
| +                         HValue* length); | 
| + | 
| private: | 
| HGraphBuilder(); | 
| CompilationInfo* info_; | 
| @@ -1133,9 +1214,6 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { | 
| AST_NODE_LIST(DECLARE_VISIT) | 
| #undef DECLARE_VISIT | 
|  | 
| -  HBasicBlock* CreateBasicBlock(HEnvironment* env); | 
| -  HBasicBlock* CreateLoopHeaderBlock(); | 
| - | 
| // Helpers for flow graph construction. | 
| enum GlobalPropertyAccess { | 
| kUseCell, | 
|  |