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

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

Issue 1336763002: Last snapshot bits to get working precompiled hello_world on x64. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/raw_object_snapshot.cc ('k') | 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // The following fields are potentially unaligned. 189 // The following fields are potentially unaligned.
190 int64_t unaligned_length_; // Stream length. 190 int64_t unaligned_length_; // Stream length.
191 int64_t unaligned_kind_; // Kind of snapshot. 191 int64_t unaligned_kind_; // Kind of snapshot.
192 192
193 // Variable length data follows here. 193 // Variable length data follows here.
194 194
195 DISALLOW_COPY_AND_ASSIGN(Snapshot); 195 DISALLOW_COPY_AND_ASSIGN(Snapshot);
196 }; 196 };
197 197
198 198
199 class InstructionsSnapshot : ValueObject {
200 public:
201 explicit InstructionsSnapshot(const void* raw_memory)
202 : raw_memory_(raw_memory) {
203 ASSERT(Utils::IsAligned(raw_memory, OS::kMaxPreferredCodeAlignment));
204 }
205
206 void* instructions_start() {
207 return reinterpret_cast<void*>(
208 reinterpret_cast<uword>(raw_memory_) + kHeaderSize);
209 }
210
211 uword instructions_size() {
212 uword snapshot_size = *reinterpret_cast<const uword*>(raw_memory_);
213 return snapshot_size - kHeaderSize;
214 }
215
216 static const intptr_t kHeaderSize = OS::kMaxPreferredCodeAlignment;
217
218 private:
219 const void* raw_memory_; // The symbol kInstructionsSnapshot.
220
221 DISALLOW_COPY_AND_ASSIGN(InstructionsSnapshot);
222 };
223
224
199 class BaseReader { 225 class BaseReader {
200 public: 226 public:
201 BaseReader(const uint8_t* buffer, intptr_t size) : stream_(buffer, size) {} 227 BaseReader(const uint8_t* buffer, intptr_t size) : stream_(buffer, size) {}
202 // Reads raw data (for basic types). 228 // Reads raw data (for basic types).
203 // sizeof(T) must be in {1,2,4,8}. 229 // sizeof(T) must be in {1,2,4,8}.
204 template <typename T> 230 template <typename T>
205 T Read() { 231 T Read() {
206 return ReadStream::Raw<sizeof(T), T>::Read(&stream_); 232 return ReadStream::Raw<sizeof(T), T>::Read(&stream_);
207 } 233 }
208 234
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 DISALLOW_COPY_AND_ASSIGN(ForwardList); 805 DISALLOW_COPY_AND_ASSIGN(ForwardList);
780 }; 806 };
781 807
782 808
783 class InstructionsWriter : public ZoneAllocated { 809 class InstructionsWriter : public ZoneAllocated {
784 public: 810 public:
785 InstructionsWriter(uint8_t** buffer, 811 InstructionsWriter(uint8_t** buffer,
786 ReAlloc alloc, 812 ReAlloc alloc,
787 intptr_t initial_size) 813 intptr_t initial_size)
788 : stream_(buffer, alloc, initial_size), 814 : stream_(buffer, alloc, initial_size),
789 next_offset_(0), 815 next_offset_(InstructionsSnapshot::kHeaderSize),
790 instructions_() { 816 instructions_() {
791 ASSERT(buffer != NULL); 817 ASSERT(buffer != NULL);
792 ASSERT(alloc != NULL); 818 ASSERT(alloc != NULL);
793 } 819 }
794 820
795 // Size of the snapshot. 821 // Size of the snapshot.
796 intptr_t BytesWritten() const { return stream_.bytes_written(); } 822 intptr_t BytesWritten() const { return stream_.bytes_written(); }
797 823
798 int32_t GetOffsetFor(RawInstructions* instructions); 824 int32_t GetOffsetFor(RawInstructions* instructions);
799 825
(...skipping 17 matching lines...) Expand all
817 union { 843 union {
818 RawInstructions* raw_insns_; 844 RawInstructions* raw_insns_;
819 const Instructions* insns_; 845 const Instructions* insns_;
820 }; 846 };
821 union { 847 union {
822 RawCode* raw_code_; 848 RawCode* raw_code_;
823 const Code* code_; 849 const Code* code_;
824 }; 850 };
825 }; 851 };
826 852
853 void WriteWordLiteral(uword value) {
854 // Padding is helpful for comparing the .S with --disassemble.
855 #if defined(ARCH_IS_64_BIT)
856 stream_.Print(".quad 0x%0.16" Px "\n", value);
857 #else
858 stream_.Print(".word 0x%0.8" Px "\n", value);
859 #endif
860 }
827 861
828 WriteStream stream_; 862 WriteStream stream_;
829 intptr_t next_offset_; 863 intptr_t next_offset_;
830 GrowableArray<InstructionsData> instructions_; 864 GrowableArray<InstructionsData> instructions_;
831 865
832 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); 866 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter);
833 }; 867 };
834 868
835 869
836 class SnapshotWriter : public BaseWriter { 870 class SnapshotWriter : public BaseWriter {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 private: 1130 private:
1097 SnapshotWriter* writer_; 1131 SnapshotWriter* writer_;
1098 bool as_references_; 1132 bool as_references_;
1099 1133
1100 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1134 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1101 }; 1135 };
1102 1136
1103 } // namespace dart 1137 } // namespace dart
1104 1138
1105 #endif // VM_SNAPSHOT_H_ 1139 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698