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

Side by Side Diff: vm/object.cc

Issue 9072011: - Add a size field to the header. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 11 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 | « vm/object.h ('k') | vm/raw_object.h » ('j') | vm/stub_code_x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 object_store->set_false_value(bool_value); 696 object_store->set_false_value(bool_value);
697 } 697 }
698 698
699 699
700 void Object::Print() const { 700 void Object::Print() const {
701 OS::Print("%s\n", ToCString()); 701 OS::Print("%s\n", ToCString());
702 } 702 }
703 703
704 704
705 void Object::InitializeObject(uword address, intptr_t size) { 705 void Object::InitializeObject(uword address, intptr_t size) {
706 // TODO(iposva): Get a proper halt instruction from the assembler which
707 // would be needed here for code objects.
706 uword initial_value = reinterpret_cast<uword>(null_); 708 uword initial_value = reinterpret_cast<uword>(null_);
707 uword cur = address; 709 uword cur = address;
708 uword end = address + size; 710 uword end = address + size;
709 while (cur < end) { 711 while (cur < end) {
710 *reinterpret_cast<uword*>(cur) = initial_value; 712 *reinterpret_cast<uword*>(cur) = initial_value;
711 cur += kWordSize; 713 cur += kWordSize;
712 } 714 }
713 } 715 }
714 716
715 717
716 RawObject* Object::Allocate(const Class& cls, 718 RawObject* Object::Allocate(const Class& cls,
717 intptr_t size, 719 intptr_t size,
718 Heap::Space space) { 720 Heap::Space space) {
721 ASSERT(Utils::IsAligned(size, kObjectAlignment));
719 Isolate* isolate = Isolate::Current(); 722 Isolate* isolate = Isolate::Current();
720 Heap* heap = isolate->heap(); 723 Heap* heap = isolate->heap();
721 724
722 // TODO(iposva): Get a proper halt instruction from the assembler.
723 uword address = heap->Allocate(size, space); 725 uword address = heap->Allocate(size, space);
724 NoGCScope no_gc; 726 NoGCScope no_gc;
725 InitializeObject(address, size); 727 InitializeObject(address, size);
726 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 728 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
727 raw_obj->ptr()->class_ = cls.raw(); 729 raw_obj->ptr()->class_ = cls.raw();
728 raw_obj->ptr()->tags_ = 0; 730 uword tags = 0;
731 tags = RawObject::SizeTag::update(size, tags);
732 raw_obj->ptr()->tags_ = tags;
729 return raw_obj; 733 return raw_obj;
730 } 734 }
731 735
732 736
733 RawString* Class::Name() const { 737 RawString* Class::Name() const {
734 if (raw_ptr()->name_ != String::null()) { 738 if (raw_ptr()->name_ != String::null()) {
735 return raw_ptr()->name_; 739 return raw_ptr()->name_;
736 } 740 }
737 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work. 741 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work.
738 intptr_t index = GetSingletonClassIndex(raw()); 742 intptr_t index = GetSingletonClassIndex(raw());
(...skipping 6752 matching lines...) Expand 10 before | Expand all | Expand 10 after
7491 const String& str = String::Handle(pattern()); 7495 const String& str = String::Handle(pattern());
7492 const char* format = "JSRegExp: pattern=%s flags=%s"; 7496 const char* format = "JSRegExp: pattern=%s flags=%s";
7493 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7497 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7494 char* chars = reinterpret_cast<char*>( 7498 char* chars = reinterpret_cast<char*>(
7495 Isolate::Current()->current_zone()->Allocate(len + 1)); 7499 Isolate::Current()->current_zone()->Allocate(len + 1));
7496 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7500 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7497 return chars; 7501 return chars;
7498 } 7502 }
7499 7503
7500 } // namespace dart 7504 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('j') | vm/stub_code_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698