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

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

Issue 1808553002: Precompilation: don't include an object header for instructions in the text section. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 InstructionsReader(const uint8_t* instructions_buffer, 363 InstructionsReader(const uint8_t* instructions_buffer,
364 const uint8_t* data_buffer) 364 const uint8_t* data_buffer)
365 : instructions_buffer_(instructions_buffer), 365 : instructions_buffer_(instructions_buffer),
366 data_buffer_(data_buffer) { 366 data_buffer_(data_buffer) {
367 ASSERT(instructions_buffer != NULL); 367 ASSERT(instructions_buffer != NULL);
368 ASSERT(data_buffer != NULL); 368 ASSERT(data_buffer != NULL);
369 ASSERT(Utils::IsAligned(reinterpret_cast<uword>(instructions_buffer), 369 ASSERT(Utils::IsAligned(reinterpret_cast<uword>(instructions_buffer),
370 OS::PreferredCodeAlignment())); 370 OS::PreferredCodeAlignment()));
371 } 371 }
372 372
373 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags); 373 uword GetInstructionsAt(int32_t offset);
374 RawObject* GetObjectAt(int32_t offset); 374 RawObject* GetObjectAt(int32_t offset);
375 375
376 private: 376 private:
377 const uint8_t* instructions_buffer_; 377 const uint8_t* instructions_buffer_;
378 const uint8_t* data_buffer_; 378 const uint8_t* data_buffer_;
379 379
380 DISALLOW_COPY_AND_ASSIGN(InstructionsReader); 380 DISALLOW_COPY_AND_ASSIGN(InstructionsReader);
381 }; 381 };
382 382
383 383
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3); 476 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3);
477 RawFloat64x2* NewFloat64x2(double v0, double v1); 477 RawFloat64x2* NewFloat64x2(double v0, double v1);
478 RawApiError* NewApiError(); 478 RawApiError* NewApiError();
479 RawLanguageError* NewLanguageError(); 479 RawLanguageError* NewLanguageError();
480 RawUnhandledException* NewUnhandledException(); 480 RawUnhandledException* NewUnhandledException();
481 RawObject* NewInteger(int64_t value); 481 RawObject* NewInteger(int64_t value);
482 RawStacktrace* NewStacktrace(); 482 RawStacktrace* NewStacktrace();
483 RawWeakProperty* NewWeakProperty(); 483 RawWeakProperty* NewWeakProperty();
484 RawRegExp* NewRegExp(); 484 RawRegExp* NewRegExp();
485 485
486 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags) { 486 uword GetInstructionsAt(int32_t offset) {
487 return instructions_reader_->GetInstructionsAt(offset, expected_tags); 487 return instructions_reader_->GetInstructionsAt(offset);
488 } 488 }
489 489
490 RawObject* GetObjectAt(int32_t offset) { 490 RawObject* GetObjectAt(int32_t offset) {
491 return instructions_reader_->GetObjectAt(offset); 491 return instructions_reader_->GetObjectAt(offset);
492 } 492 }
493 493
494 const uint8_t* instructions_buffer_; 494 const uint8_t* instructions_buffer_;
495 const uint8_t* data_buffer_; 495 const uint8_t* data_buffer_;
496 496
497 protected: 497 protected:
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 objects_() { 855 objects_() {
856 ASSERT(buffer != NULL); 856 ASSERT(buffer != NULL);
857 ASSERT(alloc != NULL); 857 ASSERT(alloc != NULL);
858 } 858 }
859 859
860 // Size of the snapshot (assembly code). 860 // Size of the snapshot (assembly code).
861 intptr_t BytesWritten() const { return stream_.bytes_written(); } 861 intptr_t BytesWritten() const { return stream_.bytes_written(); }
862 862
863 intptr_t binary_size() { return binary_size_; } 863 intptr_t binary_size() { return binary_size_; }
864 864
865 int32_t GetOffsetFor(RawInstructions* instructions); 865 int32_t GetOffsetFor(RawInstructions* instructions, RawCode* code);
866 866
867 int32_t GetObjectOffsetFor(RawObject* raw_object); 867 int32_t GetObjectOffsetFor(RawObject* raw_object);
868 868
869 void SetInstructionsCode(RawInstructions* insns, RawCode* code) {
870 for (intptr_t i = 0; i < instructions_.length(); i++) {
871 if (instructions_[i].raw_insns_ == insns) {
872 instructions_[i].raw_code_ = code;
873 return;
874 }
875 }
876 UNREACHABLE();
877 }
878
879 void WriteAssembly(); 869 void WriteAssembly();
880 870
881 private: 871 private:
882 struct InstructionsData { 872 struct InstructionsData {
883 explicit InstructionsData(RawInstructions* insns) 873 explicit InstructionsData(RawInstructions* insns,
884 : raw_insns_(insns), raw_code_(NULL) { } 874 RawCode* code,
875 intptr_t offset)
876 : raw_insns_(insns), raw_code_(code), offset_(offset) { }
885 877
886 union { 878 union {
887 RawInstructions* raw_insns_; 879 RawInstructions* raw_insns_;
888 const Instructions* insns_; 880 const Instructions* insns_;
889 }; 881 };
890 union { 882 union {
891 RawCode* raw_code_; 883 RawCode* raw_code_;
892 const Code* code_; 884 const Code* code_;
893 }; 885 };
886 intptr_t offset_;
894 }; 887 };
895 888
896 struct ObjectData { 889 struct ObjectData {
897 explicit ObjectData(RawObject* raw_obj) 890 explicit ObjectData(RawObject* raw_obj)
898 : raw_obj_(raw_obj) { } 891 : raw_obj_(raw_obj) { }
899 892
900 union { 893 union {
901 RawObject* raw_obj_; 894 RawObject* raw_obj_;
902 const Object* obj_; 895 const Object* obj_;
903 }; 896 };
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 bool can_send_any_object() const { return can_send_any_object_; } 956 bool can_send_any_object() const { return can_send_any_object_; }
964 bool snapshot_code() const { return snapshot_code_; } 957 bool snapshot_code() const { return snapshot_code_; }
965 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } 958 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; }
966 void ThrowException(Exceptions::ExceptionType type, const char* msg); 959 void ThrowException(Exceptions::ExceptionType type, const char* msg);
967 960
968 // Write a version string for the snapshot. 961 // Write a version string for the snapshot.
969 void WriteVersion(); 962 void WriteVersion();
970 963
971 static intptr_t FirstObjectId(); 964 static intptr_t FirstObjectId();
972 965
973 int32_t GetInstructionsId(RawInstructions* instructions) { 966 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) {
974 return instructions_writer_->GetOffsetFor(instructions); 967 return instructions_writer_->GetOffsetFor(instructions, code);
975 } 968 }
976 969
977 int32_t GetObjectId(RawObject* raw) { 970 int32_t GetObjectId(RawObject* raw) {
978 return instructions_writer_->GetObjectOffsetFor(raw); 971 return instructions_writer_->GetObjectOffsetFor(raw);
979 } 972 }
980 973
981 void SetInstructionsCode(RawInstructions* instructions, RawCode* code) {
982 return instructions_writer_->SetInstructionsCode(instructions, code);
983 }
984
985 void WriteFunctionId(RawFunction* func, bool owner_is_class); 974 void WriteFunctionId(RawFunction* func, bool owner_is_class);
986 975
987 RawFunction* IsSerializableClosure(RawClosure* closure); 976 RawFunction* IsSerializableClosure(RawClosure* closure);
988 977
989 void WriteStaticImplicitClosure(intptr_t object_id, 978 void WriteStaticImplicitClosure(intptr_t object_id,
990 RawFunction* func, 979 RawFunction* func,
991 intptr_t tags); 980 intptr_t tags);
992 981
993 protected: 982 protected:
994 bool CheckAndWritePredefinedObject(RawObject* raw); 983 bool CheckAndWritePredefinedObject(RawObject* raw);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 const char* exception_msg_; // Message associated with exception. 1030 const char* exception_msg_; // Message associated with exception.
1042 bool unmarked_objects_; // True if marked objects have been unmarked. 1031 bool unmarked_objects_; // True if marked objects have been unmarked.
1043 bool can_send_any_object_; // True if any Dart instance can be sent. 1032 bool can_send_any_object_; // True if any Dart instance can be sent.
1044 bool snapshot_code_; 1033 bool snapshot_code_;
1045 bool vm_isolate_is_symbolic_; 1034 bool vm_isolate_is_symbolic_;
1046 1035
1047 friend class FullSnapshotWriter; 1036 friend class FullSnapshotWriter;
1048 friend class RawArray; 1037 friend class RawArray;
1049 friend class RawClass; 1038 friend class RawClass;
1050 friend class RawClosureData; 1039 friend class RawClosureData;
1040 friend class RawCode;
1051 friend class RawContextScope; 1041 friend class RawContextScope;
1052 friend class RawExceptionHandlers; 1042 friend class RawExceptionHandlers;
1053 friend class RawField; 1043 friend class RawField;
1054 friend class RawFunction; 1044 friend class RawFunction;
1055 friend class RawGrowableObjectArray; 1045 friend class RawGrowableObjectArray;
1056 friend class RawImmutableArray; 1046 friend class RawImmutableArray;
1057 friend class RawInstructions; 1047 friend class RawInstructions;
1058 friend class RawRegExp; 1048 friend class RawRegExp;
1059 friend class RawLibrary; 1049 friend class RawLibrary;
1060 friend class RawLinkedHashMap; 1050 friend class RawLinkedHashMap;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 private: 1183 private:
1194 SnapshotWriter* writer_; 1184 SnapshotWriter* writer_;
1195 bool as_references_; 1185 bool as_references_;
1196 1186
1197 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1187 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1198 }; 1188 };
1199 1189
1200 } // namespace dart 1190 } // namespace dart
1201 1191
1202 #endif // VM_SNAPSHOT_H_ 1192 #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