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

Unified Diff: runtime/vm/object.cc

Issue 12079117: Revert changes 17962-3 which break Dartium Debug build. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | 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 b038b990eaf1d2abcce50d0378022ebb4bfaac02..ec3cb206e35b43b1992e18f0eb9d9c9d888b73f6 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -1443,9 +1443,7 @@ RawType* Class::SignatureType() const {
ASSERT(!signature_types.IsNull());
if (signature_types.Length() > 0) {
// At most one signature type per signature class.
- ASSERT((signature_types.Length() == 1) ||
- ((signature_types.Length() == 2) &&
- (signature_types.At(1) == Type::null())));
+ ASSERT(signature_types.Length() == 1);
Type& signature_type = Type::Handle();
signature_type ^= signature_types.At(0);
ASSERT(!signature_type.IsNull());
@@ -1917,29 +1915,7 @@ RawClass* Class::New(const String& name,
RawClass* Class::NewSignatureClass(const String& name,
const Function& signature_function,
- const Script& script,
- intptr_t token_pos) {
- const Class& result = Class::Handle(New<Instance>(name, script, token_pos));
- const Type& super_type = Type::Handle(Type::ObjectType());
- ASSERT(!super_type.IsNull());
- // Instances of a signature class can only be closures.
- result.set_instance_size(Closure::InstanceSize());
- result.set_next_field_offset(Closure::InstanceSize());
- result.set_super_type(super_type);
- result.set_type_arguments_field_offset(Closure::type_arguments_offset());
- // Implements interface "Function".
- const Type& function_type = Type::Handle(Type::Function());
- const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld));
- interfaces.SetAt(0, function_type);
- result.set_interfaces(interfaces);
- if (!signature_function.IsNull()) {
- result.PatchSignatureFunction(signature_function);
- }
- return result.raw();
-}
-
-
-void Class::PatchSignatureFunction(const Function& signature_function) const {
+ const Script& script) {
ASSERT(!signature_function.IsNull());
const Class& owner_class = Class::Handle(signature_function.Owner());
ASSERT(!owner_class.IsNull());
@@ -1947,25 +1923,51 @@ void Class::PatchSignatureFunction(const Function& signature_function) const {
// A signature class extends class Instance and is parameterized in the same
// way as the owner class of its non-static signature function.
// It is not type parameterized if its signature function is static.
- // In case of a function type alias, the function owner is the alias class
- // instead of the enclosing class.
if (!signature_function.is_static() &&
(owner_class.NumTypeParameters() > 0) &&
!signature_function.HasInstantiatedSignature()) {
type_parameters = owner_class.type_parameters();
}
- set_signature_function(signature_function);
- set_type_parameters(type_parameters);
- if (owner_class.raw() == raw()) {
- // This signature class is an alias, which cannot be the canonical
- // signature class for this signature function.
- ASSERT(!IsCanonicalSignatureClass());
- } else if (signature_function.signature_class() == Object::null()) {
- // Make this signature class the canonical signature class.
- signature_function.set_signature_class(*this);
- ASSERT(IsCanonicalSignatureClass());
+ const intptr_t token_pos = signature_function.token_pos();
+ Class& result = Class::Handle(New<Instance>(name, script, token_pos));
+ const Type& super_type = Type::Handle(Type::ObjectType());
+ ASSERT(!super_type.IsNull());
+ result.set_instance_size(Closure::InstanceSize());
+ result.set_next_field_offset(Closure::InstanceSize());
+ result.set_super_type(super_type);
+ result.set_signature_function(signature_function);
+ result.set_type_parameters(type_parameters);
+ result.SetFields(Object::empty_array());
+ result.SetFunctions(Object::empty_array());
+ result.set_type_arguments_field_offset(
+ Closure::type_arguments_offset());
+ // Implements interface "Function".
+ const Type& function_type = Type::Handle(Type::Function());
+ const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld));
+ interfaces.SetAt(0, function_type);
+ result.set_interfaces(interfaces);
+ // Unless the signature function already has a signature class, create a
+ // canonical signature class by having the signature function point back to
+ // the signature class.
+ if (signature_function.signature_class() == Object::null()) {
+ signature_function.set_signature_class(result);
+ result.set_is_finalized();
+ } else {
+ // This new signature class is an alias.
+ ASSERT(!result.IsCanonicalSignatureClass());
+ // Do not yet mark it as finalized, so that the class finalizer can check it
+ // for illegal self references.
+ result.set_is_prefinalized();
}
- set_is_prefinalized();
+ // Instances of a signature class can only be closures.
+ ASSERT(result.instance_size() == Closure::InstanceSize());
+ // Cache the signature type as the first canonicalized type in result.
+ const Type& signature_type = Type::Handle(result.SignatureType());
+ ASSERT(!signature_type.IsFinalized());
+ const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld));
+ new_canonical_types.SetAt(0, signature_type);
+ result.set_canonical_types(new_canonical_types);
+ return result.raw();
}
@@ -4211,8 +4213,7 @@ RawFunction* Function::ImplicitClosureFunction() const {
const Script& script = Script::Handle(this->script());
signature_class = Class::NewSignatureClass(signature,
closure_function,
- script,
- closure_function.token_pos());
+ script);
library.AddClass(signature_class);
} else {
closure_function.set_signature_class(signature_class);
@@ -4237,9 +4238,8 @@ RawString* Function::BuildSignature(
GrowableObjectArray::Handle(GrowableObjectArray::New());
String& name = String::Handle();
if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
- // Prefix the signature with its signature class and type parameters, if any
- // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the
- // signature class name is the alias name.
+ // Prefix the signature with its class and type parameters, if any (e.g.
+ // "Map<K, V>(K) => bool").
// The signature of static functions cannot be type parameterized.
const Class& function_class = Class::Handle(Owner());
ASSERT(!function_class.IsNull());
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698