Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: src/hydrogen.h

Issue 307593002: Preliminary support for block contexts in hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Port to other architectures Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/full-codegen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HYDROGEN_H_ 5 #ifndef V8_HYDROGEN_H_
6 #define V8_HYDROGEN_H_ 6 #define V8_HYDROGEN_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 PretenureFlag pretenure_flag_; 1035 PretenureFlag pretenure_flag_;
1036 }; 1036 };
1037 1037
1038 1038
1039 class HGraphBuilder { 1039 class HGraphBuilder {
1040 public: 1040 public:
1041 explicit HGraphBuilder(CompilationInfo* info) 1041 explicit HGraphBuilder(CompilationInfo* info)
1042 : info_(info), 1042 : info_(info),
1043 graph_(NULL), 1043 graph_(NULL),
1044 current_block_(NULL), 1044 current_block_(NULL),
1045 scope_(info->scope()),
1045 position_(HSourcePosition::Unknown()), 1046 position_(HSourcePosition::Unknown()),
1046 start_position_(0) {} 1047 start_position_(0) {}
1047 virtual ~HGraphBuilder() {} 1048 virtual ~HGraphBuilder() {}
1048 1049
1050 Scope* scope() const { return scope_; }
1051 void set_scope(Scope* scope) { scope_ = scope; }
1052
1049 HBasicBlock* current_block() const { return current_block_; } 1053 HBasicBlock* current_block() const { return current_block_; }
1050 void set_current_block(HBasicBlock* block) { current_block_ = block; } 1054 void set_current_block(HBasicBlock* block) { current_block_ = block; }
1051 HEnvironment* environment() const { 1055 HEnvironment* environment() const {
1052 return current_block()->last_environment(); 1056 return current_block()->last_environment();
1053 } 1057 }
1054 Zone* zone() const { return info_->zone(); } 1058 Zone* zone() const { return info_->zone(); }
1055 HGraph* graph() const { return graph_; } 1059 HGraph* graph() const { return graph_; }
1056 Isolate* isolate() const { return graph_->isolate(); } 1060 Isolate* isolate() const { return graph_->isolate(); }
1057 CompilationInfo* top_info() { return info_; } 1061 CompilationInfo* top_info() { return info_; }
1058 1062
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 int current_probe); 1867 int current_probe);
1864 1868
1865 template <class I> 1869 template <class I>
1866 I* AddInstructionTyped(I* instr) { 1870 I* AddInstructionTyped(I* instr) {
1867 return I::cast(AddInstruction(instr)); 1871 return I::cast(AddInstruction(instr));
1868 } 1872 }
1869 1873
1870 CompilationInfo* info_; 1874 CompilationInfo* info_;
1871 HGraph* graph_; 1875 HGraph* graph_;
1872 HBasicBlock* current_block_; 1876 HBasicBlock* current_block_;
1877 Scope* scope_;
1873 HSourcePosition position_; 1878 HSourcePosition position_;
1874 int start_position_; 1879 int start_position_;
1875 }; 1880 };
1876 1881
1877 1882
1878 template<> 1883 template<>
1879 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( 1884 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1880 const char* reason, Deoptimizer::BailoutType type) { 1885 const char* reason, Deoptimizer::BailoutType type) {
1881 if (type == Deoptimizer::SOFT) { 1886 if (type == Deoptimizer::SOFT) {
1882 isolate()->counters()->soft_deopts_requested()->Increment(); 1887 isolate()->counters()->soft_deopts_requested()->Increment();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 } 1995 }
1991 1996
1992 class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { 1997 class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
1993 public: 1998 public:
1994 // A class encapsulating (lazily-allocated) break and continue blocks for 1999 // A class encapsulating (lazily-allocated) break and continue blocks for
1995 // a breakable statement. Separated from BreakAndContinueScope so that it 2000 // a breakable statement. Separated from BreakAndContinueScope so that it
1996 // can have a separate lifetime. 2001 // can have a separate lifetime.
1997 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED { 2002 class BreakAndContinueInfo V8_FINAL BASE_EMBEDDED {
1998 public: 2003 public:
1999 explicit BreakAndContinueInfo(BreakableStatement* target, 2004 explicit BreakAndContinueInfo(BreakableStatement* target,
2005 Scope* scope,
2000 int drop_extra = 0) 2006 int drop_extra = 0)
2001 : target_(target), 2007 : target_(target),
2002 break_block_(NULL), 2008 break_block_(NULL),
2003 continue_block_(NULL), 2009 continue_block_(NULL),
2010 scope_(scope),
2004 drop_extra_(drop_extra) { 2011 drop_extra_(drop_extra) {
2005 } 2012 }
2006 2013
2007 BreakableStatement* target() { return target_; } 2014 BreakableStatement* target() { return target_; }
2008 HBasicBlock* break_block() { return break_block_; } 2015 HBasicBlock* break_block() { return break_block_; }
2009 void set_break_block(HBasicBlock* block) { break_block_ = block; } 2016 void set_break_block(HBasicBlock* block) { break_block_ = block; }
2010 HBasicBlock* continue_block() { return continue_block_; } 2017 HBasicBlock* continue_block() { return continue_block_; }
2011 void set_continue_block(HBasicBlock* block) { continue_block_ = block; } 2018 void set_continue_block(HBasicBlock* block) { continue_block_ = block; }
2019 Scope* scope() { return scope_; }
2012 int drop_extra() { return drop_extra_; } 2020 int drop_extra() { return drop_extra_; }
2013 2021
2014 private: 2022 private:
2015 BreakableStatement* target_; 2023 BreakableStatement* target_;
2016 HBasicBlock* break_block_; 2024 HBasicBlock* break_block_;
2017 HBasicBlock* continue_block_; 2025 HBasicBlock* continue_block_;
2026 Scope* scope_;
2018 int drop_extra_; 2027 int drop_extra_;
2019 }; 2028 };
2020 2029
2021 // A helper class to maintain a stack of current BreakAndContinueInfo 2030 // A helper class to maintain a stack of current BreakAndContinueInfo
2022 // structures mirroring BreakableStatement nesting. 2031 // structures mirroring BreakableStatement nesting.
2023 class BreakAndContinueScope V8_FINAL BASE_EMBEDDED { 2032 class BreakAndContinueScope V8_FINAL BASE_EMBEDDED {
2024 public: 2033 public:
2025 BreakAndContinueScope(BreakAndContinueInfo* info, 2034 BreakAndContinueScope(BreakAndContinueInfo* info,
2026 HOptimizedGraphBuilder* owner) 2035 HOptimizedGraphBuilder* owner)
2027 : info_(info), owner_(owner), next_(owner->break_scope()) { 2036 : info_(info), owner_(owner), next_(owner->break_scope()) {
2028 owner->set_break_scope(this); 2037 owner->set_break_scope(this);
2029 } 2038 }
2030 2039
2031 ~BreakAndContinueScope() { owner_->set_break_scope(next_); } 2040 ~BreakAndContinueScope() { owner_->set_break_scope(next_); }
2032 2041
2033 BreakAndContinueInfo* info() { return info_; } 2042 BreakAndContinueInfo* info() { return info_; }
2034 HOptimizedGraphBuilder* owner() { return owner_; } 2043 HOptimizedGraphBuilder* owner() { return owner_; }
2035 BreakAndContinueScope* next() { return next_; } 2044 BreakAndContinueScope* next() { return next_; }
2036 2045
2037 // Search the break stack for a break or continue target. 2046 // Search the break stack for a break or continue target.
2038 enum BreakType { BREAK, CONTINUE }; 2047 enum BreakType { BREAK, CONTINUE };
2039 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); 2048 HBasicBlock* Get(BreakableStatement* stmt, BreakType type,
2049 Scope** scope, int* drop_extra);
2040 2050
2041 private: 2051 private:
2042 BreakAndContinueInfo* info_; 2052 BreakAndContinueInfo* info_;
2043 HOptimizedGraphBuilder* owner_; 2053 HOptimizedGraphBuilder* owner_;
2044 BreakAndContinueScope* next_; 2054 BreakAndContinueScope* next_;
2045 }; 2055 };
2046 2056
2047 explicit HOptimizedGraphBuilder(CompilationInfo* info); 2057 explicit HOptimizedGraphBuilder(CompilationInfo* info);
2048 2058
2049 virtual bool BuildGraph() V8_OVERRIDE; 2059 virtual bool BuildGraph() V8_OVERRIDE;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 void VisitVoid(UnaryOperation* expr); 2149 void VisitVoid(UnaryOperation* expr);
2140 void VisitTypeof(UnaryOperation* expr); 2150 void VisitTypeof(UnaryOperation* expr);
2141 void VisitNot(UnaryOperation* expr); 2151 void VisitNot(UnaryOperation* expr);
2142 2152
2143 void VisitComma(BinaryOperation* expr); 2153 void VisitComma(BinaryOperation* expr);
2144 void VisitLogicalExpression(BinaryOperation* expr); 2154 void VisitLogicalExpression(BinaryOperation* expr);
2145 void VisitArithmeticExpression(BinaryOperation* expr); 2155 void VisitArithmeticExpression(BinaryOperation* expr);
2146 2156
2147 bool PreProcessOsrEntry(IterationStatement* statement); 2157 bool PreProcessOsrEntry(IterationStatement* statement);
2148 void VisitLoopBody(IterationStatement* stmt, 2158 void VisitLoopBody(IterationStatement* stmt,
2149 HBasicBlock* loop_entry, 2159 HBasicBlock* loop_entry);
2150 BreakAndContinueInfo* break_info);
2151 2160
2152 // Create a back edge in the flow graph. body_exit is the predecessor 2161 // Create a back edge in the flow graph. body_exit is the predecessor
2153 // block and loop_entry is the successor block. loop_successor is the 2162 // block and loop_entry is the successor block. loop_successor is the
2154 // block where control flow exits the loop normally (e.g., via failure of 2163 // block where control flow exits the loop normally (e.g., via failure of
2155 // the condition) and break_block is the block where control flow breaks 2164 // the condition) and break_block is the block where control flow breaks
2156 // from the loop. All blocks except loop_entry can be NULL. The return 2165 // from the loop. All blocks except loop_entry can be NULL. The return
2157 // value is the new successor block which is the join of loop_successor 2166 // value is the new successor block which is the join of loop_successor
2158 // and break_block, or NULL. 2167 // and break_block, or NULL.
2159 HBasicBlock* CreateLoop(IterationStatement* statement, 2168 HBasicBlock* CreateLoop(IterationStatement* statement,
2160 HBasicBlock* loop_entry, 2169 HBasicBlock* loop_entry,
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 } 2839 }
2831 2840
2832 private: 2841 private:
2833 HGraphBuilder* builder_; 2842 HGraphBuilder* builder_;
2834 }; 2843 };
2835 2844
2836 2845
2837 } } // namespace v8::internal 2846 } } // namespace v8::internal
2838 2847
2839 #endif // V8_HYDROGEN_H_ 2848 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698