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

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: 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 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..d7957e0923a352f4aa6005942312048ed0be4427 100644
--- a/runtime/vm/growable_array.h
+++ b/runtime/vm/growable_array.h
@@ -21,12 +21,24 @@ class BaseGrowableArray : public B {
BaseGrowableArray() : length_(0), capacity_(0), data_(NULL), zone_(NULL) {
ASSERT(Isolate::Current() != NULL);
zone_ = Isolate::Current()->current_zone();
+#ifdef DEBUG
+ isolate_zone_ = true;
+#endif
}
- explicit BaseGrowableArray(int initial_capacity)
- : length_(0), capacity_(0), data_(NULL), zone_(NULL) {
- ASSERT(Isolate::Current() != NULL);
- zone_ = Isolate::Current()->current_zone();
+ explicit BaseGrowableArray(int initial_capacity, Zone* zone = NULL)
siva 2012/02/04 01:55:43 BaseGrowableArray is not used anywhere but here, w
Søren Gjesse 2012/02/06 16:25:52 Done.
+ : length_(0), capacity_(0), data_(NULL), zone_(zone) {
+ if (zone == NULL) {
+ ASSERT(Isolate::Current() != NULL);
+ zone_ = Isolate::Current()->current_zone();
+ }
+#ifdef DEBUG
+ if (Isolate::Current() != NULL) {
+ isolate_zone_ = (zone_ == Isolate::Current()->current_zone());
+ } else {
+ isolate_zone_ = false;
+ }
+#endif
if (initial_capacity > 0) {
capacity_ = Utils::RoundUpToPowerOfTwo(initial_capacity);
data_ = reinterpret_cast<T*>(zone_->Allocate(capacity_ * sizeof(T)));
@@ -77,6 +89,9 @@ class BaseGrowableArray : public B {
int capacity_;
T* data_;
Zone* zone_; // Zone in which we are allocating the array.
+#ifdef DEBUG
+ bool isolate_zone_;
+#endif
void Resize(int new_length);
@@ -95,9 +110,13 @@ 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());
+#ifdef DEBUG
+ if (isolate_zone_) {
+ ASSERT(Isolate::Current() != NULL);
+ // Check that we allocating in the array's zone.
+ ASSERT(zone_ == Isolate::Current()->current_zone());
+ }
+#endif
int new_capacity = Utils::RoundUpToPowerOfTwo(new_length);
T* new_data = reinterpret_cast<T*>(
zone_->Reallocate(reinterpret_cast<uword>(data_),
@@ -114,8 +133,8 @@ void BaseGrowableArray<T, B>::Resize(int new_length) {
template<typename T>
class GrowableArray : public BaseGrowableArray<T, ValueObject> {
public:
- explicit GrowableArray(int initial_capacity)
- : BaseGrowableArray<T, ValueObject>(initial_capacity) {}
+ GrowableArray(int initial_capacity, Zone* zone = NULL)
+ : BaseGrowableArray<T, ValueObject>(initial_capacity, zone) {}
siva 2012/02/04 01:55:43 Have two versions of the constructor, the one argu
Søren Gjesse 2012/02/06 16:25:52 Done.
GrowableArray() : BaseGrowableArray<T, ValueObject>() {}
};

Powered by Google App Engine
This is Rietveld 408576698