Skip to content

Commit

Permalink
Toward precompiled snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmacnak-google committed Aug 19, 2015
1 parent 719794f commit 7055e48
Show file tree
Hide file tree
Showing 9 changed files with 451 additions and 72 deletions.
6 changes: 4 additions & 2 deletions runtime/vm/benchmark_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ BENCHMARK_SIZE(CoreSnapshotSize) {
// Write snapshot with object content.
FullSnapshotWriter writer(&vm_isolate_snapshot_buffer,
&isolate_snapshot_buffer,
&malloc_allocator);
&malloc_allocator,
false /* snapshot_code */);
writer.WriteFullSnapshot();
const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
ASSERT(snapshot->kind() == Snapshot::kFull);
Expand Down Expand Up @@ -536,7 +537,8 @@ BENCHMARK_SIZE(StandaloneSnapshotSize) {
// Write snapshot with object content.
FullSnapshotWriter writer(&vm_isolate_snapshot_buffer,
&isolate_snapshot_buffer,
&malloc_allocator);
&malloc_allocator,
false /* snapshot_code */);
writer.WriteFullSnapshot();
const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
ASSERT(snapshot->kind() == Snapshot::kFull);
Expand Down
3 changes: 2 additions & 1 deletion runtime/vm/dart_api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,8 @@ DART_EXPORT Dart_Handle Dart_CreateSnapshot(
isolate->object_store()->set_root_library(Library::Handle(isolate));
FullSnapshotWriter writer(vm_isolate_snapshot_buffer,
isolate_snapshot_buffer,
ApiReallocate);
ApiReallocate,
false /* snapshot_code */);
writer.WriteFullSnapshot();
*vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize();
*isolate_snapshot_size = writer.IsolateSnapshotSize();
Expand Down
33 changes: 27 additions & 6 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11100,7 +11100,7 @@ void PcDescriptors::PrintHeaderString() {

const char* PcDescriptors::ToCString() const {
if (Length() == 0) {
return "No pc descriptors\n";
return "empty PcDescriptors\n";
}
// 4 bits per hex digit.
const int addr_width = kBitsPerWord / 4;
Expand Down Expand Up @@ -11429,6 +11429,9 @@ const char* LocalVarDescriptors::ToCString() const {
if (IsNull()) {
return "LocalVarDescriptors(NULL)";
}
if (Length() == 0) {
return "empty LocalVarDescriptors";
}
intptr_t len = 1; // Trailing '\0'.
String& var_name = String::Handle();
for (intptr_t i = 0; i < Length(); i++) {
Expand Down Expand Up @@ -12364,6 +12367,22 @@ bool ICData::IsUsedAt(intptr_t i) const {
}


RawICData* ICData::New() {
ICData& result = ICData::Handle();
{
// IC data objects are long living objects, allocate them in old generation.
RawObject* raw = Object::Allocate(ICData::kClassId,
ICData::InstanceSize(),
Heap::kOld);
NoSafepointScope no_safepoint;
result ^= raw;
}
result.set_deopt_id(Isolate::kNoDeoptId);
result.set_state_bits(0);
return result.raw();
}


RawICData* ICData::New(const Function& owner,
const String& target_name,
const Array& arguments_descriptor,
Expand Down Expand Up @@ -13117,11 +13136,13 @@ intptr_t Code::GetDeoptIdForOsr(uword pc) const {


const char* Code::ToCString() const {
const char* kFormat = "Code entry:%p";
intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1;
char* chars = Thread::Current()->zone()->Alloc<char>(len);
OS::SNPrint(chars, len, kFormat, EntryPoint());
return chars;
Zone* zone = Thread::Current()->zone();
if (IsStubCode()) {
const char* name = StubCode::NameOfStub(EntryPoint());
return zone->PrintToString("[stub: %s]", name);
} else {
return zone->PrintToString("Code entry:%" Px, EntryPoint());
}
}


Expand Down
3 changes: 3 additions & 0 deletions runtime/vm/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,8 @@ class ICData : public Object {
bool is_static_call) const;

private:
static RawICData* New();

RawArray* ic_data() const {
return raw_ptr()->ic_data_;
}
Expand Down Expand Up @@ -4376,6 +4378,7 @@ class Code : public Object {

FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object);
friend class Class;
friend class SnapshotWriter;

// So that the RawFunction pointer visitor can determine whether code the
// function points to is optimized.
Expand Down
Loading

0 comments on commit 7055e48

Please sign in to comment.