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

Unified Diff: runtime/vm/object.cc

Issue 25569002: Do not share type arguments of mixin types, but clone them to avoid finalization (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
« no previous file with comments | « runtime/vm/object.h ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 28104)
+++ runtime/vm/object.cc (working copy)
@@ -1709,16 +1709,15 @@
// resolved, which is checked by the type_class() call on the super type.
// Note that calling type_class() on a MixinAppType fails.
Isolate* isolate = Isolate::Current();
- ReusableHandleScope reused_handles(isolate);
- Class& cls = reused_handles.ClassHandle();
- TypeArguments& type_params = reused_handles.TypeArgumentsHandle();
- AbstractType& sup_type = reused_handles.AbstractTypeHandle();
+ Class& cls = Class::Handle(isolate);
Ivan Posva 2013/10/01 18:50:04 Why was this changed?
regis 2013/10/01 19:11:58 We were just lucky before. NumTypeArguments() is r
+ TypeArguments& type_params = TypeArguments::Handle(isolate);
+ AbstractType& sup_type = AbstractType::Handle(isolate);
cls ^= raw();
intptr_t num_type_args = 0;
do {
if (cls.IsSignatureClass()) {
- Function& signature_fun = reused_handles.FunctionHandle();
+ Function& signature_fun = Function::Handle(isolate);
signature_fun ^= cls.signature_function();
if (!signature_fun.is_static() &&
!signature_fun.HasInstantiatedSignature()) {
@@ -3429,6 +3428,20 @@
}
+bool TypeArguments::IsFinalized() const {
+ ASSERT(!IsNull());
+ AbstractType& type = AbstractType::Handle();
+ const intptr_t num_types = Length();
+ for (intptr_t i = 0; i < num_types; i++) {
+ type = TypeAt(i);
+ if (!type.IsFinalized()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+
bool TypeArguments::IsBounded() const {
AbstractType& type = AbstractType::Handle();
const intptr_t num_types = Length();
@@ -3585,6 +3598,23 @@
}
+RawAbstractTypeArguments* TypeArguments::CloneUnfinalized() const {
+ if (IsFinalized()) {
+ return raw();
+ }
+ AbstractType& type = AbstractType::Handle();
+ const intptr_t num_types = Length();
+ const TypeArguments& clone = TypeArguments::Handle(
+ TypeArguments::New(num_types));
+ for (intptr_t i = 0; i < num_types; i++) {
+ type = TypeAt(i);
+ type = type.CloneUnfinalized();
+ clone.SetTypeAt(i, type);
+ }
+ return clone.raw();
+}
+
+
RawAbstractTypeArguments* TypeArguments::Canonicalize() const {
if (IsNull() || IsCanonical()) {
ASSERT(IsOld());
@@ -10832,6 +10862,13 @@
}
+RawAbstractType* AbstractType::CloneUnfinalized() const {
+ // AbstractType is an abstract class.
+ UNREACHABLE();
+ return NULL;
+}
+
+
RawAbstractType* AbstractType::Canonicalize() const {
// AbstractType is an abstract class.
UNREACHABLE();
@@ -11361,6 +11398,20 @@
}
+RawAbstractType* Type::CloneUnfinalized() const {
+ ASSERT(IsResolved());
+ if (IsFinalized()) {
+ return raw();
+ }
+ ASSERT(!IsMalformed()); // Malformed types are finalized.
+ ASSERT(!IsBeingFinalized()); // Cloning must occur prior to finalization.
+ AbstractTypeArguments& type_args = AbstractTypeArguments::Handle(arguments());
+ type_args = type_args.CloneUnfinalized();
+ const Class& type_cls = Class::Handle(type_class());
+ return Type::New(type_cls, type_args, token_pos());
+}
+
+
RawAbstractType* Type::Canonicalize() const {
ASSERT(IsFinalized());
if (IsCanonical() || IsMalformed()) {
@@ -11650,6 +11701,19 @@
}
+RawAbstractType* TypeParameter::CloneUnfinalized() const {
+ if (IsFinalized()) {
+ return raw();
+ }
+ // No need to clone bound, as it is not part of the finalization state.
+ return TypeParameter::New(Class::Handle(parameterized_class()),
+ index(),
+ String::Handle(name()),
+ AbstractType::Handle(bound()),
+ token_pos());
+}
+
+
intptr_t TypeParameter::Hash() const {
ASSERT(IsFinalized());
uword result = 0;
@@ -11829,6 +11893,21 @@
}
+RawAbstractType* BoundedType::CloneUnfinalized() const {
+ if (IsFinalized()) {
+ return raw();
+ }
+ AbstractType& bounded_type = AbstractType::Handle(type());
+
+ bounded_type = bounded_type.CloneUnfinalized();
+ // No need to clone bound or type parameter, as they are not part of the
+ // finalization state of this bounded type.
+ return BoundedType::New(bounded_type,
+ AbstractType::Handle(bound()),
+ TypeParameter::Handle(type_parameter()));
+}
+
+
intptr_t BoundedType::Hash() const {
uword result = 0;
result += AbstractType::Handle(type()).Hash();
« no previous file with comments | « runtime/vm/object.h ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698