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

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 14 matching lines...) Expand all
25 class Code; 25 class Code;
26 class ExternalTypedData; 26 class ExternalTypedData;
27 class GrowableObjectArray; 27 class GrowableObjectArray;
28 class Heap; 28 class Heap;
29 class Instructions; 29 class Instructions;
30 class LanguageError; 30 class LanguageError;
31 class Library; 31 class Library;
32 class Object; 32 class Object;
33 class PassiveObject; 33 class PassiveObject;
34 class ObjectStore; 34 class ObjectStore;
35 class MegamorphicCache;
35 class PageSpace; 36 class PageSpace;
36 class RawApiError; 37 class RawApiError;
37 class RawArray; 38 class RawArray;
38 class RawBigint; 39 class RawBigint;
39 class RawBoundedType; 40 class RawBoundedType;
40 class RawCapability; 41 class RawCapability;
41 class RawClass; 42 class RawClass;
42 class RawClosureData; 43 class RawClosureData;
43 class RawContext; 44 class RawContext;
44 class RawContextScope; 45 class RawContextScope;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 PassiveObject* PassiveObjectHandle() { return &pobj_; } 333 PassiveObject* PassiveObjectHandle() { return &pobj_; }
333 Array* ArrayHandle() { return &array_; } 334 Array* ArrayHandle() { return &array_; }
334 String* StringHandle() { return &str_; } 335 String* StringHandle() { return &str_; }
335 AbstractType* TypeHandle() { return &type_; } 336 AbstractType* TypeHandle() { return &type_; }
336 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } 337 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; }
337 Array* TokensHandle() { return &tokens_; } 338 Array* TokensHandle() { return &tokens_; }
338 TokenStream* StreamHandle() { return &stream_; } 339 TokenStream* StreamHandle() { return &stream_; }
339 ExternalTypedData* DataHandle() { return &data_; } 340 ExternalTypedData* DataHandle() { return &data_; }
340 TypedData* TypedDataHandle() { return &typed_data_; } 341 TypedData* TypedDataHandle() { return &typed_data_; }
341 Code* CodeHandle() { return &code_; } 342 Code* CodeHandle() { return &code_; }
343 Function* FunctionHandle() { return &function_; }
344 MegamorphicCache* MegamorphicCacheHandle() { return &megamorphic_cache_; }
342 Snapshot::Kind kind() const { return kind_; } 345 Snapshot::Kind kind() const { return kind_; }
343 bool snapshot_code() const { return snapshot_code_; } 346 bool snapshot_code() const { return snapshot_code_; }
344 347
345 // Reads an object. 348 // Reads an object.
346 RawObject* ReadObject(); 349 RawObject* ReadObject();
347 350
348 // Add object to backward references. 351 // Add object to backward references.
349 void AddBackRef(intptr_t id, 352 void AddBackRef(intptr_t id,
350 Object* obj, 353 Object* obj,
351 DeserializeState state, 354 DeserializeState state,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 Field& field_; // Temporary Field handle. 517 Field& field_; // Temporary Field handle.
515 String& str_; // Temporary String handle. 518 String& str_; // Temporary String handle.
516 Library& library_; // Temporary library handle. 519 Library& library_; // Temporary library handle.
517 AbstractType& type_; // Temporary type handle. 520 AbstractType& type_; // Temporary type handle.
518 TypeArguments& type_arguments_; // Temporary type argument handle. 521 TypeArguments& type_arguments_; // Temporary type argument handle.
519 Array& tokens_; // Temporary tokens handle. 522 Array& tokens_; // Temporary tokens handle.
520 TokenStream& stream_; // Temporary token stream handle. 523 TokenStream& stream_; // Temporary token stream handle.
521 ExternalTypedData& data_; // Temporary stream data handle. 524 ExternalTypedData& data_; // Temporary stream data handle.
522 TypedData& typed_data_; // Temporary typed data handle. 525 TypedData& typed_data_; // Temporary typed data handle.
523 Code& code_; // Temporary code handle. 526 Code& code_; // Temporary code handle.
527 Function& function_; // Temporary function handle.
528 MegamorphicCache& megamorphic_cache_; // Temporary megamorphic cache handle.
524 UnhandledException& error_; // Error handle. 529 UnhandledException& error_; // Error handle.
525 intptr_t max_vm_isolate_object_id_; 530 intptr_t max_vm_isolate_object_id_;
526 ZoneGrowableArray<BackRefNode>* backward_references_; 531 ZoneGrowableArray<BackRefNode>* backward_references_;
527 InstructionsReader* instructions_reader_; 532 InstructionsReader* instructions_reader_;
528 533
529 friend class ApiError; 534 friend class ApiError;
530 friend class Array; 535 friend class Array;
531 friend class Bigint; 536 friend class Bigint;
532 friend class BoundedType; 537 friend class BoundedType;
533 friend class Class; 538 friend class Class;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 DISALLOW_COPY_AND_ASSIGN(ForwardList); 778 DISALLOW_COPY_AND_ASSIGN(ForwardList);
774 }; 779 };
775 780
776 781
777 class InstructionsWriter : public ZoneAllocated { 782 class InstructionsWriter : public ZoneAllocated {
778 public: 783 public:
779 InstructionsWriter(uint8_t** buffer, 784 InstructionsWriter(uint8_t** buffer,
780 ReAlloc alloc, 785 ReAlloc alloc,
781 intptr_t initial_size) 786 intptr_t initial_size)
782 : stream_(buffer, alloc, initial_size), 787 : stream_(buffer, alloc, initial_size),
783 next_offset_(0), 788 next_offset_(HeaderSize()),
784 instructions_() { 789 instructions_() {
785 ASSERT(buffer != NULL); 790 ASSERT(buffer != NULL);
786 ASSERT(alloc != NULL); 791 ASSERT(alloc != NULL);
787 } 792 }
788 793
789 // Size of the snapshot. 794 // Size of the snapshot.
790 intptr_t BytesWritten() const { return stream_.bytes_written(); } 795 intptr_t BytesWritten() const { return stream_.bytes_written(); }
791 796
792 int32_t GetOffsetFor(RawInstructions* instructions); 797 int32_t GetOffsetFor(RawInstructions* instructions);
793 798
794 void SetInstructionsCode(RawInstructions* insns, RawCode* code) { 799 void SetInstructionsCode(RawInstructions* insns, RawCode* code) {
795 for (intptr_t i = 0; i < instructions_.length(); i++) { 800 for (intptr_t i = 0; i < instructions_.length(); i++) {
796 if (instructions_[i].raw_insns_ == insns) { 801 if (instructions_[i].raw_insns_ == insns) {
797 instructions_[i].raw_code_ = code; 802 instructions_[i].raw_code_ = code;
798 return; 803 return;
799 } 804 }
800 } 805 }
801 UNREACHABLE(); 806 UNREACHABLE();
802 } 807 }
803 808
804 void WriteAssembly(); 809 void WriteAssembly();
805 810
811 intptr_t HeaderSize() {
812 ASSERT(OS::kMaxPreferredCodeAlignment > sizeof(uint64_t));
813 return OS::kMaxPreferredCodeAlignment;
814 }
815
806 private: 816 private:
807 struct InstructionsData { 817 struct InstructionsData {
808 explicit InstructionsData(RawInstructions* insns) 818 explicit InstructionsData(RawInstructions* insns)
809 : raw_insns_(insns), raw_code_(NULL) { } 819 : raw_insns_(insns), raw_code_(NULL) { }
810 820
811 union { 821 union {
812 RawInstructions* raw_insns_; 822 RawInstructions* raw_insns_;
813 const Instructions* insns_; 823 const Instructions* insns_;
814 }; 824 };
815 union { 825 union {
816 RawCode* raw_code_; 826 RawCode* raw_code_;
817 const Code* code_; 827 const Code* code_;
818 }; 828 };
819 }; 829 };
820 830
831 void WriteWordLiteral(uword value) {
832 // Padding is helpful for comparing the .S with --disassemble.
833 #if defined(ARCH_IS_64_BIT)
834 stream_.Print(".word 0x%0.16" Px "\n", value);
835 #else
836 stream_.Print(".word 0x%0.8" Px "\n", value);
837 #endif
838 }
821 839
822 WriteStream stream_; 840 WriteStream stream_;
823 intptr_t next_offset_; 841 intptr_t next_offset_;
824 GrowableArray<InstructionsData> instructions_; 842 GrowableArray<InstructionsData> instructions_;
825 843
826 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); 844 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter);
827 }; 845 };
828 846
829 847
830 class SnapshotWriter : public BaseWriter { 848 class SnapshotWriter : public BaseWriter {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 private: 1106 private:
1089 SnapshotWriter* writer_; 1107 SnapshotWriter* writer_;
1090 bool as_references_; 1108 bool as_references_;
1091 1109
1092 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1110 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1093 }; 1111 };
1094 1112
1095 } // namespace dart 1113 } // namespace dart
1096 1114
1097 #endif // VM_SNAPSHOT_H_ 1115 #endif // VM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698