| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index 1248744c2cf20986d19bd0cc4163128571f24f12..3d282a804b964d900abbe6582d2f2e3067731540 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -627,11 +627,9 @@ void Object::InitOnce(Isolate* isolate) {
|
|
|
| // Allocate and initialize the empty_descriptors instance.
|
| {
|
| - uword address = heap->Allocate(
|
| - PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize),
|
| - Heap::kOld);
|
| + uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld);
|
| InitializeObject(address, kPcDescriptorsCid,
|
| - PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize));
|
| + PcDescriptors::InstanceSize(0));
|
| PcDescriptors::initializeHandle(
|
| empty_descriptors_,
|
| reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
|
| @@ -10555,6 +10553,45 @@ void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
| }
|
|
|
|
|
| +// Encode integer in SLEB128 format.
|
| +void PcDescriptors::EncodeInteger(GrowableArray<uint8_t>* data,
|
| + intptr_t value) {
|
| + bool is_last_part = false;
|
| + while (!is_last_part) {
|
| + intptr_t part = value & 0x7f;
|
| + value >>= 7;
|
| + if ((value == 0 && (part & 0x40) == 0) ||
|
| + (value == -1 && (part & 0x40) != 0)) {
|
| + is_last_part = true;
|
| + } else {
|
| + part |= 0x80;
|
| + }
|
| + data->Add(part);
|
| + }
|
| +}
|
| +
|
| +
|
| +// Decode SLEB128 encoded integer. Update byte_index to the next integer.
|
| +intptr_t PcDescriptors::DecodeInteger(intptr_t* byte_index) const {
|
| + NoSafepointScope no_safepoint;
|
| + const uint8_t* data = raw_ptr()->data();
|
| + ASSERT(*byte_index < Length());
|
| + uword shift = 0;
|
| + intptr_t value = 0;
|
| + intptr_t part = 0;
|
| + do {
|
| + part = data[(*byte_index)++];
|
| + value |= (part & 0x7f) << shift;
|
| + shift += 7;
|
| + } while ((part & 0x80) != 0);
|
| +
|
| + if (shift < sizeof(value) * 8 && (part & 0x40) != 0) {
|
| + value |= -(1 << shift);
|
| + }
|
| + return value;
|
| +}
|
| +
|
| +
|
| intptr_t PcDescriptors::Length() const {
|
| return raw_ptr()->length_;
|
| }
|
| @@ -10565,29 +10602,21 @@ void PcDescriptors::SetLength(intptr_t value) const {
|
| }
|
|
|
|
|
| -intptr_t PcDescriptors::RecordSizeInBytes() const {
|
| - return raw_ptr()->record_size_in_bytes_;
|
| -}
|
| -
|
| -
|
| -void PcDescriptors::SetRecordSizeInBytes(intptr_t value) const {
|
| - StoreNonPointer(&raw_ptr()->record_size_in_bytes_, value);
|
| +void PcDescriptors::CopyData(GrowableArray<uint8_t>* delta_encoded_data) {
|
| + NoSafepointScope no_safepoint;
|
| + uint8_t* data = UnsafeMutableNonPointer(&raw_ptr()->data()[0]);
|
| + for (intptr_t i = 0; i < delta_encoded_data->length(); ++i) {
|
| + data[i] = (*delta_encoded_data)[i];
|
| + }
|
| }
|
|
|
|
|
| -RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors,
|
| - bool has_try_index) {
|
| +RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) {
|
| ASSERT(Object::pc_descriptors_class() != Class::null());
|
| - if (num_descriptors < 0 || num_descriptors > kMaxElements) {
|
| - // This should be caught before we reach here.
|
| - FATAL1("Fatal error in PcDescriptors::New: "
|
| - "invalid num_descriptors %" Pd "\n", num_descriptors);
|
| - }
|
| Isolate* isolate = Isolate::Current();
|
| PcDescriptors& result = PcDescriptors::Handle(isolate);
|
| {
|
| - const intptr_t rec_size = RawPcDescriptors::RecordSize(has_try_index);
|
| - uword size = PcDescriptors::InstanceSize(num_descriptors, rec_size);
|
| + uword size = PcDescriptors::InstanceSize(data->length());
|
| RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
|
| size,
|
| Heap::kOld);
|
| @@ -10595,8 +10624,8 @@ RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors,
|
| INC_STAT(isolate, pc_desc_size, size);
|
| NoSafepointScope no_safepoint;
|
| result ^= raw;
|
| - result.SetLength(num_descriptors);
|
| - result.SetRecordSizeInBytes(rec_size);
|
| + result.SetLength(data->length());
|
| + result.CopyData(data);
|
| }
|
| return result.raw();
|
| }
|
|
|