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

Side by Side Diff: runtime/vm/object.cc

Issue 14238036: Improve type optimization reusing the type argument vector of the instantiator (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 9005 matching lines...) Expand 10 before | Expand all | Expand 10 after
9016 } 9016 }
9017 const Class& cls = Class::Handle(clazz()); 9017 const Class& cls = Class::Handle(clazz());
9018 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 9018 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
9019 const intptr_t num_type_arguments = cls.NumTypeArguments(); 9019 const intptr_t num_type_arguments = cls.NumTypeArguments();
9020 if (num_type_arguments > 0) { 9020 if (num_type_arguments > 0) {
9021 type_arguments = GetTypeArguments(); 9021 type_arguments = GetTypeArguments();
9022 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { 9022 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) {
9023 type_arguments = type_arguments.Canonicalize(); 9023 type_arguments = type_arguments.Canonicalize();
9024 SetTypeArguments(type_arguments); 9024 SetTypeArguments(type_arguments);
9025 } 9025 }
9026 // Verify that the number of type arguments in the instance matches the 9026 // The number of type arguments in the instance must be greater or equal to
9027 // number of type arguments expected by the instance class. 9027 // the number of type arguments expected by the instance class.
9028 // A discrepancy is allowed for closures, which borrow the type argument 9028 // A discrepancy is allowed for closures, which borrow the type argument
9029 // vector of their instantiator, which may be of a subclass of the class 9029 // vector of their instantiator, which may be of a subclass of the class
9030 // defining the closure. Truncating the vector to the correct length on 9030 // defining the closure. Truncating the vector to the correct length on
9031 // instantiation is unnecessary. The vector may therefore be longer. 9031 // instantiation is unnecessary. The vector may therefore be longer.
9032 // Also, an optimization reuses the type argument vector of the instantiator
9033 // of generic instances when its layout is compatible.
9032 ASSERT(type_arguments.IsNull() || 9034 ASSERT(type_arguments.IsNull() ||
9033 (type_arguments.Length() == num_type_arguments) || 9035 (type_arguments.Length() >= num_type_arguments));
9034 (cls.IsSignatureClass() &&
9035 (type_arguments.Length() > num_type_arguments)));
9036 } 9036 }
9037 Class& other_class = Class::Handle(); 9037 Class& other_class = Class::Handle();
9038 AbstractTypeArguments& other_type_arguments = AbstractTypeArguments::Handle(); 9038 AbstractTypeArguments& other_type_arguments = AbstractTypeArguments::Handle();
9039 // Note that we may encounter a bound error in checked mode. 9039 // Note that we may encounter a bound error in checked mode.
9040 if (!other.IsInstantiated()) { 9040 if (!other.IsInstantiated()) {
9041 const AbstractType& instantiated_other = AbstractType::Handle( 9041 const AbstractType& instantiated_other = AbstractType::Handle(
9042 other.InstantiateFrom(other_instantiator, malformed_error)); 9042 other.InstantiateFrom(other_instantiator, malformed_error));
9043 if ((malformed_error != NULL) && !malformed_error->IsNull()) { 9043 if ((malformed_error != NULL) && !malformed_error->IsNull()) {
9044 ASSERT(FLAG_enable_type_checks); 9044 ASSERT(FLAG_enable_type_checks);
9045 return false; 9045 return false;
(...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after
13168 } 13168 }
13169 return result.raw(); 13169 return result.raw();
13170 } 13170 }
13171 13171
13172 13172
13173 const char* WeakProperty::ToCString() const { 13173 const char* WeakProperty::ToCString() const {
13174 return "_WeakProperty"; 13174 return "_WeakProperty";
13175 } 13175 }
13176 13176
13177 } // namespace dart 13177 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698