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

Unified Diff: runtime/vm/snapshot.h

Issue 1318803002: Toward precompiled snapshots. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.h
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index f838ef3370f29b804f6d014d9c85f3ef6f835a6e..d84d3fe8386e93a10a626cb301a0ebe128ecaaa6 100644
--- a/runtime/vm/snapshot.h
+++ b/runtime/vm/snapshot.h
@@ -39,7 +39,9 @@ class RawCapability;
class RawClass;
class RawClosureData;
class RawContext;
+class RawContextScope;
class RawDouble;
+class RawExceptionHandlers;
class RawField;
class RawFloat32x4;
class RawFloat64x2;
@@ -54,6 +56,7 @@ class RawLibrary;
class RawLibraryPrefix;
class RawLinkedHashMap;
class RawLiteralToken;
+class RawLocalVarDescriptors;
class RawMegamorphicCache;
class RawMint;
class RawMixinAppType;
@@ -63,11 +66,13 @@ class RawObject;
class RawObjectPool;
class RawOneByteString;
class RawPatchClass;
+class RawPcDescriptors;
class RawReceivePort;
class RawRedirectionData;
class RawScript;
class RawSendPort;
class RawSmi;
+class RawStackmap;
class RawStacktrace;
class RawSubtypeTestCache;
class RawTokenStream;
@@ -295,6 +300,24 @@ class BackRefNode : public ValueObject {
};
+class InstructionsReader : public ZoneAllocated {
+ public:
+ explicit InstructionsReader(const uint8_t* buffer)
+ : buffer_(buffer) {
+ ASSERT(buffer != NULL);
+ ASSERT(Utils::IsAligned(reinterpret_cast<uword>(buffer),
+ OS::PreferredCodeAlignment()));
+ }
+
+ RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags);
+
+ private:
+ const uint8_t* buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstructionsReader);
+};
+
+
// Reads a snapshot into objects.
class SnapshotReader : public BaseReader {
public:
@@ -313,6 +336,7 @@ class SnapshotReader : public BaseReader {
TokenStream* StreamHandle() { return &stream_; }
ExternalTypedData* DataHandle() { return &data_; }
TypedData* TypedDataHandle() { return &typed_data_; }
+ Code* CodeHandle() { return &code_; }
Snapshot::Kind kind() const { return kind_; }
bool snapshot_code() const { return snapshot_code_; }
@@ -365,9 +389,15 @@ class SnapshotReader : public BaseReader {
RawFunction* NewFunction();
RawCode* NewCode(intptr_t pointer_offsets_length);
RawObjectPool* NewObjectPool(intptr_t length);
+ RawPcDescriptors* NewPcDescriptors(intptr_t length);
+ RawLocalVarDescriptors* NewLocalVarDescriptors(intptr_t num_entries);
+ RawExceptionHandlers* NewExceptionHandlers(intptr_t num_entries);
+ RawStackmap* NewStackmap(intptr_t length);
+ RawContextScope* NewContextScope(intptr_t num_variables);
RawICData* NewICData();
RawMegamorphicCache* NewMegamorphicCache();
RawSubtypeTestCache* NewSubtypeTestCache();
+ RawLinkedHashMap* NewLinkedHashMap();
RawField* NewField();
RawLibrary* NewLibrary();
RawLibraryPrefix* NewLibraryPrefix();
@@ -384,11 +414,16 @@ class SnapshotReader : public BaseReader {
RawObject* NewInteger(int64_t value);
RawStacktrace* NewStacktrace();
- RawInstructions* GetInstructionsById(int32_t id);
+ RawInstructions* GetInstructionsAt(int32_t offset, uword expected_tags) {
+ return instructions_reader_->GetInstructionsAt(offset, expected_tags);
+ }
+
+ const uint8_t* instructions_buffer_;
protected:
SnapshotReader(const uint8_t* buffer,
intptr_t size,
+ const uint8_t* instructions_buffer,
Snapshot::Kind kind,
ZoneGrowableArray<BackRefNode>* backward_references,
Thread* thread);
@@ -483,9 +518,11 @@ class SnapshotReader : public BaseReader {
TokenStream& stream_; // Temporary token stream handle.
ExternalTypedData& data_; // Temporary stream data handle.
TypedData& typed_data_; // Temporary typed data handle.
+ Code& code_; // Temporary code handle.
UnhandledException& error_; // Error handle.
intptr_t max_vm_isolate_object_id_;
ZoneGrowableArray<BackRefNode>* backward_references_;
+ InstructionsReader* instructions_reader_;
friend class ApiError;
friend class Array;
@@ -502,6 +539,7 @@ class SnapshotReader : public BaseReader {
friend class GrowableObjectArray;
friend class ICData;
friend class ImmutableArray;
+ friend class Instructions;
friend class JSRegExp;
friend class LanguageError;
friend class Library;
@@ -533,7 +571,10 @@ class SnapshotReader : public BaseReader {
class VmIsolateSnapshotReader : public SnapshotReader {
public:
- VmIsolateSnapshotReader(const uint8_t* buffer, intptr_t size, Thread* thread);
+ VmIsolateSnapshotReader(const uint8_t* buffer,
+ intptr_t size,
+ const uint8_t* instructions_buffer,
+ Thread* thread);
~VmIsolateSnapshotReader();
RawApiError* ReadVmIsolateSnapshot();
@@ -547,6 +588,7 @@ class IsolateSnapshotReader : public SnapshotReader {
public:
IsolateSnapshotReader(const uint8_t* buffer,
intptr_t size,
+ const uint8_t* instructions_buffer,
Thread* thread);
~IsolateSnapshotReader();
@@ -730,6 +772,28 @@ class ForwardList {
};
+class InstructionsWriter : public ZoneAllocated {
+ public:
+ InstructionsWriter(uint8_t** buffer,
+ ReAlloc alloc,
+ intptr_t initial_size)
+ : stream_(buffer, alloc, initial_size) {
+ ASSERT(buffer != NULL);
+ ASSERT(alloc != NULL);
+ }
+
+ // Size of the snapshot.
+ intptr_t BytesWritten() const { return stream_.bytes_written(); }
+
+ int32_t GetOffsetFor(RawInstructions* instructions);
+
+ private:
+ WriteStream stream_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstructionsWriter);
+};
+
+
class SnapshotWriter : public BaseWriter {
protected:
SnapshotWriter(Snapshot::Kind kind,
@@ -737,8 +801,10 @@ class SnapshotWriter : public BaseWriter {
ReAlloc alloc,
intptr_t initial_size,
ForwardList* forward_list,
+ InstructionsWriter* instructions_writer,
bool can_send_any_object,
- bool snapshot_code);
+ bool snapshot_code,
+ bool vm_isolate_is_symbolic);
public:
// Snapshot kind.
@@ -761,6 +827,7 @@ class SnapshotWriter : public BaseWriter {
}
bool can_send_any_object() const { return can_send_any_object_; }
bool snapshot_code() const { return snapshot_code_; }
+ bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; }
void ThrowException(Exceptions::ExceptionType type, const char* msg);
// Write a version string for the snapshot.
@@ -768,7 +835,9 @@ class SnapshotWriter : public BaseWriter {
static intptr_t FirstObjectId();
- int32_t GetInstructionsId(RawInstructions* instructions) { return 0; }
+ int32_t GetInstructionsId(RawInstructions* instructions) {
+ return instructions_writer_->GetOffsetFor(instructions);
+ }
protected:
void UnmarkAll() {
@@ -779,7 +848,7 @@ class SnapshotWriter : public BaseWriter {
}
bool CheckAndWritePredefinedObject(RawObject* raw);
- void HandleVMIsolateObject(RawObject* raw);
+ bool HandleVMIsolateObject(RawObject* raw);
void WriteClassId(RawClass* cls);
void WriteStaticImplicitClosure(intptr_t object_id,
@@ -826,11 +895,13 @@ class SnapshotWriter : public BaseWriter {
ObjectStore* object_store_; // Object store for common classes.
ClassTable* class_table_; // Class table for the class index to class lookup.
ForwardList* forward_list_;
+ InstructionsWriter* instructions_writer_;
Exceptions::ExceptionType exception_type_; // Exception type.
const char* exception_msg_; // Message associated with exception.
bool unmarked_objects_; // True if marked objects have been unmarked.
bool can_send_any_object_; // True if any Dart instance can be sent.
bool snapshot_code_;
+ bool vm_isolate_is_symbolic_;
friend class FullSnapshotWriter;
friend class RawArray;
@@ -866,8 +937,10 @@ class FullSnapshotWriter {
static const intptr_t kInitialSize = 64 * KB;
FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer,
uint8_t** isolate_snapshot_buffer,
+ uint8_t** instructions_snapshot_buffer,
ReAlloc alloc,
- bool snapshot_code);
+ bool snapshot_code,
+ bool vm_isolate_is_symbolic);
~FullSnapshotWriter();
uint8_t** vm_isolate_snapshot_buffer() {
@@ -887,6 +960,9 @@ class FullSnapshotWriter {
intptr_t IsolateSnapshotSize() const {
return isolate_snapshot_size_;
}
+ intptr_t InstructionsSnapshotSize() const {
+ return instructions_snapshot_size_;
+ }
private:
// Writes a snapshot of the VM Isolate.
@@ -898,13 +974,17 @@ class FullSnapshotWriter {
Isolate* isolate_;
uint8_t** vm_isolate_snapshot_buffer_;
uint8_t** isolate_snapshot_buffer_;
+ uint8_t** instructions_snapshot_buffer_;
ReAlloc alloc_;
intptr_t vm_isolate_snapshot_size_;
intptr_t isolate_snapshot_size_;
+ intptr_t instructions_snapshot_size_;
ForwardList* forward_list_;
+ InstructionsWriter* instructions_writer_;
Array& scripts_;
Array& symbol_table_;
bool snapshot_code_;
+ bool vm_isolate_is_symbolic_;
DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter);
};
@@ -914,6 +994,7 @@ class PrecompiledSnapshotWriter : public FullSnapshotWriter {
public:
PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer,
uint8_t** isolate_snapshot_buffer,
+ uint8_t** instructions_snapshot_buffer,
ReAlloc alloc);
~PrecompiledSnapshotWriter();
};
« 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