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

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

Issue 1128183007: Delta encode pc descriptors, and combine pc kind and try index into single field. (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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 Array::initializeHandle( 620 Array::initializeHandle(
621 zero_array_, 621 zero_array_,
622 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 622 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
623 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); 623 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1));
624 smi = Smi::New(0); 624 smi = Smi::New(0);
625 zero_array_->SetAt(0, smi); 625 zero_array_->SetAt(0, smi);
626 } 626 }
627 627
628 // Allocate and initialize the empty_descriptors instance. 628 // Allocate and initialize the empty_descriptors instance.
629 { 629 {
630 uword address = heap->Allocate( 630 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld);
631 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize),
632 Heap::kOld);
633 InitializeObject(address, kPcDescriptorsCid, 631 InitializeObject(address, kPcDescriptorsCid,
634 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize)); 632 PcDescriptors::InstanceSize(0));
635 PcDescriptors::initializeHandle( 633 PcDescriptors::initializeHandle(
636 empty_descriptors_, 634 empty_descriptors_,
637 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); 635 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
638 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, 636 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_,
639 0); 637 0);
640 } 638 }
641 639
642 // Allocate and initialize the canonical empty variable descriptor object. 640 // Allocate and initialize the canonical empty variable descriptor object.
643 { 641 {
644 uword address = 642 uword address =
(...skipping 9903 matching lines...) Expand 10 before | Expand all | Expand 10 after
10548 const char* Instructions::ToCString() const { 10546 const char* Instructions::ToCString() const {
10549 return "Instructions"; 10547 return "Instructions";
10550 } 10548 }
10551 10549
10552 10550
10553 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const { 10551 void Instructions::PrintJSONImpl(JSONStream* stream, bool ref) const {
10554 Object::PrintJSONImpl(stream, ref); 10552 Object::PrintJSONImpl(stream, ref);
10555 } 10553 }
10556 10554
10557 10555
10556 // Encode integer in SLEB128 format.
10557 void PcDescriptors::EncodeInteger(GrowableArray<uint8_t>* data,
10558 intptr_t value) {
10559 bool is_last_part = false;
10560 while (!is_last_part) {
10561 intptr_t part = value & 0x7f;
10562 value >>= 7;
10563 if ((value == 0 && (part & 0x40) == 0) ||
10564 (value == -1 && (part & 0x40) != 0)) {
10565 is_last_part = true;
10566 } else {
10567 part |= 0x80;
10568 }
10569 data->Add(part);
10570 }
10571 }
10572
10573
10574 // Decode SLEB128 encoded integer. Update byte_index to the next integer.
10575 intptr_t PcDescriptors::DecodeInteger(intptr_t* byte_index) const {
10576 NoSafepointScope no_safepoint;
10577 const uint8_t* data = raw_ptr()->data();
10578 ASSERT(*byte_index < Length());
10579 uword shift = 0;
10580 intptr_t value = 0;
10581 intptr_t part = 0;
10582 do {
10583 part = data[(*byte_index)++];
10584 value |= (part & 0x7f) << shift;
10585 shift += 7;
10586 } while ((part & 0x80) != 0);
10587
10588 if (shift < sizeof(value) * 8 && (part & 0x40) != 0) {
10589 value |= -(1 << shift);
10590 }
10591 return value;
10592 }
10593
10594
10558 intptr_t PcDescriptors::Length() const { 10595 intptr_t PcDescriptors::Length() const {
10559 return raw_ptr()->length_; 10596 return raw_ptr()->length_;
10560 } 10597 }
10561 10598
10562 10599
10563 void PcDescriptors::SetLength(intptr_t value) const { 10600 void PcDescriptors::SetLength(intptr_t value) const {
10564 StoreNonPointer(&raw_ptr()->length_, value); 10601 StoreNonPointer(&raw_ptr()->length_, value);
10565 } 10602 }
10566 10603
10567 10604
10568 intptr_t PcDescriptors::RecordSizeInBytes() const { 10605 void PcDescriptors::CopyData(GrowableArray<uint8_t>* delta_encoded_data) {
10569 return raw_ptr()->record_size_in_bytes_; 10606 NoSafepointScope no_safepoint;
10607 uint8_t* data = UnsafeMutableNonPointer(&raw_ptr()->data()[0]);
10608 for (intptr_t i = 0; i < delta_encoded_data->length(); ++i) {
10609 data[i] = (*delta_encoded_data)[i];
10610 }
10570 } 10611 }
10571 10612
10572 10613
10573 void PcDescriptors::SetRecordSizeInBytes(intptr_t value) const { 10614 RawPcDescriptors* PcDescriptors::New(GrowableArray<uint8_t>* data) {
10574 StoreNonPointer(&raw_ptr()->record_size_in_bytes_, value);
10575 }
10576
10577
10578 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors,
10579 bool has_try_index) {
10580 ASSERT(Object::pc_descriptors_class() != Class::null()); 10615 ASSERT(Object::pc_descriptors_class() != Class::null());
10581 if (num_descriptors < 0 || num_descriptors > kMaxElements) {
10582 // This should be caught before we reach here.
10583 FATAL1("Fatal error in PcDescriptors::New: "
10584 "invalid num_descriptors %" Pd "\n", num_descriptors);
10585 }
10586 Isolate* isolate = Isolate::Current(); 10616 Isolate* isolate = Isolate::Current();
10587 PcDescriptors& result = PcDescriptors::Handle(isolate); 10617 PcDescriptors& result = PcDescriptors::Handle(isolate);
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 INC_STAT(isolate, total_code_size, size); 10623 INC_STAT(isolate, total_code_size, size);
10595 INC_STAT(isolate, pc_desc_size, size); 10624 INC_STAT(isolate, pc_desc_size, size);
10596 NoSafepointScope no_safepoint; 10625 NoSafepointScope no_safepoint;
10597 result ^= raw; 10626 result ^= raw;
10598 result.SetLength(num_descriptors); 10627 result.SetLength(data->length());
10599 result.SetRecordSizeInBytes(rec_size); 10628 result.CopyData(data);
10600 } 10629 }
10601 return result.raw(); 10630 return result.raw();
10602 } 10631 }
10603 10632
10604 10633
10605 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { 10634 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) {
10606 switch (kind) { 10635 switch (kind) {
10607 case RawPcDescriptors::kDeopt: return "deopt "; 10636 case RawPcDescriptors::kDeopt: return "deopt ";
10608 case RawPcDescriptors::kIcCall: return "ic-call "; 10637 case RawPcDescriptors::kIcCall: return "ic-call ";
10609 case RawPcDescriptors::kOptStaticCall: return "opt-call "; 10638 case RawPcDescriptors::kOptStaticCall: return "opt-call ";
(...skipping 10102 matching lines...) Expand 10 before | Expand all | Expand 10 after
20712 return tag_label.ToCString(); 20741 return tag_label.ToCString();
20713 } 20742 }
20714 20743
20715 20744
20716 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20745 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20717 Instance::PrintJSONImpl(stream, ref); 20746 Instance::PrintJSONImpl(stream, ref);
20718 } 20747 }
20719 20748
20720 20749
20721 } // namespace dart 20750 } // 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