| OLD | NEW |
| 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 Loading... |
| 25 class Closure; | 25 class Closure; |
| 26 class Code; | 26 class Code; |
| 27 class ExternalTypedData; | 27 class ExternalTypedData; |
| 28 class GrowableObjectArray; | 28 class GrowableObjectArray; |
| 29 class Heap; | 29 class Heap; |
| 30 class Instructions; | 30 class Instructions; |
| 31 class LanguageError; | 31 class LanguageError; |
| 32 class Library; | 32 class Library; |
| 33 class Object; | 33 class Object; |
| 34 class PassiveObject; | 34 class PassiveObject; |
| 35 class ObjectPool; |
| 35 class ObjectStore; | 36 class ObjectStore; |
| 36 class MegamorphicCache; | 37 class MegamorphicCache; |
| 37 class PageSpace; | 38 class PageSpace; |
| 38 class RawApiError; | 39 class RawApiError; |
| 39 class RawArray; | 40 class RawArray; |
| 40 class RawBigint; | 41 class RawBigint; |
| 41 class RawBoundedType; | 42 class RawBoundedType; |
| 42 class RawCapability; | 43 class RawCapability; |
| 43 class RawClass; | 44 class RawClass; |
| 44 class RawClosure; | 45 class RawClosure; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 InstructionsReader(const uint8_t* instructions_buffer, | 364 InstructionsReader(const uint8_t* instructions_buffer, |
| 364 const uint8_t* data_buffer) | 365 const uint8_t* data_buffer) |
| 365 : instructions_buffer_(instructions_buffer), | 366 : instructions_buffer_(instructions_buffer), |
| 366 data_buffer_(data_buffer) { | 367 data_buffer_(data_buffer) { |
| 367 ASSERT(instructions_buffer != NULL); | 368 ASSERT(instructions_buffer != NULL); |
| 368 ASSERT(data_buffer != NULL); | 369 ASSERT(data_buffer != NULL); |
| 369 ASSERT(Utils::IsAligned(reinterpret_cast<uword>(instructions_buffer), | 370 ASSERT(Utils::IsAligned(reinterpret_cast<uword>(instructions_buffer), |
| 370 OS::PreferredCodeAlignment())); | 371 OS::PreferredCodeAlignment())); |
| 371 } | 372 } |
| 372 | 373 |
| 373 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags); | 374 uword GetInstructionsAt(int32_t offset); |
| 374 RawObject* GetObjectAt(int32_t offset); | 375 RawObject* GetObjectAt(int32_t offset); |
| 375 | 376 |
| 376 private: | 377 private: |
| 377 const uint8_t* instructions_buffer_; | 378 const uint8_t* instructions_buffer_; |
| 378 const uint8_t* data_buffer_; | 379 const uint8_t* data_buffer_; |
| 379 | 380 |
| 380 DISALLOW_COPY_AND_ASSIGN(InstructionsReader); | 381 DISALLOW_COPY_AND_ASSIGN(InstructionsReader); |
| 381 }; | 382 }; |
| 382 | 383 |
| 383 | 384 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 395 String* StringHandle() { return &str_; } | 396 String* StringHandle() { return &str_; } |
| 396 AbstractType* TypeHandle() { return &type_; } | 397 AbstractType* TypeHandle() { return &type_; } |
| 397 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } | 398 TypeArguments* TypeArgumentsHandle() { return &type_arguments_; } |
| 398 GrowableObjectArray* TokensHandle() { return &tokens_; } | 399 GrowableObjectArray* TokensHandle() { return &tokens_; } |
| 399 TokenStream* StreamHandle() { return &stream_; } | 400 TokenStream* StreamHandle() { return &stream_; } |
| 400 ExternalTypedData* DataHandle() { return &data_; } | 401 ExternalTypedData* DataHandle() { return &data_; } |
| 401 TypedData* TypedDataHandle() { return &typed_data_; } | 402 TypedData* TypedDataHandle() { return &typed_data_; } |
| 402 Code* CodeHandle() { return &code_; } | 403 Code* CodeHandle() { return &code_; } |
| 403 Function* FunctionHandle() { return &function_; } | 404 Function* FunctionHandle() { return &function_; } |
| 404 MegamorphicCache* MegamorphicCacheHandle() { return &megamorphic_cache_; } | 405 MegamorphicCache* MegamorphicCacheHandle() { return &megamorphic_cache_; } |
| 406 ObjectPool* ObjectPoolHandle() { return &object_pool_; } |
| 405 Snapshot::Kind kind() const { return kind_; } | 407 Snapshot::Kind kind() const { return kind_; } |
| 406 bool snapshot_code() const { return snapshot_code_; } | 408 bool snapshot_code() const { return snapshot_code_; } |
| 407 | 409 |
| 408 // Reads an object. | 410 // Reads an object. |
| 409 RawObject* ReadObject(); | 411 RawObject* ReadObject(); |
| 410 | 412 |
| 411 // Add object to backward references. | 413 // Add object to backward references. |
| 412 void AddBackRef(intptr_t id, | 414 void AddBackRef(intptr_t id, |
| 413 Object* obj, | 415 Object* obj, |
| 414 DeserializeState state, | 416 DeserializeState state, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3); | 478 RawInt32x4* NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, uint32_t v3); |
| 477 RawFloat64x2* NewFloat64x2(double v0, double v1); | 479 RawFloat64x2* NewFloat64x2(double v0, double v1); |
| 478 RawApiError* NewApiError(); | 480 RawApiError* NewApiError(); |
| 479 RawLanguageError* NewLanguageError(); | 481 RawLanguageError* NewLanguageError(); |
| 480 RawUnhandledException* NewUnhandledException(); | 482 RawUnhandledException* NewUnhandledException(); |
| 481 RawObject* NewInteger(int64_t value); | 483 RawObject* NewInteger(int64_t value); |
| 482 RawStacktrace* NewStacktrace(); | 484 RawStacktrace* NewStacktrace(); |
| 483 RawWeakProperty* NewWeakProperty(); | 485 RawWeakProperty* NewWeakProperty(); |
| 484 RawRegExp* NewRegExp(); | 486 RawRegExp* NewRegExp(); |
| 485 | 487 |
| 486 RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags) { | 488 uword GetInstructionsAt(int32_t offset) { |
| 487 return instructions_reader_->GetInstructionsAt(offset, expected_tags); | 489 return instructions_reader_->GetInstructionsAt(offset); |
| 488 } | 490 } |
| 489 | 491 |
| 490 RawObject* GetObjectAt(int32_t offset) { | 492 RawObject* GetObjectAt(int32_t offset) { |
| 491 return instructions_reader_->GetObjectAt(offset); | 493 return instructions_reader_->GetObjectAt(offset); |
| 492 } | 494 } |
| 493 | 495 |
| 494 const uint8_t* instructions_buffer_; | 496 const uint8_t* instructions_buffer_; |
| 495 const uint8_t* data_buffer_; | 497 const uint8_t* data_buffer_; |
| 496 | 498 |
| 497 protected: | 499 protected: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 Library& library_; // Temporary library handle. | 583 Library& library_; // Temporary library handle. |
| 582 AbstractType& type_; // Temporary type handle. | 584 AbstractType& type_; // Temporary type handle. |
| 583 TypeArguments& type_arguments_; // Temporary type argument handle. | 585 TypeArguments& type_arguments_; // Temporary type argument handle. |
| 584 GrowableObjectArray& tokens_; // Temporary tokens handle. | 586 GrowableObjectArray& tokens_; // Temporary tokens handle. |
| 585 TokenStream& stream_; // Temporary token stream handle. | 587 TokenStream& stream_; // Temporary token stream handle. |
| 586 ExternalTypedData& data_; // Temporary stream data handle. | 588 ExternalTypedData& data_; // Temporary stream data handle. |
| 587 TypedData& typed_data_; // Temporary typed data handle. | 589 TypedData& typed_data_; // Temporary typed data handle. |
| 588 Code& code_; // Temporary code handle. | 590 Code& code_; // Temporary code handle. |
| 589 Function& function_; // Temporary function handle. | 591 Function& function_; // Temporary function handle. |
| 590 MegamorphicCache& megamorphic_cache_; // Temporary megamorphic cache handle. | 592 MegamorphicCache& megamorphic_cache_; // Temporary megamorphic cache handle. |
| 593 ObjectPool& object_pool_; // Temporary object pool handle. |
| 591 UnhandledException& error_; // Error handle. | 594 UnhandledException& error_; // Error handle. |
| 592 intptr_t max_vm_isolate_object_id_; | 595 intptr_t max_vm_isolate_object_id_; |
| 593 ZoneGrowableArray<BackRefNode>* backward_references_; | 596 ZoneGrowableArray<BackRefNode>* backward_references_; |
| 594 InstructionsReader* instructions_reader_; | 597 InstructionsReader* instructions_reader_; |
| 595 | 598 |
| 596 friend class ApiError; | 599 friend class ApiError; |
| 597 friend class Array; | 600 friend class Array; |
| 598 friend class Bigint; | 601 friend class Bigint; |
| 599 friend class BoundedType; | 602 friend class BoundedType; |
| 600 friend class Class; | 603 friend class Class; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 objects_() { | 858 objects_() { |
| 856 ASSERT(buffer != NULL); | 859 ASSERT(buffer != NULL); |
| 857 ASSERT(alloc != NULL); | 860 ASSERT(alloc != NULL); |
| 858 } | 861 } |
| 859 | 862 |
| 860 // Size of the snapshot (assembly code). | 863 // Size of the snapshot (assembly code). |
| 861 intptr_t BytesWritten() const { return stream_.bytes_written(); } | 864 intptr_t BytesWritten() const { return stream_.bytes_written(); } |
| 862 | 865 |
| 863 intptr_t binary_size() { return binary_size_; } | 866 intptr_t binary_size() { return binary_size_; } |
| 864 | 867 |
| 865 int32_t GetOffsetFor(RawInstructions* instructions); | 868 int32_t GetOffsetFor(RawInstructions* instructions, RawCode* code); |
| 866 | 869 |
| 867 int32_t GetObjectOffsetFor(RawObject* raw_object); | 870 int32_t GetObjectOffsetFor(RawObject* raw_object); |
| 868 | 871 |
| 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(); | 872 void WriteAssembly(); |
| 880 | 873 |
| 881 private: | 874 private: |
| 882 struct InstructionsData { | 875 struct InstructionsData { |
| 883 explicit InstructionsData(RawInstructions* insns) | 876 explicit InstructionsData(RawInstructions* insns, |
| 884 : raw_insns_(insns), raw_code_(NULL) { } | 877 RawCode* code, |
| 878 intptr_t offset) |
| 879 : raw_insns_(insns), raw_code_(code), offset_(offset) { } |
| 885 | 880 |
| 886 union { | 881 union { |
| 887 RawInstructions* raw_insns_; | 882 RawInstructions* raw_insns_; |
| 888 const Instructions* insns_; | 883 const Instructions* insns_; |
| 889 }; | 884 }; |
| 890 union { | 885 union { |
| 891 RawCode* raw_code_; | 886 RawCode* raw_code_; |
| 892 const Code* code_; | 887 const Code* code_; |
| 893 }; | 888 }; |
| 889 intptr_t offset_; |
| 894 }; | 890 }; |
| 895 | 891 |
| 896 struct ObjectData { | 892 struct ObjectData { |
| 897 explicit ObjectData(RawObject* raw_obj) | 893 explicit ObjectData(RawObject* raw_obj) |
| 898 : raw_obj_(raw_obj) { } | 894 : raw_obj_(raw_obj) { } |
| 899 | 895 |
| 900 union { | 896 union { |
| 901 RawObject* raw_obj_; | 897 RawObject* raw_obj_; |
| 902 const Object* obj_; | 898 const Object* obj_; |
| 903 }; | 899 }; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 bool can_send_any_object() const { return can_send_any_object_; } | 959 bool can_send_any_object() const { return can_send_any_object_; } |
| 964 bool snapshot_code() const { return snapshot_code_; } | 960 bool snapshot_code() const { return snapshot_code_; } |
| 965 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } | 961 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } |
| 966 void ThrowException(Exceptions::ExceptionType type, const char* msg); | 962 void ThrowException(Exceptions::ExceptionType type, const char* msg); |
| 967 | 963 |
| 968 // Write a version string for the snapshot. | 964 // Write a version string for the snapshot. |
| 969 void WriteVersion(); | 965 void WriteVersion(); |
| 970 | 966 |
| 971 static intptr_t FirstObjectId(); | 967 static intptr_t FirstObjectId(); |
| 972 | 968 |
| 973 int32_t GetInstructionsId(RawInstructions* instructions) { | 969 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) { |
| 974 return instructions_writer_->GetOffsetFor(instructions); | 970 return instructions_writer_->GetOffsetFor(instructions, code); |
| 975 } | 971 } |
| 976 | 972 |
| 977 int32_t GetObjectId(RawObject* raw) { | 973 int32_t GetObjectId(RawObject* raw) { |
| 978 return instructions_writer_->GetObjectOffsetFor(raw); | 974 return instructions_writer_->GetObjectOffsetFor(raw); |
| 979 } | 975 } |
| 980 | 976 |
| 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); | 977 void WriteFunctionId(RawFunction* func, bool owner_is_class); |
| 986 | 978 |
| 987 RawFunction* IsSerializableClosure(RawClosure* closure); | 979 RawFunction* IsSerializableClosure(RawClosure* closure); |
| 988 | 980 |
| 989 void WriteStaticImplicitClosure(intptr_t object_id, | 981 void WriteStaticImplicitClosure(intptr_t object_id, |
| 990 RawFunction* func, | 982 RawFunction* func, |
| 991 intptr_t tags); | 983 intptr_t tags); |
| 992 | 984 |
| 993 protected: | 985 protected: |
| 994 bool CheckAndWritePredefinedObject(RawObject* raw); | 986 bool CheckAndWritePredefinedObject(RawObject* raw); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 const char* exception_msg_; // Message associated with exception. | 1033 const char* exception_msg_; // Message associated with exception. |
| 1042 bool unmarked_objects_; // True if marked objects have been unmarked. | 1034 bool unmarked_objects_; // True if marked objects have been unmarked. |
| 1043 bool can_send_any_object_; // True if any Dart instance can be sent. | 1035 bool can_send_any_object_; // True if any Dart instance can be sent. |
| 1044 bool snapshot_code_; | 1036 bool snapshot_code_; |
| 1045 bool vm_isolate_is_symbolic_; | 1037 bool vm_isolate_is_symbolic_; |
| 1046 | 1038 |
| 1047 friend class FullSnapshotWriter; | 1039 friend class FullSnapshotWriter; |
| 1048 friend class RawArray; | 1040 friend class RawArray; |
| 1049 friend class RawClass; | 1041 friend class RawClass; |
| 1050 friend class RawClosureData; | 1042 friend class RawClosureData; |
| 1043 friend class RawCode; |
| 1051 friend class RawContextScope; | 1044 friend class RawContextScope; |
| 1052 friend class RawExceptionHandlers; | 1045 friend class RawExceptionHandlers; |
| 1053 friend class RawField; | 1046 friend class RawField; |
| 1054 friend class RawFunction; | 1047 friend class RawFunction; |
| 1055 friend class RawGrowableObjectArray; | 1048 friend class RawGrowableObjectArray; |
| 1056 friend class RawImmutableArray; | 1049 friend class RawImmutableArray; |
| 1057 friend class RawInstructions; | 1050 friend class RawInstructions; |
| 1058 friend class RawRegExp; | 1051 friend class RawRegExp; |
| 1059 friend class RawLibrary; | 1052 friend class RawLibrary; |
| 1060 friend class RawLinkedHashMap; | 1053 friend class RawLinkedHashMap; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 private: | 1186 private: |
| 1194 SnapshotWriter* writer_; | 1187 SnapshotWriter* writer_; |
| 1195 bool as_references_; | 1188 bool as_references_; |
| 1196 | 1189 |
| 1197 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1190 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 1198 }; | 1191 }; |
| 1199 | 1192 |
| 1200 } // namespace dart | 1193 } // namespace dart |
| 1201 | 1194 |
| 1202 #endif // VM_SNAPSHOT_H_ | 1195 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |