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

Unified Diff: runtime/vm/object.cc

Issue 1309113004: Change trail from GrowableObjectArray to ZoneGrowableArray. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Formatting Created 5 years, 4 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
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index dddddfb9de4ed94c1d5d25cc1ce9f3cd62fe2a85..c9252cfcdf058932c0059c410037647aa1498029 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -4459,7 +4459,7 @@ RawString* TypeArguments::SubvectorName(intptr_t from_index,
bool TypeArguments::IsSubvectorEquivalent(const TypeArguments& other,
intptr_t from_index,
intptr_t len,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
if (this->raw() == other.raw()) {
return true;
}
@@ -4656,7 +4656,7 @@ bool TypeArguments::IsResolved() const {
bool TypeArguments::IsSubvectorInstantiated(intptr_t from_index,
intptr_t len,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(!IsNull());
AbstractType& type = AbstractType::Handle();
for (intptr_t i = 0; i < len; i++) {
@@ -4814,7 +4814,7 @@ bool TypeArguments::IsBounded() const {
RawTypeArguments* TypeArguments::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(!IsInstantiated());
if (!instantiator_type_arguments.IsNull() &&
IsUninstantiatedIdentity() &&
@@ -5048,7 +5048,7 @@ RawTypeArguments* TypeArguments::CloneUnfinalized() const {
RawTypeArguments* TypeArguments::CloneUninstantiated(
const Class& new_owner,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(!IsNull());
ASSERT(IsFinalized());
ASSERT(!IsInstantiated());
@@ -5068,8 +5068,7 @@ RawTypeArguments* TypeArguments::CloneUninstantiated(
}
-RawTypeArguments* TypeArguments::Canonicalize(
- GrowableObjectArray* trail) const {
+RawTypeArguments* TypeArguments::Canonicalize(TrailPtr trail) const {
if (IsNull() || IsCanonical()) {
ASSERT(IsOld());
return this->raw();
@@ -14800,7 +14799,7 @@ intptr_t AbstractType::token_pos() const {
}
-bool AbstractType::IsInstantiated(GrowableObjectArray* trail) const {
+bool AbstractType::IsInstantiated(TrailPtr trail) const {
// AbstractType is an abstract class.
UNREACHABLE();
return false;
@@ -14855,8 +14854,7 @@ void AbstractType::set_error(const LanguageError& value) const {
}
-bool AbstractType::IsEquivalent(const Instance& other,
- GrowableObjectArray* trail) const {
+bool AbstractType::IsEquivalent(const Instance& other, TrailPtr trail) const {
// AbstractType is an abstract class.
UNREACHABLE();
return false;
@@ -14873,7 +14871,7 @@ bool AbstractType::IsRecursive() const {
RawAbstractType* AbstractType::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
// AbstractType is an abstract class.
UNREACHABLE();
return NULL;
@@ -14888,46 +14886,47 @@ RawAbstractType* AbstractType::CloneUnfinalized() const {
RawAbstractType* AbstractType::CloneUninstantiated(
- const Class& new_owner,
- GrowableObjectArray* trail) const {
+ const Class& new_owner, TrailPtr trail) const {
// AbstractType is an abstract class.
UNREACHABLE();
return NULL;
}
-RawAbstractType* AbstractType::Canonicalize(GrowableObjectArray* trail) const {
+RawAbstractType* AbstractType::Canonicalize(TrailPtr trail) const {
// AbstractType is an abstract class.
UNREACHABLE();
return NULL;
}
-RawObject* AbstractType::OnlyBuddyInTrail(GrowableObjectArray* trail) const {
+RawInstance* AbstractType::OnlyBuddyInTrail(TrailPtr trail) const {
regis 2015/08/27 02:30:26 see comment in header
srdjan 2015/08/27 16:09:49 Done.
if (trail == NULL) {
- return Object::null();
+ return Instance::null();
regis 2015/08/27 02:30:26 ditto
srdjan 2015/08/27 16:09:49 Done.
}
- const intptr_t len = trail->Length();
+ const intptr_t len = trail->length();
ASSERT((len % 2) == 0);
for (intptr_t i = 0; i < len; i += 2) {
- if (trail->At(i) == this->raw()) {
- ASSERT(trail->At(i + 1) != Object::null());
- return trail->At(i + 1);
+ if (trail->At(i)->raw() == this->raw()) {
+ ASSERT(!trail->At(i + 1)->IsNull());
+ return trail->At(i + 1)->raw();
}
}
- return Object::null();
+ return Instance::null();
regis 2015/08/27 02:30:25 ditto
srdjan 2015/08/27 16:09:49 Done.
}
-void AbstractType::AddOnlyBuddyToTrail(GrowableObjectArray** trail,
- const Object& buddy) const {
+void AbstractType::AddOnlyBuddyToTrail(TrailPtr* trail,
+ const AbstractType& buddy) const {
if (*trail == NULL) {
- *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New());
+ *trail = new Trail();
} else {
ASSERT(OnlyBuddyInTrail(*trail) == Object::null());
regis 2015/08/27 02:30:26 AbstractType:null()
srdjan 2015/08/27 16:09:49 Done.
}
- (*trail)->Add(*this);
- (*trail)->Add(buddy);
+ AbstractType& t = AbstractType::ZoneHandle(this->raw());
+ AbstractType& b = AbstractType::ZoneHandle(buddy.raw());
+ (*trail)->Add(&t);
+ (*trail)->Add(&b);
}
@@ -15432,7 +15431,7 @@ RawTypeArguments* Type::arguments() const {
}
-bool Type::IsInstantiated(GrowableObjectArray* trail) const {
+bool Type::IsInstantiated(TrailPtr trail) const {
if (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) {
return true;
}
@@ -15466,7 +15465,7 @@ bool Type::IsInstantiated(GrowableObjectArray* trail) const {
RawAbstractType* Type::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(IsFinalized() || IsBeingFinalized());
ASSERT(!IsInstantiated());
// Return the uninstantiated type unchanged if malformed. No copy needed.
@@ -15512,8 +15511,7 @@ RawAbstractType* Type::InstantiateFrom(
}
-bool Type::IsEquivalent(const Instance& other,
- GrowableObjectArray* trail) const {
+bool Type::IsEquivalent(const Instance& other, TrailPtr trail) const {
ASSERT(!IsNull());
if (raw() == other.raw()) {
return true;
@@ -15608,7 +15606,7 @@ RawAbstractType* Type::CloneUnfinalized() const {
RawAbstractType* Type::CloneUninstantiated(const Class& new_owner,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(IsFinalized());
ASSERT(!IsMalformed());
if (IsInstantiated()) {
@@ -15635,7 +15633,7 @@ RawAbstractType* Type::CloneUninstantiated(const Class& new_owner,
}
-RawAbstractType* Type::Canonicalize(GrowableObjectArray* trail) const {
+RawAbstractType* Type::Canonicalize(TrailPtr trail) const {
ASSERT(IsFinalized());
if (IsCanonical() || IsMalformed()) {
ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld());
@@ -15883,7 +15881,7 @@ void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
}
-bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const {
+bool TypeRef::IsInstantiated(TrailPtr trail) const {
if (TestAndAddToTrail(&trail)) {
return true;
}
@@ -15891,8 +15889,7 @@ bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const {
}
-bool TypeRef::IsEquivalent(const Instance& other,
- GrowableObjectArray* trail) const {
+bool TypeRef::IsEquivalent(const Instance& other, TrailPtr trail) const {
if (raw() == other.raw()) {
return true;
}
@@ -15906,7 +15903,7 @@ bool TypeRef::IsEquivalent(const Instance& other,
RawTypeRef* TypeRef::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
TypeRef& instantiated_type_ref = TypeRef::Handle();
instantiated_type_ref ^= OnlyBuddyInTrail(trail);
if (!instantiated_type_ref.IsNull()) {
@@ -15925,7 +15922,7 @@ RawTypeRef* TypeRef::InstantiateFrom(
RawTypeRef* TypeRef::CloneUninstantiated(const Class& new_owner,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
TypeRef& cloned_type_ref = TypeRef::Handle();
cloned_type_ref ^= OnlyBuddyInTrail(trail);
if (!cloned_type_ref.IsNull()) {
@@ -15953,7 +15950,7 @@ void TypeRef::set_type(const AbstractType& value) const {
// Consider the type Derived, where class Derived extends Base<Derived>.
// The first type argument of its flattened type argument vector is Derived,
// represented by a TypeRef pointing to itself.
-RawAbstractType* TypeRef::Canonicalize(GrowableObjectArray* trail) const {
+RawAbstractType* TypeRef::Canonicalize(TrailPtr trail) const {
if (TestAndAddToTrail(&trail)) {
return raw();
}
@@ -15974,38 +15971,41 @@ intptr_t TypeRef::Hash() const {
}
-bool TypeRef::TestAndAddToTrail(GrowableObjectArray** trail) const {
+bool TypeRef::TestAndAddToTrail(TrailPtr* trail) const {
if (*trail == NULL) {
- *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New());
+ *trail = new Trail();
} else {
- const intptr_t len = (*trail)->Length();
+ const intptr_t len = (*trail)->length();
for (intptr_t i = 0; i < len; i++) {
- if ((*trail)->At(i) == this->raw()) {
+ if ((*trail)->At(i)->raw() == this->raw()) {
return true;
}
}
}
- (*trail)->Add(*this);
+ AbstractType& t = AbstractType::ZoneHandle(this->raw());
+ (*trail)->Add(&t);
return false;
}
-bool TypeRef::TestAndAddBuddyToTrail(GrowableObjectArray** trail,
- const Object& buddy) const {
+bool TypeRef::TestAndAddBuddyToTrail(TrailPtr* trail,
+ const Instance& buddy) const {
regis 2015/08/27 02:30:26 AbstractType instead of Instance.
srdjan 2015/08/27 16:09:49 Done.
if (*trail == NULL) {
- *trail = &GrowableObjectArray::ZoneHandle(GrowableObjectArray::New());
+ *trail = new Trail();
} else {
- const intptr_t len = (*trail)->Length();
+ const intptr_t len = (*trail)->length();
ASSERT((len % 2) == 0);
for (intptr_t i = 0; i < len; i += 2) {
- if (((*trail)->At(i) == this->raw()) &&
- ((*trail)->At(i + 1) == buddy.raw())) {
+ if (((*trail)->At(i)->raw() == this->raw()) &&
+ ((*trail)->At(i + 1)->raw() == buddy.raw())) {
return true;
}
}
}
- (*trail)->Add(*this);
- (*trail)->Add(buddy);
+ AbstractType& t = AbstractType::ZoneHandle(this->raw());
+ Instance& b = Instance::ZoneHandle(buddy.raw());
+ (*trail)->Add(&t);
+ (*trail)->Add(&b);
return false;
}
@@ -16068,8 +16068,7 @@ void TypeParameter::set_is_finalized() const {
}
-bool TypeParameter::IsEquivalent(const Instance& other,
- GrowableObjectArray* trail) const {
+bool TypeParameter::IsEquivalent(const Instance& other, TrailPtr trail) const {
if (raw() == other.raw()) {
return true;
}
@@ -16121,7 +16120,7 @@ void TypeParameter::set_bound(const AbstractType& value) const {
RawAbstractType* TypeParameter::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(IsFinalized());
if (instantiator_type_arguments.IsNull()) {
return Type::DynamicType();
@@ -16197,8 +16196,7 @@ RawAbstractType* TypeParameter::CloneUnfinalized() const {
RawAbstractType* TypeParameter::CloneUninstantiated(
- const Class& new_owner,
- GrowableObjectArray* trail) const {
+ const Class& new_owner, TrailPtr trail) const {
ASSERT(IsFinalized());
AbstractType& upper_bound = AbstractType::Handle(bound());
upper_bound = upper_bound.CloneUninstantiated(new_owner, trail);
@@ -16321,8 +16319,7 @@ RawLanguageError* BoundedType::error() const {
}
-bool BoundedType::IsEquivalent(const Instance& other,
- GrowableObjectArray* trail) const {
+bool BoundedType::IsEquivalent(const Instance& other, TrailPtr trail) const {
// BoundedType are not canonicalized, because their bound may get finalized
// after the BoundedType is created and initialized.
if (raw() == other.raw()) {
@@ -16386,7 +16383,7 @@ void BoundedType::set_type_parameter(const TypeParameter& value) const {
RawAbstractType* BoundedType::InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
- GrowableObjectArray* trail) const {
+ TrailPtr trail) const {
ASSERT(IsFinalized());
AbstractType& bounded_type = AbstractType::Handle(type());
ASSERT(bounded_type.IsFinalized());
@@ -16442,8 +16439,7 @@ RawAbstractType* BoundedType::CloneUnfinalized() const {
RawAbstractType* BoundedType::CloneUninstantiated(
- const Class& new_owner,
- GrowableObjectArray* trail) const {
+ const Class& new_owner, TrailPtr trail) const {
if (IsInstantiated()) {
return raw();
}
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698