OLD | NEW |
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_CRANKSHAFT_HYDROGEN_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_H_ |
7 | 7 |
8 #include "src/accessors.h" | 8 #include "src/accessors.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/ast/ast-type-bounds.h" | 10 #include "src/ast/ast-type-bounds.h" |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 private: | 1058 private: |
1059 HValue* current_site_; | 1059 HValue* current_site_; |
1060 Handle<AllocationSite> feedback_site_; | 1060 Handle<AllocationSite> feedback_site_; |
1061 PretenureFlag pretenure_flag_; | 1061 PretenureFlag pretenure_flag_; |
1062 }; | 1062 }; |
1063 | 1063 |
1064 | 1064 |
1065 class HGraphBuilder { | 1065 class HGraphBuilder { |
1066 public: | 1066 public: |
1067 explicit HGraphBuilder(CompilationInfo* info, | 1067 explicit HGraphBuilder(CompilationInfo* info, |
1068 CallInterfaceDescriptor descriptor) | 1068 CallInterfaceDescriptor descriptor, |
| 1069 bool track_positions) |
1069 : info_(info), | 1070 : info_(info), |
1070 descriptor_(descriptor), | 1071 descriptor_(descriptor), |
1071 graph_(NULL), | 1072 graph_(NULL), |
1072 current_block_(NULL), | 1073 current_block_(NULL), |
1073 scope_(info->scope()), | 1074 scope_(info->scope()), |
1074 position_(SourcePosition::Unknown()), | 1075 position_(SourcePosition::Unknown()), |
1075 start_position_(0) {} | 1076 start_position_(0), |
| 1077 track_positions_(track_positions) {} |
1076 virtual ~HGraphBuilder() {} | 1078 virtual ~HGraphBuilder() {} |
1077 | 1079 |
1078 Scope* scope() const { return scope_; } | 1080 Scope* scope() const { return scope_; } |
1079 void set_scope(Scope* scope) { scope_ = scope; } | 1081 void set_scope(Scope* scope) { scope_ = scope; } |
1080 | 1082 |
1081 HBasicBlock* current_block() const { return current_block_; } | 1083 HBasicBlock* current_block() const { return current_block_; } |
1082 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 1084 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
1083 HEnvironment* environment() const { | 1085 HEnvironment* environment() const { |
1084 return current_block()->last_environment(); | 1086 return current_block()->last_environment(); |
1085 } | 1087 } |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 | 1869 |
1868 protected: | 1870 protected: |
1869 void SetSourcePosition(int position) { | 1871 void SetSourcePosition(int position) { |
1870 if (position != kNoSourcePosition) { | 1872 if (position != kNoSourcePosition) { |
1871 position_.set_position(position - start_position_); | 1873 position_.set_position(position - start_position_); |
1872 } | 1874 } |
1873 // Otherwise position remains unknown. | 1875 // Otherwise position remains unknown. |
1874 } | 1876 } |
1875 | 1877 |
1876 void EnterInlinedSource(int start_position, int id) { | 1878 void EnterInlinedSource(int start_position, int id) { |
1877 if (top_info()->is_tracking_positions()) { | 1879 if (is_tracking_positions()) { |
1878 start_position_ = start_position; | 1880 start_position_ = start_position; |
1879 position_.set_inlining_id(id); | 1881 position_.set_inlining_id(id); |
1880 } | 1882 } |
1881 } | 1883 } |
1882 | 1884 |
1883 // Convert the given absolute offset from the start of the script to | 1885 // Convert the given absolute offset from the start of the script to |
1884 // the SourcePosition assuming that this position corresponds to the | 1886 // the SourcePosition assuming that this position corresponds to the |
1885 // same function as current position_. | 1887 // same function as current position_. |
1886 SourcePosition ScriptPositionToSourcePosition(int position) { | 1888 SourcePosition ScriptPositionToSourcePosition(int position) { |
1887 if (position == kNoSourcePosition) { | 1889 if (position == kNoSourcePosition) { |
1888 return SourcePosition::Unknown(); | 1890 return SourcePosition::Unknown(); |
1889 } | 1891 } |
1890 SourcePosition pos = position_; | 1892 SourcePosition pos = position_; |
1891 pos.set_position(position - start_position_); | 1893 pos.set_position(position - start_position_); |
1892 return pos; | 1894 return pos; |
1893 } | 1895 } |
1894 | 1896 |
1895 SourcePosition source_position() { return position_; } | 1897 SourcePosition source_position() { return position_; } |
1896 void set_source_position(SourcePosition position) { position_ = position; } | 1898 void set_source_position(SourcePosition position) { position_ = position; } |
1897 | 1899 |
| 1900 bool is_tracking_positions() { return track_positions_; } |
| 1901 |
1898 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 1902 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
1899 SourcePosition position); | 1903 SourcePosition position); |
1900 | 1904 |
1901 HValue* BuildAllocateEmptyArrayBuffer(HValue* byte_length); | 1905 HValue* BuildAllocateEmptyArrayBuffer(HValue* byte_length); |
1902 template <typename ViewClass> | 1906 template <typename ViewClass> |
1903 void BuildArrayBufferViewInitialization(HValue* obj, | 1907 void BuildArrayBufferViewInitialization(HValue* obj, |
1904 HValue* buffer, | 1908 HValue* buffer, |
1905 HValue* byte_offset, | 1909 HValue* byte_offset, |
1906 HValue* byte_length); | 1910 HValue* byte_length); |
1907 | 1911 |
1908 private: | 1912 private: |
1909 HGraphBuilder(); | 1913 HGraphBuilder(); |
1910 | 1914 |
1911 template <class I> | 1915 template <class I> |
1912 I* AddInstructionTyped(I* instr) { | 1916 I* AddInstructionTyped(I* instr) { |
1913 return I::cast(AddInstruction(instr)); | 1917 return I::cast(AddInstruction(instr)); |
1914 } | 1918 } |
1915 | 1919 |
1916 CompilationInfo* info_; | 1920 CompilationInfo* info_; |
1917 CallInterfaceDescriptor descriptor_; | 1921 CallInterfaceDescriptor descriptor_; |
1918 HGraph* graph_; | 1922 HGraph* graph_; |
1919 HBasicBlock* current_block_; | 1923 HBasicBlock* current_block_; |
1920 Scope* scope_; | 1924 Scope* scope_; |
1921 SourcePosition position_; | 1925 SourcePosition position_; |
1922 int start_position_; | 1926 int start_position_; |
| 1927 bool track_positions_; |
1923 }; | 1928 }; |
1924 | 1929 |
1925 template <> | 1930 template <> |
1926 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1931 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
1927 DeoptimizeReason reason, Deoptimizer::BailoutType type) { | 1932 DeoptimizeReason reason, Deoptimizer::BailoutType type) { |
1928 if (type == Deoptimizer::SOFT) { | 1933 if (type == Deoptimizer::SOFT) { |
1929 isolate()->counters()->soft_deopts_requested()->Increment(); | 1934 isolate()->counters()->soft_deopts_requested()->Increment(); |
1930 if (FLAG_always_opt) return NULL; | 1935 if (FLAG_always_opt) return NULL; |
1931 } | 1936 } |
1932 if (current_block()->IsDeoptimizing()) return NULL; | 1937 if (current_block()->IsDeoptimizing()) return NULL; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 enum BreakType { BREAK, CONTINUE }; | 2115 enum BreakType { BREAK, CONTINUE }; |
2111 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, | 2116 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, |
2112 Scope** scope, int* drop_extra); | 2117 Scope** scope, int* drop_extra); |
2113 | 2118 |
2114 private: | 2119 private: |
2115 BreakAndContinueInfo* info_; | 2120 BreakAndContinueInfo* info_; |
2116 HOptimizedGraphBuilder* owner_; | 2121 HOptimizedGraphBuilder* owner_; |
2117 BreakAndContinueScope* next_; | 2122 BreakAndContinueScope* next_; |
2118 }; | 2123 }; |
2119 | 2124 |
2120 explicit HOptimizedGraphBuilder(CompilationInfo* info); | 2125 explicit HOptimizedGraphBuilder(CompilationInfo* info, bool track_positions); |
2121 | 2126 |
2122 bool BuildGraph() override; | 2127 bool BuildGraph() override; |
2123 | 2128 |
2124 // Simple accessors. | 2129 // Simple accessors. |
2125 BreakAndContinueScope* break_scope() const { return break_scope_; } | 2130 BreakAndContinueScope* break_scope() const { return break_scope_; } |
2126 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 2131 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
2127 | 2132 |
2128 HValue* context() override { return environment()->context(); } | 2133 HValue* context() override { return environment()->context(); } |
2129 | 2134 |
2130 HOsrBuilder* osr() const { return osr_; } | 2135 HOsrBuilder* osr() const { return osr_; } |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3032 } | 3037 } |
3033 | 3038 |
3034 private: | 3039 private: |
3035 HOptimizedGraphBuilder* builder_; | 3040 HOptimizedGraphBuilder* builder_; |
3036 }; | 3041 }; |
3037 | 3042 |
3038 } // namespace internal | 3043 } // namespace internal |
3039 } // namespace v8 | 3044 } // namespace v8 |
3040 | 3045 |
3041 #endif // V8_CRANKSHAFT_HYDROGEN_H_ | 3046 #endif // V8_CRANKSHAFT_HYDROGEN_H_ |
OLD | NEW |