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

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

Issue 1219023002: Redirection type of a redirecting factory can be deferred (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add test case Created 5 years, 5 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
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 OS::Exit(255); 241 OS::Exit(255);
242 } 242 }
243 if (FLAG_trace_class_finalization) { 243 if (FLAG_trace_class_finalization) {
244 OS::Print("VerifyBootstrapClasses END.\n"); 244 OS::Print("VerifyBootstrapClasses END.\n");
245 } 245 }
246 Isolate::Current()->heap()->Verify(); 246 Isolate::Current()->heap()->Verify();
247 } 247 }
248 #endif // defined(DART_NO_SNAPSHOT). 248 #endif // defined(DART_NO_SNAPSHOT).
249 249
250 250
251 static bool IsLoaded(const Type& type) {
252 if (type.HasResolvedTypeClass()) {
253 return true;
254 }
255 const UnresolvedClass& unresolved_class =
256 UnresolvedClass::Handle(type.unresolved_class());
257 const LibraryPrefix& prefix =
258 LibraryPrefix::Handle(unresolved_class.library_prefix());
259 return prefix.IsNull() || prefix.is_loaded();
260 }
261
262
251 // Resolve unresolved_class in the library of cls, or return null. 263 // Resolve unresolved_class in the library of cls, or return null.
252 RawClass* ClassFinalizer::ResolveClass( 264 RawClass* ClassFinalizer::ResolveClass(
253 const Class& cls, 265 const Class& cls,
254 const UnresolvedClass& unresolved_class) { 266 const UnresolvedClass& unresolved_class) {
255 const String& class_name = String::Handle(unresolved_class.ident()); 267 const String& class_name = String::Handle(unresolved_class.ident());
256 Library& lib = Library::Handle(); 268 Library& lib = Library::Handle();
257 Class& resolved_class = Class::Handle(); 269 Class& resolved_class = Class::Handle();
258 if (unresolved_class.library_prefix() == LibraryPrefix::null()) { 270 if (unresolved_class.library_prefix() == LibraryPrefix::null()) {
259 lib = cls.library(); 271 lib = cls.library();
260 ASSERT(!lib.IsNull()); 272 ASSERT(!lib.IsNull());
261 resolved_class = lib.LookupClass(class_name); 273 resolved_class = lib.LookupClass(class_name);
262 } else { 274 } else {
263 LibraryPrefix& lib_prefix = LibraryPrefix::Handle(); 275 LibraryPrefix& lib_prefix = LibraryPrefix::Handle();
264 lib_prefix = unresolved_class.library_prefix(); 276 lib_prefix = unresolved_class.library_prefix();
265 ASSERT(!lib_prefix.IsNull()); 277 ASSERT(!lib_prefix.IsNull());
266 resolved_class = lib_prefix.LookupClass(class_name); 278 resolved_class = lib_prefix.LookupClass(class_name);
267 } 279 }
268 return resolved_class.raw(); 280 return resolved_class.raw();
269 } 281 }
270 282
271 283
272 284
273 void ClassFinalizer::ResolveRedirectingFactory(const Class& cls, 285 void ClassFinalizer::ResolveRedirectingFactory(const Class& cls,
274 const Function& factory) { 286 const Function& factory) {
275 const Function& target = Function::Handle(factory.RedirectionTarget()); 287 const Function& target = Function::Handle(factory.RedirectionTarget());
276 if (target.IsNull()) { 288 if (target.IsNull()) {
277 Type& type = Type::Handle(factory.RedirectionType()); 289 Type& type = Type::Handle(factory.RedirectionType());
278 if (!type.IsMalformed()) { 290 if (!type.IsMalformed() && IsLoaded(type)) {
279 const GrowableObjectArray& visited_factories = 291 const GrowableObjectArray& visited_factories =
280 GrowableObjectArray::Handle(GrowableObjectArray::New()); 292 GrowableObjectArray::Handle(GrowableObjectArray::New());
281 ResolveRedirectingFactoryTarget(cls, factory, visited_factories); 293 ResolveRedirectingFactoryTarget(cls, factory, visited_factories);
282 } 294 }
283 if (factory.is_const()) { 295 if (factory.is_const()) {
284 type = factory.RedirectionType(); 296 type = factory.RedirectionType();
285 if (type.IsMalformedOrMalbounded()) { 297 if (type.IsMalformedOrMalbounded()) {
286 ReportError(Error::Handle(type.error())); 298 ReportError(Error::Handle(type.error()));
287 } 299 }
288 } 300 }
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 function.IsImplicitGetterFunction()) ? "getter" : "method", 1503 function.IsImplicitGetterFunction()) ? "getter" : "method",
1492 name.ToCString(), 1504 name.ToCString(),
1493 class_name.ToCString(), 1505 class_name.ToCString(),
1494 name.ToCString(), 1506 name.ToCString(),
1495 super_class_name.ToCString()); 1507 super_class_name.ToCString());
1496 } 1508 }
1497 if (function.IsRedirectingFactory()) { 1509 if (function.IsRedirectingFactory()) {
1498 // The function may be a still unresolved redirecting factory. Do not 1510 // The function may be a still unresolved redirecting factory. Do not
1499 // yet try to resolve it in order to avoid cycles in class finalization. 1511 // yet try to resolve it in order to avoid cycles in class finalization.
1500 // However, the redirection type should be finalized. 1512 // However, the redirection type should be finalized.
1513 // If the redirection type is from a deferred library and is not
1514 // yet loaded, do not attempt to resolve.
1501 Type& type = Type::Handle(I, function.RedirectionType()); 1515 Type& type = Type::Handle(I, function.RedirectionType());
1502 type ^= FinalizeType(cls, type, kCanonicalize); 1516 if (IsLoaded(type)) {
1503 function.SetRedirectionType(type); 1517 type ^= FinalizeType(cls, type, kCanonicalize);
1518 function.SetRedirectionType(type);
1519 }
1504 } 1520 }
1505 } else if (function.IsGetterFunction() || 1521 } else if (function.IsGetterFunction() ||
1506 function.IsImplicitGetterFunction()) { 1522 function.IsImplicitGetterFunction()) {
1507 super_class = FindSuperOwnerOfFunction(cls, name); 1523 super_class = FindSuperOwnerOfFunction(cls, name);
1508 if (!super_class.IsNull()) { 1524 if (!super_class.IsNull()) {
1509 const String& class_name = String::Handle(I, cls.Name()); 1525 const String& class_name = String::Handle(I, cls.Name());
1510 const String& super_class_name = String::Handle(I, super_class.Name()); 1526 const String& super_class_name = String::Handle(I, super_class.Name());
1511 ReportError(cls, function.token_pos(), 1527 ReportError(cls, function.token_pos(),
1512 "getter '%s' of class '%s' conflicts with " 1528 "getter '%s' of class '%s' conflicts with "
1513 "method '%s' of super class '%s'", 1529 "method '%s' of super class '%s'",
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); 3200 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields());
3185 field ^= fields_array.At(0); 3201 field ^= fields_array.At(0);
3186 ASSERT(field.Offset() == ByteBuffer::data_offset()); 3202 ASSERT(field.Offset() == ByteBuffer::data_offset());
3187 name ^= field.name(); 3203 name ^= field.name();
3188 expected_name ^= String::New("_data"); 3204 expected_name ^= String::New("_data");
3189 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 3205 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
3190 #endif 3206 #endif
3191 } 3207 }
3192 3208
3193 } // namespace dart 3209 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698