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

Side by Side Diff: src/hydrogen.h

Issue 20767002: Merge 15827, 15842, and 15912 into 3.19 (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.19
Patch Set: Final version Created 7 years, 4 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void Finish(HControlInstruction* last); 129 void Finish(HControlInstruction* last);
130 void FinishExit(HControlInstruction* instruction); 130 void FinishExit(HControlInstruction* instruction);
131 void Goto(HBasicBlock* block, 131 void Goto(HBasicBlock* block,
132 FunctionState* state = NULL, 132 FunctionState* state = NULL,
133 bool add_simulate = true); 133 bool add_simulate = true);
134 void GotoNoSimulate(HBasicBlock* block) { 134 void GotoNoSimulate(HBasicBlock* block) {
135 Goto(block, NULL, false); 135 Goto(block, NULL, false);
136 } 136 }
137 137
138 int PredecessorIndexOf(HBasicBlock* predecessor) const; 138 int PredecessorIndexOf(HBasicBlock* predecessor) const;
139 void AddSimulate(BailoutId ast_id, 139 HSimulate* AddSimulate(BailoutId ast_id,
140 RemovableSimulate removable = FIXED_SIMULATE) { 140 RemovableSimulate removable = FIXED_SIMULATE) {
141 AddInstruction(CreateSimulate(ast_id, removable)); 141 HSimulate* instr = CreateSimulate(ast_id, removable);
142 AddInstruction(instr);
143 return instr;
142 } 144 }
143 void AssignCommonDominator(HBasicBlock* other); 145 void AssignCommonDominator(HBasicBlock* other);
144 void AssignLoopSuccessorDominators(); 146 void AssignLoopSuccessorDominators();
145 147
146 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) {
147 FinishExit(CreateDeoptimize(has_uses));
148 }
149
150 // Add the inlined function exit sequence, adding an HLeaveInlined 148 // Add the inlined function exit sequence, adding an HLeaveInlined
151 // instruction and updating the bailout environment. 149 // instruction and updating the bailout environment.
152 void AddLeaveInlined(HValue* return_value, FunctionState* state); 150 void AddLeaveInlined(HValue* return_value, FunctionState* state);
153 151
154 // If a target block is tagged as an inline function return, all 152 // If a target block is tagged as an inline function return, all
155 // predecessors should contain the inlined exit sequence: 153 // predecessors should contain the inlined exit sequence:
156 // 154 //
157 // LeaveInlined 155 // LeaveInlined
158 // Simulate (caller's environment) 156 // Simulate (caller's environment)
159 // Goto (target block) 157 // Goto (target block)
(...skipping 14 matching lines...) Expand all
174 dominates_loop_successors_ = true; 172 dominates_loop_successors_ = true;
175 } 173 }
176 174
177 inline Zone* zone() const; 175 inline Zone* zone() const;
178 176
179 #ifdef DEBUG 177 #ifdef DEBUG
180 void Verify(); 178 void Verify();
181 #endif 179 #endif
182 180
183 private: 181 private:
182 friend class HGraphBuilder;
183
184 void RegisterPredecessor(HBasicBlock* pred); 184 void RegisterPredecessor(HBasicBlock* pred);
185 void AddDominatedBlock(HBasicBlock* block); 185 void AddDominatedBlock(HBasicBlock* block);
186 186
187 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); 187 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
188 HDeoptimize* CreateDeoptimize(HDeoptimize::UseEnvironment has_uses);
189 188
190 int block_id_; 189 int block_id_;
191 HGraph* graph_; 190 HGraph* graph_;
192 ZoneList<HPhi*> phis_; 191 ZoneList<HPhi*> phis_;
193 HInstruction* first_; 192 HInstruction* first_;
194 HInstruction* last_; 193 HInstruction* last_;
195 HControlInstruction* end_; 194 HControlInstruction* end_;
196 HLoopInformation* loop_information_; 195 HLoopInformation* loop_information_;
197 ZoneList<HBasicBlock*> predecessors_; 196 ZoneList<HBasicBlock*> predecessors_;
198 HBasicBlock* dominator_; 197 HBasicBlock* dominator_;
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 CompilationInfo* top_info() { return info_; } 983 CompilationInfo* top_info() { return info_; }
985 984
986 HGraph* CreateGraph(); 985 HGraph* CreateGraph();
987 986
988 // Bailout environment manipulation. 987 // Bailout environment manipulation.
989 void Push(HValue* value) { environment()->Push(value); } 988 void Push(HValue* value) { environment()->Push(value); }
990 HValue* Pop() { return environment()->Pop(); } 989 HValue* Pop() { return environment()->Pop(); }
991 990
992 // Adding instructions. 991 // Adding instructions.
993 HInstruction* AddInstruction(HInstruction* instr); 992 HInstruction* AddInstruction(HInstruction* instr);
994 void AddSimulate(BailoutId id,
995 RemovableSimulate removable = FIXED_SIMULATE);
996 HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length); 993 HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length);
997 994
998 HReturn* AddReturn(HValue* value); 995 HReturn* AddReturn(HValue* value);
999 996
1000 void IncrementInNoSideEffectsScope() { 997 void IncrementInNoSideEffectsScope() {
1001 no_side_effects_scope_count_++; 998 no_side_effects_scope_count_++;
1002 } 999 }
1003 1000
1004 void DecrementInNoSideEffectsScope() { 1001 void DecrementInNoSideEffectsScope() {
1005 no_side_effects_scope_count_--; 1002 no_side_effects_scope_count_--;
1006 } 1003 }
1007 1004
1005 void FinishExitWithHardDeoptimization(HBasicBlock* continuation);
1006
1007 template<class I, class P1>
1008 I* Add(P1 p1) {
1009 return I::cast(AddInstruction(new (zone()) I(p1)));
1010 }
1011
1012 template<class I, class P1, class P2>
1013 I* Add(P1 p1, P2 p2) {
1014 return I::cast(AddInstruction(new (zone()) I(p1, p2)));
1015 }
1016
1008 protected: 1017 protected:
1009 virtual bool BuildGraph() = 0; 1018 virtual bool BuildGraph() = 0;
1010 1019
1011 HBasicBlock* CreateBasicBlock(HEnvironment* env); 1020 HBasicBlock* CreateBasicBlock(HEnvironment* env);
1012 HBasicBlock* CreateLoopHeaderBlock(); 1021 HBasicBlock* CreateLoopHeaderBlock();
1013 1022
1014 HValue* BuildCheckNonSmi(HValue* object); 1023 HValue* BuildCheckNonSmi(HValue* object);
1015 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); 1024 HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
1016 1025
1017 // Building common constructs 1026 // Building common constructs
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 void CaptureContinuation(HIfContinuation* continuation); 1185 void CaptureContinuation(HIfContinuation* continuation);
1177 1186
1178 void Then(); 1187 void Then();
1179 void Else(); 1188 void Else();
1180 void End(); 1189 void End();
1181 1190
1182 void Deopt(); 1191 void Deopt();
1183 void ElseDeopt() { 1192 void ElseDeopt() {
1184 Else(); 1193 Else();
1185 Deopt(); 1194 Deopt();
1186 End();
1187 } 1195 }
1188 1196
1189 void Return(HValue* value); 1197 void Return(HValue* value);
1190 1198
1191 private: 1199 private:
1192 void AddCompare(HControlInstruction* compare); 1200 void AddCompare(HControlInstruction* compare);
1193 1201
1194 Zone* zone() { return builder_->zone(); } 1202 Zone* zone() { return builder_->zone(); }
1195 1203
1196 HGraphBuilder* builder_; 1204 HGraphBuilder* builder_;
1197 int position_; 1205 int position_;
1198 bool finished_ : 1; 1206 bool finished_ : 1;
1207 bool deopt_then_ : 1;
1208 bool deopt_else_ : 1;
1199 bool did_then_ : 1; 1209 bool did_then_ : 1;
1200 bool did_else_ : 1; 1210 bool did_else_ : 1;
1201 bool did_and_ : 1; 1211 bool did_and_ : 1;
1202 bool did_or_ : 1; 1212 bool did_or_ : 1;
1203 bool captured_ : 1; 1213 bool captured_ : 1;
1204 bool needs_compare_ : 1; 1214 bool needs_compare_ : 1;
1205 HBasicBlock* first_true_block_; 1215 HBasicBlock* first_true_block_;
1206 HBasicBlock* last_true_block_; 1216 HBasicBlock* last_true_block_;
1207 HBasicBlock* first_false_block_; 1217 HBasicBlock* first_false_block_;
1208 HBasicBlock* split_edge_merge_block_; 1218 HBasicBlock* split_edge_merge_block_;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1377
1368 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, 1378 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object,
1369 int previous_object_size, 1379 int previous_object_size,
1370 HValue* payload); 1380 HValue* payload);
1371 1381
1372 HInstruction* BuildGetNativeContext(HValue* context); 1382 HInstruction* BuildGetNativeContext(HValue* context);
1373 HInstruction* BuildGetArrayFunction(HValue* context); 1383 HInstruction* BuildGetArrayFunction(HValue* context);
1374 1384
1375 private: 1385 private:
1376 HGraphBuilder(); 1386 HGraphBuilder();
1387
1388 void PadEnvironmentForContinuation(HBasicBlock* from,
1389 HBasicBlock* continuation);
1390
1377 CompilationInfo* info_; 1391 CompilationInfo* info_;
1378 HGraph* graph_; 1392 HGraph* graph_;
1379 HBasicBlock* current_block_; 1393 HBasicBlock* current_block_;
1380 int no_side_effects_scope_count_; 1394 int no_side_effects_scope_count_;
1381 }; 1395 };
1382 1396
1383 1397
1398 template<>
1399 inline HDeoptimize* HGraphBuilder::Add(Deoptimizer::BailoutType type) {
1400 if (type == Deoptimizer::SOFT) {
1401 if (FLAG_always_opt) return NULL;
1402 }
1403 if (current_block()->IsDeoptimizing()) return NULL;
1404 HDeoptimize* instr = new(zone()) HDeoptimize(type);
1405 AddInstruction(instr);
1406 if (type == Deoptimizer::SOFT) {
1407 graph()->set_has_soft_deoptimize(true);
1408 }
1409 current_block()->MarkAsDeoptimizing();
1410 return instr;
1411 }
1412
1413
1414 template<>
1415 inline HSimulate* HGraphBuilder::Add(BailoutId id,
1416 RemovableSimulate removable) {
1417 HSimulate* instr = current_block()->CreateSimulate(id, removable);
1418 AddInstruction(instr);
1419 return instr;
1420 }
1421
1422
1423 template<>
1424 inline HSimulate* HGraphBuilder::Add(BailoutId id) {
1425 return Add<HSimulate>(id, FIXED_SIMULATE);
1426 }
1427
1428
1429 template<>
1430 inline HReturn* HGraphBuilder::Add(HValue* value) {
1431 HValue* context = environment()->LookupContext();
1432 int num_parameters = graph()->info()->num_parameters();
1433 HValue* params = Add<HConstant>(num_parameters);
1434 HReturn* return_instruction = new(graph()->zone())
1435 HReturn(value, context, params);
1436 current_block()->FinishExit(return_instruction);
1437 return return_instruction;
1438 }
1439
1440
1441 template<>
1442 inline HReturn* HGraphBuilder::Add(HConstant* p1) {
1443 return Add<HReturn>(static_cast<HValue*>(p1));
1444 }
1445
1446
1384 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { 1447 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1385 public: 1448 public:
1386 // A class encapsulating (lazily-allocated) break and continue blocks for 1449 // A class encapsulating (lazily-allocated) break and continue blocks for
1387 // a breakable statement. Separated from BreakAndContinueScope so that it 1450 // a breakable statement. Separated from BreakAndContinueScope so that it
1388 // can have a separate lifetime. 1451 // can have a separate lifetime.
1389 class BreakAndContinueInfo BASE_EMBEDDED { 1452 class BreakAndContinueInfo BASE_EMBEDDED {
1390 public: 1453 public:
1391 explicit BreakAndContinueInfo(BreakableStatement* target, 1454 explicit BreakAndContinueInfo(BreakableStatement* target,
1392 int drop_extra = 0) 1455 int drop_extra = 0)
1393 : target_(target), 1456 : target_(target),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 explicit HOptimizedGraphBuilder(CompilationInfo* info); 1502 explicit HOptimizedGraphBuilder(CompilationInfo* info);
1440 1503
1441 virtual bool BuildGraph(); 1504 virtual bool BuildGraph();
1442 1505
1443 // Simple accessors. 1506 // Simple accessors.
1444 BreakAndContinueScope* break_scope() const { return break_scope_; } 1507 BreakAndContinueScope* break_scope() const { return break_scope_; }
1445 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 1508 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
1446 1509
1447 bool inline_bailout() { return inline_bailout_; } 1510 bool inline_bailout() { return inline_bailout_; }
1448 1511
1449 void AddSoftDeoptimize();
1450
1451 void Bailout(const char* reason); 1512 void Bailout(const char* reason);
1452 1513
1453 HBasicBlock* CreateJoin(HBasicBlock* first, 1514 HBasicBlock* CreateJoin(HBasicBlock* first,
1454 HBasicBlock* second, 1515 HBasicBlock* second,
1455 BailoutId join_id); 1516 BailoutId join_id);
1456 1517
1457 FunctionState* function_state() const { return function_state_; } 1518 FunctionState* function_state() const { return function_state_; }
1458 1519
1459 void VisitDeclarations(ZoneList<Declaration*>* declarations); 1520 void VisitDeclarations(ZoneList<Declaration*>* declarations);
1460 1521
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 EmbeddedVector<char, 64> filename_; 2109 EmbeddedVector<char, 64> filename_;
2049 HeapStringAllocator string_allocator_; 2110 HeapStringAllocator string_allocator_;
2050 StringStream trace_; 2111 StringStream trace_;
2051 int indent_; 2112 int indent_;
2052 }; 2113 };
2053 2114
2054 2115
2055 } } // namespace v8::internal 2116 } } // namespace v8::internal
2056 2117
2057 #endif // V8_HYDROGEN_H_ 2118 #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