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

Side by Side Diff: runtime/vm/object.cc

Issue 1129113002: Delta encode pc descriptors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 Array::initializeHandle( 619 Array::initializeHandle(
620 zero_array_, 620 zero_array_,
621 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 621 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
622 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); 622 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1));
623 smi = Smi::New(0); 623 smi = Smi::New(0);
624 zero_array_->SetAt(0, smi); 624 zero_array_->SetAt(0, smi);
625 } 625 }
626 626
627 // Allocate and initialize the empty_descriptors instance. 627 // Allocate and initialize the empty_descriptors instance.
628 { 628 {
629 uword address = heap->Allocate( 629 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld);
630 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize),
631 Heap::kOld);
632 InitializeObject(address, kPcDescriptorsCid, 630 InitializeObject(address, kPcDescriptorsCid,
633 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize)); 631 PcDescriptors::InstanceSize(0));
634 PcDescriptors::initializeHandle( 632 PcDescriptors::initializeHandle(
635 empty_descriptors_, 633 empty_descriptors_,
636 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); 634 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
637 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, 635 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_,
638 0); 636 0);
639 } 637 }
640 638
641 // Allocate and initialize the canonical empty variable descriptor object. 639 // Allocate and initialize the canonical empty variable descriptor object.
642 { 640 {
643 uword address = 641 uword address =
(...skipping 9905 matching lines...) Expand 10 before | Expand all | Expand 10 after
10549 const char* Instructions::ToCString() const { 10547 const char* Instructions::ToCString() const {
10550 return "Instructions"; 10548 return "Instructions";
10551 } 10549 }
10552 10550
10553 10551
10554 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const { 10552 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const {
10555 Object::PrintJSONImpl(stream, ref); 10553 Object::PrintJSONImpl(stream, ref);
10556 } 10554 }
10557 10555
10558 10556
10557 // Encode integer in SLEB128 format.
10558 void PcDescriptors::EncodeInteger(GrowableArray<uint8_t>* data,
10559 intptr_t value) {
10560 bool is_last_part = false;
10561 while (!is_last_part) {
10562 intptr_t part = value & 0x7f;
10563 value >>= 7;
10564 if ((value == 0 && (part & 0x40) == 0) ||
10565 (value == -1 && (part & 0x40) != 0)) {
10566 is_last_part = true;
10567 } else {
10568 part |= 0x80;
10569 }
10570 data->Add(part);
10571 }
10572 }
10573
10574
10575 // Decode SLEB128 encoded integer. Update byte_index to the next integer.
10576 intptr_t PcDescriptors::DecodeInteger(intptr_t* byte_index) const {
10577 NoSafepointScope no_safepoint;
10578 const uint8_t* data = raw_ptr()->data();
10579 ASSERT(*byte_index < Length());
10580 uword shift = 0;
10581 intptr_t value = 0;
10582 intptr_t part = 0;
10583 do {
10584 part = data[(*byte_index)++];
10585 value |= (part & 0x7f) << shift;
10586 shift += 7;
10587 } while ((part & 0x80) != 0);
10588
10589 if (shift < sizeof(value) * 8 && (part & 0x40) != 0) {
10590 value |= -(1 << shift);
10591 }
10592 return value;
10593 }
10594
10595
10559 intptr_t PcDescriptors::Length() const { 10596 intptr_t PcDescriptors::Length() const {
10560 return raw_ptr()->length_; 10597 return raw_ptr()->length_;
10561 } 10598 }
10562 10599
10563 10600
10564 void PcDescriptors::SetLength(intptr_t value) const { 10601 void PcDescriptors::SetLength(intptr_t value) const {
10565 StoreNonPointer(&raw_ptr()->length_, value); 10602 StoreNonPointer(&raw_ptr()->length_, value);
10566 } 10603 }
10567 10604
10568 10605
10569 intptr_t PcDescriptors::RecordSizeInBytes() const { 10606 void PcDescriptors::CopyData(GrowableArray<uint8_t>* delta_encoded_data) {
10570 return raw_ptr()->record_size_in_bytes_; 10607 NoSafepointScope no_safepoint;
10608 uint8_t* data = UnsafeMutableNonPointer(&raw_ptr()->data()[0]);
10609 for (intptr_t i = 0; i < delta_encoded_data->length(); ++i) {
10610 data[i] = (*delta_encoded_data)[i];
10611 }
10571 } 10612 }
10572 10613
10573 10614
10574 void PcDescriptors::SetRecordSizeInBytes(intptr_t value) const { 10615 RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) {
10575 StoreNonPointer(&raw_ptr()->record_size_in_bytes_, value);
10576 }
10577
10578
10579 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors,
10580 bool has_try_index) {
10581 ASSERT(Object::pc_descriptors_class() != Class::null()); 10616 ASSERT(Object::pc_descriptors_class() != Class::null());
10582 if (num_descriptors < 0 || num_descriptors > kMaxElements) {
10583 // This should be caught before we reach here.
10584 FATAL1("Fatal error in PcDescriptors::New: "
10585 "invalid num_descriptors %" Pd "\n", num_descriptors);
10586 }
10587 PcDescriptors& result = PcDescriptors::Handle(); 10617 PcDescriptors& result = PcDescriptors::Handle();
10588 { 10618 {
10589 const intptr_t rec_size = RawPcDescriptors::RecordSize(has_try_index); 10619 uword size = PcDescriptors::InstanceSize(data->length());
10590 uword size = PcDescriptors::InstanceSize(num_descriptors, rec_size);
10591 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, 10620 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
10592 size, 10621 size,
10593 Heap::kOld); 10622 Heap::kOld);
10594 NoSafepointScope no_safepoint; 10623 NoSafepointScope no_safepoint;
10595 result ^= raw; 10624 result ^= raw;
10596 result.SetLength(num_descriptors); 10625 result.SetLength(data->length());
10597 result.SetRecordSizeInBytes(rec_size); 10626 result.CopyData(data);
10598 } 10627 }
10599 return result.raw(); 10628 return result.raw();
10600 } 10629 }
10601 10630
10602 10631
10603 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { 10632 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) {
10604 switch (kind) { 10633 switch (kind) {
10605 case RawPcDescriptors::kDeopt: return "deopt "; 10634 case RawPcDescriptors::kDeopt: return "deopt ";
10606 case RawPcDescriptors::kIcCall: return "ic-call "; 10635 case RawPcDescriptors::kIcCall: return "ic-call ";
10607 case RawPcDescriptors::kOptStaticCall: return "opt-call "; 10636 case RawPcDescriptors::kOptStaticCall: return "opt-call ";
(...skipping 10122 matching lines...) Expand 10 before | Expand all | Expand 10 after
20730 return tag_label.ToCString(); 20759 return tag_label.ToCString();
20731 } 20760 }
20732 20761
20733 20762
20734 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20763 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20735 Instance::PrintJSONImpl(stream, ref); 20764 Instance::PrintJSONImpl(stream, ref);
20736 } 20765 }
20737 20766
20738 20767
20739 } // namespace dart 20768 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698