Chromium Code Reviews| Index: src/hydrogen.h |
| diff --git a/src/hydrogen.h b/src/hydrogen.h |
| index 98b05d147a290d67e10cbe57daae8bc2f73b02ea..ac115ee01e73bc9ec7b89ec70c50edac58f9eb2e 100644 |
| --- a/src/hydrogen.h |
| +++ b/src/hydrogen.h |
| @@ -429,7 +429,8 @@ enum FrameType { |
| JS_CONSTRUCT, |
| JS_GETTER, |
| JS_SETTER, |
| - ARGUMENTS_ADAPTOR |
| + ARGUMENTS_ADAPTOR, |
| + STUB |
| }; |
| @@ -440,6 +441,8 @@ class HEnvironment: public ZoneObject { |
| Handle<JSFunction> closure, |
| Zone* zone); |
| + explicit HEnvironment(Zone* zone); |
| + |
| HEnvironment* arguments_environment() { |
| return outer()->frame_type() == ARGUMENTS_ADAPTOR ? outer() : this; |
| } |
| @@ -636,7 +639,7 @@ class HInferRepresentation BASE_EMBEDDED { |
| }; |
| -class HGraphBuilder; |
| +class HOptimizedGraphBuilder; |
| enum ArgumentsAllowedFlag { |
| ARGUMENTS_NOT_ALLOWED, |
| @@ -672,10 +675,10 @@ class AstContext { |
| bool is_for_typeof() { return for_typeof_; } |
| protected: |
| - AstContext(HGraphBuilder* owner, Expression::Context kind); |
| + AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind); |
| virtual ~AstContext(); |
| - HGraphBuilder* owner() const { return owner_; } |
| + HOptimizedGraphBuilder* owner() const { return owner_; } |
| inline Zone* zone() const; |
| @@ -686,7 +689,7 @@ class AstContext { |
| #endif |
| private: |
| - HGraphBuilder* owner_; |
| + HOptimizedGraphBuilder* owner_; |
| Expression::Context kind_; |
| AstContext* outer_; |
| bool for_typeof_; |
| @@ -695,7 +698,7 @@ class AstContext { |
| class EffectContext: public AstContext { |
| public: |
| - explicit EffectContext(HGraphBuilder* owner) |
| + explicit EffectContext(HOptimizedGraphBuilder* owner) |
| : AstContext(owner, Expression::kEffect) { |
| } |
| virtual ~EffectContext(); |
| @@ -708,7 +711,8 @@ class EffectContext: public AstContext { |
| class ValueContext: public AstContext { |
| public: |
| - explicit ValueContext(HGraphBuilder* owner, ArgumentsAllowedFlag flag) |
| + explicit ValueContext(HOptimizedGraphBuilder* owner, |
|
Jakob Kummerow
2012/11/28 16:28:22
nit: no need for "explicit"
danno
2012/11/30 16:23:24
Done.
|
| + ArgumentsAllowedFlag flag) |
| : AstContext(owner, Expression::kValue), flag_(flag) { |
| } |
| virtual ~ValueContext(); |
| @@ -726,7 +730,7 @@ class ValueContext: public AstContext { |
| class TestContext: public AstContext { |
| public: |
| - TestContext(HGraphBuilder* owner, |
| + TestContext(HOptimizedGraphBuilder* owner, |
| Expression* condition, |
| TypeFeedbackOracle* oracle, |
| HBasicBlock* if_true, |
| @@ -766,7 +770,7 @@ class TestContext: public AstContext { |
| class FunctionState { |
| public: |
| - FunctionState(HGraphBuilder* owner, |
| + FunctionState(HOptimizedGraphBuilder* owner, |
| CompilationInfo* info, |
| TypeFeedbackOracle* oracle, |
| InliningKind inlining_kind); |
| @@ -796,7 +800,7 @@ class FunctionState { |
| bool arguments_pushed() { return arguments_elements() != NULL; } |
| private: |
| - HGraphBuilder* owner_; |
| + HOptimizedGraphBuilder* owner_; |
| CompilationInfo* compilation_info_; |
| TypeFeedbackOracle* oracle_; |
| @@ -828,7 +832,65 @@ class FunctionState { |
| }; |
| -class HGraphBuilder: public AstVisitor { |
| +class HGraphBuilder { |
| + public: |
| + explicit HGraphBuilder(CompilationInfo* info) |
| + : info_(info), graph_(NULL), current_block_(NULL) {} |
| + virtual ~HGraphBuilder() {} |
| + |
| + HBasicBlock* current_block() const { return current_block_; } |
| + void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| + HEnvironment* environment() const { |
| + return current_block()->last_environment(); |
| + } |
| + Zone* zone() const { return info_->zone(); } |
| + HGraph* graph() { return graph_; } |
| + |
| + HGraph* CreateGraph(); |
| + |
| + // Adding instructions. |
| + HInstruction* AddInstruction(HInstruction* instr); |
| + void AddSimulate(BailoutId id, |
| + RemovableSimulate removable = FIXED_SIMULATE); |
| + |
| + protected: |
| + virtual bool BuildGraph() = 0; |
| + |
| + // Building common constructs |
| + HInstruction* BuildExternalArrayElementAccess( |
| + HValue* external_elements, |
| + HValue* checked_key, |
| + HValue* val, |
| + HValue* dependency, |
| + ElementsKind elements_kind, |
| + bool is_store); |
| + |
| + HInstruction* BuildFastElementAccess( |
| + HValue* elements, |
| + HValue* checked_key, |
| + HValue* val, |
| + HValue* dependency, |
| + ElementsKind elements_kind, |
| + bool is_store); |
| + |
| + HInstruction* BuildUncheckedMonomorphicElementAccess( |
| + HValue* object, |
| + HValue* key, |
| + HValue* val, |
| + HCheckMaps* mapcheck, |
| + bool is_js_array, |
| + ElementsKind elements_kind, |
| + bool is_store); |
| + |
| + private: |
| + HGraphBuilder(); |
| + CompilationInfo* info_; |
| + HGraph* graph_; |
| + HBasicBlock* current_block_; |
| +}; |
| + |
| + |
| +class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { |
| public: |
| enum BreakType { BREAK, CONTINUE }; |
| enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH }; |
| @@ -864,7 +926,8 @@ class HGraphBuilder: public AstVisitor { |
| // structures mirroring BreakableStatement nesting. |
| class BreakAndContinueScope BASE_EMBEDDED { |
| public: |
| - BreakAndContinueScope(BreakAndContinueInfo* info, HGraphBuilder* owner) |
| + BreakAndContinueScope(BreakAndContinueInfo* info, |
| + HOptimizedGraphBuilder* owner) |
| : info_(info), owner_(owner), next_(owner->break_scope()) { |
| owner->set_break_scope(this); |
| } |
| @@ -872,7 +935,7 @@ class HGraphBuilder: public AstVisitor { |
| ~BreakAndContinueScope() { owner_->set_break_scope(next_); } |
| BreakAndContinueInfo* info() { return info_; } |
| - HGraphBuilder* owner() { return owner_; } |
| + HOptimizedGraphBuilder* owner() { return owner_; } |
| BreakAndContinueScope* next() { return next_; } |
| // Search the break stack for a break or continue target. |
| @@ -880,32 +943,20 @@ class HGraphBuilder: public AstVisitor { |
| private: |
| BreakAndContinueInfo* info_; |
| - HGraphBuilder* owner_; |
| + HOptimizedGraphBuilder* owner_; |
| BreakAndContinueScope* next_; |
| }; |
| - HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); |
| + HOptimizedGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); |
| - HGraph* CreateGraph(); |
| + virtual bool BuildGraph(); |
| // Simple accessors. |
| - HGraph* graph() const { return graph_; } |
| BreakAndContinueScope* break_scope() const { return break_scope_; } |
| void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| - HBasicBlock* current_block() const { return current_block_; } |
| - void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| - HEnvironment* environment() const { |
| - return current_block()->last_environment(); |
| - } |
| - |
| bool inline_bailout() { return inline_bailout_; } |
| - // Adding instructions. |
| - HInstruction* AddInstruction(HInstruction* instr); |
| - void AddSimulate(BailoutId ast_id, |
| - RemovableSimulate removable = FIXED_SIMULATE); |
| - |
| // Bailout environment manipulation. |
| void Push(HValue* value) { environment()->Push(value); } |
| HValue* Pop() { return environment()->Pop(); } |
| @@ -930,7 +981,8 @@ class HGraphBuilder: public AstVisitor { |
| private: |
| // Type of a member function that generates inline code for a native function. |
| - typedef void (HGraphBuilder::*InlineFunctionGenerator)(CallRuntime* call); |
| + typedef void (HOptimizedGraphBuilder::*InlineFunctionGenerator) |
| + (CallRuntime* call); |
| // Forward declarations for inner scope classes. |
| class SubgraphScope; |
| @@ -1139,25 +1191,14 @@ class HGraphBuilder: public AstVisitor { |
| HValue* right); |
| HInstruction* BuildIncrement(bool returns_original_input, |
| CountOperation* expr); |
| - HInstruction* BuildFastElementAccess(HValue* elements, |
| - HValue* checked_key, |
| - HValue* val, |
| - HValue* dependency, |
| - ElementsKind elements_kind, |
| - bool is_store); |
| + HInstruction* BuildLoadKeyedGeneric(HValue* object, |
| + HValue* key); |
| HInstruction* TryBuildConsolidatedElementLoad(HValue* object, |
| HValue* key, |
| HValue* val, |
| SmallMapList* maps); |
| - HInstruction* BuildUncheckedMonomorphicElementAccess(HValue* object, |
| - HValue* key, |
| - HValue* val, |
| - HCheckMaps* mapcheck, |
| - Handle<Map> map, |
| - bool is_store); |
| - |
| HInstruction* BuildMonomorphicElementAccess(HValue* object, |
| HValue* key, |
| HValue* val, |
| @@ -1197,14 +1238,6 @@ class HGraphBuilder: public AstVisitor { |
| Handle<String> name, |
| Property* expr, |
| Handle<Map> map); |
| - HInstruction* BuildLoadKeyedGeneric(HValue* object, HValue* key); |
| - HInstruction* BuildExternalArrayElementAccess( |
| - HValue* external_elements, |
| - HValue* checked_key, |
| - HValue* val, |
| - HValue* dependency, |
| - ElementsKind elements_kind, |
| - bool is_store); |
| void AddCheckMapsWithTransitions(HValue* object, |
| Handle<Map> map); |
| @@ -1246,8 +1279,6 @@ class HGraphBuilder: public AstVisitor { |
| HValue** operand, |
| HValue** shift_amount); |
| - Zone* zone() const { return zone_; } |
| - |
| // The translation state of the currently-being-translated function. |
| FunctionState* function_state_; |
| @@ -1261,20 +1292,17 @@ class HGraphBuilder: public AstVisitor { |
| // A stack of breakable statements entered. |
| BreakAndContinueScope* break_scope_; |
| - HGraph* graph_; |
| - HBasicBlock* current_block_; |
| - |
| int inlined_count_; |
| ZoneList<Handle<Object> > globals_; |
| - Zone* zone_; |
| - |
| bool inline_bailout_; |
| friend class FunctionState; // Pushes and pops the state stack. |
| friend class AstContext; // Pushes and pops the AST context stack. |
| + friend class KeyedLoadFastElementStub; |
| - DISALLOW_COPY_AND_ASSIGN(HGraphBuilder); |
| + DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
|
Jakob Kummerow
2012/11/28 16:28:22
These used to be public; did you move them to the
danno
2012/11/30 16:23:24
Done.
Jakob Kummerow
2012/11/30 16:43:02
Actually, since the macro's expansions contains ap
|
| + DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); |
| }; |
| @@ -1447,7 +1475,7 @@ class HPhase BASE_EMBEDDED { |
| class HTracer: public Malloced { |
| public: |
| - void TraceCompilation(FunctionLiteral* function); |
| + void TraceCompilation(CompilationInfo* info); |
| void TraceHydrogen(const char* name, HGraph* graph); |
| void TraceLithium(const char* name, LChunk* chunk); |
| void TraceLiveRanges(const char* name, LAllocator* allocator); |