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

Unified Diff: runtime/vm/growable_array.h

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Undo unneeded changes Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/growable_array.h
diff --git a/runtime/vm/growable_array.h b/runtime/vm/growable_array.h
index 692da64a6706664090d878e2e1c58a6d3d798028..3093233df966b08abde3e31caedab2116e92740d 100644
--- a/runtime/vm/growable_array.h
+++ b/runtime/vm/growable_array.h
@@ -18,15 +18,14 @@ namespace dart {
template<typename T, typename B>
class BaseGrowableArray : public B {
public:
- BaseGrowableArray() : length_(0), capacity_(0), data_(NULL), zone_(NULL) {
- ASSERT(Isolate::Current() != NULL);
- zone_ = Isolate::Current()->current_zone();
+ explicit BaseGrowableArray(BaseZone* zone)
+ : length_(0), capacity_(0), data_(NULL), zone_(zone) {
+ ASSERT(zone_ != NULL);
}
- explicit BaseGrowableArray(int initial_capacity)
- : length_(0), capacity_(0), data_(NULL), zone_(NULL) {
- ASSERT(Isolate::Current() != NULL);
- zone_ = Isolate::Current()->current_zone();
+ BaseGrowableArray(int initial_capacity, BaseZone* zone)
+ : length_(0), capacity_(0), data_(NULL), zone_(zone) {
+ ASSERT(zone_ != NULL);
if (initial_capacity > 0) {
capacity_ = Utils::RoundUpToPowerOfTwo(initial_capacity);
data_ = reinterpret_cast<T*>(zone_->Allocate(capacity_ * sizeof(T)));
@@ -76,7 +75,7 @@ class BaseGrowableArray : public B {
int length_;
int capacity_;
T* data_;
- Zone* zone_; // Zone in which we are allocating the array.
+ BaseZone* zone_; // Zone in which we are allocating the array.
void Resize(int new_length);
@@ -95,9 +94,6 @@ inline void BaseGrowableArray<T, B>::Sort(
template<typename T, typename B>
void BaseGrowableArray<T, B>::Resize(int new_length) {
if (new_length > capacity_) {
- ASSERT(Isolate::Current() != NULL);
- // Check that we allocating in the array's zone.
- ASSERT(zone_ == Isolate::Current()->current_zone());
int new_capacity = Utils::RoundUpToPowerOfTwo(new_length);
T* new_data = reinterpret_cast<T*>(
zone_->Reallocate(reinterpret_cast<uword>(data_),
@@ -114,9 +110,16 @@ void BaseGrowableArray<T, B>::Resize(int new_length) {
template<typename T>
class GrowableArray : public BaseGrowableArray<T, ValueObject> {
public:
+ GrowableArray(int initial_capacity, Zone* zone)
+ : BaseGrowableArray<T, ValueObject>(
+ initial_capacity, zone->GetBaseZone()) {}
siva 2012/02/09 00:45:29 Are there any users for this variation of the cons
Søren Gjesse 2012/02/09 08:44:01 No, removed.
explicit GrowableArray(int initial_capacity)
- : BaseGrowableArray<T, ValueObject>(initial_capacity) {}
- GrowableArray() : BaseGrowableArray<T, ValueObject>() {}
+ : BaseGrowableArray<T, ValueObject>(
+ initial_capacity,
+ Isolate::Current()->current_zone()->GetBaseZone()) {}
+ GrowableArray()
+ : BaseGrowableArray<T, ValueObject>(
+ Isolate::Current()->current_zone()->GetBaseZone()) {}
};
@@ -124,8 +127,12 @@ template<typename T>
class ZoneGrowableArray : public BaseGrowableArray<T, ZoneAllocated> {
public:
explicit ZoneGrowableArray(int initial_capacity)
- : BaseGrowableArray<T, ZoneAllocated>(initial_capacity) {}
- ZoneGrowableArray() : BaseGrowableArray<T, ZoneAllocated>() {}
+ : BaseGrowableArray<T, ZoneAllocated>(
+ initial_capacity,
+ Isolate::Current()->current_zone()->GetBaseZone()) {}
+ ZoneGrowableArray() :
+ BaseGrowableArray<T, ZoneAllocated>(
+ Isolate::Current()->current_zone()->GetBaseZone()) {}
};
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698