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

Unified Diff: runtime/vm/object.cc

Issue 1188973003: Port "Add snapshoting methods for code's metadata." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 88802f36c21615825e4f9633767472c81503d68a..1249a5ea2d4d2d5ae71b0d883a220070c1a783bc 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -10842,6 +10842,25 @@ RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) {
}
+RawPcDescriptors* PcDescriptors::New(intptr_t length) {
+ ASSERT(Object::pc_descriptors_class() != Class::null());
+ Isolate* isolate = Isolate::Current();
+ PcDescriptors& result = PcDescriptors::Handle(isolate);
+ {
+ uword size = PcDescriptors::InstanceSize(length);
+ RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
+ size,
+ Heap::kOld);
+ INC_STAT(isolate, total_code_size, size);
+ INC_STAT(isolate, pc_desc_size, size);
+ NoSafepointScope no_safepoint;
+ result ^= raw;
+ result.SetLength(length);
+ }
+ return result.raw();
+}
+
+
const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) {
switch (kind) {
case RawPcDescriptors::kDeopt: return "deopt ";
@@ -11039,6 +11058,40 @@ RawStackmap* Stackmap::New(intptr_t pc_offset,
}
+RawStackmap* Stackmap::New(intptr_t length,
+ intptr_t register_bit_count,
+ intptr_t pc_offset) {
+ ASSERT(Object::stackmap_class() != Class::null());
+ Stackmap& result = Stackmap::Handle();
+ // Guard against integer overflow of the instance size computation.
+ intptr_t payload_size =
+ Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte;
+ if ((payload_size < 0) ||
+ (payload_size > kMaxLengthInBytes)) {
+ // This should be caught before we reach here.
+ FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n",
+ length);
+ }
+ {
+ // Stackmap data objects are associated with a code object, allocate them
+ // in old generation.
+ RawObject* raw = Object::Allocate(Stackmap::kClassId,
+ Stackmap::InstanceSize(length),
+ Heap::kOld);
+ NoSafepointScope no_safepoint;
+ result ^= raw;
+ result.SetLength(length);
+ }
+ // When constructing a stackmap we store the pc offset in the stackmap's
+ // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
+ // address.
+ ASSERT(pc_offset >= 0);
+ result.SetPcOffset(pc_offset);
+ result.SetRegisterBitCount(register_bit_count);
+ return result.raw();
+}
+
+
const char* Stackmap::ToCString() const {
if (IsNull()) {
return "{null}";
@@ -11360,6 +11413,29 @@ RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
}
+RawExceptionHandlers* ExceptionHandlers::New(const Array& handled_types_data) {
+ ASSERT(Object::exception_handlers_class() != Class::null());
+ const intptr_t num_handlers = handled_types_data.Length();
+ if ((num_handlers < 0) || (num_handlers >= kMaxHandlers)) {
+ FATAL1("Fatal error in ExceptionHandlers::New(): "
+ "invalid num_handlers %" Pd "\n",
+ num_handlers);
+ }
+ ExceptionHandlers& result = ExceptionHandlers::Handle();
+ {
+ uword size = ExceptionHandlers::InstanceSize(num_handlers);
+ RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
+ size,
+ Heap::kOld);
+ NoSafepointScope no_safepoint;
+ result ^= raw;
+ result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers);
+ }
+ result.set_handled_types_data(handled_types_data);
+ return result.raw();
+}
+
+
const char* ExceptionHandlers::ToCString() const {
if (num_entries() == 0) {
return "No exception handlers\n";
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698