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

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

Issue 1414083004: Output precompiled snapshot size. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: \ Created 5 years, 1 month 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 | « no previous file | runtime/vm/snapshot.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_SNAPSHOT_H_ 5 #ifndef VM_SNAPSHOT_H_
6 #define VM_SNAPSHOT_H_ 6 #define VM_SNAPSHOT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 }; 797 };
798 798
799 799
800 class InstructionsWriter : public ZoneAllocated { 800 class InstructionsWriter : public ZoneAllocated {
801 public: 801 public:
802 InstructionsWriter(uint8_t** buffer, 802 InstructionsWriter(uint8_t** buffer,
803 ReAlloc alloc, 803 ReAlloc alloc,
804 intptr_t initial_size) 804 intptr_t initial_size)
805 : stream_(buffer, alloc, initial_size), 805 : stream_(buffer, alloc, initial_size),
806 next_offset_(InstructionsSnapshot::kHeaderSize), 806 next_offset_(InstructionsSnapshot::kHeaderSize),
807 binary_size_(0),
807 instructions_() { 808 instructions_() {
808 ASSERT(buffer != NULL); 809 ASSERT(buffer != NULL);
809 ASSERT(alloc != NULL); 810 ASSERT(alloc != NULL);
810 } 811 }
811 812
812 // Size of the snapshot. 813 // Size of the snapshot (assembly code).
813 intptr_t BytesWritten() const { return stream_.bytes_written(); } 814 intptr_t BytesWritten() const { return stream_.bytes_written(); }
814 815
816 intptr_t binary_size() { return binary_size_; }
817
815 int32_t GetOffsetFor(RawInstructions* instructions); 818 int32_t GetOffsetFor(RawInstructions* instructions);
816 819
817 void SetInstructionsCode(RawInstructions* insns, RawCode* code) { 820 void SetInstructionsCode(RawInstructions* insns, RawCode* code) {
818 for (intptr_t i = 0; i < instructions_.length(); i++) { 821 for (intptr_t i = 0; i < instructions_.length(); i++) {
819 if (instructions_[i].raw_insns_ == insns) { 822 if (instructions_[i].raw_insns_ == insns) {
820 instructions_[i].raw_code_ = code; 823 instructions_[i].raw_code_ = code;
821 return; 824 return;
822 } 825 }
823 } 826 }
824 UNREACHABLE(); 827 UNREACHABLE();
(...skipping 16 matching lines...) Expand all
841 }; 844 };
842 }; 845 };
843 846
844 void WriteWordLiteral(uword value) { 847 void WriteWordLiteral(uword value) {
845 // Padding is helpful for comparing the .S with --disassemble. 848 // Padding is helpful for comparing the .S with --disassemble.
846 #if defined(ARCH_IS_64_BIT) 849 #if defined(ARCH_IS_64_BIT)
847 stream_.Print(".quad 0x%0.16" Px "\n", value); 850 stream_.Print(".quad 0x%0.16" Px "\n", value);
848 #else 851 #else
849 stream_.Print(".long 0x%0.8" Px "\n", value); 852 stream_.Print(".long 0x%0.8" Px "\n", value);
850 #endif 853 #endif
854 binary_size_ += sizeof(value);
851 } 855 }
852 856
853 WriteStream stream_; 857 WriteStream stream_;
854 intptr_t next_offset_; 858 intptr_t next_offset_;
859 intptr_t binary_size_;
855 GrowableArray<InstructionsData> instructions_; 860 GrowableArray<InstructionsData> instructions_;
856 861
857 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); 862 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter);
858 }; 863 };
859 864
860 865
861 class SnapshotWriter : public BaseWriter { 866 class SnapshotWriter : public BaseWriter {
862 protected: 867 protected:
863 SnapshotWriter(Snapshot::Kind kind, 868 SnapshotWriter(Snapshot::Kind kind,
864 Thread* thread, 869 Thread* thread,
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 private: 1126 private:
1122 SnapshotWriter* writer_; 1127 SnapshotWriter* writer_;
1123 bool as_references_; 1128 bool as_references_;
1124 1129
1125 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1130 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1126 }; 1131 };
1127 1132
1128 } // namespace dart 1133 } // namespace dart
1129 1134
1130 #endif // VM_SNAPSHOT_H_ 1135 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698