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

Side by Side Diff: vm/object.cc

Issue 8827016: Add a flags field to RawObject so that we can tag objects with certain (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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) 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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 Heap::Space space) { 708 Heap::Space space) {
709 Isolate* isolate = Isolate::Current(); 709 Isolate* isolate = Isolate::Current();
710 Heap* heap = isolate->heap(); 710 Heap* heap = isolate->heap();
711 711
712 // TODO(iposva): Get a proper halt instruction from the assembler. 712 // TODO(iposva): Get a proper halt instruction from the assembler.
713 uword address = heap->Allocate(size, space); 713 uword address = heap->Allocate(size, space);
714 NoGCScope no_gc; 714 NoGCScope no_gc;
715 InitializeObject(address, size); 715 InitializeObject(address, size);
716 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 716 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
717 raw_obj->ptr()->class_ = cls.raw(); 717 raw_obj->ptr()->class_ = cls.raw();
718 raw_obj->ptr()->tags_ = 0;
718 return raw_obj; 719 return raw_obj;
719 } 720 }
720 721
721 722
722 RawString* Class::Name() const { 723 RawString* Class::Name() const {
723 if (raw_ptr()->name_ != String::null()) { 724 if (raw_ptr()->name_ != String::null()) {
724 return raw_ptr()->name_; 725 return raw_ptr()->name_;
725 } 726 }
726 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work. 727 ASSERT(class_class() != null_); // Or GetSingletonClassIndex will not work.
727 intptr_t index = GetSingletonClassIndex(raw()); 728 intptr_t index = GetSingletonClassIndex(raw());
(...skipping 4419 matching lines...) Expand 10 before | Expand all | Expand 10 after
5147 return cls.TestType(test, type_arguments, other_class, other_type_arguments); 5148 return cls.TestType(test, type_arguments, other_class, other_type_arguments);
5148 } 5149 }
5149 5150
5150 5151
5151 bool Instance::IsValidNativeIndex(int index) const { 5152 bool Instance::IsValidNativeIndex(int index) const {
5152 const Class& cls = Class::Handle(clazz()); 5153 const Class& cls = Class::Handle(clazz());
5153 return (index >= 0 && index < cls.num_native_fields()); 5154 return (index >= 0 && index < cls.num_native_fields());
5154 } 5155 }
5155 5156
5156 5157
5157 RawInstance* Instance::New(const Class& cls, Heap::Space space) { 5158 RawInstance* Instance::New(const Class& cls, Heap::Space space) {
5158 Instance& result = Instance::Handle(); 5159 Instance& result = Instance::Handle();
5159 { 5160 {
5160 intptr_t instance_size = cls.instance_size(); 5161 intptr_t instance_size = cls.instance_size();
5161 ASSERT(instance_size > 0); 5162 ASSERT(instance_size > 0);
5162 RawObject* raw = Object::Allocate(cls, instance_size, space); 5163 RawObject* raw = Object::Allocate(cls, instance_size, space);
5163 NoGCScope no_gc; 5164 NoGCScope no_gc;
5164 result ^= raw; 5165 result ^= raw;
5165 uword addr = reinterpret_cast<uword>(result.raw_ptr()); 5166 uword addr = reinterpret_cast<uword>(result.raw_ptr());
5166 // Initialize fields. 5167 // Initialize fields.
5167 intptr_t offset = sizeof(RawObject); 5168 intptr_t offset = sizeof(RawObject);
(...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after
7320 const String& str = String::Handle(pattern()); 7321 const String& str = String::Handle(pattern());
7321 const char* format = "JSRegExp: pattern=%s flags=%s"; 7322 const char* format = "JSRegExp: pattern=%s flags=%s";
7322 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7323 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7323 char* chars = reinterpret_cast<char*>( 7324 char* chars = reinterpret_cast<char*>(
7324 Isolate::Current()->current_zone()->Allocate(len + 1)); 7325 Isolate::Current()->current_zone()->Allocate(len + 1));
7325 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7326 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7326 return chars; 7327 return chars;
7327 } 7328 }
7328 7329
7329 } // namespace dart 7330 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/object_test.cc » ('j') | vm/stub_code_ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698