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

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
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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 DISALLOW_COPY_AND_ASSIGN(ForwardList); 804 DISALLOW_COPY_AND_ASSIGN(ForwardList);
779 }; 805 };
780 806
781 807
782 class InstructionsWriter : public ZoneAllocated { 808 class InstructionsWriter : public ZoneAllocated {
783 public: 809 public:
784 InstructionsWriter(uint8_t** buffer, 810 InstructionsWriter(uint8_t** buffer,
785 ReAlloc alloc, 811 ReAlloc alloc,
786 intptr_t initial_size) 812 intptr_t initial_size)
787 : stream_(buffer, alloc, initial_size), 813 : stream_(buffer, alloc, initial_size),
788 next_offset_(0), 814 next_offset_(InstructionsSnapshot::kHeaderSize),
789 instructions_() { 815 instructions_() {
790 ASSERT(buffer != NULL); 816 ASSERT(buffer != NULL);
791 ASSERT(alloc != NULL); 817 ASSERT(alloc != NULL);
792 } 818 }
793 819
794 // Size of the snapshot. 820 // Size of the snapshot.
795 intptr_t BytesWritten() const { return stream_.bytes_written(); } 821 intptr_t BytesWritten() const { return stream_.bytes_written(); }
796 822
797 int32_t GetOffsetFor(RawInstructions* instructions); 823 int32_t GetOffsetFor(RawInstructions* instructions);
798 824
(...skipping 17 matching lines...) Expand all
816 union { 842 union {
817 RawInstructions* raw_insns_; 843 RawInstructions* raw_insns_;
818 const Instructions* insns_; 844 const Instructions* insns_;
819 }; 845 };
820 union { 846 union {
821 RawCode* raw_code_; 847 RawCode* raw_code_;
822 const Code* code_; 848 const Code* code_;
823 }; 849 };
824 }; 850 };
825 851
852 void WriteWordLiteral(uword value) {
853 // Padding is helpful for comparing the .S with --disassemble.
854 #if defined(ARCH_IS_64_BIT)
855 stream_.Print(".quad 0x%0.16" Px "\n", value);
856 #else
857 stream_.Print(".word 0x%0.8" Px "\n", value);
858 #endif
859 }
826 860
827 WriteStream stream_; 861 WriteStream stream_;
828 intptr_t next_offset_; 862 intptr_t next_offset_;
829 GrowableArray<InstructionsData> instructions_; 863 GrowableArray<InstructionsData> instructions_;
830 864
831 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); 865 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter);
832 }; 866 };
833 867
834 868
835 class SnapshotWriter : public BaseWriter { 869 class SnapshotWriter : public BaseWriter {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 private: 1127 private:
1094 SnapshotWriter* writer_; 1128 SnapshotWriter* writer_;
1095 bool as_references_; 1129 bool as_references_;
1096 1130
1097 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1131 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1098 }; 1132 };
1099 1133
1100 } // namespace dart 1134 } // namespace dart
1101 1135
1102 #endif // VM_SNAPSHOT_H_ 1136 #endif // VM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698