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

Side by Side Diff: src/hydrogen.h

Issue 12450003: Separate output files for --trace-hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some simplifications Created 7 years, 9 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/compiler.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 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 unsigned total_size_; 1574 unsigned total_size_;
1575 int64_t full_code_gen_; 1575 int64_t full_code_gen_;
1576 double source_size_; 1576 double source_size_;
1577 }; 1577 };
1578 1578
1579 1579
1580 class HPhase BASE_EMBEDDED { 1580 class HPhase BASE_EMBEDDED {
1581 public: 1581 public:
1582 static const char* const kFullCodeGen; 1582 static const char* const kFullCodeGen;
1583 1583
1584 explicit HPhase(const char* name) { Begin(name, NULL, NULL, NULL); } 1584 HPhase(const char* name, Isolate* isolate);
1585 HPhase(const char* name, HGraph* graph) { 1585 HPhase(const char* name, HGraph* graph);
1586 Begin(name, graph, NULL, NULL); 1586 HPhase(const char* name, LChunk* chunk);
1587 } 1587 HPhase(const char* name, LAllocator* allocator);
1588 HPhase(const char* name, LChunk* chunk) { 1588 ~HPhase();
1589 Begin(name, NULL, chunk, NULL);
1590 }
1591 HPhase(const char* name, LAllocator* allocator) {
1592 Begin(name, NULL, NULL, allocator);
1593 }
1594
1595 ~HPhase() {
1596 End();
1597 }
1598 1589
1599 private: 1590 private:
1600 void Begin(const char* name, 1591 void Init(Isolate* isolate,
1592 const char* name,
1601 HGraph* graph, 1593 HGraph* graph,
1602 LChunk* chunk, 1594 LChunk* chunk,
1603 LAllocator* allocator); 1595 LAllocator* allocator);
1604 void End() const;
1605 1596
1606 int64_t start_; 1597 Isolate* isolate_;
1607 const char* name_; 1598 const char* name_;
1608 HGraph* graph_; 1599 HGraph* graph_;
1609 LChunk* chunk_; 1600 LChunk* chunk_;
1610 LAllocator* allocator_; 1601 LAllocator* allocator_;
1602 int64_t start_ticks_;
1611 unsigned start_allocation_size_; 1603 unsigned start_allocation_size_;
1612 }; 1604 };
1613 1605
1614 1606
1615 class HTracer: public Malloced { 1607 class HTracer: public Malloced {
1616 public: 1608 public:
1609 explicit HTracer(int isolate_id)
1610 : trace_(&string_allocator_), indent_(0) {
1611 OS::SNPrintF(filename_,
1612 "hydrogen-%d-%d.cfg",
1613 OS::GetCurrentProcessId(),
1614 isolate_id);
1615 WriteChars(filename_.start(), "", 0, false);
1616 }
1617
1617 void TraceCompilation(CompilationInfo* info); 1618 void TraceCompilation(CompilationInfo* info);
1618 void TraceHydrogen(const char* name, HGraph* graph); 1619 void TraceHydrogen(const char* name, HGraph* graph);
1619 void TraceLithium(const char* name, LChunk* chunk); 1620 void TraceLithium(const char* name, LChunk* chunk);
1620 void TraceLiveRanges(const char* name, LAllocator* allocator); 1621 void TraceLiveRanges(const char* name, LAllocator* allocator);
1621 1622
1622 static HTracer* Instance() {
1623 static SetOncePointer<HTracer> instance;
1624 if (!instance.is_set()) {
1625 instance.set(new HTracer("hydrogen.cfg"));
1626 }
1627 return instance.get();
1628 }
1629
1630 private: 1623 private:
1631 class Tag BASE_EMBEDDED { 1624 class Tag BASE_EMBEDDED {
1632 public: 1625 public:
1633 Tag(HTracer* tracer, const char* name) { 1626 Tag(HTracer* tracer, const char* name) {
1634 name_ = name; 1627 name_ = name;
1635 tracer_ = tracer; 1628 tracer_ = tracer;
1636 tracer->PrintIndent(); 1629 tracer->PrintIndent();
1637 tracer->trace_.Add("begin_%s\n", name); 1630 tracer->trace_.Add("begin_%s\n", name);
1638 tracer->indent_++; 1631 tracer->indent_++;
1639 } 1632 }
1640 1633
1641 ~Tag() { 1634 ~Tag() {
1642 tracer_->indent_--; 1635 tracer_->indent_--;
1643 tracer_->PrintIndent(); 1636 tracer_->PrintIndent();
1644 tracer_->trace_.Add("end_%s\n", name_); 1637 tracer_->trace_.Add("end_%s\n", name_);
1645 ASSERT(tracer_->indent_ >= 0); 1638 ASSERT(tracer_->indent_ >= 0);
1646 tracer_->FlushToFile(); 1639 tracer_->FlushToFile();
1647 } 1640 }
1648 1641
1649 private: 1642 private:
1650 HTracer* tracer_; 1643 HTracer* tracer_;
1651 const char* name_; 1644 const char* name_;
1652 }; 1645 };
1653 1646
1654 explicit HTracer(const char* filename)
1655 : filename_(filename), trace_(&string_allocator_), indent_(0) {
1656 WriteChars(filename, "", 0, false);
1657 }
1658
1659 void TraceLiveRange(LiveRange* range, const char* type, Zone* zone); 1647 void TraceLiveRange(LiveRange* range, const char* type, Zone* zone);
1660 void Trace(const char* name, HGraph* graph, LChunk* chunk); 1648 void Trace(const char* name, HGraph* graph, LChunk* chunk);
1661 void FlushToFile(); 1649 void FlushToFile();
1662 1650
1663 void PrintEmptyProperty(const char* name) { 1651 void PrintEmptyProperty(const char* name) {
1664 PrintIndent(); 1652 PrintIndent();
1665 trace_.Add("%s\n", name); 1653 trace_.Add("%s\n", name);
1666 } 1654 }
1667 1655
1668 void PrintStringProperty(const char* name, const char* value) { 1656 void PrintStringProperty(const char* name, const char* value) {
(...skipping 15 matching lines...) Expand all
1684 PrintIndent(); 1672 PrintIndent();
1685 trace_.Add("%s %d\n", name, value); 1673 trace_.Add("%s %d\n", name, value);
1686 } 1674 }
1687 1675
1688 void PrintIndent() { 1676 void PrintIndent() {
1689 for (int i = 0; i < indent_; i++) { 1677 for (int i = 0; i < indent_; i++) {
1690 trace_.Add(" "); 1678 trace_.Add(" ");
1691 } 1679 }
1692 } 1680 }
1693 1681
1694 const char* filename_; 1682 EmbeddedVector<char, 64> filename_;
1695 HeapStringAllocator string_allocator_; 1683 HeapStringAllocator string_allocator_;
1696 StringStream trace_; 1684 StringStream trace_;
1697 int indent_; 1685 int indent_;
1698 }; 1686 };
1699 1687
1700 1688
1701 } } // namespace v8::internal 1689 } } // namespace v8::internal
1702 1690
1703 #endif // V8_HYDROGEN_H_ 1691 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698