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

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

Issue 566053002: Save more memory by compacting LocalVarDescriptors (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/raw_object.h » ('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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 InitializeObject(address, kPcDescriptorsCid, 662 InitializeObject(address, kPcDescriptorsCid,
663 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize)); 663 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize));
664 PcDescriptors::initializeHandle( 664 PcDescriptors::initializeHandle(
665 empty_descriptors_, 665 empty_descriptors_,
666 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); 666 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
667 empty_descriptors_->raw_ptr()->length_ = 0; 667 empty_descriptors_->raw_ptr()->length_ = 0;
668 } 668 }
669 669
670 // Allocate and initialize the canonical empty variable descriptor object. 670 // Allocate and initialize the canonical empty variable descriptor object.
671 { 671 {
672 uword address = heap->Allocate( 672 uword address =
673 LocalVarDescriptors::InstanceSize(0), Heap::kOld); 673 heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld);
674 InitializeObject(address, kLocalVarDescriptorsCid, 674 InitializeObject(address,
675 LocalVarDescriptors::InstanceSize(0)); 675 kLocalVarDescriptorsCid,
676 LocalVarDescriptors::InstanceSize(0));
676 LocalVarDescriptors::initializeHandle( 677 LocalVarDescriptors::initializeHandle(
677 empty_var_descriptors_, 678 empty_var_descriptors_,
678 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag)); 679 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag));
679 empty_var_descriptors_->raw_ptr()->length_ = 0; 680 empty_var_descriptors_->raw_ptr()->num_entries_ = 0;
680 // Can't use instance mentod StorePointer() here, but this pointer
681 // assignment is safe (from old space to old space).
682 empty_var_descriptors_->raw_ptr()->names_ = empty_array_->raw_ptr();
683 } 681 }
684 682
685 cls = Class::New<Instance>(kDynamicCid); 683 cls = Class::New<Instance>(kDynamicCid);
686 cls.set_is_abstract(); 684 cls.set_is_abstract();
687 cls.set_num_type_arguments(0); 685 cls.set_num_type_arguments(0);
688 cls.set_num_own_type_arguments(0); 686 cls.set_num_own_type_arguments(0);
689 cls.set_is_type_finalized(); 687 cls.set_is_type_finalized();
690 cls.set_is_finalized(); 688 cls.set_is_finalized();
691 dynamic_class_ = cls.raw(); 689 dynamic_class_ = cls.raw();
692 690
(...skipping 10100 matching lines...) Expand 10 before | Expand all | Expand 10 after
10793 } 10791 }
10794 10792
10795 10793
10796 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { 10794 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const {
10797 Object::PrintJSONImpl(stream, ref); 10795 Object::PrintJSONImpl(stream, ref);
10798 } 10796 }
10799 10797
10800 10798
10801 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { 10799 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const {
10802 ASSERT(var_index < Length()); 10800 ASSERT(var_index < Length());
10803 const Array& names = Array::Handle(raw_ptr()->names_); 10801 ASSERT(Object::Handle(*raw()->nameAddrAt(var_index)).IsString());
10804 ASSERT(Length() == names.Length()); 10802 return *raw()->nameAddrAt(var_index);
10805 String& name = String::Handle();
10806 name ^= names.At(var_index);
10807 return name.raw();
10808 } 10803 }
10809 10804
10810 10805
10811 void LocalVarDescriptors::SetVar(intptr_t var_index, 10806 void LocalVarDescriptors::SetVar(intptr_t var_index,
10812 const String& name, 10807 const String& name,
10813 RawLocalVarDescriptors::VarInfo* info) const { 10808 RawLocalVarDescriptors::VarInfo* info) const {
10814 ASSERT(var_index < Length()); 10809 ASSERT(var_index < Length());
10815 const Array& names = Array::Handle(raw_ptr()->names_); 10810 StorePointer(raw()->nameAddrAt(var_index), name.raw());
10816 ASSERT(Length() == names.Length()); 10811 raw()->data()[var_index] = *info;
10817 names.SetAt(var_index, name);
10818 raw_ptr()->data()[var_index] = *info;
10819 } 10812 }
10820 10813
10821 10814
10822 void LocalVarDescriptors::GetInfo(intptr_t var_index, 10815 void LocalVarDescriptors::GetInfo(intptr_t var_index,
10823 RawLocalVarDescriptors::VarInfo* info) const { 10816 RawLocalVarDescriptors::VarInfo* info) const {
10824 ASSERT(var_index < Length()); 10817 ASSERT(var_index < Length());
10825 *info = raw_ptr()->data()[var_index]; 10818 *info = raw()->data()[var_index];
10826 } 10819 }
10827 10820
10828 10821
10829 static const char* VarKindString(int kind) { 10822 static const char* VarKindString(int kind) {
10830 switch (kind) { 10823 switch (kind) {
10831 case RawLocalVarDescriptors::kStackVar: 10824 case RawLocalVarDescriptors::kStackVar:
10832 return "StackVar"; 10825 return "StackVar";
10833 break; 10826 break;
10834 case RawLocalVarDescriptors::kContextVar: 10827 case RawLocalVarDescriptors::kContextVar:
10835 return "ContextVar"; 10828 return "ContextVar";
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
10987 num_variables, RawLocalVarDescriptors::kMaxIndex); 10980 num_variables, RawLocalVarDescriptors::kMaxIndex);
10988 } 10981 }
10989 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 10982 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
10990 { 10983 {
10991 uword size = LocalVarDescriptors::InstanceSize(num_variables); 10984 uword size = LocalVarDescriptors::InstanceSize(num_variables);
10992 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 10985 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
10993 size, 10986 size,
10994 Heap::kOld); 10987 Heap::kOld);
10995 NoGCScope no_gc; 10988 NoGCScope no_gc;
10996 result ^= raw; 10989 result ^= raw;
10997 result.raw_ptr()->length_ = num_variables; 10990 result.raw_ptr()->num_entries_ = num_variables;
10998 } 10991 }
10999 const Array& names = (num_variables == 0) ? Object::empty_array() :
11000 Array::Handle(Array::New(num_variables, Heap::kOld));
11001 result.raw_ptr()->names_ = names.raw();
11002 return result.raw(); 10992 return result.raw();
11003 } 10993 }
11004 10994
11005 10995
11006 intptr_t LocalVarDescriptors::Length() const { 10996 intptr_t LocalVarDescriptors::Length() const {
11007 return raw_ptr()->length_; 10997 return raw_ptr()->num_entries_;
11008 } 10998 }
11009 10999
11010 11000
11011 intptr_t ExceptionHandlers::Length() const { 11001 intptr_t ExceptionHandlers::Length() const {
11012 return raw_ptr()->length_; 11002 return raw_ptr()->length_;
11013 } 11003 }
11014 11004
11015 11005
11016 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, 11006 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index,
11017 intptr_t outer_try_index, 11007 intptr_t outer_try_index,
(...skipping 9334 matching lines...) Expand 10 before | Expand all | Expand 10 after
20352 return tag_label.ToCString(); 20342 return tag_label.ToCString();
20353 } 20343 }
20354 20344
20355 20345
20356 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20346 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20357 Instance::PrintJSONImpl(stream, ref); 20347 Instance::PrintJSONImpl(stream, ref);
20358 } 20348 }
20359 20349
20360 20350
20361 } // namespace dart 20351 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698