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

Side by Side Diff: src/hydrogen.h

Issue 19528003: Unify SoftDeoptimize and Deoptimize hydrogen instructions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 5 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/code-stubs-hydrogen.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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void Finish(HControlInstruction* last); 130 void Finish(HControlInstruction* last);
131 void FinishExit(HControlInstruction* instruction); 131 void FinishExit(HControlInstruction* instruction);
132 void Goto(HBasicBlock* block, 132 void Goto(HBasicBlock* block,
133 FunctionState* state = NULL, 133 FunctionState* state = NULL,
134 bool add_simulate = true); 134 bool add_simulate = true);
135 void GotoNoSimulate(HBasicBlock* block) { 135 void GotoNoSimulate(HBasicBlock* block) {
136 Goto(block, NULL, false); 136 Goto(block, NULL, false);
137 } 137 }
138 138
139 int PredecessorIndexOf(HBasicBlock* predecessor) const; 139 int PredecessorIndexOf(HBasicBlock* predecessor) const;
140 void AddSimulate(BailoutId ast_id, 140 HSimulate* AddSimulate(BailoutId ast_id,
141 RemovableSimulate removable = FIXED_SIMULATE) { 141 RemovableSimulate removable = FIXED_SIMULATE) {
142 AddInstruction(CreateSimulate(ast_id, removable)); 142 HSimulate* instr = CreateSimulate(ast_id, removable);
143 AddInstruction(instr);
144 return instr;
143 } 145 }
144 void AssignCommonDominator(HBasicBlock* other); 146 void AssignCommonDominator(HBasicBlock* other);
145 void AssignLoopSuccessorDominators(); 147 void AssignLoopSuccessorDominators();
146 148
147 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) {
148 FinishExit(CreateDeoptimize(has_uses));
149 }
150
151 // Add the inlined function exit sequence, adding an HLeaveInlined 149 // Add the inlined function exit sequence, adding an HLeaveInlined
152 // instruction and updating the bailout environment. 150 // instruction and updating the bailout environment.
153 void AddLeaveInlined(HValue* return_value, FunctionState* state); 151 void AddLeaveInlined(HValue* return_value, FunctionState* state);
154 152
155 // If a target block is tagged as an inline function return, all 153 // If a target block is tagged as an inline function return, all
156 // predecessors should contain the inlined exit sequence: 154 // predecessors should contain the inlined exit sequence:
157 // 155 //
158 // LeaveInlined 156 // LeaveInlined
159 // Simulate (caller's environment) 157 // Simulate (caller's environment)
160 // Goto (target block) 158 // Goto (target block)
(...skipping 14 matching lines...) Expand all
175 dominates_loop_successors_ = true; 173 dominates_loop_successors_ = true;
176 } 174 }
177 175
178 inline Zone* zone() const; 176 inline Zone* zone() const;
179 177
180 #ifdef DEBUG 178 #ifdef DEBUG
181 void Verify(); 179 void Verify();
182 #endif 180 #endif
183 181
184 private: 182 private:
183 friend class HGraphBuilder;
184
185 void RegisterPredecessor(HBasicBlock* pred); 185 void RegisterPredecessor(HBasicBlock* pred);
186 void AddDominatedBlock(HBasicBlock* block); 186 void AddDominatedBlock(HBasicBlock* block);
187 187
188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); 188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
189 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses);
190 189
191 int block_id_; 190 int block_id_;
192 HGraph* graph_; 191 HGraph* graph_;
193 ZoneList<HPhi*> phis_; 192 ZoneList<HPhi*> phis_;
194 HInstruction* first_; 193 HInstruction* first_;
195 HInstruction* last_; 194 HInstruction* last_;
196 HControlInstruction* end_; 195 HControlInstruction* end_;
197 HLoopInformation* loop_information_; 196 HLoopInformation* loop_information_;
198 ZoneList<HBasicBlock*> predecessors_; 197 ZoneList<HBasicBlock*> predecessors_;
199 HBasicBlock* dominator_; 198 HBasicBlock* dominator_;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 new(zone()) I(p1, p2, p3, p4, p5, p6, p7))); 1015 new(zone()) I(p1, p2, p3, p4, p5, p6, p7)));
1017 } 1016 }
1018 1017
1019 template<class I, class P1, class P2, class P3, class P4, 1018 template<class I, class P1, class P2, class P3, class P4,
1020 class P5, class P6, class P7, class P8> 1019 class P5, class P6, class P7, class P8>
1021 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { 1020 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1022 return static_cast<I*>(AddInstruction( 1021 return static_cast<I*>(AddInstruction(
1023 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8))); 1022 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)));
1024 } 1023 }
1025 1024
1026 void AddSimulate(BailoutId id,
1027 RemovableSimulate removable = FIXED_SIMULATE);
1028
1029 HReturn* AddReturn(HValue* value);
1030
1031 void IncrementInNoSideEffectsScope() { 1025 void IncrementInNoSideEffectsScope() {
1032 no_side_effects_scope_count_++; 1026 no_side_effects_scope_count_++;
1033 } 1027 }
1034 1028
1035 void DecrementInNoSideEffectsScope() { 1029 void DecrementInNoSideEffectsScope() {
1036 no_side_effects_scope_count_--; 1030 no_side_effects_scope_count_--;
1037 } 1031 }
1038 1032
1039 protected: 1033 protected:
1040 virtual bool BuildGraph() = 0; 1034 virtual bool BuildGraph() = 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 Representation representation = Representation::Tagged()); 1105 Representation representation = Representation::Tagged());
1112 1106
1113 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); 1107 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>);
1114 1108
1115 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); 1109 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL);
1116 1110
1117 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); 1111 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1118 1112
1119 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context); 1113 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HValue* context);
1120 1114
1121 enum SoftDeoptimizeMode { 1115 void FinishExitWithHardDeoptimization(HBasicBlock* continuation);
1122 MUST_EMIT_SOFT_DEOPT,
1123 CAN_OMIT_SOFT_DEOPT
1124 };
1125
1126 void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT);
1127 1116
1128 class IfBuilder { 1117 class IfBuilder {
1129 public: 1118 public:
1130 explicit IfBuilder(HGraphBuilder* builder, 1119 explicit IfBuilder(HGraphBuilder* builder,
1131 int position = RelocInfo::kNoPosition); 1120 int position = RelocInfo::kNoPosition);
1132 IfBuilder(HGraphBuilder* builder, 1121 IfBuilder(HGraphBuilder* builder,
1133 HIfContinuation* continuation); 1122 HIfContinuation* continuation);
1134 1123
1135 ~IfBuilder() { 1124 ~IfBuilder() {
1136 if (!finished_) End(); 1125 if (!finished_) End();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 void CaptureContinuation(HIfContinuation* continuation); 1210 void CaptureContinuation(HIfContinuation* continuation);
1222 1211
1223 void Then(); 1212 void Then();
1224 void Else(); 1213 void Else();
1225 void End(); 1214 void End();
1226 1215
1227 void Deopt(); 1216 void Deopt();
1228 void ElseDeopt() { 1217 void ElseDeopt() {
1229 Else(); 1218 Else();
1230 Deopt(); 1219 Deopt();
1231 End();
1232 } 1220 }
1233 1221
1234 void Return(HValue* value); 1222 void Return(HValue* value);
1235 1223
1236 private: 1224 private:
1237 void AddCompare(HControlInstruction* compare); 1225 void AddCompare(HControlInstruction* compare);
1238 1226
1239 Zone* zone() { return builder_->zone(); } 1227 Zone* zone() { return builder_->zone(); }
1240 1228
1241 HGraphBuilder* builder_; 1229 HGraphBuilder* builder_;
1242 int position_; 1230 int position_;
1243 bool finished_ : 1; 1231 bool finished_ : 1;
1232 bool deopt_then_ : 1;
1233 bool deopt_else_ : 1;
1244 bool did_then_ : 1; 1234 bool did_then_ : 1;
1245 bool did_else_ : 1; 1235 bool did_else_ : 1;
1246 bool did_and_ : 1; 1236 bool did_and_ : 1;
1247 bool did_or_ : 1; 1237 bool did_or_ : 1;
1248 bool captured_ : 1; 1238 bool captured_ : 1;
1249 bool needs_compare_ : 1; 1239 bool needs_compare_ : 1;
1250 HBasicBlock* first_true_block_; 1240 HBasicBlock* first_true_block_;
1251 HBasicBlock* last_true_block_; 1241 HBasicBlock* last_true_block_;
1252 HBasicBlock* first_false_block_; 1242 HBasicBlock* first_false_block_;
1253 HBasicBlock* split_edge_merge_block_; 1243 HBasicBlock* split_edge_merge_block_;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 1405
1416 HValue* BuildCreateAllocationMemento(HValue* previous_object, 1406 HValue* BuildCreateAllocationMemento(HValue* previous_object,
1417 int previous_object_size, 1407 int previous_object_size,
1418 HValue* payload); 1408 HValue* payload);
1419 1409
1420 HInstruction* BuildGetNativeContext(HValue* context); 1410 HInstruction* BuildGetNativeContext(HValue* context);
1421 HInstruction* BuildGetArrayFunction(HValue* context); 1411 HInstruction* BuildGetArrayFunction(HValue* context);
1422 1412
1423 private: 1413 private:
1424 HGraphBuilder(); 1414 HGraphBuilder();
1415
1416 void PadEnvironmentForContinuation(HBasicBlock* from,
1417 HBasicBlock* continuation);
1418
1425 CompilationInfo* info_; 1419 CompilationInfo* info_;
1426 HGraph* graph_; 1420 HGraph* graph_;
1427 HBasicBlock* current_block_; 1421 HBasicBlock* current_block_;
1428 int no_side_effects_scope_count_; 1422 int no_side_effects_scope_count_;
1429 }; 1423 };
1430 1424
1425
1426 template<>
1427 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) {
1428 if (type == Deoptimizer::SOFT) {
1429 isolate()->counters()->soft_deopts_requested()->Increment();
1430 if (FLAG_always_opt) return NULL;
1431 }
1432 if (current_block()->IsDeoptimizing()) return NULL;
1433 HDeoptimize* instr = new(zone()) HDeoptimize(type);
1434 AddInstruction(instr);
1435 if (type == Deoptimizer::SOFT) {
1436 isolate()->counters()->soft_deopts_inserted()->Increment();
1437 graph()->set_has_soft_deoptimize(true);
1438 }
1439 current_block()->MarkAsDeoptimizing();
1440 return instr;
1441 }
1442
1443
1444 template<>
1445 inline HSimulate* HGraphBuilder::Add(BailoutId id,
1446 RemovableSimulate removable) {
1447 HSimulate* instr = current_block()->CreateSimulate(id, removable);
1448 AddInstruction(instr);
1449 return instr;
1450 }
1451
1452
1453 template<>
1454 inline HSimulate* HGraphBuilder::Add(BailoutId id) {
1455 return Add<HSimulate>(id, FIXED_SIMULATE);
1456 }
1457
1458
1459 template<>
1460 inline HReturn* HGraphBuilder::Add(HValue* value) {
1461 HValue* context = environment()->LookupContext();
1462 int num_parameters = graph()->info()->num_parameters();
1463 HValue* params = Add<HConstant>(num_parameters);
1464 HReturn* return_instruction = new(graph()->zone())
1465 HReturn(value, context, params);
1466 current_block()->FinishExit(return_instruction);
1467 return return_instruction;
1468 }
1469
1470
1471 template<>
1472 inline HReturn* HGraphBuilder::Add(HConstant* p1) {
1473 return Add<HReturn>(static_cast<HValue*>(p1));
1474 }
1475
1476
1431 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { 1477 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1432 public: 1478 public:
1433 // A class encapsulating (lazily-allocated) break and continue blocks for 1479 // A class encapsulating (lazily-allocated) break and continue blocks for
1434 // a breakable statement. Separated from BreakAndContinueScope so that it 1480 // a breakable statement. Separated from BreakAndContinueScope so that it
1435 // can have a separate lifetime. 1481 // can have a separate lifetime.
1436 class BreakAndContinueInfo BASE_EMBEDDED { 1482 class BreakAndContinueInfo BASE_EMBEDDED {
1437 public: 1483 public:
1438 explicit BreakAndContinueInfo(BreakableStatement* target, 1484 explicit BreakAndContinueInfo(BreakableStatement* target,
1439 int drop_extra = 0) 1485 int drop_extra = 0)
1440 : target_(target), 1486 : target_(target),
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 EmbeddedVector<char, 64> filename_; 2141 EmbeddedVector<char, 64> filename_;
2096 HeapStringAllocator string_allocator_; 2142 HeapStringAllocator string_allocator_;
2097 StringStream trace_; 2143 StringStream trace_;
2098 int indent_; 2144 int indent_;
2099 }; 2145 };
2100 2146
2101 2147
2102 } } // namespace v8::internal 2148 } } // namespace v8::internal
2103 2149
2104 #endif // V8_HYDROGEN_H_ 2150 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698