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

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

Issue 1935703002: - reset 'dirty' flag to false after the libraries mirrors is computed, this ensures that we compute… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/lib/mirrors_impl.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/mirrors.h" 5 #include "lib/mirrors.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 args.SetAt(3, owner_mirror); 347 args.SetAt(3, owner_mirror);
348 args.SetAt(4, Bool::Get(cls.is_abstract())); 348 args.SetAt(4, Bool::Get(cls.is_abstract()));
349 args.SetAt(5, Bool::Get(cls.IsGeneric())); 349 args.SetAt(5, Bool::Get(cls.IsGeneric()));
350 args.SetAt(6, Bool::Get(cls.is_mixin_app_alias())); 350 args.SetAt(6, Bool::Get(cls.is_mixin_app_alias()));
351 args.SetAt(7, cls.NumTypeParameters() == 0 ? Bool::False() : is_declaration); 351 args.SetAt(7, cls.NumTypeParameters() == 0 ? Bool::False() : is_declaration);
352 args.SetAt(8, Bool::Get(cls.is_enum_class())); 352 args.SetAt(8, Bool::Get(cls.is_enum_class()));
353 return CreateMirror(Symbols::_LocalClassMirror(), args); 353 return CreateMirror(Symbols::_LocalClassMirror(), args);
354 } 354 }
355 355
356 356
357 static RawInstance* CreateLibraryMirror(const Library& lib) { 357 static RawInstance* CreateLibraryMirror(Thread* thread, const Library& lib) {
358 Thread* thread = Thread::Current();
359 Zone* zone = thread->zone(); 358 Zone* zone = thread->zone();
360 ASSERT(!lib.IsNull()); 359 ASSERT(!lib.IsNull());
361 const Array& args = Array::Handle(zone, Array::New(3)); 360 const Array& args = Array::Handle(zone, Array::New(3));
362 args.SetAt(0, MirrorReference::Handle(zone, MirrorReference::New(lib))); 361 args.SetAt(0, MirrorReference::Handle(zone, MirrorReference::New(lib)));
363 String& str = String::Handle(zone); 362 String& str = String::Handle(zone);
364 str = lib.name(); 363 str = lib.name();
365 args.SetAt(1, str); 364 args.SetAt(1, str);
366 str = lib.url(); 365 str = lib.url();
367 const char* censored_libraries[] = { 366 const char* censored_libraries[] = {
368 "dart:_builtin", 367 "dart:_builtin",
(...skipping 29 matching lines...) Expand all
398 397
399 static RawInstance* CreateCombinatorMirror(const Object& identifiers, 398 static RawInstance* CreateCombinatorMirror(const Object& identifiers,
400 bool is_show) { 399 bool is_show) {
401 const Array& args = Array::Handle(Array::New(2)); 400 const Array& args = Array::Handle(Array::New(2));
402 args.SetAt(0, identifiers); 401 args.SetAt(0, identifiers);
403 args.SetAt(1, Bool::Get(is_show)); 402 args.SetAt(1, Bool::Get(is_show));
404 return CreateMirror(Symbols::_LocalCombinatorMirror(), args); 403 return CreateMirror(Symbols::_LocalCombinatorMirror(), args);
405 } 404 }
406 405
407 406
408 static RawInstance* CreateLibraryDependencyMirror(const Instance& importer, 407 static RawInstance* CreateLibraryDependencyMirror(Thread* thread,
408 const Instance& importer,
409 const Namespace& ns, 409 const Namespace& ns,
410 const LibraryPrefix& prefix, 410 const LibraryPrefix& prefix,
411 const bool is_import, 411 const bool is_import,
412 const bool is_deferred) { 412 const bool is_deferred) {
413 const Library& importee = Library::Handle(ns.library()); 413 const Library& importee = Library::Handle(ns.library());
414 const Instance& importee_mirror = 414 const Instance& importee_mirror =
415 Instance::Handle(CreateLibraryMirror(importee)); 415 Instance::Handle(CreateLibraryMirror(thread, importee));
416 if (importee_mirror.IsNull()) { 416 if (importee_mirror.IsNull()) {
417 // Imported library is censored: censor the import. 417 // Imported library is censored: censor the import.
418 return Instance::null(); 418 return Instance::null();
419 } 419 }
420 420
421 const Array& show_names = Array::Handle(ns.show_names()); 421 const Array& show_names = Array::Handle(ns.show_names());
422 const Array& hide_names = Array::Handle(ns.hide_names()); 422 const Array& hide_names = Array::Handle(ns.hide_names());
423 intptr_t n = show_names.IsNull() ? 0 : show_names.Length(); 423 intptr_t n = show_names.IsNull() ? 0 : show_names.Length();
424 intptr_t m = hide_names.IsNull() ? 0 : hide_names.Length(); 424 intptr_t m = hide_names.IsNull() ? 0 : hide_names.Length();
425 const Array& combinators = Array::Handle(Array::New(n + m)); 425 const Array& combinators = Array::Handle(Array::New(n + m));
(...skipping 29 matching lines...) Expand all
455 } 455 }
456 456
457 457
458 DEFINE_NATIVE_ENTRY(LibraryMirror_fromPrefix, 1) { 458 DEFINE_NATIVE_ENTRY(LibraryMirror_fromPrefix, 1) {
459 GET_NON_NULL_NATIVE_ARGUMENT(LibraryPrefix, prefix, 459 GET_NON_NULL_NATIVE_ARGUMENT(LibraryPrefix, prefix,
460 arguments->NativeArgAt(0)); 460 arguments->NativeArgAt(0));
461 const Library& deferred_lib = Library::Handle(prefix.GetLibrary(0)); 461 const Library& deferred_lib = Library::Handle(prefix.GetLibrary(0));
462 if (!deferred_lib.Loaded()) { 462 if (!deferred_lib.Loaded()) {
463 return Instance::null(); 463 return Instance::null();
464 } 464 }
465 return CreateLibraryMirror(deferred_lib); 465 return CreateLibraryMirror(thread, deferred_lib);
466 } 466 }
467 467
468 468
469 DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) { 469 DEFINE_NATIVE_ENTRY(LibraryMirror_libraryDependencies, 2) {
470 GET_NON_NULL_NATIVE_ARGUMENT(Instance, lib_mirror, arguments->NativeArgAt(0)); 470 GET_NON_NULL_NATIVE_ARGUMENT(Instance, lib_mirror, arguments->NativeArgAt(0));
471 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 471 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
472 const Library& lib = Library::Handle(ref.GetLibraryReferent()); 472 const Library& lib = Library::Handle(ref.GetLibraryReferent());
473 473
474 Array& ports = Array::Handle(); 474 Array& ports = Array::Handle();
475 Namespace& ns = Namespace::Handle(); 475 Namespace& ns = Namespace::Handle();
476 Instance& dep = Instance::Handle(); 476 Instance& dep = Instance::Handle();
477 LibraryPrefix& prefix = LibraryPrefix::Handle(); 477 LibraryPrefix& prefix = LibraryPrefix::Handle();
478 GrowableObjectArray& deps = 478 GrowableObjectArray& deps =
479 GrowableObjectArray::Handle(GrowableObjectArray::New()); 479 GrowableObjectArray::Handle(GrowableObjectArray::New());
480 480
481 // Unprefixed imports. 481 // Unprefixed imports.
482 ports = lib.imports(); 482 ports = lib.imports();
483 for (intptr_t i = 0; i < ports.Length(); i++) { 483 for (intptr_t i = 0; i < ports.Length(); i++) {
484 ns ^= ports.At(i); 484 ns ^= ports.At(i);
485 if (!ns.IsNull()) { 485 if (!ns.IsNull()) {
486 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true, false); 486 dep = CreateLibraryDependencyMirror(
487 thread, lib_mirror, ns, prefix, true, false);
487 if (!dep.IsNull()) { 488 if (!dep.IsNull()) {
488 deps.Add(dep); 489 deps.Add(dep);
489 } 490 }
490 } 491 }
491 } 492 }
492 493
493 // Exports. 494 // Exports.
494 ports = lib.exports(); 495 ports = lib.exports();
495 for (intptr_t i = 0; i < ports.Length(); i++) { 496 for (intptr_t i = 0; i < ports.Length(); i++) {
496 ns ^= ports.At(i); 497 ns ^= ports.At(i);
497 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, false, false); 498 dep = CreateLibraryDependencyMirror(
499 thread, lib_mirror, ns, prefix, false, false);
498 if (!dep.IsNull()) { 500 if (!dep.IsNull()) {
499 deps.Add(dep); 501 deps.Add(dep);
500 } 502 }
501 } 503 }
502 504
503 // Prefixed imports. 505 // Prefixed imports.
504 DictionaryIterator entries(lib); 506 DictionaryIterator entries(lib);
505 Object& entry = Object::Handle(); 507 Object& entry = Object::Handle();
506 while (entries.HasNext()) { 508 while (entries.HasNext()) {
507 entry = entries.GetNext(); 509 entry = entries.GetNext();
508 if (entry.IsLibraryPrefix()) { 510 if (entry.IsLibraryPrefix()) {
509 prefix ^= entry.raw(); 511 prefix ^= entry.raw();
510 ports = prefix.imports(); 512 ports = prefix.imports();
511 for (intptr_t i = 0; i < ports.Length(); i++) { 513 for (intptr_t i = 0; i < ports.Length(); i++) {
512 ns ^= ports.At(i); 514 ns ^= ports.At(i);
513 if (!ns.IsNull()) { 515 if (!ns.IsNull()) {
514 dep = CreateLibraryDependencyMirror(lib_mirror, ns, prefix, true, 516 dep = CreateLibraryDependencyMirror(
515 prefix.is_deferred_load()); 517 thread, lib_mirror, ns, prefix, true, prefix.is_deferred_load());
516 if (!dep.IsNull()) { 518 if (!dep.IsNull()) {
517 deps.Add(dep); 519 deps.Add(dep);
518 } 520 }
519 } 521 }
520 } 522 }
521 } 523 }
522 } 524 }
523 525
524 return deps.raw(); 526 return deps.raw();
525 } 527 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 573 }
572 574
573 575
574 static RawInstance* CreateIsolateMirror() { 576 static RawInstance* CreateIsolateMirror() {
575 Thread* thread = Thread::Current(); 577 Thread* thread = Thread::Current();
576 Isolate* isolate = thread->isolate(); 578 Isolate* isolate = thread->isolate();
577 const String& debug_name = String::Handle(String::New(isolate->name())); 579 const String& debug_name = String::Handle(String::New(isolate->name()));
578 const Library& root_library = Library::Handle(thread->zone(), 580 const Library& root_library = Library::Handle(thread->zone(),
579 isolate->object_store()->root_library()); 581 isolate->object_store()->root_library());
580 const Instance& root_library_mirror = 582 const Instance& root_library_mirror =
581 Instance::Handle(CreateLibraryMirror(root_library)); 583 Instance::Handle(CreateLibraryMirror(thread, root_library));
582 584
583 const Array& args = Array::Handle(Array::New(2)); 585 const Array& args = Array::Handle(Array::New(2));
584 args.SetAt(0, debug_name); 586 args.SetAt(0, debug_name);
585 args.SetAt(1, root_library_mirror); 587 args.SetAt(1, root_library_mirror);
586 return CreateMirror(Symbols::_LocalIsolateMirror(), args); 588 return CreateMirror(Symbols::_LocalIsolateMirror(), args);
587 } 589 }
588 590
589 591
590 static void VerifyMethodKindShifts() { 592 static void VerifyMethodKindShifts() {
591 #ifdef DEBUG 593 #ifdef DEBUG
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 zone, isolate->object_store()->libraries()); 795 zone, isolate->object_store()->libraries());
794 796
795 const intptr_t num_libraries = libraries.Length(); 797 const intptr_t num_libraries = libraries.Length();
796 const GrowableObjectArray& library_mirrors = GrowableObjectArray::Handle( 798 const GrowableObjectArray& library_mirrors = GrowableObjectArray::Handle(
797 zone, GrowableObjectArray::New(num_libraries)); 799 zone, GrowableObjectArray::New(num_libraries));
798 Library& library = Library::Handle(zone); 800 Library& library = Library::Handle(zone);
799 Instance& library_mirror = Instance::Handle(zone); 801 Instance& library_mirror = Instance::Handle(zone);
800 802
801 for (int i = 0; i < num_libraries; i++) { 803 for (int i = 0; i < num_libraries; i++) {
802 library ^= libraries.At(i); 804 library ^= libraries.At(i);
803 library_mirror = CreateLibraryMirror(library); 805 library_mirror = CreateLibraryMirror(thread, library);
804 if (!library_mirror.IsNull() && library.Loaded()) { 806 if (!library_mirror.IsNull() && library.Loaded()) {
805 library_mirrors.Add(library_mirror); 807 library_mirrors.Add(library_mirror);
806 } 808 }
807 } 809 }
808 return library_mirrors.raw(); 810 return library_mirrors.raw();
809 } 811 }
810 812
811 813
812 DEFINE_NATIVE_ENTRY(MirrorSystem_isolate, 0) { 814 DEFINE_NATIVE_ENTRY(MirrorSystem_isolate, 0) {
813 VerifyMethodKindShifts(); 815 VerifyMethodKindShifts();
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 2) { 1926 DEFINE_NATIVE_ENTRY(MethodMirror_owner, 2) {
1925 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 1927 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
1926 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1)); 1928 GET_NATIVE_ARGUMENT(AbstractType, instantiator, arguments->NativeArgAt(1));
1927 const Function& func = Function::Handle(ref.GetFunctionReferent()); 1929 const Function& func = Function::Handle(ref.GetFunctionReferent());
1928 if (func.IsNonImplicitClosureFunction()) { 1930 if (func.IsNonImplicitClosureFunction()) {
1929 return CreateMethodMirror(Function::Handle( 1931 return CreateMethodMirror(Function::Handle(
1930 func.parent_function()), Object::null_instance(), instantiator); 1932 func.parent_function()), Object::null_instance(), instantiator);
1931 } 1933 }
1932 const Class& owner = Class::Handle(func.Owner()); 1934 const Class& owner = Class::Handle(func.Owner());
1933 if (owner.IsTopLevel()) { 1935 if (owner.IsTopLevel()) {
1934 return CreateLibraryMirror(Library::Handle(owner.library())); 1936 return CreateLibraryMirror(thread, Library::Handle(owner.library()));
1935 } 1937 }
1936 1938
1937 AbstractType& type = AbstractType::Handle(owner.DeclarationType()); 1939 AbstractType& type = AbstractType::Handle(owner.DeclarationType());
1938 return CreateClassMirror(owner, type, Bool::True(), Object::null_instance()); 1940 return CreateClassMirror(owner, type, Bool::True(), Object::null_instance());
1939 } 1941 }
1940 1942
1941 1943
1942 DEFINE_NATIVE_ENTRY(MethodMirror_parameters, 2) { 1944 DEFINE_NATIVE_ENTRY(MethodMirror_parameters, 2) {
1943 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0)); 1945 GET_NON_NULL_NATIVE_ARGUMENT(Instance, owner, arguments->NativeArgAt(0));
1944 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); 1946 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2097
2096 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2098 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2097 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2099 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2098 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2099 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw(); 2101 return Bool::Get(a.IsSubtypeOf(b, NULL, NULL, Heap::kNew)).raw();
2100 } 2102 }
2101 2103
2102 #endif // !PRODUCT 2104 #endif // !PRODUCT
2103 2105
2104 } // namespace dart 2106 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698