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

Side by Side Diff: src/hydrogen.h

Issue 928343003: CpuProfile: rename HSourcePosition to SourcePosition and move it to compiler.* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 5 years, 10 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
« no previous file with comments | « src/compiler.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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 void AttachLoopInformation(); 82 void AttachLoopInformation();
83 void DetachLoopInformation(); 83 void DetachLoopInformation();
84 bool IsLoopHeader() const { return loop_information() != NULL; } 84 bool IsLoopHeader() const { return loop_information() != NULL; }
85 bool IsStartBlock() const { return block_id() == 0; } 85 bool IsStartBlock() const { return block_id() == 0; }
86 void PostProcessLoopHeader(IterationStatement* stmt); 86 void PostProcessLoopHeader(IterationStatement* stmt);
87 87
88 bool IsFinished() const { return end_ != NULL; } 88 bool IsFinished() const { return end_ != NULL; }
89 void AddPhi(HPhi* phi); 89 void AddPhi(HPhi* phi);
90 void RemovePhi(HPhi* phi); 90 void RemovePhi(HPhi* phi);
91 void AddInstruction(HInstruction* instr, HSourcePosition position); 91 void AddInstruction(HInstruction* instr, SourcePosition position);
92 bool Dominates(HBasicBlock* other) const; 92 bool Dominates(HBasicBlock* other) const;
93 bool EqualToOrDominates(HBasicBlock* other) const; 93 bool EqualToOrDominates(HBasicBlock* other) const;
94 int LoopNestingDepth() const; 94 int LoopNestingDepth() const;
95 95
96 void SetInitialEnvironment(HEnvironment* env); 96 void SetInitialEnvironment(HEnvironment* env);
97 void ClearEnvironment() { 97 void ClearEnvironment() {
98 DCHECK(IsFinished()); 98 DCHECK(IsFinished());
99 DCHECK(end()->SuccessorCount() == 0); 99 DCHECK(end()->SuccessorCount() == 0);
100 last_environment_ = NULL; 100 last_environment_ = NULL;
101 } 101 }
102 bool HasEnvironment() const { return last_environment_ != NULL; } 102 bool HasEnvironment() const { return last_environment_ != NULL; }
103 void UpdateEnvironment(HEnvironment* env); 103 void UpdateEnvironment(HEnvironment* env);
104 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } 104 HBasicBlock* parent_loop_header() const { return parent_loop_header_; }
105 105
106 void set_parent_loop_header(HBasicBlock* block) { 106 void set_parent_loop_header(HBasicBlock* block) {
107 DCHECK(parent_loop_header_ == NULL); 107 DCHECK(parent_loop_header_ == NULL);
108 parent_loop_header_ = block; 108 parent_loop_header_ = block;
109 } 109 }
110 110
111 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } 111 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; }
112 112
113 void SetJoinId(BailoutId ast_id); 113 void SetJoinId(BailoutId ast_id);
114 114
115 int PredecessorIndexOf(HBasicBlock* predecessor) const; 115 int PredecessorIndexOf(HBasicBlock* predecessor) const;
116 HPhi* AddNewPhi(int merged_index); 116 HPhi* AddNewPhi(int merged_index);
117 HSimulate* AddNewSimulate(BailoutId ast_id, 117 HSimulate* AddNewSimulate(BailoutId ast_id, SourcePosition position,
118 HSourcePosition position,
119 RemovableSimulate removable = FIXED_SIMULATE) { 118 RemovableSimulate removable = FIXED_SIMULATE) {
120 HSimulate* instr = CreateSimulate(ast_id, removable); 119 HSimulate* instr = CreateSimulate(ast_id, removable);
121 AddInstruction(instr, position); 120 AddInstruction(instr, position);
122 return instr; 121 return instr;
123 } 122 }
124 void AssignCommonDominator(HBasicBlock* other); 123 void AssignCommonDominator(HBasicBlock* other);
125 void AssignLoopSuccessorDominators(); 124 void AssignLoopSuccessorDominators();
126 125
127 // If a target block is tagged as an inline function return, all 126 // If a target block is tagged as an inline function return, all
128 // predecessors should contain the inlined exit sequence: 127 // predecessors should contain the inlined exit sequence:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 inline Zone* zone() const; 159 inline Zone* zone() const;
161 160
162 #ifdef DEBUG 161 #ifdef DEBUG
163 void Verify(); 162 void Verify();
164 #endif 163 #endif
165 164
166 protected: 165 protected:
167 friend class HGraphBuilder; 166 friend class HGraphBuilder;
168 167
169 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); 168 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
170 void Finish(HControlInstruction* last, HSourcePosition position); 169 void Finish(HControlInstruction* last, SourcePosition position);
171 void FinishExit(HControlInstruction* instruction, HSourcePosition position); 170 void FinishExit(HControlInstruction* instruction, SourcePosition position);
172 void Goto(HBasicBlock* block, 171 void Goto(HBasicBlock* block, SourcePosition position,
173 HSourcePosition position, 172 FunctionState* state = NULL, bool add_simulate = true);
174 FunctionState* state = NULL, 173 void GotoNoSimulate(HBasicBlock* block, SourcePosition position) {
175 bool add_simulate = true);
176 void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) {
177 Goto(block, position, NULL, false); 174 Goto(block, position, NULL, false);
178 } 175 }
179 176
180 // Add the inlined function exit sequence, adding an HLeaveInlined 177 // Add the inlined function exit sequence, adding an HLeaveInlined
181 // instruction and updating the bailout environment. 178 // instruction and updating the bailout environment.
182 void AddLeaveInlined(HValue* return_value, 179 void AddLeaveInlined(HValue* return_value, FunctionState* state,
183 FunctionState* state, 180 SourcePosition position);
184 HSourcePosition position);
185 181
186 private: 182 private:
187 void RegisterPredecessor(HBasicBlock* pred); 183 void RegisterPredecessor(HBasicBlock* pred);
188 void AddDominatedBlock(HBasicBlock* block); 184 void AddDominatedBlock(HBasicBlock* block);
189 185
190 int block_id_; 186 int block_id_;
191 HGraph* graph_; 187 HGraph* graph_;
192 ZoneList<HPhi*> phis_; 188 ZoneList<HPhi*> phis_;
193 HInstruction* first_; 189 HInstruction* first_;
194 HInstruction* last_; 190 HInstruction* last_;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 450 }
455 451
456 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } 452 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; }
457 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } 453 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; }
458 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } 454 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; }
459 455
460 // If we are tracking source positions then this function assigns a unique 456 // If we are tracking source positions then this function assigns a unique
461 // identifier to each inlining and dumps function source if it was inlined 457 // identifier to each inlining and dumps function source if it was inlined
462 // for the first time during the current optimization. 458 // for the first time during the current optimization.
463 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, 459 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
464 HSourcePosition position); 460 SourcePosition position);
465 461
466 // Converts given HSourcePosition to the absolute offset from the start of 462 // Converts given SourcePosition to the absolute offset from the start of
467 // the corresponding script. 463 // the corresponding script.
468 int SourcePositionToScriptPosition(HSourcePosition position); 464 int SourcePositionToScriptPosition(SourcePosition position);
469 465
470 private: 466 private:
471 HConstant* ReinsertConstantIfNecessary(HConstant* constant); 467 HConstant* ReinsertConstantIfNecessary(HConstant* constant);
472 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, 468 HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
473 int32_t integer_value); 469 int32_t integer_value);
474 470
475 template<class Phase> 471 template<class Phase>
476 void Run() { 472 void Run() {
477 Phase phase(this); 473 Phase phase(this);
478 phase.Run(); 474 phase.Run();
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 TestContext* test_context_; 930 TestContext* test_context_;
935 931
936 // When inlining HEnterInlined instruction corresponding to the function 932 // When inlining HEnterInlined instruction corresponding to the function
937 // entry. 933 // entry.
938 HEnterInlined* entry_; 934 HEnterInlined* entry_;
939 935
940 HArgumentsObject* arguments_object_; 936 HArgumentsObject* arguments_object_;
941 HArgumentsElements* arguments_elements_; 937 HArgumentsElements* arguments_elements_;
942 938
943 int inlining_id_; 939 int inlining_id_;
944 HSourcePosition outer_source_position_; 940 SourcePosition outer_source_position_;
945 941
946 FunctionState* outer_; 942 FunctionState* outer_;
947 }; 943 };
948 944
949 945
950 class HIfContinuation FINAL { 946 class HIfContinuation FINAL {
951 public: 947 public:
952 HIfContinuation() 948 HIfContinuation()
953 : continuation_captured_(false), 949 : continuation_captured_(false),
954 true_branch_(NULL), 950 true_branch_(NULL),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 }; 1018 };
1023 1019
1024 1020
1025 class HGraphBuilder { 1021 class HGraphBuilder {
1026 public: 1022 public:
1027 explicit HGraphBuilder(CompilationInfo* info) 1023 explicit HGraphBuilder(CompilationInfo* info)
1028 : info_(info), 1024 : info_(info),
1029 graph_(NULL), 1025 graph_(NULL),
1030 current_block_(NULL), 1026 current_block_(NULL),
1031 scope_(info->scope()), 1027 scope_(info->scope()),
1032 position_(HSourcePosition::Unknown()), 1028 position_(SourcePosition::Unknown()),
1033 start_position_(0) {} 1029 start_position_(0) {}
1034 virtual ~HGraphBuilder() {} 1030 virtual ~HGraphBuilder() {}
1035 1031
1036 Scope* scope() const { return scope_; } 1032 Scope* scope() const { return scope_; }
1037 void set_scope(Scope* scope) { scope_ = scope; } 1033 void set_scope(Scope* scope) { scope_ = scope; }
1038 1034
1039 HBasicBlock* current_block() const { return current_block_; } 1035 HBasicBlock* current_block() const { return current_block_; }
1040 void set_current_block(HBasicBlock* block) { current_block_ = block; } 1036 void set_current_block(HBasicBlock* block) { current_block_ = block; }
1041 HEnvironment* environment() const { 1037 HEnvironment* environment() const {
1042 return current_block()->last_environment(); 1038 return current_block()->last_environment();
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 } 1874 }
1879 1875
1880 void EnterInlinedSource(int start_position, int id) { 1876 void EnterInlinedSource(int start_position, int id) {
1881 if (FLAG_hydrogen_track_positions) { 1877 if (FLAG_hydrogen_track_positions) {
1882 start_position_ = start_position; 1878 start_position_ = start_position;
1883 position_.set_inlining_id(id); 1879 position_.set_inlining_id(id);
1884 } 1880 }
1885 } 1881 }
1886 1882
1887 // Convert the given absolute offset from the start of the script to 1883 // Convert the given absolute offset from the start of the script to
1888 // the HSourcePosition assuming that this position corresponds to the 1884 // the SourcePosition assuming that this position corresponds to the
1889 // same function as current position_. 1885 // same function as current position_.
1890 HSourcePosition ScriptPositionToSourcePosition(int position) { 1886 SourcePosition ScriptPositionToSourcePosition(int position) {
1891 HSourcePosition pos = position_; 1887 SourcePosition pos = position_;
1892 pos.set_position(position - start_position_); 1888 pos.set_position(position - start_position_);
1893 return pos; 1889 return pos;
1894 } 1890 }
1895 1891
1896 HSourcePosition source_position() { return position_; } 1892 SourcePosition source_position() { return position_; }
1897 void set_source_position(HSourcePosition position) { 1893 void set_source_position(SourcePosition position) { position_ = position; }
1898 position_ = position;
1899 }
1900 1894
1901 template <typename ViewClass> 1895 template <typename ViewClass>
1902 void BuildArrayBufferViewInitialization(HValue* obj, 1896 void BuildArrayBufferViewInitialization(HValue* obj,
1903 HValue* buffer, 1897 HValue* buffer,
1904 HValue* byte_offset, 1898 HValue* byte_offset,
1905 HValue* byte_length); 1899 HValue* byte_length);
1906 1900
1907 private: 1901 private:
1908 HGraphBuilder(); 1902 HGraphBuilder();
1909 1903
1910 template <class I> 1904 template <class I>
1911 I* AddInstructionTyped(I* instr) { 1905 I* AddInstructionTyped(I* instr) {
1912 return I::cast(AddInstruction(instr)); 1906 return I::cast(AddInstruction(instr));
1913 } 1907 }
1914 1908
1915 CompilationInfo* info_; 1909 CompilationInfo* info_;
1916 HGraph* graph_; 1910 HGraph* graph_;
1917 HBasicBlock* current_block_; 1911 HBasicBlock* current_block_;
1918 Scope* scope_; 1912 Scope* scope_;
1919 HSourcePosition position_; 1913 SourcePosition position_;
1920 int start_position_; 1914 int start_position_;
1921 }; 1915 };
1922 1916
1923 1917
1924 template <> 1918 template <>
1925 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( 1919 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1926 Deoptimizer::DeoptReason reason, Deoptimizer::BailoutType type) { 1920 Deoptimizer::DeoptReason reason, Deoptimizer::BailoutType type) {
1927 if (type == Deoptimizer::SOFT) { 1921 if (type == Deoptimizer::SOFT) {
1928 isolate()->counters()->soft_deopts_requested()->Increment(); 1922 isolate()->counters()->soft_deopts_requested()->Increment();
1929 if (FLAG_always_opt) return NULL; 1923 if (FLAG_always_opt) return NULL;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 enum ArrayIndexOfMode { kFirstIndexOf, kLastIndexOf }; 2312 enum ArrayIndexOfMode { kFirstIndexOf, kLastIndexOf };
2319 HValue* BuildArrayIndexOf(HValue* receiver, 2313 HValue* BuildArrayIndexOf(HValue* receiver,
2320 HValue* search_element, 2314 HValue* search_element,
2321 ElementsKind kind, 2315 ElementsKind kind,
2322 ArrayIndexOfMode mode); 2316 ArrayIndexOfMode mode);
2323 2317
2324 HValue* ImplicitReceiverFor(HValue* function, 2318 HValue* ImplicitReceiverFor(HValue* function,
2325 Handle<JSFunction> target); 2319 Handle<JSFunction> target);
2326 2320
2327 int InliningAstSize(Handle<JSFunction> target); 2321 int InliningAstSize(Handle<JSFunction> target);
2328 bool TryInline(Handle<JSFunction> target, 2322 bool TryInline(Handle<JSFunction> target, int arguments_count,
2329 int arguments_count, 2323 HValue* implicit_return_value, BailoutId ast_id,
2330 HValue* implicit_return_value, 2324 BailoutId return_id, InliningKind inlining_kind,
2331 BailoutId ast_id, 2325 SourcePosition position);
2332 BailoutId return_id,
2333 InliningKind inlining_kind,
2334 HSourcePosition position);
2335 2326
2336 bool TryInlineCall(Call* expr); 2327 bool TryInlineCall(Call* expr);
2337 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); 2328 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value);
2338 bool TryInlineGetter(Handle<JSFunction> getter, 2329 bool TryInlineGetter(Handle<JSFunction> getter,
2339 Handle<Map> receiver_map, 2330 Handle<Map> receiver_map,
2340 BailoutId ast_id, 2331 BailoutId ast_id,
2341 BailoutId return_id); 2332 BailoutId return_id);
2342 bool TryInlineSetter(Handle<JSFunction> setter, 2333 bool TryInlineSetter(Handle<JSFunction> setter,
2343 Handle<Map> receiver_map, 2334 Handle<Map> receiver_map,
2344 BailoutId id, 2335 BailoutId id,
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 void HandleLiteralCompareNil(CompareOperation* expr, 2581 void HandleLiteralCompareNil(CompareOperation* expr,
2591 Expression* sub_expr, 2582 Expression* sub_expr,
2592 NilValue nil); 2583 NilValue nil);
2593 2584
2594 enum PushBeforeSimulateBehavior { 2585 enum PushBeforeSimulateBehavior {
2595 PUSH_BEFORE_SIMULATE, 2586 PUSH_BEFORE_SIMULATE,
2596 NO_PUSH_BEFORE_SIMULATE 2587 NO_PUSH_BEFORE_SIMULATE
2597 }; 2588 };
2598 2589
2599 HControlInstruction* BuildCompareInstruction( 2590 HControlInstruction* BuildCompareInstruction(
2600 Token::Value op, 2591 Token::Value op, HValue* left, HValue* right, Type* left_type,
2601 HValue* left, 2592 Type* right_type, Type* combined_type, SourcePosition left_position,
2602 HValue* right, 2593 SourcePosition right_position, PushBeforeSimulateBehavior push_sim_result,
2603 Type* left_type,
2604 Type* right_type,
2605 Type* combined_type,
2606 HSourcePosition left_position,
2607 HSourcePosition right_position,
2608 PushBeforeSimulateBehavior push_sim_result,
2609 BailoutId bailout_id); 2594 BailoutId bailout_id);
2610 2595
2611 HInstruction* BuildStringCharCodeAt(HValue* string, 2596 HInstruction* BuildStringCharCodeAt(HValue* string,
2612 HValue* index); 2597 HValue* index);
2613 2598
2614 HValue* BuildBinaryOperation( 2599 HValue* BuildBinaryOperation(
2615 BinaryOperation* expr, 2600 BinaryOperation* expr,
2616 HValue* left, 2601 HValue* left,
2617 HValue* right, 2602 HValue* right,
2618 PushBeforeSimulateBehavior push_sim_result); 2603 PushBeforeSimulateBehavior push_sim_result);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2930 } 2915 }
2931 2916
2932 private: 2917 private:
2933 HGraphBuilder* builder_; 2918 HGraphBuilder* builder_;
2934 }; 2919 };
2935 2920
2936 2921
2937 } } // namespace v8::internal 2922 } } // namespace v8::internal
2938 2923
2939 #endif // V8_HYDROGEN_H_ 2924 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698