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

Side by Side Diff: src/hydrogen.h

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 void AttachLoopInformation(); 104 void AttachLoopInformation();
105 void DetachLoopInformation(); 105 void DetachLoopInformation();
106 bool IsLoopHeader() const { return loop_information() != NULL; } 106 bool IsLoopHeader() const { return loop_information() != NULL; }
107 bool IsStartBlock() const { return block_id() == 0; } 107 bool IsStartBlock() const { return block_id() == 0; }
108 void PostProcessLoopHeader(IterationStatement* stmt); 108 void PostProcessLoopHeader(IterationStatement* stmt);
109 109
110 bool IsFinished() const { return end_ != NULL; } 110 bool IsFinished() const { return end_ != NULL; }
111 void AddPhi(HPhi* phi); 111 void AddPhi(HPhi* phi);
112 void RemovePhi(HPhi* phi); 112 void RemovePhi(HPhi* phi);
113 void AddInstruction(HInstruction* instr, HSourcePosition position); 113 void AddInstruction(HInstruction* instr, int position);
114 bool Dominates(HBasicBlock* other) const; 114 bool Dominates(HBasicBlock* other) const;
115 bool EqualToOrDominates(HBasicBlock* other) const; 115 bool EqualToOrDominates(HBasicBlock* other) const;
116 int LoopNestingDepth() const; 116 int LoopNestingDepth() const;
117 117
118 void SetInitialEnvironment(HEnvironment* env); 118 void SetInitialEnvironment(HEnvironment* env);
119 void ClearEnvironment() { 119 void ClearEnvironment() {
120 ASSERT(IsFinished()); 120 ASSERT(IsFinished());
121 ASSERT(end()->SuccessorCount() == 0); 121 ASSERT(end()->SuccessorCount() == 0);
122 last_environment_ = NULL; 122 last_environment_ = NULL;
123 } 123 }
124 bool HasEnvironment() const { return last_environment_ != NULL; } 124 bool HasEnvironment() const { return last_environment_ != NULL; }
125 void UpdateEnvironment(HEnvironment* env); 125 void UpdateEnvironment(HEnvironment* env);
126 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } 126 HBasicBlock* parent_loop_header() const { return parent_loop_header_; }
127 127
128 void set_parent_loop_header(HBasicBlock* block) { 128 void set_parent_loop_header(HBasicBlock* block) {
129 ASSERT(parent_loop_header_ == NULL); 129 ASSERT(parent_loop_header_ == NULL);
130 parent_loop_header_ = block; 130 parent_loop_header_ = block;
131 } 131 }
132 132
133 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } 133 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; }
134 134
135 void SetJoinId(BailoutId ast_id); 135 void SetJoinId(BailoutId ast_id);
136 136
137 int PredecessorIndexOf(HBasicBlock* predecessor) const; 137 int PredecessorIndexOf(HBasicBlock* predecessor) const;
138 HPhi* AddNewPhi(int merged_index); 138 HPhi* AddNewPhi(int merged_index);
139 HSimulate* AddNewSimulate(BailoutId ast_id, 139 HSimulate* AddNewSimulate(BailoutId ast_id,
140 HSourcePosition position, 140 int position,
141 RemovableSimulate removable = FIXED_SIMULATE) { 141 RemovableSimulate removable = FIXED_SIMULATE) {
142 HSimulate* instr = CreateSimulate(ast_id, removable); 142 HSimulate* instr = CreateSimulate(ast_id, removable);
143 AddInstruction(instr, position); 143 AddInstruction(instr, position);
144 return instr; 144 return instr;
145 } 145 }
146 void AssignCommonDominator(HBasicBlock* other); 146 void AssignCommonDominator(HBasicBlock* other);
147 void AssignLoopSuccessorDominators(); 147 void AssignLoopSuccessorDominators();
148 148
149 // If a target block is tagged as an inline function return, all 149 // If a target block is tagged as an inline function return, all
150 // predecessors should contain the inlined exit sequence: 150 // predecessors should contain the inlined exit sequence:
(...skipping 16 matching lines...) Expand all
167 bool IsUnreachable() const { return !is_reachable_; } 167 bool IsUnreachable() const { return !is_reachable_; }
168 bool IsReachable() const { return is_reachable_; } 168 bool IsReachable() const { return is_reachable_; }
169 169
170 bool IsLoopSuccessorDominator() const { 170 bool IsLoopSuccessorDominator() const {
171 return dominates_loop_successors_; 171 return dominates_loop_successors_;
172 } 172 }
173 void MarkAsLoopSuccessorDominator() { 173 void MarkAsLoopSuccessorDominator() {
174 dominates_loop_successors_ = true; 174 dominates_loop_successors_ = true;
175 } 175 }
176 176
177 void MarkSuccEdgeUnreachable(int succ);
178
179 inline Zone* zone() const; 177 inline Zone* zone() const;
180 178
181 #ifdef DEBUG 179 #ifdef DEBUG
182 void Verify(); 180 void Verify();
183 #endif 181 #endif
184 182
185 protected: 183 protected:
186 friend class HGraphBuilder; 184 friend class HGraphBuilder;
187 185
188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); 186 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
189 void Finish(HControlInstruction* last, HSourcePosition position); 187 void Finish(HControlInstruction* last, int position);
190 void FinishExit(HControlInstruction* instruction, HSourcePosition position); 188 void FinishExit(HControlInstruction* instruction, int position);
191 void Goto(HBasicBlock* block, 189 void Goto(HBasicBlock* block,
192 HSourcePosition position, 190 int position,
193 FunctionState* state = NULL, 191 FunctionState* state = NULL,
194 bool add_simulate = true); 192 bool add_simulate = true);
195 void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) { 193 void GotoNoSimulate(HBasicBlock* block, int position) {
196 Goto(block, position, NULL, false); 194 Goto(block, position, NULL, false);
197 } 195 }
198 196
199 // Add the inlined function exit sequence, adding an HLeaveInlined 197 // Add the inlined function exit sequence, adding an HLeaveInlined
200 // instruction and updating the bailout environment. 198 // instruction and updating the bailout environment.
201 void AddLeaveInlined(HValue* return_value, 199 void AddLeaveInlined(HValue* return_value,
202 FunctionState* state, 200 FunctionState* state,
203 HSourcePosition position); 201 int position);
204 202
205 private: 203 private:
206 void RegisterPredecessor(HBasicBlock* pred); 204 void RegisterPredecessor(HBasicBlock* pred);
207 void AddDominatedBlock(HBasicBlock* block); 205 void AddDominatedBlock(HBasicBlock* block);
208 206
209 int block_id_; 207 int block_id_;
210 HGraph* graph_; 208 HGraph* graph_;
211 ZoneList<HPhi*> phis_; 209 ZoneList<HPhi*> phis_;
212 HInstruction* first_; 210 HInstruction* first_;
213 HInstruction* last_; 211 HInstruction* last_;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (uint32_instructions_ == NULL) { 462 if (uint32_instructions_ == NULL) {
465 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); 463 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone());
466 } 464 }
467 uint32_instructions_->Add(instr, zone()); 465 uint32_instructions_->Add(instr, zone());
468 } 466 }
469 467
470 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } 468 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; }
471 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } 469 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; }
472 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } 470 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; }
473 471
474 // If we are tracking source positions then this function assigns a unique
475 // identifier to each inlining and dumps function source if it was inlined
476 // for the first time during the current optimization.
477 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
478 HSourcePosition position);
479
480 // Converts given HSourcePosition to the absolute offset from the start of
481 // the corresponding script.
482 int SourcePositionToScriptPosition(HSourcePosition position);
483
484 private: 472 private:
485 HConstant* ReinsertConstantIfNecessary(HConstant* constant); 473 HConstant* ReinsertConstantIfNecessary(HConstant* constant);
486 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, 474 HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
487 int32_t integer_value); 475 int32_t integer_value);
488 476
489 template<class Phase> 477 template<class Phase>
490 void Run() { 478 void Run() {
491 Phase phase(this); 479 Phase phase(this);
492 phase.Run(); 480 phase.Run();
493 } 481 }
(...skipping 25 matching lines...) Expand all
519 Zone* zone_; 507 Zone* zone_;
520 508
521 bool is_recursive_; 509 bool is_recursive_;
522 bool use_optimistic_licm_; 510 bool use_optimistic_licm_;
523 bool depends_on_empty_array_proto_elements_; 511 bool depends_on_empty_array_proto_elements_;
524 int type_change_checksum_; 512 int type_change_checksum_;
525 int maximum_environment_size_; 513 int maximum_environment_size_;
526 int no_side_effects_scope_count_; 514 int no_side_effects_scope_count_;
527 bool disallow_adding_new_values_; 515 bool disallow_adding_new_values_;
528 516
529 class InlinedFunctionInfo {
530 public:
531 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared)
532 : shared_(shared), start_position_(shared->start_position()) {
533 }
534
535 Handle<SharedFunctionInfo> shared() const { return shared_; }
536 int start_position() const { return start_position_; }
537
538 private:
539 Handle<SharedFunctionInfo> shared_;
540 int start_position_;
541 };
542
543 int next_inline_id_;
544 ZoneList<InlinedFunctionInfo> inlined_functions_;
545
546 DISALLOW_COPY_AND_ASSIGN(HGraph); 517 DISALLOW_COPY_AND_ASSIGN(HGraph);
547 }; 518 };
548 519
549 520
550 Zone* HBasicBlock::zone() const { return graph_->zone(); } 521 Zone* HBasicBlock::zone() const { return graph_->zone(); }
551 522
552 523
553 // Type of stack frame an environment might refer to. 524 // Type of stack frame an environment might refer to.
554 enum FrameType { 525 enum FrameType {
555 JS_FUNCTION, 526 JS_FUNCTION,
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 Expression* condition_; 873 Expression* condition_;
903 HBasicBlock* if_true_; 874 HBasicBlock* if_true_;
904 HBasicBlock* if_false_; 875 HBasicBlock* if_false_;
905 }; 876 };
906 877
907 878
908 class FunctionState V8_FINAL { 879 class FunctionState V8_FINAL {
909 public: 880 public:
910 FunctionState(HOptimizedGraphBuilder* owner, 881 FunctionState(HOptimizedGraphBuilder* owner,
911 CompilationInfo* info, 882 CompilationInfo* info,
912 InliningKind inlining_kind, 883 InliningKind inlining_kind);
913 int inlining_id);
914 ~FunctionState(); 884 ~FunctionState();
915 885
916 CompilationInfo* compilation_info() { return compilation_info_; } 886 CompilationInfo* compilation_info() { return compilation_info_; }
917 AstContext* call_context() { return call_context_; } 887 AstContext* call_context() { return call_context_; }
918 InliningKind inlining_kind() const { return inlining_kind_; } 888 InliningKind inlining_kind() const { return inlining_kind_; }
919 HBasicBlock* function_return() { return function_return_; } 889 HBasicBlock* function_return() { return function_return_; }
920 TestContext* test_context() { return test_context_; } 890 TestContext* test_context() { return test_context_; }
921 void ClearInlinedTestContext() { 891 void ClearInlinedTestContext() {
922 delete test_context_; 892 delete test_context_;
923 test_context_ = NULL; 893 test_context_ = NULL;
924 } 894 }
925 895
926 FunctionState* outer() { return outer_; } 896 FunctionState* outer() { return outer_; }
927 897
928 HEnterInlined* entry() { return entry_; } 898 HEnterInlined* entry() { return entry_; }
929 void set_entry(HEnterInlined* entry) { entry_ = entry; } 899 void set_entry(HEnterInlined* entry) { entry_ = entry; }
930 900
931 HArgumentsObject* arguments_object() { return arguments_object_; } 901 HArgumentsObject* arguments_object() { return arguments_object_; }
932 void set_arguments_object(HArgumentsObject* arguments_object) { 902 void set_arguments_object(HArgumentsObject* arguments_object) {
933 arguments_object_ = arguments_object; 903 arguments_object_ = arguments_object;
934 } 904 }
935 905
936 HArgumentsElements* arguments_elements() { return arguments_elements_; } 906 HArgumentsElements* arguments_elements() { return arguments_elements_; }
937 void set_arguments_elements(HArgumentsElements* arguments_elements) { 907 void set_arguments_elements(HArgumentsElements* arguments_elements) {
938 arguments_elements_ = arguments_elements; 908 arguments_elements_ = arguments_elements;
939 } 909 }
940 910
941 bool arguments_pushed() { return arguments_elements() != NULL; } 911 bool arguments_pushed() { return arguments_elements() != NULL; }
942 912
943 int inlining_id() const { return inlining_id_; }
944
945 private: 913 private:
946 HOptimizedGraphBuilder* owner_; 914 HOptimizedGraphBuilder* owner_;
947 915
948 CompilationInfo* compilation_info_; 916 CompilationInfo* compilation_info_;
949 917
950 // During function inlining, expression context of the call being 918 // During function inlining, expression context of the call being
951 // inlined. NULL when not inlining. 919 // inlined. NULL when not inlining.
952 AstContext* call_context_; 920 AstContext* call_context_;
953 921
954 // The kind of call which is currently being inlined. 922 // The kind of call which is currently being inlined.
955 InliningKind inlining_kind_; 923 InliningKind inlining_kind_;
956 924
957 // When inlining in an effect or value context, this is the return block. 925 // When inlining in an effect or value context, this is the return block.
958 // It is NULL otherwise. When inlining in a test context, there are a 926 // It is NULL otherwise. When inlining in a test context, there are a
959 // pair of return blocks in the context. When not inlining, there is no 927 // pair of return blocks in the context. When not inlining, there is no
960 // local return point. 928 // local return point.
961 HBasicBlock* function_return_; 929 HBasicBlock* function_return_;
962 930
963 // When inlining a call in a test context, a context containing a pair of 931 // When inlining a call in a test context, a context containing a pair of
964 // return blocks. NULL in all other cases. 932 // return blocks. NULL in all other cases.
965 TestContext* test_context_; 933 TestContext* test_context_;
966 934
967 // When inlining HEnterInlined instruction corresponding to the function 935 // When inlining HEnterInlined instruction corresponding to the function
968 // entry. 936 // entry.
969 HEnterInlined* entry_; 937 HEnterInlined* entry_;
970 938
971 HArgumentsObject* arguments_object_; 939 HArgumentsObject* arguments_object_;
972 HArgumentsElements* arguments_elements_; 940 HArgumentsElements* arguments_elements_;
973 941
974 int inlining_id_;
975 HSourcePosition outer_source_position_;
976
977 FunctionState* outer_; 942 FunctionState* outer_;
978 }; 943 };
979 944
980 945
981 class HIfContinuation V8_FINAL { 946 class HIfContinuation V8_FINAL {
982 public: 947 public:
983 HIfContinuation() 948 HIfContinuation()
984 : continuation_captured_(false), 949 : continuation_captured_(false),
985 true_branch_(NULL), 950 true_branch_(NULL),
986 false_branch_(NULL) {} 951 false_branch_(NULL) {}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 PretenureFlag pretenure_flag_; 1015 PretenureFlag pretenure_flag_;
1051 }; 1016 };
1052 1017
1053 1018
1054 class HGraphBuilder { 1019 class HGraphBuilder {
1055 public: 1020 public:
1056 explicit HGraphBuilder(CompilationInfo* info) 1021 explicit HGraphBuilder(CompilationInfo* info)
1057 : info_(info), 1022 : info_(info),
1058 graph_(NULL), 1023 graph_(NULL),
1059 current_block_(NULL), 1024 current_block_(NULL),
1060 position_(HSourcePosition::Unknown()), 1025 position_(RelocInfo::kNoPosition) {}
1061 start_position_(0) {}
1062 virtual ~HGraphBuilder() {} 1026 virtual ~HGraphBuilder() {}
1063 1027
1064 HBasicBlock* current_block() const { return current_block_; } 1028 HBasicBlock* current_block() const { return current_block_; }
1065 void set_current_block(HBasicBlock* block) { current_block_ = block; } 1029 void set_current_block(HBasicBlock* block) { current_block_ = block; }
1066 HEnvironment* environment() const { 1030 HEnvironment* environment() const {
1067 return current_block()->last_environment(); 1031 return current_block()->last_environment();
1068 } 1032 }
1069 Zone* zone() const { return info_->zone(); } 1033 Zone* zone() const { return info_->zone(); }
1070 HGraph* graph() const { return graph_; } 1034 HGraph* graph() const { return graph_; }
1071 Isolate* isolate() const { return graph_->isolate(); } 1035 Isolate* isolate() const { return graph_->isolate(); }
1072 CompilationInfo* top_info() { return info_; } 1036 CompilationInfo* top_info() { return info_; }
1073 1037
1074 HGraph* CreateGraph(); 1038 HGraph* CreateGraph();
1075 1039
1076 // Bailout environment manipulation. 1040 // Bailout environment manipulation.
1077 void Push(HValue* value) { environment()->Push(value); } 1041 void Push(HValue* value) { environment()->Push(value); }
1078 HValue* Pop() { return environment()->Pop(); } 1042 HValue* Pop() { return environment()->Pop(); }
1079 1043
1080 virtual HValue* context() = 0; 1044 virtual HValue* context() = 0;
1081 1045
1082 // Adding instructions. 1046 // Adding instructions.
1083 HInstruction* AddInstruction(HInstruction* instr); 1047 HInstruction* AddInstruction(HInstruction* instr);
1084 void FinishCurrentBlock(HControlInstruction* last); 1048 void FinishCurrentBlock(HControlInstruction* last);
1085 void FinishExitCurrentBlock(HControlInstruction* instruction); 1049 void FinishExitCurrentBlock(HControlInstruction* instruction);
1086 1050
1087 void Goto(HBasicBlock* from, 1051 void Goto(HBasicBlock* from,
1088 HBasicBlock* target, 1052 HBasicBlock* target,
1089 FunctionState* state = NULL, 1053 FunctionState* state = NULL,
1090 bool add_simulate = true) { 1054 bool add_simulate = true) {
1091 from->Goto(target, source_position(), state, add_simulate); 1055 from->Goto(target, position_, state, add_simulate);
1092 } 1056 }
1093 void Goto(HBasicBlock* target, 1057 void Goto(HBasicBlock* target,
1094 FunctionState* state = NULL, 1058 FunctionState* state = NULL,
1095 bool add_simulate = true) { 1059 bool add_simulate = true) {
1096 Goto(current_block(), target, state, add_simulate); 1060 Goto(current_block(), target, state, add_simulate);
1097 } 1061 }
1098 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { 1062 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) {
1099 Goto(from, target, NULL, false); 1063 Goto(from, target, NULL, false);
1100 } 1064 }
1101 void GotoNoSimulate(HBasicBlock* target) { 1065 void GotoNoSimulate(HBasicBlock* target) {
1102 Goto(target, NULL, false); 1066 Goto(target, NULL, false);
1103 } 1067 }
1104 void AddLeaveInlined(HBasicBlock* block, 1068 void AddLeaveInlined(HBasicBlock* block,
1105 HValue* return_value, 1069 HValue* return_value,
1106 FunctionState* state) { 1070 FunctionState* state) {
1107 block->AddLeaveInlined(return_value, state, source_position()); 1071 block->AddLeaveInlined(return_value, state, position_);
1108 } 1072 }
1109 void AddLeaveInlined(HValue* return_value, FunctionState* state) { 1073 void AddLeaveInlined(HValue* return_value, FunctionState* state) {
1110 return AddLeaveInlined(current_block(), return_value, state); 1074 return AddLeaveInlined(current_block(), return_value, state);
1111 } 1075 }
1112 1076
1113 template<class I> 1077 template<class I>
1114 HInstruction* NewUncasted() { return I::New(zone(), context()); } 1078 HInstruction* NewUncasted() { return I::New(zone(), context()); }
1115 1079
1116 template<class I> 1080 template<class I>
1117 I* New() { return I::New(zone(), context()); } 1081 I* New() { return I::New(zone(), context()); }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 } 1267 }
1304 1268
1305 template<class I, class P1, class P2, class P3, class P4, 1269 template<class I, class P1, class P2, class P3, class P4,
1306 class P5, class P6, class P7, class P8> 1270 class P5, class P6, class P7, class P8>
1307 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { 1271 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1308 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); 1272 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1309 } 1273 }
1310 1274
1311 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); 1275 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE);
1312 1276
1277 int position() const { return position_; }
1278
1313 protected: 1279 protected:
1314 virtual bool BuildGraph() = 0; 1280 virtual bool BuildGraph() = 0;
1315 1281
1316 HBasicBlock* CreateBasicBlock(HEnvironment* env); 1282 HBasicBlock* CreateBasicBlock(HEnvironment* env);
1317 HBasicBlock* CreateLoopHeaderBlock(); 1283 HBasicBlock* CreateLoopHeaderBlock();
1318 1284
1319 HValue* BuildCheckHeapObject(HValue* object); 1285 HValue* BuildCheckHeapObject(HValue* object);
1320 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); 1286 HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
1321 HValue* BuildCheckString(HValue* string); 1287 HValue* BuildCheckString(HValue* string);
1322 HValue* BuildWrapReceiver(HValue* object, HValue* function); 1288 HValue* BuildWrapReceiver(HValue* object, HValue* function);
1323 1289
1324 // Building common constructs 1290 // Building common constructs
1325 HValue* BuildCheckForCapacityGrow(HValue* object, 1291 HValue* BuildCheckForCapacityGrow(HValue* object,
1326 HValue* elements, 1292 HValue* elements,
1327 ElementsKind kind, 1293 ElementsKind kind,
1328 HValue* length, 1294 HValue* length,
1329 HValue* key, 1295 HValue* key,
1330 bool is_js_array, 1296 bool is_js_array,
1331 PropertyAccessType access_type); 1297 bool is_store);
1332 1298
1333 HValue* BuildCopyElementsOnWrite(HValue* object, 1299 HValue* BuildCopyElementsOnWrite(HValue* object,
1334 HValue* elements, 1300 HValue* elements,
1335 ElementsKind kind, 1301 ElementsKind kind,
1336 HValue* length); 1302 HValue* length);
1337 1303
1338 void BuildTransitionElementsKind(HValue* object, 1304 void BuildTransitionElementsKind(HValue* object,
1339 HValue* map, 1305 HValue* map,
1340 ElementsKind from_kind, 1306 ElementsKind from_kind,
1341 ElementsKind to_kind, 1307 ElementsKind to_kind,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 HValue* BuildStringAdd(HValue* left, 1344 HValue* BuildStringAdd(HValue* left,
1379 HValue* right, 1345 HValue* right,
1380 HAllocationMode allocation_mode); 1346 HAllocationMode allocation_mode);
1381 1347
1382 HInstruction* BuildUncheckedMonomorphicElementAccess( 1348 HInstruction* BuildUncheckedMonomorphicElementAccess(
1383 HValue* checked_object, 1349 HValue* checked_object,
1384 HValue* key, 1350 HValue* key,
1385 HValue* val, 1351 HValue* val,
1386 bool is_js_array, 1352 bool is_js_array,
1387 ElementsKind elements_kind, 1353 ElementsKind elements_kind,
1388 PropertyAccessType access_type, 1354 bool is_store,
1389 LoadKeyedHoleMode load_mode, 1355 LoadKeyedHoleMode load_mode,
1390 KeyedAccessStoreMode store_mode); 1356 KeyedAccessStoreMode store_mode);
1391 1357
1392 HInstruction* AddElementAccess( 1358 HInstruction* AddElementAccess(
1393 HValue* elements, 1359 HValue* elements,
1394 HValue* checked_key, 1360 HValue* checked_key,
1395 HValue* val, 1361 HValue* val,
1396 HValue* dependency, 1362 HValue* dependency,
1397 ElementsKind elements_kind, 1363 ElementsKind elements_kind,
1398 PropertyAccessType access_type, 1364 bool is_store,
1399 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE); 1365 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);
1400 1366
1367 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
1368 HInstruction* AddLoadNamedField(HValue* object, HObjectAccess access);
1401 HInstruction* AddLoadStringInstanceType(HValue* string); 1369 HInstruction* AddLoadStringInstanceType(HValue* string);
1402 HInstruction* AddLoadStringLength(HValue* string); 1370 HInstruction* AddLoadStringLength(HValue* string);
1403 HStoreNamedField* AddStoreMapNoWriteBarrier(HValue* object, HValue* map) { 1371 HStoreNamedField* AddStoreMapNoWriteBarrier(HValue* object, HValue* map) {
1404 HStoreNamedField* store_map = Add<HStoreNamedField>( 1372 HStoreNamedField* store_map = Add<HStoreNamedField>(
1405 object, HObjectAccess::ForMap(), map); 1373 object, HObjectAccess::ForMap(), map);
1406 store_map->SkipWriteBarrier(); 1374 store_map->SkipWriteBarrier();
1407 return store_map; 1375 return store_map;
1408 } 1376 }
1409 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map> map); 1377 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map> map);
1410 HStoreNamedField* AddStoreMapConstantNoWriteBarrier(HValue* object, 1378 HStoreNamedField* AddStoreMapConstantNoWriteBarrier(HValue* object,
(...skipping 18 matching lines...) Expand all
1429 Maybe<int> fixed_right_arg, 1397 Maybe<int> fixed_right_arg,
1430 HAllocationMode allocation_mode); 1398 HAllocationMode allocation_mode);
1431 1399
1432 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); 1400 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1433 1401
1434 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); 1402 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin);
1435 1403
1436 HValue* EnforceNumberType(HValue* number, Type* expected); 1404 HValue* EnforceNumberType(HValue* number, Type* expected);
1437 HValue* TruncateToNumber(HValue* value, Type** expected); 1405 HValue* TruncateToNumber(HValue* value, Type** expected);
1438 1406
1439 void FinishExitWithHardDeoptimization(const char* reason); 1407 void FinishExitWithHardDeoptimization(const char* reason,
1408 HBasicBlock* continuation);
1440 1409
1441 void AddIncrementCounter(StatsCounter* counter); 1410 void AddIncrementCounter(StatsCounter* counter);
1442 1411
1443 class IfBuilder V8_FINAL { 1412 class IfBuilder V8_FINAL {
1444 public: 1413 public:
1445 explicit IfBuilder(HGraphBuilder* builder); 1414 explicit IfBuilder(HGraphBuilder* builder);
1446 IfBuilder(HGraphBuilder* builder, 1415 IfBuilder(HGraphBuilder* builder,
1447 HIfContinuation* continuation); 1416 HIfContinuation* continuation);
1448 1417
1449 ~IfBuilder() { 1418 ~IfBuilder() {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, 1770 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype,
1802 Handle<JSObject> holder); 1771 Handle<JSObject> holder);
1803 1772
1804 HInstruction* BuildGetNativeContext(HValue* closure); 1773 HInstruction* BuildGetNativeContext(HValue* closure);
1805 HInstruction* BuildGetNativeContext(); 1774 HInstruction* BuildGetNativeContext();
1806 HInstruction* BuildGetArrayFunction(); 1775 HInstruction* BuildGetArrayFunction();
1807 1776
1808 protected: 1777 protected:
1809 void SetSourcePosition(int position) { 1778 void SetSourcePosition(int position) {
1810 ASSERT(position != RelocInfo::kNoPosition); 1779 ASSERT(position != RelocInfo::kNoPosition);
1811 position_.set_position(position - start_position_);
1812 }
1813
1814 void EnterInlinedSource(int start_position, int id) {
1815 if (FLAG_hydrogen_track_positions) {
1816 start_position_ = start_position;
1817 position_.set_inlining_id(id);
1818 }
1819 }
1820
1821 // Convert the given absolute offset from the start of the script to
1822 // the HSourcePosition assuming that this position corresponds to the
1823 // same function as current position_.
1824 HSourcePosition ScriptPositionToSourcePosition(int position) {
1825 HSourcePosition pos = position_;
1826 pos.set_position(position - start_position_);
1827 return pos;
1828 }
1829
1830 HSourcePosition source_position() { return position_; }
1831 void set_source_position(HSourcePosition position) {
1832 position_ = position; 1780 position_ = position;
1833 } 1781 }
1834 1782
1835 template <typename ViewClass> 1783 template <typename ViewClass>
1836 void BuildArrayBufferViewInitialization(HValue* obj, 1784 void BuildArrayBufferViewInitialization(HValue* obj,
1837 HValue* buffer, 1785 HValue* buffer,
1838 HValue* byte_offset, 1786 HValue* byte_offset,
1839 HValue* byte_length); 1787 HValue* byte_length);
1840 1788
1841 private: 1789 private:
1842 HGraphBuilder(); 1790 HGraphBuilder();
1843 1791
1844 HValue* BuildUncheckedDictionaryElementLoadHelper( 1792 HValue* BuildUncheckedDictionaryElementLoadHelper(
1845 HValue* elements, 1793 HValue* elements,
1846 HValue* key, 1794 HValue* key,
1847 HValue* hash, 1795 HValue* hash,
1848 HValue* mask, 1796 HValue* mask,
1849 int current_probe); 1797 int current_probe);
1850 1798
1799 void PadEnvironmentForContinuation(HBasicBlock* from,
1800 HBasicBlock* continuation);
1801
1851 template <class I> 1802 template <class I>
1852 I* AddInstructionTyped(I* instr) { 1803 I* AddInstructionTyped(I* instr) {
1853 return I::cast(AddInstruction(instr)); 1804 return I::cast(AddInstruction(instr));
1854 } 1805 }
1855 1806
1856 CompilationInfo* info_; 1807 CompilationInfo* info_;
1857 HGraph* graph_; 1808 HGraph* graph_;
1858 HBasicBlock* current_block_; 1809 HBasicBlock* current_block_;
1859 HSourcePosition position_; 1810 int position_;
1860 int start_position_;
1861 }; 1811 };
1862 1812
1863 1813
1864 template<> 1814 template<>
1865 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( 1815 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1866 const char* reason, Deoptimizer::BailoutType type) { 1816 const char* reason, Deoptimizer::BailoutType type) {
1867 if (type == Deoptimizer::SOFT) { 1817 if (type == Deoptimizer::SOFT) {
1868 isolate()->counters()->soft_deopts_requested()->Increment(); 1818 isolate()->counters()->soft_deopts_requested()->Increment();
1869 if (FLAG_always_opt) return NULL; 1819 if (FLAG_always_opt) return NULL;
1870 } 1820 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 void SetUpScope(Scope* scope); 2180 void SetUpScope(Scope* scope);
2231 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; 2181 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE;
2232 2182
2233 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; 2183 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE;
2234 AST_NODE_LIST(DECLARE_VISIT) 2184 AST_NODE_LIST(DECLARE_VISIT)
2235 #undef DECLARE_VISIT 2185 #undef DECLARE_VISIT
2236 2186
2237 Type* ToType(Handle<Map> map) { return IC::MapToType<Type>(map, zone()); } 2187 Type* ToType(Handle<Map> map) { return IC::MapToType<Type>(map, zone()); }
2238 2188
2239 private: 2189 private:
2190 enum PropertyAccessType { LOAD, STORE };
2191
2240 // Helpers for flow graph construction. 2192 // Helpers for flow graph construction.
2241 enum GlobalPropertyAccess { 2193 enum GlobalPropertyAccess {
2242 kUseCell, 2194 kUseCell,
2243 kUseGeneric 2195 kUseGeneric
2244 }; 2196 };
2245 GlobalPropertyAccess LookupGlobalProperty(Variable* var, 2197 GlobalPropertyAccess LookupGlobalProperty(Variable* var,
2246 LookupResult* lookup, 2198 LookupResult* lookup,
2247 PropertyAccessType access_type); 2199 bool is_store);
2248 2200
2249 void EnsureArgumentsArePushedForAccess(); 2201 void EnsureArgumentsArePushedForAccess();
2250 bool TryArgumentsAccess(Property* expr); 2202 bool TryArgumentsAccess(Property* expr);
2251 2203
2252 // Try to optimize fun.apply(receiver, arguments) pattern. 2204 // Try to optimize fun.apply(receiver, arguments) pattern.
2253 bool TryCallApply(Call* expr); 2205 bool TryCallApply(Call* expr);
2254 2206
2255 HValue* ImplicitReceiverFor(HValue* function, 2207 HValue* ImplicitReceiverFor(HValue* function,
2256 Handle<JSFunction> target); 2208 Handle<JSFunction> target);
2257 2209
2258 int InliningAstSize(Handle<JSFunction> target); 2210 int InliningAstSize(Handle<JSFunction> target);
2259 bool TryInline(Handle<JSFunction> target, 2211 bool TryInline(Handle<JSFunction> target,
2260 int arguments_count, 2212 int arguments_count,
2261 HValue* implicit_return_value, 2213 HValue* implicit_return_value,
2262 BailoutId ast_id, 2214 BailoutId ast_id,
2263 BailoutId return_id, 2215 BailoutId return_id,
2264 InliningKind inlining_kind, 2216 InliningKind inlining_kind);
2265 HSourcePosition position);
2266 2217
2267 bool TryInlineCall(Call* expr); 2218 bool TryInlineCall(Call* expr);
2268 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); 2219 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value);
2269 bool TryInlineGetter(Handle<JSFunction> getter, 2220 bool TryInlineGetter(Handle<JSFunction> getter,
2270 Handle<Map> receiver_map, 2221 Handle<Map> receiver_map,
2271 BailoutId ast_id, 2222 BailoutId ast_id,
2272 BailoutId return_id); 2223 BailoutId return_id);
2273 bool TryInlineSetter(Handle<JSFunction> setter, 2224 bool TryInlineSetter(Handle<JSFunction> setter,
2274 Handle<Map> receiver_map, 2225 Handle<Map> receiver_map,
2275 BailoutId id, 2226 BailoutId id,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 void HandlePolymorphicCallNamed(Call* expr, 2409 void HandlePolymorphicCallNamed(Call* expr,
2459 HValue* receiver, 2410 HValue* receiver,
2460 SmallMapList* types, 2411 SmallMapList* types,
2461 Handle<String> name); 2412 Handle<String> name);
2462 void HandleLiteralCompareTypeof(CompareOperation* expr, 2413 void HandleLiteralCompareTypeof(CompareOperation* expr,
2463 Expression* sub_expr, 2414 Expression* sub_expr,
2464 Handle<String> check); 2415 Handle<String> check);
2465 void HandleLiteralCompareNil(CompareOperation* expr, 2416 void HandleLiteralCompareNil(CompareOperation* expr,
2466 Expression* sub_expr, 2417 Expression* sub_expr,
2467 NilValue nil); 2418 NilValue nil);
2419 HControlInstruction* BuildCompareInstruction(Token::Value op,
2420 HValue* left,
2421 HValue* right,
2422 Type* left_type,
2423 Type* right_type,
2424 Type* combined_type,
2425 int left_position,
2426 int right_position,
2427 BailoutId bailout_id);
2428
2429 HInstruction* BuildStringCharCodeAt(HValue* string,
2430 HValue* index);
2468 2431
2469 enum PushBeforeSimulateBehavior { 2432 enum PushBeforeSimulateBehavior {
2470 PUSH_BEFORE_SIMULATE, 2433 PUSH_BEFORE_SIMULATE,
2471 NO_PUSH_BEFORE_SIMULATE 2434 NO_PUSH_BEFORE_SIMULATE
2472 }; 2435 };
2473
2474 HControlInstruction* BuildCompareInstruction(
2475 Token::Value op,
2476 HValue* left,
2477 HValue* right,
2478 Type* left_type,
2479 Type* right_type,
2480 Type* combined_type,
2481 HSourcePosition left_position,
2482 HSourcePosition right_position,
2483 PushBeforeSimulateBehavior push_sim_result,
2484 BailoutId bailout_id);
2485
2486 HInstruction* BuildStringCharCodeAt(HValue* string,
2487 HValue* index);
2488
2489 HValue* BuildBinaryOperation( 2436 HValue* BuildBinaryOperation(
2490 BinaryOperation* expr, 2437 BinaryOperation* expr,
2491 HValue* left, 2438 HValue* left,
2492 HValue* right, 2439 HValue* right,
2493 PushBeforeSimulateBehavior push_sim_result); 2440 PushBeforeSimulateBehavior push_sim_result);
2494 HInstruction* BuildIncrement(bool returns_original_input, 2441 HInstruction* BuildIncrement(bool returns_original_input,
2495 CountOperation* expr); 2442 CountOperation* expr);
2496 HInstruction* BuildKeyedGeneric(PropertyAccessType access_type, 2443 HInstruction* BuildLoadKeyedGeneric(HValue* object,
2497 HValue* object, 2444 HValue* key);
2498 HValue* key,
2499 HValue* value);
2500 2445
2501 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, 2446 HInstruction* TryBuildConsolidatedElementLoad(HValue* object,
2502 HValue* key, 2447 HValue* key,
2503 HValue* val, 2448 HValue* val,
2504 SmallMapList* maps); 2449 SmallMapList* maps);
2505 2450
2506 LoadKeyedHoleMode BuildKeyedHoleMode(Handle<Map> map); 2451 LoadKeyedHoleMode BuildKeyedHoleMode(Handle<Map> map);
2507 2452
2508 HInstruction* BuildMonomorphicElementAccess(HValue* object, 2453 HInstruction* BuildMonomorphicElementAccess(HValue* object,
2509 HValue* key, 2454 HValue* key,
2510 HValue* val, 2455 HValue* val,
2511 HValue* dependency, 2456 HValue* dependency,
2512 Handle<Map> map, 2457 Handle<Map> map,
2513 PropertyAccessType access_type, 2458 bool is_store,
2514 KeyedAccessStoreMode store_mode); 2459 KeyedAccessStoreMode store_mode);
2515 2460
2516 HValue* HandlePolymorphicElementAccess(HValue* object, 2461 HValue* HandlePolymorphicElementAccess(HValue* object,
2517 HValue* key, 2462 HValue* key,
2518 HValue* val, 2463 HValue* val,
2519 SmallMapList* maps, 2464 SmallMapList* maps,
2520 PropertyAccessType access_type, 2465 bool is_store,
2521 KeyedAccessStoreMode store_mode, 2466 KeyedAccessStoreMode store_mode,
2522 bool* has_side_effects); 2467 bool* has_side_effects);
2523 2468
2524 HValue* HandleKeyedElementAccess(HValue* obj, 2469 HValue* HandleKeyedElementAccess(HValue* obj,
2525 HValue* key, 2470 HValue* key,
2526 HValue* val, 2471 HValue* val,
2527 Expression* expr, 2472 Expression* expr,
2528 PropertyAccessType access_type, 2473 bool is_store,
2529 bool* has_side_effects); 2474 bool* has_side_effects);
2530 2475
2531 HInstruction* BuildNamedGeneric(PropertyAccessType access, 2476 HInstruction* BuildLoadNamedGeneric(HValue* object,
2532 HValue* object, 2477 Handle<String> name,
2533 Handle<String> name, 2478 bool is_uninitialized = false);
2534 HValue* value,
2535 bool is_uninitialized = false);
2536 2479
2537 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); 2480 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map);
2538 2481
2539 void BuildLoad(Property* property, 2482 void BuildLoad(Property* property,
2540 BailoutId ast_id); 2483 BailoutId ast_id);
2541 void PushLoad(Property* property, 2484 void PushLoad(Property* property,
2542 HValue* object, 2485 HValue* object,
2543 HValue* key); 2486 HValue* key);
2544 2487
2545 void BuildStoreForEffect(Expression* expression, 2488 void BuildStoreForEffect(Expression* expression,
2546 Property* prop, 2489 Property* prop,
2547 BailoutId ast_id, 2490 BailoutId ast_id,
2548 BailoutId return_id, 2491 BailoutId return_id,
2549 HValue* object, 2492 HValue* object,
2550 HValue* key, 2493 HValue* key,
2551 HValue* value); 2494 HValue* value);
2552 2495
2553 void BuildStore(Expression* expression, 2496 void BuildStore(Expression* expression,
2554 Property* prop, 2497 Property* prop,
2555 BailoutId ast_id, 2498 BailoutId ast_id,
2556 BailoutId return_id, 2499 BailoutId return_id,
2557 bool is_uninitialized = false); 2500 bool is_uninitialized = false);
2558 2501
2559 HInstruction* BuildLoadNamedField(PropertyAccessInfo* info,
2560 HValue* checked_object);
2561 HInstruction* BuildStoreNamedField(PropertyAccessInfo* info, 2502 HInstruction* BuildStoreNamedField(PropertyAccessInfo* info,
2562 HValue* checked_object, 2503 HValue* checked_object,
2563 HValue* value); 2504 HValue* value);
2505 HInstruction* BuildStoreNamedGeneric(HValue* object,
2506 Handle<String> name,
2507 HValue* value,
2508 bool is_uninitialized = false);
2509 HInstruction* BuildStoreKeyedGeneric(HValue* object,
2510 HValue* key,
2511 HValue* value);
2564 2512
2565 HValue* BuildContextChainWalk(Variable* var); 2513 HValue* BuildContextChainWalk(Variable* var);
2566 2514
2567 HInstruction* BuildThisFunction(); 2515 HInstruction* BuildThisFunction();
2568 2516
2569 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object, 2517 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object,
2570 AllocationSiteUsageContext* site_context); 2518 AllocationSiteUsageContext* site_context);
2571 2519
2572 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object, 2520 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object,
2573 HInstruction* object); 2521 HInstruction* object);
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 } 2741 }
2794 2742
2795 private: 2743 private:
2796 HGraphBuilder* builder_; 2744 HGraphBuilder* builder_;
2797 }; 2745 };
2798 2746
2799 2747
2800 } } // namespace v8::internal 2748 } } // namespace v8::internal
2801 2749
2802 #endif // V8_HYDROGEN_H_ 2750 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698