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

Side by Side Diff: vm/object.h

Issue 11443024: Restructure Add and SetAt to not create a Handle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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
« no previous file with comments | « lib/string.cc ('k') | vm/object.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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 4411 matching lines...) Expand 10 before | Expand all | Expand 10 after
4422 4422
4423 RawObject* At(intptr_t index) const { 4423 RawObject* At(intptr_t index) const {
4424 NoGCScope no_gc; 4424 NoGCScope no_gc;
4425 ASSERT(!IsNull()); 4425 ASSERT(!IsNull());
4426 ASSERT(index < Length()); 4426 ASSERT(index < Length());
4427 return *ObjectAddr(index); 4427 return *ObjectAddr(index);
4428 } 4428 }
4429 void SetAt(intptr_t index, const Object& value) const { 4429 void SetAt(intptr_t index, const Object& value) const {
4430 ASSERT(!IsNull()); 4430 ASSERT(!IsNull());
4431 ASSERT(index < Length()); 4431 ASSERT(index < Length());
4432 const Array& arr = Array::Handle(data()); 4432
4433 arr.SetAt(index, value); 4433 // TODO(iposva): Add storing NoGCScope.
4434 DataStorePointer(ObjectAddr(index), value.raw());
4434 } 4435 }
4435 4436
4436 void Add(const Object& value, Heap::Space space = Heap::kNew) const; 4437 void Add(const Object& value, Heap::Space space = Heap::kNew) const;
4437 void Add(Isolate* isolate,
4438 const Object& value,
4439 Heap::Space space = Heap::kNew) const;
4440 4438
4441 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; 4439 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const;
4442 RawObject* RemoveLast() const; 4440 RawObject* RemoveLast() const;
4443 4441
4444 virtual RawAbstractTypeArguments* GetTypeArguments() const { 4442 virtual RawAbstractTypeArguments* GetTypeArguments() const {
4445 ASSERT(AbstractTypeArguments::AreEqual( 4443 ASSERT(AbstractTypeArguments::AreEqual(
4446 AbstractTypeArguments::Handle(Array::Handle(data()).GetTypeArguments()), 4444 AbstractTypeArguments::Handle(Array::Handle(data()).GetTypeArguments()),
4447 AbstractTypeArguments::Handle(raw_ptr()->type_arguments_))); 4445 AbstractTypeArguments::Handle(raw_ptr()->type_arguments_)));
4448 return raw_ptr()->type_arguments_; 4446 return raw_ptr()->type_arguments_;
4449 } 4447 }
(...skipping 28 matching lines...) Expand all
4478 Heap::Space space = Heap::kNew); 4476 Heap::Space space = Heap::kNew);
4479 static RawGrowableObjectArray* New(const Array& array, 4477 static RawGrowableObjectArray* New(const Array& array,
4480 Heap::Space space = Heap::kNew); 4478 Heap::Space space = Heap::kNew);
4481 4479
4482 private: 4480 private:
4483 RawArray* DataArray() const { return data()->ptr(); } 4481 RawArray* DataArray() const { return data()->ptr(); }
4484 RawObject** ObjectAddr(intptr_t index) const { 4482 RawObject** ObjectAddr(intptr_t index) const {
4485 ASSERT((index >= 0) && (index < Length())); 4483 ASSERT((index >= 0) && (index < Length()));
4486 return &(DataArray()->data()[index]); 4484 return &(DataArray()->data()[index]);
4487 } 4485 }
4486 bool DataContains(uword addr) const {
4487 intptr_t data_size = data()->Size();
4488 uword data_addr = RawObject::ToAddr(data());
4489 return (addr >= data_addr) && (addr < (data_addr + data_size));
4490 }
4491 void DataStorePointer(RawObject** addr, RawObject* value) const {
4492 // Ensure that the backing array object contains the addr.
4493 ASSERT(DataContains(reinterpret_cast<uword>(addr)));
4494 *addr = value;
4495 // Filter stores based on source and target.
4496 if (!value->IsHeapObject()) return;
4497 if (value->IsNewObject() && data()->IsOldObject()) {
4498 uword ptr = reinterpret_cast<uword>(addr);
4499 Isolate::Current()->store_buffer()->AddPointer(ptr);
4500 }
4501 }
4488 4502
4489 static const int kDefaultInitialCapacity = 4; 4503 static const int kDefaultInitialCapacity = 4;
4490 4504
4491 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 4505 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
4492 friend class Array; 4506 friend class Array;
4493 friend class Class; 4507 friend class Class;
4494 }; 4508 };
4495 4509
4496 4510
4497 class ByteArray : public Instance { 4511 class ByteArray : public Instance {
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
5993 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 6007 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5994 return false; 6008 return false;
5995 } 6009 }
5996 } 6010 }
5997 return true; 6011 return true;
5998 } 6012 }
5999 6013
6000 } // namespace dart 6014 } // namespace dart
6001 6015
6002 #endif // VM_OBJECT_H_ 6016 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « lib/string.cc ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698