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

Side by Side Diff: runtime/vm/flow_graph_optimizer.h

Issue 395943003: Support allocation sinking for compound objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: improve tests Created 6 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 | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_optimizer.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_
6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/flow_graph.h" 9 #include "vm/flow_graph.h"
10 10
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 class IfConverter : public AllStatic { 422 class IfConverter : public AllStatic {
423 public: 423 public:
424 static void Simplify(FlowGraph* flow_graph); 424 static void Simplify(FlowGraph* flow_graph);
425 }; 425 };
426 426
427 427
428 class AllocationSinking : public ZoneAllocated { 428 class AllocationSinking : public ZoneAllocated {
429 public: 429 public:
430 explicit AllocationSinking(FlowGraph* flow_graph) 430 explicit AllocationSinking(FlowGraph* flow_graph)
431 : flow_graph_(flow_graph), 431 : flow_graph_(flow_graph),
432 candidates_(5),
432 materializations_(5) { } 433 materializations_(5) { }
433 434
435 const GrowableArray<AllocateObjectInstr*>& candidates() const {
436 return candidates_;
437 }
438
439 // Find the materialization insterted for the given allocation
440 // at the given exit.
441 MaterializeObjectInstr* MaterializationFor(Definition* alloc,
442 Instruction* exit);
443
434 void Optimize(); 444 void Optimize();
435 445
436 void DetachMaterializations(); 446 void DetachMaterializations();
437 447
438 private: 448 private:
449 // Helper class to collect deoptimization exits that might need to
450 // rematerialize an object: that is either instructions that reference
451 // this object explicitly in their deoptimization environment or
452 // reference some other allocation sinking candidate that points to
453 // this object.
454 class ExitsCollector : public ValueObject {
455 public:
456 ExitsCollector() : exits_(10), worklist_(3) { }
457
458 const GrowableArray<Instruction*>& exits() const { return exits_; }
459
460 void CollectTransitively(Definition* alloc);
461
462 private:
463 // Collect immediate uses of this object in the environments.
464 // If this object is stored into other allocation sinking candidates
465 // put them onto worklist so that CollectTransitively will process them.
466 void Collect(Definition* alloc);
467
468 GrowableArray<Instruction*> exits_;
469 GrowableArray<Definition*> worklist_;
470 };
471
472 void CollectCandidates();
473
474 void NormalizeMaterializations();
475
476 void RemoveUnusedMaterializations();
477
478 void DiscoverFailedCandidates();
479
439 void InsertMaterializations(AllocateObjectInstr* alloc); 480 void InsertMaterializations(AllocateObjectInstr* alloc);
440 481
441 void CreateMaterializationAt( 482 void CreateMaterializationAt(
442 Instruction* exit, 483 Instruction* exit,
443 AllocateObjectInstr* alloc, 484 AllocateObjectInstr* alloc,
444 const Class& cls, 485 const Class& cls,
445 const ZoneGrowableArray<const Object*>& fields); 486 const ZoneGrowableArray<const Object*>& fields);
446 487
488 void EliminateAllocation(AllocateObjectInstr* alloc);
489
447 Isolate* isolate() const { return flow_graph_->isolate(); } 490 Isolate* isolate() const { return flow_graph_->isolate(); }
448 491
449 FlowGraph* flow_graph_; 492 FlowGraph* flow_graph_;
450 493
494 GrowableArray<AllocateObjectInstr*> candidates_;
451 GrowableArray<MaterializeObjectInstr*> materializations_; 495 GrowableArray<MaterializeObjectInstr*> materializations_;
496
497 ExitsCollector exits_collector_;
452 }; 498 };
453 499
454 500
455 // Optimize spill stores inside try-blocks by identifying values that always 501 // Optimize spill stores inside try-blocks by identifying values that always
456 // contain a single known constant at catch block entry. 502 // contain a single known constant at catch block entry.
457 class TryCatchAnalyzer : public AllStatic { 503 class TryCatchAnalyzer : public AllStatic {
458 public: 504 public:
459 static void Optimize(FlowGraph* flow_graph); 505 static void Optimize(FlowGraph* flow_graph);
460 }; 506 };
461 507
462 } // namespace dart 508 } // namespace dart
463 509
464 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ 510 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698