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

Side by Side Diff: src/hydrogen.h

Issue 11415173: Array bounds check elimination. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Refactoring (and fixing refactoring issues). Created 8 years 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int argument_count() const { return argument_count_; } 84 int argument_count() const { return argument_count_; }
85 void set_argument_count(int count) { argument_count_ = count; } 85 void set_argument_count(int count) { argument_count_ = count; }
86 int first_instruction_index() const { return first_instruction_index_; } 86 int first_instruction_index() const { return first_instruction_index_; }
87 void set_first_instruction_index(int index) { 87 void set_first_instruction_index(int index) {
88 first_instruction_index_ = index; 88 first_instruction_index_ = index;
89 } 89 }
90 int last_instruction_index() const { return last_instruction_index_; } 90 int last_instruction_index() const { return last_instruction_index_; }
91 void set_last_instruction_index(int index) { 91 void set_last_instruction_index(int index) {
92 last_instruction_index_ = index; 92 last_instruction_index_ = index;
93 } 93 }
94 bool is_osr_entry() { return is_osr_entry_; }
95 void set_osr_entry() { is_osr_entry_ = true; }
94 96
95 void AttachLoopInformation(); 97 void AttachLoopInformation();
96 void DetachLoopInformation(); 98 void DetachLoopInformation();
97 bool IsLoopHeader() const { return loop_information() != NULL; } 99 bool IsLoopHeader() const { return loop_information() != NULL; }
98 bool IsStartBlock() const { return block_id() == 0; } 100 bool IsStartBlock() const { return block_id() == 0; }
99 void PostProcessLoopHeader(IterationStatement* stmt); 101 void PostProcessLoopHeader(IterationStatement* stmt);
100 102
101 bool IsFinished() const { return end_ != NULL; } 103 bool IsFinished() const { return end_ != NULL; }
102 void AddPhi(HPhi* phi); 104 void AddPhi(HPhi* phi);
103 void RemovePhi(HPhi* phi); 105 void RemovePhi(HPhi* phi);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Outgoing parameter count at block exit, set during lithium translation. 188 // Outgoing parameter count at block exit, set during lithium translation.
187 int argument_count_; 189 int argument_count_;
188 // Instruction indices into the lithium code stream. 190 // Instruction indices into the lithium code stream.
189 int first_instruction_index_; 191 int first_instruction_index_;
190 int last_instruction_index_; 192 int last_instruction_index_;
191 ZoneList<int> deleted_phis_; 193 ZoneList<int> deleted_phis_;
192 HBasicBlock* parent_loop_header_; 194 HBasicBlock* parent_loop_header_;
193 bool is_inline_return_target_; 195 bool is_inline_return_target_;
194 bool is_deoptimizing_; 196 bool is_deoptimizing_;
195 bool dominates_loop_successors_; 197 bool dominates_loop_successors_;
198 bool is_osr_entry_;
196 }; 199 };
197 200
198 201
199 class HPredecessorIterator BASE_EMBEDDED { 202 class HPredecessorIterator BASE_EMBEDDED {
200 public: 203 public:
201 explicit HPredecessorIterator(HBasicBlock* block) 204 explicit HPredecessorIterator(HBasicBlock* block)
202 : predecessor_list_(block->predecessors()), current_(0) { } 205 : predecessor_list_(block->predecessors()), current_(0) { }
203 206
204 bool Done() { return current_ >= predecessor_list_->length(); } 207 bool Done() { return current_ >= predecessor_list_->length(); }
205 HBasicBlock* Current() { return predecessor_list_->at(current_); } 208 HBasicBlock* Current() { return predecessor_list_->at(current_); }
(...skipping 12 matching lines...) Expand all
218 loop_header_(loop_header), 221 loop_header_(loop_header),
219 blocks_(8, zone), 222 blocks_(8, zone),
220 stack_check_(NULL) { 223 stack_check_(NULL) {
221 blocks_.Add(loop_header, zone); 224 blocks_.Add(loop_header, zone);
222 } 225 }
223 virtual ~HLoopInformation() {} 226 virtual ~HLoopInformation() {}
224 227
225 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; } 228 const ZoneList<HBasicBlock*>* back_edges() const { return &back_edges_; }
226 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 229 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
227 HBasicBlock* loop_header() const { return loop_header_; } 230 HBasicBlock* loop_header() const { return loop_header_; }
231 HBasicBlock* loop_pre_header() const {
232 return loop_header_->predecessors()->at(0);
233 }
228 HBasicBlock* GetLastBackEdge() const; 234 HBasicBlock* GetLastBackEdge() const;
229 void RegisterBackEdge(HBasicBlock* block); 235 void RegisterBackEdge(HBasicBlock* block);
230 236
231 HStackCheck* stack_check() const { return stack_check_; } 237 HStackCheck* stack_check() const { return stack_check_; }
232 void set_stack_check(HStackCheck* stack_check) { 238 void set_stack_check(HStackCheck* stack_check) {
233 stack_check_ = stack_check; 239 stack_check_ = stack_check;
234 } 240 }
235 241
236 private: 242 private:
237 void AddBlock(HBasicBlock* block); 243 void AddBlock(HBasicBlock* block);
238 244
239 ZoneList<HBasicBlock*> back_edges_; 245 ZoneList<HBasicBlock*> back_edges_;
240 HBasicBlock* loop_header_; 246 HBasicBlock* loop_header_;
241 ZoneList<HBasicBlock*> blocks_; 247 ZoneList<HBasicBlock*> blocks_;
242 HStackCheck* stack_check_; 248 HStackCheck* stack_check_;
243 }; 249 };
244 250
245 class BoundsCheckTable; 251 class BoundsCheckTable;
252 class BoundsCheckValueInfoTable;
253 class BoundsCheckRemovalBlockContext;
246 class HGraph: public ZoneObject { 254 class HGraph: public ZoneObject {
247 public: 255 public:
248 explicit HGraph(CompilationInfo* info); 256 explicit HGraph(CompilationInfo* info);
249 257
250 Isolate* isolate() { return isolate_; } 258 Isolate* isolate() { return isolate_; }
251 Zone* zone() const { return zone_; } 259 Zone* zone() const { return zone_; }
252 CompilationInfo* info() const { return info_; } 260 CompilationInfo* info() const { return info_; }
253 261
254 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 262 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
255 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } 263 const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
256 HBasicBlock* entry_block() const { return entry_block_; } 264 HBasicBlock* entry_block() const { return entry_block_; }
257 HEnvironment* start_environment() const { return start_environment_; } 265 HEnvironment* start_environment() const { return start_environment_; }
258 266
259 void InitializeInferredTypes(); 267 void InitializeInferredTypes();
260 void InsertTypeConversions(); 268 void InsertTypeConversions();
261 void MergeRemovableSimulates(); 269 void MergeRemovableSimulates();
262 void InsertRepresentationChanges(); 270 void InsertRepresentationChanges();
263 void MarkDeoptimizeOnUndefined(); 271 void MarkDeoptimizeOnUndefined();
264 void ComputeMinusZeroChecks(); 272 void ComputeMinusZeroChecks();
265 void ComputeSafeUint32Operations(); 273 void ComputeSafeUint32Operations();
266 bool ProcessArgumentsObject(); 274 bool ProcessArgumentsObject();
267 void EliminateRedundantPhis(); 275 void EliminateRedundantPhis();
268 void EliminateUnreachablePhis(); 276 void EliminateUnreachablePhis();
269 void Canonicalize(); 277 void Canonicalize();
270 void OrderBlocks(); 278 void OrderBlocks();
271 void AssignDominators(); 279 void AssignDominators();
272 void ReplaceCheckedValues(); 280 void ReplaceCheckedValues();
273 void EliminateRedundantBoundsChecks(); 281 void EliminateRedundantBoundsChecks();
282 void EliminateOrDehoistBoundsChecks();
274 void DehoistSimpleArrayIndexComputations(); 283 void DehoistSimpleArrayIndexComputations();
275 void DeadCodeElimination(); 284 void DeadCodeElimination();
276 void PropagateDeoptimizingMark(); 285 void PropagateDeoptimizingMark();
277 void EliminateUnusedInstructions(); 286 void EliminateUnusedInstructions();
278 287
279 // Returns false if there are phi-uses of the arguments-object 288 // Returns false if there are phi-uses of the arguments-object
280 // which are not supported by the optimizing compiler. 289 // which are not supported by the optimizing compiler.
281 bool CheckArgumentsPhiUses(); 290 bool CheckArgumentsPhiUses();
282 291
283 // Returns false if there are phi-uses of an uninitialized const 292 // Returns false if there are phi-uses of an uninitialized const
284 // which are not supported by the optimizing compiler. 293 // which are not supported by the optimizing compiler.
285 bool CheckConstPhiUses(); 294 bool CheckConstPhiUses();
286 295
287 void CollectPhis(); 296 void CollectPhis();
288 297
289 void set_undefined_constant(HConstant* constant) { 298 void set_undefined_constant(HConstant* constant) {
290 undefined_constant_.set(constant); 299 undefined_constant_.set(constant);
291 } 300 }
292 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } 301 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); }
302 HConstant* GetConstant0();
293 HConstant* GetConstant1(); 303 HConstant* GetConstant1();
294 HConstant* GetConstantMinus1(); 304 HConstant* GetConstantMinus1();
295 HConstant* GetConstantTrue(); 305 HConstant* GetConstantTrue();
296 HConstant* GetConstantFalse(); 306 HConstant* GetConstantFalse();
297 HConstant* GetConstantHole(); 307 HConstant* GetConstantHole();
298 308
299 HBasicBlock* CreateBasicBlock(); 309 HBasicBlock* CreateBasicBlock();
300 HArgumentsObject* GetArgumentsObject() const { 310 HArgumentsObject* GetArgumentsObject() const {
301 return arguments_object_.get(); 311 return arguments_object_.get();
302 } 312 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void PropagateMinusZeroChecks(HValue* value, BitVector* visited); 391 void PropagateMinusZeroChecks(HValue* value, BitVector* visited);
382 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); 392 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi);
383 void InsertRepresentationChangeForUse(HValue* value, 393 void InsertRepresentationChangeForUse(HValue* value,
384 HValue* use_value, 394 HValue* use_value,
385 int use_index, 395 int use_index,
386 Representation to); 396 Representation to);
387 void InsertRepresentationChangesForValue(HValue* value); 397 void InsertRepresentationChangesForValue(HValue* value);
388 void InferTypes(ZoneList<HValue*>* worklist); 398 void InferTypes(ZoneList<HValue*>* worklist);
389 void InitializeInferredTypes(int from_inclusive, int to_inclusive); 399 void InitializeInferredTypes(int from_inclusive, int to_inclusive);
390 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); 400 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor);
391 void EliminateRedundantBoundsChecks(HBasicBlock* bb, BoundsCheckTable* table); 401 void EliminateRedundantBoundsChecks(HBasicBlock* bb,
402 BoundsCheckTable* table);
403 void EliminateOrDehoistBoundsChecks(
404 HBasicBlock* bb,
405 BoundsCheckRemovalBlockContext* previous_context);
392 406
393 Isolate* isolate_; 407 Isolate* isolate_;
394 int next_block_id_; 408 int next_block_id_;
395 HBasicBlock* entry_block_; 409 HBasicBlock* entry_block_;
396 HEnvironment* start_environment_; 410 HEnvironment* start_environment_;
397 ZoneList<HBasicBlock*> blocks_; 411 ZoneList<HBasicBlock*> blocks_;
398 ZoneList<HValue*> values_; 412 ZoneList<HValue*> values_;
399 ZoneList<HPhi*>* phi_list_; 413 ZoneList<HPhi*>* phi_list_;
400 ZoneList<HInstruction*>* uint32_instructions_; 414 ZoneList<HInstruction*>* uint32_instructions_;
401 SetOncePointer<HConstant> undefined_constant_; 415 SetOncePointer<HConstant> undefined_constant_;
416 SetOncePointer<HConstant> constant_0_;
402 SetOncePointer<HConstant> constant_1_; 417 SetOncePointer<HConstant> constant_1_;
403 SetOncePointer<HConstant> constant_minus1_; 418 SetOncePointer<HConstant> constant_minus1_;
404 SetOncePointer<HConstant> constant_true_; 419 SetOncePointer<HConstant> constant_true_;
405 SetOncePointer<HConstant> constant_false_; 420 SetOncePointer<HConstant> constant_false_;
406 SetOncePointer<HConstant> constant_hole_; 421 SetOncePointer<HConstant> constant_hole_;
407 SetOncePointer<HArgumentsObject> arguments_object_; 422 SetOncePointer<HArgumentsObject> arguments_object_;
408 423
409 SetOncePointer<HBasicBlock> osr_loop_entry_; 424 SetOncePointer<HBasicBlock> osr_loop_entry_;
410 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; 425 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_;
411 426
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 const char* filename_; 1542 const char* filename_;
1528 HeapStringAllocator string_allocator_; 1543 HeapStringAllocator string_allocator_;
1529 StringStream trace_; 1544 StringStream trace_;
1530 int indent_; 1545 int indent_;
1531 }; 1546 };
1532 1547
1533 1548
1534 } } // namespace v8::internal 1549 } } // namespace v8::internal
1535 1550
1536 #endif // V8_HYDROGEN_H_ 1551 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698