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

Unified Diff: runtime/vm/snapshot.cc

Issue 1938653002: JIT precompilated snapshots. (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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/snapshot.cc
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 6107c5306e3fb23c517f88e32ba60ca5b98d5f91..e31c35e0eadb21c376750155a48672de88e56e1d 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -625,7 +625,7 @@ RawApiError* SnapshotReader::ReadFullSnapshot() {
}
}
- if (Snapshot::IncludesCode(kind_)) {
+ if (kind_ == Snapshot::kAppNoJIT) {
ICData& ic = ICData::Handle(thread->zone());
Object& funcOrCode = Object::Handle(thread->zone());
Code& code = Code::Handle(thread->zone());
@@ -1160,13 +1160,9 @@ int32_t InstructionsWriter::GetOffsetFor(RawInstructions* instructions,
}
#endif
- intptr_t payload_size = instructions->ptr()->size_;
- payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment());
-
+ intptr_t heap_size = instructions->Size();
intptr_t offset = next_offset_;
- ASSERT(Utils::IsAligned(next_offset_, OS::PreferredCodeAlignment()));
- next_offset_ += payload_size;
- ASSERT(Utils::IsAligned(next_offset_, OS::PreferredCodeAlignment()));
+ next_offset_ += heap_size;
instructions_.Add(InstructionsData(instructions, code, offset));
return offset;
@@ -1235,7 +1231,32 @@ void AssemblyInstructionsWriter::Write() {
ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0);
- // 1. Write a label at the entry point.
+ // 1. Write from the header to the entry point.
+ {
+ NoSafepointScope no_safepoint;
+
+ uword beginning = reinterpret_cast<uword>(insns.raw_ptr());
+ uword entry = beginning + Instructions::HeaderSize();
+
+ ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t)));
+ ASSERT(Utils::IsAligned(entry, sizeof(uint64_t)));
+
+ // Write Instructions with the mark and VM heap bits set.
+ uword marked_tags = insns.raw_ptr()->tags_;
+ marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
+ marked_tags = RawObject::MarkBit::update(true, marked_tags);
+
+ WriteWordLiteral(marked_tags);
+ beginning += sizeof(uword);
+
+ for (uword* cursor = reinterpret_cast<uword*>(beginning);
+ cursor < reinterpret_cast<uword*>(entry);
+ cursor++) {
+ WriteWordLiteral(*cursor);
+ }
+ }
+
+ // 2. Write a label at the entry point.
owner = code.owner();
if (owner.IsNull()) {
const char* name = StubCode::NameOfStub(insns.EntryPoint());
@@ -1255,7 +1276,7 @@ void AssemblyInstructionsWriter::Write() {
}
{
- // 2. Write from the entry point to the end.
+ // 3. Write from the entry point to the end.
NoSafepointScope no_safepoint;
uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag;
uword entry = beginning + Instructions::HeaderSize();
@@ -1342,8 +1363,33 @@ void BlobInstructionsWriter::Write() {
for (intptr_t i = 0; i < instructions_.length(); i++) {
const Instructions& insns = *instructions_[i].insns_;
+ // 1. Write from the header to the entry point.
+ {
+ NoSafepointScope no_safepoint;
+
+ uword beginning = reinterpret_cast<uword>(insns.raw_ptr());
+ uword entry = beginning + Instructions::HeaderSize();
+
+ ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t)));
+ ASSERT(Utils::IsAligned(entry, sizeof(uint64_t)));
+
+ // Write Instructions with the mark and VM heap bits set.
+ uword marked_tags = insns.raw_ptr()->tags_;
+ marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
+ marked_tags = RawObject::MarkBit::update(true, marked_tags);
+
+ instructions_blob_stream_.WriteWord(marked_tags);
+ beginning += sizeof(uword);
+
+ for (uword* cursor = reinterpret_cast<uword*>(beginning);
+ cursor < reinterpret_cast<uword*>(entry);
+ cursor++) {
+ instructions_blob_stream_.WriteWord(*cursor);
+ }
+ }
+
+ // 2. Write from the entry point to the end.
{
- // 2. Write from the entry point to the end.
NoSafepointScope no_safepoint;
uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag;
uword entry = beginning + Instructions::HeaderSize();
@@ -1718,7 +1764,7 @@ IsolateSnapshotReader::IsolateSnapshotReader(Snapshot::Kind kind,
new ZoneGrowableArray<BackRefNode>(
kNumInitialReferencesInFullSnapshot),
thread) {
- isolate()->set_compilation_allowed(instructions_buffer_ == NULL);
+ isolate()->set_compilation_allowed(kind != Snapshot::kAppNoJIT);
ASSERT(Snapshot::IsFull(kind));
}
@@ -2142,23 +2188,6 @@ void FullSnapshotWriter::WriteFullSnapshot() {
}
-PrecompiledSnapshotWriter::PrecompiledSnapshotWriter(
- uint8_t** vm_isolate_snapshot_buffer,
- uint8_t** isolate_snapshot_buffer,
- ReAlloc alloc,
- InstructionsWriter* instructions_writer)
- : FullSnapshotWriter(Snapshot::kAppNoJIT,
- vm_isolate_snapshot_buffer,
- isolate_snapshot_buffer,
- alloc,
- instructions_writer,
- false /* vm_isolate_is_symbolic */) {
-}
-
-
-PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {}
-
-
ForwardList::ForwardList(Thread* thread, intptr_t first_object_id)
: thread_(thread),
first_object_id_(first_object_id),

Powered by Google App Engine
This is Rietveld 408576698