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

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
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 return raw_ptr()->names()[var_index];
siva 2014/09/12 22:08:39 return raw_ptr()->nameAt(var_index); (see raw_obj
hausner 2014/09/12 23:48:04 Done.
10804 ASSERT(Length() == names.Length());
10805 String& name = String::Handle();
10806 name ^= names.At(var_index);
10807 return name.raw();
10808 } 10802 }
10809 10803
10810 10804
10811 void LocalVarDescriptors::SetVar(intptr_t var_index, 10805 void LocalVarDescriptors::SetVar(intptr_t var_index,
10812 const String& name, 10806 const String& name,
10813 RawLocalVarDescriptors::VarInfo* info) const { 10807 RawLocalVarDescriptors::VarInfo* info) const {
10814 ASSERT(var_index < Length()); 10808 ASSERT(var_index < Length());
10815 const Array& names = Array::Handle(raw_ptr()->names_); 10809 StorePointer(raw_ptr()->names() + var_index, name.raw());
siva 2014/09/12 22:08:39 StorePointer(&(raw_ptr()->nameAt(var_index)), name
hausner 2014/09/12 23:48:04 Done.
10816 ASSERT(Length() == names.Length());
10817 names.SetAt(var_index, name);
10818 raw_ptr()->data()[var_index] = *info; 10810 raw_ptr()->data()[var_index] = *info;
10819 } 10811 }
10820 10812
10821 10813
10822 void LocalVarDescriptors::GetInfo(intptr_t var_index, 10814 void LocalVarDescriptors::GetInfo(intptr_t var_index,
10823 RawLocalVarDescriptors::VarInfo* info) const { 10815 RawLocalVarDescriptors::VarInfo* info) const {
10824 ASSERT(var_index < Length()); 10816 ASSERT(var_index < Length());
10825 *info = raw_ptr()->data()[var_index]; 10817 *info = raw_ptr()->data()[var_index];
10826 } 10818 }
10827 10819
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
10987 num_variables, RawLocalVarDescriptors::kMaxIndex); 10979 num_variables, RawLocalVarDescriptors::kMaxIndex);
10988 } 10980 }
10989 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 10981 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
10990 { 10982 {
10991 uword size = LocalVarDescriptors::InstanceSize(num_variables); 10983 uword size = LocalVarDescriptors::InstanceSize(num_variables);
10992 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 10984 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
10993 size, 10985 size,
10994 Heap::kOld); 10986 Heap::kOld);
10995 NoGCScope no_gc; 10987 NoGCScope no_gc;
10996 result ^= raw; 10988 result ^= raw;
10997 result.raw_ptr()->length_ = num_variables; 10989 result.raw_ptr()->num_entries_ = num_variables;
10998 } 10990 }
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(); 10991 return result.raw();
11003 } 10992 }
11004 10993
11005 10994
11006 intptr_t LocalVarDescriptors::Length() const { 10995 intptr_t LocalVarDescriptors::Length() const {
11007 return raw_ptr()->length_; 10996 return raw_ptr()->num_entries_;
11008 } 10997 }
11009 10998
11010 10999
11011 intptr_t ExceptionHandlers::Length() const { 11000 intptr_t ExceptionHandlers::Length() const {
11012 return raw_ptr()->length_; 11001 return raw_ptr()->length_;
11013 } 11002 }
11014 11003
11015 11004
11016 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, 11005 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index,
11017 intptr_t outer_try_index, 11006 intptr_t outer_try_index,
(...skipping 9334 matching lines...) Expand 10 before | Expand all | Expand 10 after
20352 return tag_label.ToCString(); 20341 return tag_label.ToCString();
20353 } 20342 }
20354 20343
20355 20344
20356 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20345 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20357 Instance::PrintJSONImpl(stream, ref); 20346 Instance::PrintJSONImpl(stream, ref);
20358 } 20347 }
20359 20348
20360 20349
20361 } // namespace dart 20350 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698