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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 109593003: Use a trail instead of a mark bit when processing recursive types in the VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('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) 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 "lib/invocation_mirror.h" 5 #include "lib/invocation_mirror.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 lookup_cls = lookup_cls.SuperClass(); 311 lookup_cls = lookup_cls.SuperClass();
312 } while (!lookup_cls.IsNull()); 312 } while (!lookup_cls.IsNull());
313 return Function::null(); 313 return Function::null();
314 } 314 }
315 315
316 static RawInstance* CreateClassMirror(const Class& cls, 316 static RawInstance* CreateClassMirror(const Class& cls,
317 const AbstractType& type, 317 const AbstractType& type,
318 const Bool& is_declaration, 318 const Bool& is_declaration,
319 const Instance& owner_mirror) { 319 const Instance& owner_mirror) {
320 if (type.IsTypeRef()) {
321 AbstractType& ref_type = AbstractType::Handle(TypeRef::Cast(type).type());
322 ASSERT(!ref_type.IsTypeRef());
323 ASSERT(ref_type.IsCanonical());
324 return CreateClassMirror(cls, ref_type, is_declaration, owner_mirror);
325 }
320 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass()); 326 ASSERT(!cls.IsDynamicClass() && !cls.IsVoidClass());
321 ASSERT(!type.IsNull()); 327 ASSERT(!type.IsNull());
322 ASSERT(type.IsFinalized()); 328 ASSERT(type.IsFinalized());
323 ASSERT(!type.IsTypeRef());
324 329
325 if (cls.IsSignatureClass()) { 330 if (cls.IsSignatureClass()) {
326 if (cls.IsCanonicalSignatureClass()) { 331 if (cls.IsCanonicalSignatureClass()) {
327 // We represent function types as canonical signature classes. 332 // We represent function types as canonical signature classes.
328 return CreateFunctionTypeMirror(cls, type); 333 return CreateFunctionTypeMirror(cls, type);
329 } else { 334 } else {
330 // We represent typedefs as non-canonical signature classes. 335 // We represent typedefs as non-canonical signature classes.
331 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror); 336 return CreateTypedefMirror(cls, type, is_declaration, owner_mirror);
332 } 337 }
333 } 338 }
(...skipping 24 matching lines...) Expand all
358 String& str = String::Handle(); 363 String& str = String::Handle();
359 str = lib.name(); 364 str = lib.name();
360 args.SetAt(1, str); 365 args.SetAt(1, str);
361 str = lib.url(); 366 str = lib.url();
362 args.SetAt(2, str); 367 args.SetAt(2, str);
363 return CreateMirror(Symbols::_LocalLibraryMirror(), args); 368 return CreateMirror(Symbols::_LocalLibraryMirror(), args);
364 } 369 }
365 370
366 371
367 static RawInstance* CreateTypeMirror(const AbstractType& type) { 372 static RawInstance* CreateTypeMirror(const AbstractType& type) {
373 if (type.IsTypeRef()) {
374 AbstractType& ref_type = AbstractType::Handle(TypeRef::Cast(type).type());
375 ASSERT(!ref_type.IsTypeRef());
376 ASSERT(ref_type.IsCanonical());
377 return CreateTypeMirror(ref_type);
378 }
368 ASSERT(type.IsFinalized()); 379 ASSERT(type.IsFinalized());
369 ASSERT(!type.IsMalformed()); 380 ASSERT(!type.IsMalformed());
370 ASSERT(!type.IsTypeRef());
371 if (type.HasResolvedTypeClass()) { 381 if (type.HasResolvedTypeClass()) {
372 const Class& cls = Class::Handle(type.type_class()); 382 const Class& cls = Class::Handle(type.type_class());
373 // Handle void and dynamic types. 383 // Handle void and dynamic types.
374 if (cls.IsVoidClass()) { 384 if (cls.IsVoidClass()) {
375 Array& args = Array::Handle(Array::New(1)); 385 Array& args = Array::Handle(Array::New(1));
376 args.SetAt(0, Symbols::Void()); 386 args.SetAt(0, Symbols::Void());
377 // TODO(mlippautz): Create once in the VM isolate and retrieve from there. 387 // TODO(mlippautz): Create once in the VM isolate and retrieve from there.
378 return CreateMirror(Symbols::_SpecialTypeMirror(), args); 388 return CreateMirror(Symbols::_SpecialTypeMirror(), args);
379 } else if (cls.IsDynamicClass()) { 389 } else if (cls.IsDynamicClass()) {
380 Array& args = Array::Handle(Array::New(1)); 390 Array& args = Array::Handle(Array::New(1));
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 for (intptr_t i = 0; i < num_params; i++) { 1263 for (intptr_t i = 0; i < num_params; i++) {
1254 result.SetAt(i, type_mirror); 1264 result.SetAt(i, type_mirror);
1255 } 1265 }
1256 return result.raw(); 1266 return result.raw();
1257 } 1267 }
1258 1268
1259 ASSERT(args.Length() >= num_params); 1269 ASSERT(args.Length() >= num_params);
1260 const intptr_t num_inherited_args = args.Length() - num_params; 1270 const intptr_t num_inherited_args = args.Length() - num_params;
1261 for (intptr_t i = 0; i < num_params; i++) { 1271 for (intptr_t i = 0; i < num_params; i++) {
1262 arg_type ^= args.TypeAt(i + num_inherited_args); 1272 arg_type ^= args.TypeAt(i + num_inherited_args);
1263 arg_type = arg_type.Canonicalize(); // Necessary for recursive types.
1264 type_mirror = CreateTypeMirror(arg_type); 1273 type_mirror = CreateTypeMirror(arg_type);
1265 result.SetAt(i, type_mirror); 1274 result.SetAt(i, type_mirror);
1266 } 1275 }
1267 return result.raw(); 1276 return result.raw();
1268 } 1277 }
1269 1278
1270 1279
1271 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) { 1280 DEFINE_NATIVE_ENTRY(TypeVariableMirror_owner, 1) {
1272 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0)); 1281 GET_NON_NULL_NATIVE_ARGUMENT(TypeParameter, param, arguments->NativeArgAt(0));
1273 const Class& owner = Class::Handle(param.parameterized_class()); 1282 const Class& owner = Class::Handle(param.parameterized_class());
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 2055
2047 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) { 2056 DEFINE_NATIVE_ENTRY(VariableMirror_type, 2) {
2048 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 2057 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
2049 const Field& field = Field::Handle(ref.GetFieldReferent()); 2058 const Field& field = Field::Handle(ref.GetFieldReferent());
2050 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); 2059 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1));
2051 const AbstractType& type = AbstractType::Handle(field.type()); 2060 const AbstractType& type = AbstractType::Handle(field.type());
2052 return InstantiateType(type, instantiator); 2061 return InstantiateType(type, instantiator);
2053 } 2062 }
2054 2063
2055 } // namespace dart 2064 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698