Chromium Code Reviews| Index: src/hydrogen.h |
| diff --git a/src/hydrogen.h b/src/hydrogen.h |
| index 271835b8fdad97f74aac6d7a5c700bd5ec6184f2..48fd8f2241884cbb28cddab943a7c8120b35d5ea 100644 |
| --- a/src/hydrogen.h |
| +++ b/src/hydrogen.h |
| @@ -110,7 +110,7 @@ class HBasicBlock V8_FINAL : public ZoneObject { |
| bool IsFinished() const { return end_ != NULL; } |
| void AddPhi(HPhi* phi); |
| void RemovePhi(HPhi* phi); |
| - void AddInstruction(HInstruction* instr); |
| + void AddInstruction(HInstruction* instr, int position); |
| bool Dominates(HBasicBlock* other) const; |
| int LoopNestingDepth() const; |
| @@ -133,30 +133,18 @@ class HBasicBlock V8_FINAL : public ZoneObject { |
| void SetJoinId(BailoutId ast_id); |
| - void Finish(HControlInstruction* last); |
| - void FinishExit(HControlInstruction* instruction); |
| - void Goto(HBasicBlock* block, |
| - FunctionState* state = NULL, |
| - bool add_simulate = true); |
| - void GotoNoSimulate(HBasicBlock* block) { |
| - Goto(block, NULL, false); |
| - } |
| - |
| int PredecessorIndexOf(HBasicBlock* predecessor) const; |
| HPhi* AddNewPhi(int merged_index); |
| HSimulate* AddNewSimulate(BailoutId ast_id, |
| + int position, |
| RemovableSimulate removable = FIXED_SIMULATE) { |
| HSimulate* instr = CreateSimulate(ast_id, removable); |
| - AddInstruction(instr); |
| + AddInstruction(instr, position); |
| return instr; |
| } |
| void AssignCommonDominator(HBasicBlock* other); |
| void AssignLoopSuccessorDominators(); |
| - // Add the inlined function exit sequence, adding an HLeaveInlined |
| - // instruction and updating the bailout environment. |
| - void AddLeaveInlined(HValue* return_value, FunctionState* state); |
| - |
| // If a target block is tagged as an inline function return, all |
| // predecessors should contain the inlined exit sequence: |
| // |
| @@ -191,14 +179,29 @@ class HBasicBlock V8_FINAL : public ZoneObject { |
| void Verify(); |
| #endif |
| - private: |
| + protected: |
| friend class HGraphBuilder; |
| + HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
| + void Finish(HControlInstruction* last, int position); |
| + void FinishExit(HControlInstruction* instruction, int position); |
| + void Goto(HBasicBlock* block, |
| + int position, |
| + FunctionState* state = NULL, |
| + bool add_simulate = true); |
| + void GotoNoSimulate(HBasicBlock* block, int position) { |
| + Goto(block, position, NULL, false); |
| + } |
| + // Add the inlined function exit sequence, adding an HLeaveInlined |
|
Michael Starzinger
2013/10/18 13:04:21
nit: Can we add an empty new-line before the comme
danno
2013/10/19 17:11:40
Done.
|
| + // instruction and updating the bailout environment. |
| + void AddLeaveInlined(HValue* return_value, |
| + FunctionState* state, |
| + int position); |
| + |
| + private: |
| void RegisterPredecessor(HBasicBlock* pred); |
| void AddDominatedBlock(HBasicBlock* block); |
| - HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
| - |
| int block_id_; |
| HGraph* graph_; |
| ZoneList<HPhi*> phis_; |
| @@ -940,29 +943,24 @@ class HIfContinuation V8_FINAL { |
| public: |
| HIfContinuation() : continuation_captured_(false) {} |
| HIfContinuation(HBasicBlock* true_branch, |
| - HBasicBlock* false_branch, |
| - int position = RelocInfo::kNoPosition) |
| + HBasicBlock* false_branch) |
| : continuation_captured_(true), true_branch_(true_branch), |
| - false_branch_(false_branch), position_(position) {} |
| + false_branch_(false_branch) {} |
| ~HIfContinuation() { ASSERT(!continuation_captured_); } |
| void Capture(HBasicBlock* true_branch, |
| - HBasicBlock* false_branch, |
| - int position) { |
| + HBasicBlock* false_branch) { |
| ASSERT(!continuation_captured_); |
| true_branch_ = true_branch; |
| false_branch_ = false_branch; |
| - position_ = position; |
| continuation_captured_ = true; |
| } |
| void Continue(HBasicBlock** true_branch, |
| - HBasicBlock** false_branch, |
| - int* position) { |
| + HBasicBlock** false_branch) { |
| ASSERT(continuation_captured_); |
| *true_branch = true_branch_; |
| *false_branch = false_branch_; |
| - if (position != NULL) *position = position_; |
| continuation_captured_ = false; |
| } |
| @@ -979,7 +977,6 @@ class HIfContinuation V8_FINAL { |
| bool continuation_captured_; |
| HBasicBlock* true_branch_; |
| HBasicBlock* false_branch_; |
| - int position_; |
| }; |
| @@ -988,7 +985,8 @@ class HGraphBuilder { |
| explicit HGraphBuilder(CompilationInfo* info) |
| : info_(info), |
| graph_(NULL), |
| - current_block_(NULL) {} |
| + current_block_(NULL), |
| + position_(RelocInfo::kNoPosition) {} |
| virtual ~HGraphBuilder() {} |
| HBasicBlock* current_block() const { return current_block_; } |
| @@ -1011,6 +1009,34 @@ class HGraphBuilder { |
| // Adding instructions. |
| HInstruction* AddInstruction(HInstruction* instr); |
| + void FinishCurrentBlock(HControlInstruction* last); |
| + void FinishExitCurrentBlock(HControlInstruction* instruction); |
| + |
| + void Goto(HBasicBlock* from, |
| + HBasicBlock* target, |
| + FunctionState* state = NULL, |
| + bool add_simulate = true) { |
| + from->Goto(target, position_, state, add_simulate); |
| + } |
| + void Goto(HBasicBlock* target, |
| + FunctionState* state = NULL, |
| + bool add_simulate = true) { |
| + Goto(current_block(), target, state, add_simulate); |
| + } |
| + void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { |
| + Goto(from, target, NULL, false); |
| + } |
| + void GotoNoSimulate(HBasicBlock* target) { |
| + Goto(target, NULL, false); |
| + } |
| + void AddLeaveInlined(HBasicBlock* block, |
| + HValue* return_value, |
| + FunctionState* state) { |
| + block->AddLeaveInlined(return_value, state, position_); |
| + } |
| + void AddLeaveInlined(HValue* return_value, FunctionState* state) { |
| + return AddLeaveInlined(current_block(), return_value, state); |
| + } |
| template<class I> |
| HInstruction* NewUncasted() { return I::New(zone(), context()); } |
| @@ -1205,6 +1231,8 @@ class HGraphBuilder { |
| void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
| + int position() const { return position_; } |
| + |
| protected: |
| virtual bool BuildGraph() = 0; |
| @@ -1306,8 +1334,7 @@ class HGraphBuilder { |
| class IfBuilder V8_FINAL { |
| public: |
| - explicit IfBuilder(HGraphBuilder* builder, |
| - int position = RelocInfo::kNoPosition); |
| + explicit IfBuilder(HGraphBuilder* builder); |
| IfBuilder(HGraphBuilder* builder, |
| HIfContinuation* continuation); |
| @@ -1458,7 +1485,6 @@ class HGraphBuilder { |
| HGraphBuilder* builder() const { return builder_; } |
| HGraphBuilder* builder_; |
| - int position_; |
| bool finished_ : 1; |
| bool deopt_then_ : 1; |
| bool deopt_else_ : 1; |
| @@ -1619,7 +1645,6 @@ class HGraphBuilder { |
| void BuildCompareNil( |
| HValue* value, |
| Handle<Type> type, |
| - int position, |
| HIfContinuation* continuation); |
| HValue* BuildCreateAllocationMemento(HValue* previous_object, |
| @@ -1634,6 +1659,12 @@ class HGraphBuilder { |
| HInstruction* BuildGetNativeContext(); |
| HInstruction* BuildGetArrayFunction(); |
| + protected: |
| + void SetSourcePosition(int position) { |
| + ASSERT(position != RelocInfo::kNoPosition); |
| + position_ = position; |
| + } |
| + |
| private: |
| HGraphBuilder(); |
| @@ -1643,6 +1674,7 @@ class HGraphBuilder { |
| CompilationInfo* info_; |
| HGraph* graph_; |
| HBasicBlock* current_block_; |
| + int position_; |
| }; |
| @@ -1660,7 +1692,7 @@ inline HInstruction* HGraphBuilder::AddUncasted<HDeoptimize>( |
| if (type == Deoptimizer::SOFT) { |
| isolate()->counters()->soft_deopts_inserted()->Increment(); |
| } |
| - current_block()->Finish(instr); |
| + FinishCurrentBlock(instr); |
| set_current_block(after_deopt_block); |
| return instr; |
| } |
| @@ -1694,7 +1726,7 @@ inline HInstruction* HGraphBuilder::AddUncasted<HReturn>(HValue* value) { |
| int num_parameters = graph()->info()->num_parameters(); |
| HValue* params = AddUncasted<HConstant>(num_parameters); |
| HReturn* return_instruction = New<HReturn>(value, params); |
| - current_block()->FinishExit(return_instruction); |
| + FinishExitCurrentBlock(return_instruction); |
| return return_instruction; |
| } |
| @@ -1728,8 +1760,7 @@ inline HInstruction* HGraphBuilder::NewUncasted<HContext>() { |
| } |
| -class HOptimizedGraphBuilder V8_FINAL |
| - : public HGraphBuilder, public AstVisitor { |
| +class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { |
| public: |
| // A class encapsulating (lazily-allocated) break and continue blocks for |
| // a breakable statement. Separated from BreakAndContinueScope so that it |
| @@ -1816,7 +1847,7 @@ class HOptimizedGraphBuilder V8_FINAL |
| DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| - private: |
| + protected: |
| // Type of a member function that generates inline code for a native function. |
| typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) |
| (CallRuntime* call); |
| @@ -2037,13 +2068,11 @@ class HOptimizedGraphBuilder V8_FINAL |
| void HandleGlobalVariableAssignment(Variable* var, |
| HValue* value, |
| - int position, |
| BailoutId ast_id); |
| void HandlePropertyAssignment(Assignment* expr); |
| void HandleCompoundAssignment(Assignment* expr); |
| - void HandlePolymorphicLoadNamedField(int position, |
| - BailoutId ast_id, |
| + void HandlePolymorphicLoadNamedField(BailoutId ast_id, |
| BailoutId return_id, |
| HValue* object, |
| SmallMapList* types, |
| @@ -2140,14 +2169,12 @@ class HOptimizedGraphBuilder V8_FINAL |
| BailoutId return_id, |
| bool can_inline_accessor = true); |
| - void HandlePolymorphicStoreNamedField(int position, |
| - BailoutId assignment_id, |
| + void HandlePolymorphicStoreNamedField(BailoutId assignment_id, |
| HValue* object, |
| HValue* value, |
| SmallMapList* types, |
| Handle<String> name); |
| - bool TryStorePolymorphicAsMonomorphic(int position, |
| - BailoutId assignment_id, |
| + bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, |
| HValue* object, |
| HValue* value, |
| SmallMapList* types, |
| @@ -2197,7 +2224,6 @@ class HOptimizedGraphBuilder V8_FINAL |
| HValue* val, |
| SmallMapList* maps, |
| BailoutId ast_id, |
| - int position, |
| bool is_store, |
| KeyedAccessStoreMode store_mode, |
| bool* has_side_effects); |
| @@ -2207,7 +2233,6 @@ class HOptimizedGraphBuilder V8_FINAL |
| HValue* val, |
| Expression* expr, |
| BailoutId ast_id, |
| - int position, |
| bool is_store, |
| bool* has_side_effects); |
| @@ -2218,12 +2243,10 @@ class HOptimizedGraphBuilder V8_FINAL |
| HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); |
| void BuildLoad(Property* property, |
| - int position, |
| BailoutId ast_id); |
| void PushLoad(Property* property, |
| HValue* object, |
| - HValue* key, |
| - int position); |
| + HValue* key); |
| void BuildStoreForEffect(Expression* expression, |
| Property* prop, |