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

Side by Side Diff: runtime/vm/snapshot.cc

Issue 2316513005: Separate size stats for rodata and instructions. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | 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 #include "vm/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 assembly_stream_.Print(".text\n"); 726 assembly_stream_.Print(".text\n");
727 assembly_stream_.Print(".globl _kInstructionsSnapshot\n"); 727 assembly_stream_.Print(".globl _kInstructionsSnapshot\n");
728 // Start snapshot at page boundary. 728 // Start snapshot at page boundary.
729 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment); 729 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment);
730 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); 730 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize());
731 assembly_stream_.Print("_kInstructionsSnapshot:\n"); 731 assembly_stream_.Print("_kInstructionsSnapshot:\n");
732 732
733 // This head also provides the gap to make the instructions snapshot 733 // This head also provides the gap to make the instructions snapshot
734 // look like a HeapPage. 734 // look like a HeapPage.
735 intptr_t instructions_length = next_offset_; 735 intptr_t instructions_length = next_offset_;
736 WriteWordLiteral(instructions_length); 736 WriteWordLiteralText(instructions_length);
737 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword); 737 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword);
738 for (intptr_t i = 1; i < header_words; i++) { 738 for (intptr_t i = 1; i < header_words; i++) {
739 WriteWordLiteral(0); 739 WriteWordLiteralText(0);
740 } 740 }
741 741
742 Object& owner = Object::Handle(zone); 742 Object& owner = Object::Handle(zone);
743 String& str = String::Handle(zone); 743 String& str = String::Handle(zone);
744 744
745 for (intptr_t i = 0; i < instructions_.length(); i++) { 745 for (intptr_t i = 0; i < instructions_.length(); i++) {
746 const Instructions& insns = *instructions_[i].insns_; 746 const Instructions& insns = *instructions_[i].insns_;
747 const Code& code = *instructions_[i].code_; 747 const Code& code = *instructions_[i].code_;
748 748
749 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0); 749 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0);
750 750
751 // 1. Write from the header to the entry point. 751 // 1. Write from the header to the entry point.
752 { 752 {
753 NoSafepointScope no_safepoint; 753 NoSafepointScope no_safepoint;
754 754
755 uword beginning = reinterpret_cast<uword>(insns.raw_ptr()); 755 uword beginning = reinterpret_cast<uword>(insns.raw_ptr());
756 uword entry = beginning + Instructions::HeaderSize(); 756 uword entry = beginning + Instructions::HeaderSize();
757 757
758 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t))); 758 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t)));
759 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t))); 759 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t)));
760 760
761 // Write Instructions with the mark and VM heap bits set. 761 // Write Instructions with the mark and VM heap bits set.
762 uword marked_tags = insns.raw_ptr()->tags_; 762 uword marked_tags = insns.raw_ptr()->tags_;
763 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); 763 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
764 marked_tags = RawObject::MarkBit::update(true, marked_tags); 764 marked_tags = RawObject::MarkBit::update(true, marked_tags);
765 765
766 WriteWordLiteral(marked_tags); 766 WriteWordLiteralText(marked_tags);
767 beginning += sizeof(uword); 767 beginning += sizeof(uword);
768 768
769 for (uword* cursor = reinterpret_cast<uword*>(beginning); 769 for (uword* cursor = reinterpret_cast<uword*>(beginning);
770 cursor < reinterpret_cast<uword*>(entry); 770 cursor < reinterpret_cast<uword*>(entry);
771 cursor++) { 771 cursor++) {
772 WriteWordLiteral(*cursor); 772 WriteWordLiteralText(*cursor);
773 } 773 }
774 } 774 }
775 775
776 // 2. Write a label at the entry point. 776 // 2. Write a label at the entry point.
777 owner = code.owner(); 777 owner = code.owner();
778 if (owner.IsNull()) { 778 if (owner.IsNull()) {
779 const char* name = StubCode::NameOfStub(insns.UncheckedEntryPoint()); 779 const char* name = StubCode::NameOfStub(insns.UncheckedEntryPoint());
780 assembly_stream_.Print("Precompiled_Stub_%s:\n", name); 780 assembly_stream_.Print("Precompiled_Stub_%s:\n", name);
781 } else if (owner.IsClass()) { 781 } else if (owner.IsClass()) {
782 str = Class::Cast(owner).Name(); 782 str = Class::Cast(owner).Name();
(...skipping 18 matching lines...) Expand all
801 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment()); 801 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment());
802 uword end = entry + payload_size; 802 uword end = entry + payload_size;
803 803
804 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t))); 804 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t)));
805 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t))); 805 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t)));
806 ASSERT(Utils::IsAligned(end, sizeof(uint64_t))); 806 ASSERT(Utils::IsAligned(end, sizeof(uint64_t)));
807 807
808 for (uword* cursor = reinterpret_cast<uword*>(entry); 808 for (uword* cursor = reinterpret_cast<uword*>(entry);
809 cursor < reinterpret_cast<uword*>(end); 809 cursor < reinterpret_cast<uword*>(end);
810 cursor++) { 810 cursor++) {
811 WriteWordLiteral(*cursor); 811 WriteWordLiteralText(*cursor);
812 } 812 }
813 } 813 }
814 } 814 }
815 #if defined(TARGET_OS_LINUX) 815 #if defined(TARGET_OS_LINUX)
816 assembly_stream_.Print(".section .rodata\n"); 816 assembly_stream_.Print(".section .rodata\n");
817 #elif defined(TARGET_OS_MACOS) 817 #elif defined(TARGET_OS_MACOS)
818 assembly_stream_.Print(".const\n"); 818 assembly_stream_.Print(".const\n");
819 #else 819 #else
820 // Unsupported platform. 820 // Unsupported platform.
821 UNREACHABLE(); 821 UNREACHABLE();
822 #endif 822 #endif
823 assembly_stream_.Print(".globl _kDataSnapshot\n"); 823 assembly_stream_.Print(".globl _kDataSnapshot\n");
824 // Start snapshot at page boundary. 824 // Start snapshot at page boundary.
825 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); 825 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize());
826 assembly_stream_.Print("_kDataSnapshot:\n"); 826 assembly_stream_.Print("_kDataSnapshot:\n");
827 WriteWordLiteral(next_object_offset_); // Data length. 827 WriteWordLiteralData(next_object_offset_); // Data length.
828 COMPILE_ASSERT(OS::kMaxPreferredCodeAlignment >= kObjectAlignment); 828 COMPILE_ASSERT(OS::kMaxPreferredCodeAlignment >= kObjectAlignment);
829 assembly_stream_.Print(".balign %" Pd ", 0\n", 829 assembly_stream_.Print(".balign %" Pd ", 0\n",
830 OS::kMaxPreferredCodeAlignment); 830 OS::kMaxPreferredCodeAlignment);
831 831
832 for (intptr_t i = 0; i < objects_.length(); i++) { 832 for (intptr_t i = 0; i < objects_.length(); i++) {
833 const Object& obj = *objects_[i].obj_; 833 const Object& obj = *objects_[i].obj_;
834 assembly_stream_.Print("Precompiled_Obj_%d:\n", i); 834 assembly_stream_.Print("Precompiled_Obj_%d:\n", i);
835 835
836 NoSafepointScope no_safepoint; 836 NoSafepointScope no_safepoint;
837 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag; 837 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag;
838 uword end = start + obj.raw()->Size(); 838 uword end = start + obj.raw()->Size();
839 839
840 // Write object header with the mark and VM heap bits set. 840 // Write object header with the mark and VM heap bits set.
841 uword marked_tags = obj.raw()->ptr()->tags_; 841 uword marked_tags = obj.raw()->ptr()->tags_;
842 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); 842 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
843 marked_tags = RawObject::MarkBit::update(true, marked_tags); 843 marked_tags = RawObject::MarkBit::update(true, marked_tags);
844 WriteWordLiteral(marked_tags); 844 WriteWordLiteralData(marked_tags);
845 start += sizeof(uword); 845 start += sizeof(uword);
846 for (uword* cursor = reinterpret_cast<uword*>(start); 846 for (uword* cursor = reinterpret_cast<uword*>(start);
847 cursor < reinterpret_cast<uword*>(end); 847 cursor < reinterpret_cast<uword*>(end);
848 cursor++) { 848 cursor++) {
849 WriteWordLiteral(*cursor); 849 WriteWordLiteralData(*cursor);
850 } 850 }
851 } 851 }
852 } 852 }
853 853
854 854
855 void BlobInstructionsWriter::Write() { 855 void BlobInstructionsWriter::Write() {
856 Thread* thread = Thread::Current(); 856 Thread* thread = Thread::Current();
857 Zone* zone = thread->zone(); 857 Zone* zone = thread->zone();
858 NOT_IN_PRODUCT(TimelineDurationScope tds(thread, 858 NOT_IN_PRODUCT(TimelineDurationScope tds(thread,
859 Timeline::GetIsolateStream(), "WriteInstructions")); 859 Timeline::GetIsolateStream(), "WriteInstructions"));
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 if (setjmp(*jump.Set()) == 0) { 1935 if (setjmp(*jump.Set()) == 0) {
1936 NoSafepointScope no_safepoint; 1936 NoSafepointScope no_safepoint;
1937 WriteObject(obj.raw()); 1937 WriteObject(obj.raw());
1938 } else { 1938 } else {
1939 ThrowException(exception_type(), exception_msg()); 1939 ThrowException(exception_type(), exception_msg());
1940 } 1940 }
1941 } 1941 }
1942 1942
1943 1943
1944 } // namespace dart 1944 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698