OLD | NEW |
---|---|
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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 | 553 |
554 // Set up the libraries array before initializing the core library. | 554 // Set up the libraries array before initializing the core library. |
555 const GrowableObjectArray& libraries = | 555 const GrowableObjectArray& libraries = |
556 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 556 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
557 object_store->set_libraries(libraries); | 557 object_store->set_libraries(libraries); |
558 | 558 |
559 // Basic infrastructure has been setup, initialize the class dictionary. | 559 // Basic infrastructure has been setup, initialize the class dictionary. |
560 Library::InitCoreLibrary(isolate); | 560 Library::InitCoreLibrary(isolate); |
561 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 561 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
562 ASSERT(!core_lib.IsNull()); | 562 ASSERT(!core_lib.IsNull()); |
563 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | |
564 ASSERT(!core_impl_lib.IsNull()); | |
565 | 563 |
566 const GrowableObjectArray& pending_classes = | 564 const GrowableObjectArray& pending_classes = |
567 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 565 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
568 object_store->set_pending_classes(pending_classes); | 566 object_store->set_pending_classes(pending_classes); |
569 | 567 |
570 Context& context = Context::Handle(Context::New(0, Heap::kOld)); | 568 Context& context = Context::Handle(Context::New(0, Heap::kOld)); |
571 object_store->set_empty_context(context); | 569 object_store->set_empty_context(context); |
572 | 570 |
573 // Now that the symbol table is initialized and that the core dictionary as | 571 // Now that the symbol table is initialized and that the core dictionary as |
574 // well as the core implementation dictionary have been setup, preallocate | 572 // well as the core implementation dictionary have been setup, preallocate |
575 // remaining classes and register them by name in the dictionaries. | 573 // remaining classes and register them by name in the dictionaries. |
576 const Script& impl_script = Script::Handle( | |
577 Bootstrap::LoadCoreImplScript(false)); | |
578 | |
579 String& name = String::Handle(); | 574 String& name = String::Handle(); |
580 cls = Class::New<Bool>(); | 575 cls = Class::New<Bool>(); |
581 object_store->set_bool_class(cls); | 576 object_store->set_bool_class(cls); |
582 name = Symbols::Bool(); | 577 name = Symbols::Bool(); |
583 RegisterClass(cls, name, core_lib); | 578 RegisterClass(cls, name, core_lib); |
584 pending_classes.Add(cls, Heap::kOld); | 579 pending_classes.Add(cls, Heap::kOld); |
585 | 580 |
586 cls = object_store->array_class(); // Was allocated above. | 581 cls = object_store->array_class(); // Was allocated above. |
587 name = Symbols::ObjectArray(); | 582 name = Symbols::ObjectArray(); |
588 RegisterPrivateClass(cls, name, core_lib); | 583 RegisterPrivateClass(cls, name, core_lib); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 | 615 |
621 cls = Class::NewStringClass(kExternalTwoByteStringCid); | 616 cls = Class::NewStringClass(kExternalTwoByteStringCid); |
622 object_store->set_external_two_byte_string_class(cls); | 617 object_store->set_external_two_byte_string_class(cls); |
623 name = Symbols::ExternalTwoByteString(); | 618 name = Symbols::ExternalTwoByteString(); |
624 RegisterPrivateClass(cls, name, core_lib); | 619 RegisterPrivateClass(cls, name, core_lib); |
625 pending_classes.Add(cls, Heap::kOld); | 620 pending_classes.Add(cls, Heap::kOld); |
626 | 621 |
627 cls = Class::New<Stacktrace>(); | 622 cls = Class::New<Stacktrace>(); |
628 object_store->set_stacktrace_class(cls); | 623 object_store->set_stacktrace_class(cls); |
629 name = Symbols::Stacktrace(); | 624 name = Symbols::Stacktrace(); |
630 RegisterClass(cls, name, core_impl_lib); | 625 RegisterClass(cls, name, core_lib); |
631 pending_classes.Add(cls, Heap::kOld); | 626 pending_classes.Add(cls, Heap::kOld); |
632 // Super type set below, after Object is allocated. | 627 // Super type set below, after Object is allocated. |
633 | 628 |
634 cls = Class::New<JSRegExp>(); | 629 cls = Class::New<JSRegExp>(); |
635 object_store->set_jsregexp_class(cls); | 630 object_store->set_jsregexp_class(cls); |
636 name = Symbols::JSSyntaxRegExp(); | 631 name = Symbols::JSSyntaxRegExp(); |
637 RegisterClass(cls, name, core_impl_lib); | 632 RegisterPrivateClass(cls, name, core_lib); |
638 pending_classes.Add(cls, Heap::kOld); | 633 pending_classes.Add(cls, Heap::kOld); |
639 | 634 |
640 // Initialize the base interfaces used by the core VM classes. | 635 // Initialize the base interfaces used by the core VM classes. |
641 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); | 636 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); |
642 | 637 |
643 // Allocate and initialize the pre-allocated classes in the core library. | 638 // Allocate and initialize the pre-allocated classes in the core library. |
644 cls = Class::New<Instance>(kInstanceCid); | 639 cls = Class::New<Instance>(kInstanceCid); |
645 object_store->set_object_class(cls); | 640 object_store->set_object_class(cls); |
646 name = Symbols::Object(); | 641 name = Symbols::Object(); |
647 cls.set_name(name); | 642 cls.set_name(name); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
896 Error& error = Error::Handle(); | 891 Error& error = Error::Handle(); |
897 error = Bootstrap::Compile(core_lib, script); | 892 error = Bootstrap::Compile(core_lib, script); |
898 if (!error.IsNull()) { | 893 if (!error.IsNull()) { |
899 return error.raw(); | 894 return error.raw(); |
900 } | 895 } |
901 Script& patch_script = Script::Handle(Bootstrap::LoadCoreScript(true)); | 896 Script& patch_script = Script::Handle(Bootstrap::LoadCoreScript(true)); |
902 error = core_lib.Patch(patch_script); | 897 error = core_lib.Patch(patch_script); |
903 if (!error.IsNull()) { | 898 if (!error.IsNull()) { |
904 return error.raw(); | 899 return error.raw(); |
905 } | 900 } |
906 error = Bootstrap::Compile(core_impl_lib, impl_script); | |
907 if (!error.IsNull()) { | |
908 return error.raw(); | |
909 } | |
910 patch_script = Bootstrap::LoadCoreImplScript(true); | |
911 error = core_impl_lib.Patch(patch_script); | |
912 if (!error.IsNull()) { | |
913 return error.raw(); | |
914 } | |
915 const Script& collection_script = | 901 const Script& collection_script = |
916 Script::Handle(Bootstrap::LoadCollectionScript(false)); | 902 Script::Handle(Bootstrap::LoadCollectionScript(false)); |
917 const Library& collection_lib = | 903 const Library& collection_lib = |
918 Library::Handle(Library::CollectionLibrary()); | 904 Library::Handle(Library::CollectionLibrary()); |
919 ASSERT(!collection_lib.IsNull()); | 905 ASSERT(!collection_lib.IsNull()); |
920 error = Bootstrap::Compile(collection_lib, collection_script); | 906 error = Bootstrap::Compile(collection_lib, collection_script); |
921 if (!error.IsNull()) { | 907 if (!error.IsNull()) { |
922 return error.raw(); | 908 return error.raw(); |
923 } | 909 } |
924 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript(false)); | 910 const Script& math_script = Script::Handle(Bootstrap::LoadMathScript(false)); |
(...skipping 4923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5848 RawLibrary* Library::New(const String& url) { | 5834 RawLibrary* Library::New(const String& url) { |
5849 return NewLibraryHelper(url, false); | 5835 return NewLibraryHelper(url, false); |
5850 } | 5836 } |
5851 | 5837 |
5852 | 5838 |
5853 void Library::InitCoreLibrary(Isolate* isolate) { | 5839 void Library::InitCoreLibrary(Isolate* isolate) { |
5854 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); | 5840 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); |
5855 const Library& core_lib = | 5841 const Library& core_lib = |
5856 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); | 5842 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); |
5857 core_lib.Register(); | 5843 core_lib.Register(); |
5858 const Namespace& core_ns = Namespace::Handle( | |
5859 Namespace::New(core_lib, Array::Handle(), Array::Handle())); | |
5860 isolate->object_store()->set_core_library(core_lib); | 5844 isolate->object_store()->set_core_library(core_lib); |
5861 const String& core_impl_lib_url = | |
5862 String::Handle(Symbols::New("dart:coreimpl")); | |
5863 const Library& core_impl_lib = | |
5864 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); | |
5865 isolate->object_store()->set_core_impl_library(core_impl_lib); | |
5866 core_impl_lib.Register(); | |
5867 const Namespace& impl_ns = Namespace::Handle( | |
5868 Namespace::New(core_impl_lib, Array::Handle(), Array::Handle())); | |
5869 core_lib.AddImport(impl_ns); | |
5870 core_impl_lib.AddImport(core_ns); | |
5871 Library::InitMathLibrary(isolate); | 5845 Library::InitMathLibrary(isolate); |
5872 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 5846 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
5873 const Namespace& math_ns = Namespace::Handle( | 5847 const Namespace& math_ns = Namespace::Handle( |
5874 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | 5848 Namespace::New(math_lib, Array::Handle(), Array::Handle())); |
5875 Library::InitCollectionLibrary(isolate); | 5849 Library::InitCollectionLibrary(isolate); |
5876 const Library& collection_lib = | 5850 const Library& collection_lib = |
5877 Library::Handle(Library::CollectionLibrary()); | 5851 Library::Handle(Library::CollectionLibrary()); |
5878 const Namespace& collection_ns = Namespace::Handle( | 5852 const Namespace& collection_ns = Namespace::Handle( |
5879 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); | 5853 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); |
5880 core_lib.AddImport(math_ns); | 5854 core_lib.AddImport(math_ns); |
5881 core_impl_lib.AddImport(math_ns); | |
5882 core_lib.AddImport(collection_ns); | 5855 core_lib.AddImport(collection_ns); |
5883 core_impl_lib.AddImport(collection_ns); | |
5884 isolate->object_store()->set_root_library(Library::Handle()); | 5856 isolate->object_store()->set_root_library(Library::Handle()); |
5885 | 5857 |
5886 // Hook up predefined classes without setting their library pointers. These | 5858 // Hook up predefined classes without setting their library pointers. These |
5887 // classes are coming from the VM isolate, and are shared between multiple | 5859 // classes are coming from the VM isolate, and are shared between multiple |
5888 // isolates so setting their library pointers would be wrong. | 5860 // isolates so setting their library pointers would be wrong. |
5889 const Class& cls = Class::Handle(Object::dynamic_class()); | 5861 const Class& cls = Class::Handle(Object::dynamic_class()); |
5890 core_lib.AddObject(cls, String::Handle(cls.Name())); | 5862 core_lib.AddObject(cls, String::Handle(cls.Name())); |
5891 } | 5863 } |
5892 | 5864 |
5893 | 5865 |
5894 void Library::InitCollectionLibrary(Isolate* isolate) { | 5866 void Library::InitCollectionLibrary(Isolate* isolate) { |
5895 const String& url = String::Handle(Symbols::New("dart:collection")); | 5867 const String& url = String::Handle(Symbols::New("dart:collection")); |
5896 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5868 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5897 lib.Register(); | 5869 lib.Register(); |
5898 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 5870 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
5899 const Namespace& math_ns = Namespace::Handle( | 5871 const Namespace& math_ns = Namespace::Handle( |
5900 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | 5872 Namespace::New(math_lib, Array::Handle(), Array::Handle())); |
5901 lib.AddImport(math_ns); | 5873 lib.AddImport(math_ns); |
5902 isolate->object_store()->set_collection_library(lib); | 5874 isolate->object_store()->set_collection_library(lib); |
5903 } | 5875 } |
5904 | 5876 |
5905 | 5877 |
5906 void Library::InitMathLibrary(Isolate* isolate) { | 5878 void Library::InitMathLibrary(Isolate* isolate) { |
5907 const String& url = String::Handle(Symbols::New("dart:math")); | 5879 const String& url = String::Handle(Symbols::New("dart:math")); |
5908 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5880 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5909 lib.Register(); | 5881 lib.Register(); |
5910 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | |
5911 const Namespace& impl_ns = Namespace::Handle( | |
5912 Namespace::New(core_impl_lib, Array::Handle(), Array::Handle())); | |
5913 lib.AddImport(impl_ns); | |
5914 isolate->object_store()->set_math_library(lib); | 5882 isolate->object_store()->set_math_library(lib); |
5915 } | 5883 } |
5916 | 5884 |
5917 | 5885 |
5918 void Library::InitIsolateLibrary(Isolate* isolate) { | 5886 void Library::InitIsolateLibrary(Isolate* isolate) { |
5919 const String& url = String::Handle(Symbols::New("dart:isolate")); | 5887 const String& url = String::Handle(Symbols::New("dart:isolate")); |
5920 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5888 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5921 lib.Register(); | 5889 lib.Register(); |
5922 isolate->object_store()->set_isolate_library(lib); | 5890 isolate->object_store()->set_isolate_library(lib); |
5923 } | 5891 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6054 set_index(libs.Length()); | 6022 set_index(libs.Length()); |
6055 libs.Add(*this); | 6023 libs.Add(*this); |
6056 } | 6024 } |
6057 | 6025 |
6058 | 6026 |
6059 RawLibrary* Library::CoreLibrary() { | 6027 RawLibrary* Library::CoreLibrary() { |
6060 return Isolate::Current()->object_store()->core_library(); | 6028 return Isolate::Current()->object_store()->core_library(); |
6061 } | 6029 } |
6062 | 6030 |
6063 | 6031 |
6064 RawLibrary* Library::CoreImplLibrary() { | |
6065 return Isolate::Current()->object_store()->core_impl_library(); | |
6066 } | |
6067 | |
6068 | |
6069 RawLibrary* Library::CollectionLibrary() { | 6032 RawLibrary* Library::CollectionLibrary() { |
floitsch
2012/11/12 16:31:56
2 collection-libraries.
Anders Johnsen
2012/11/12 16:58:38
Bad merge.
| |
6070 return Isolate::Current()->object_store()->collection_library(); | 6033 return Isolate::Current()->object_store()->collection_library(); |
6071 } | 6034 } |
6072 | 6035 |
6073 | 6036 |
6074 RawLibrary* Library::MathLibrary() { | 6037 RawLibrary* Library::MathLibrary() { |
6075 return Isolate::Current()->object_store()->math_library(); | 6038 return Isolate::Current()->object_store()->math_library(); |
6076 } | 6039 } |
6077 | 6040 |
6078 | 6041 |
6079 RawLibrary* Library::IsolateLibrary() { | 6042 RawLibrary* Library::IsolateLibrary() { |
(...skipping 5905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11985 } | 11948 } |
11986 return result.raw(); | 11949 return result.raw(); |
11987 } | 11950 } |
11988 | 11951 |
11989 | 11952 |
11990 const char* WeakProperty::ToCString() const { | 11953 const char* WeakProperty::ToCString() const { |
11991 return "_WeakProperty"; | 11954 return "_WeakProperty"; |
11992 } | 11955 } |
11993 | 11956 |
11994 } // namespace dart | 11957 } // namespace dart |
OLD | NEW |