| Index: runtime/vm/snapshot.cc
|
| diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
|
| index ea0dce38e500901d107bd7242abed7717da02cf2..ef6aa66134c44748611798b33b9d6dd1c0d38ee4 100644
|
| --- a/runtime/vm/snapshot.cc
|
| +++ b/runtime/vm/snapshot.cc
|
| @@ -203,6 +203,7 @@ SnapshotReader::SnapshotReader(
|
| code_(Code::Handle(zone_)),
|
| function_(Function::Handle(zone_)),
|
| megamorphic_cache_(MegamorphicCache::Handle(zone_)),
|
| + object_pool_(ObjectPool::Handle(zone_)),
|
| error_(UnhandledException::Handle(zone_)),
|
| max_vm_isolate_object_id_(
|
| (kind == Snapshot::kFull) ?
|
| @@ -1142,11 +1143,27 @@ RawStacktrace* SnapshotReader::NewStacktrace() {
|
| }
|
|
|
|
|
| -int32_t InstructionsWriter::GetOffsetFor(RawInstructions* instructions) {
|
| - intptr_t heap_size = instructions->Size();
|
| +int32_t InstructionsWriter::GetOffsetFor(RawInstructions* instructions,
|
| + RawCode* code) {
|
| +#if defined(PRODUCT)
|
| + // Instructions are only dedup in product mode because it obfuscates profiler
|
| + // results.
|
| + for (intptr_t i = 0; i < instructions_.length(); i++) {
|
| + if (instructions_[i].raw_insns_ == instructions) {
|
| + return instructions_[i].offset_;
|
| + }
|
| + }
|
| +#endif
|
| +
|
| + intptr_t payload_size = instructions->ptr()->size_;
|
| + payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment());
|
| +
|
| intptr_t offset = next_offset_;
|
| - next_offset_ += heap_size;
|
| - instructions_.Add(InstructionsData(instructions));
|
| + ASSERT(Utils::IsAligned(next_offset_, OS::PreferredCodeAlignment()));
|
| + next_offset_ += payload_size;
|
| + ASSERT(Utils::IsAligned(next_offset_, OS::PreferredCodeAlignment()));
|
| + instructions_.Add(InstructionsData(instructions, code, offset));
|
| +
|
| return offset;
|
| }
|
|
|
| @@ -1213,32 +1230,7 @@ void InstructionsWriter::WriteAssembly() {
|
|
|
| ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0);
|
|
|
| - {
|
| - // 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.
|
| + // 1. Write a label at the entry point.
|
| owner = code.owner();
|
| if (owner.IsNull()) {
|
| const char* name = StubCode::NameOfStub(insns.EntryPoint());
|
| @@ -1261,7 +1253,9 @@ void InstructionsWriter::WriteAssembly() {
|
| NoSafepointScope no_safepoint;
|
| uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag;
|
| uword entry = beginning + Instructions::HeaderSize();
|
| - uword end = beginning + insns.raw()->Size();
|
| + uword payload_size = insns.size();
|
| + payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment());
|
| + uword end = entry + payload_size;
|
|
|
| ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t)));
|
| ASSERT(Utils::IsAligned(entry, sizeof(uint64_t)));
|
| @@ -1313,27 +1307,9 @@ void InstructionsWriter::WriteAssembly() {
|
| }
|
|
|
|
|
| -RawInstructions* InstructionsReader::GetInstructionsAt(int32_t offset,
|
| - uword expected_tags) {
|
| +uword InstructionsReader::GetInstructionsAt(int32_t offset) {
|
| ASSERT(Utils::IsAligned(offset, OS::PreferredCodeAlignment()));
|
| -
|
| - RawInstructions* result =
|
| - reinterpret_cast<RawInstructions*>(
|
| - reinterpret_cast<uword>(instructions_buffer_) +
|
| - offset + kHeapObjectTag);
|
| -
|
| -#ifdef DEBUG
|
| - uword actual_tags = result->ptr()->tags_;
|
| - if (actual_tags != expected_tags) {
|
| - FATAL2("Instructions tag mismatch: expected %" Pd ", saw %" Pd,
|
| - expected_tags,
|
| - actual_tags);
|
| - }
|
| -#endif
|
| -
|
| - ASSERT(result->IsMarked());
|
| -
|
| - return result;
|
| + return reinterpret_cast<uword>(instructions_buffer_) + offset;
|
| }
|
|
|
|
|
|
|