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 4952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5877 RawLibrary* Library::New(const String& url) { | 5863 RawLibrary* Library::New(const String& url) { |
5878 return NewLibraryHelper(url, false); | 5864 return NewLibraryHelper(url, false); |
5879 } | 5865 } |
5880 | 5866 |
5881 | 5867 |
5882 void Library::InitCoreLibrary(Isolate* isolate) { | 5868 void Library::InitCoreLibrary(Isolate* isolate) { |
5883 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); | 5869 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); |
5884 const Library& core_lib = | 5870 const Library& core_lib = |
5885 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); | 5871 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); |
5886 core_lib.Register(); | 5872 core_lib.Register(); |
5887 const Namespace& core_ns = Namespace::Handle( | |
5888 Namespace::New(core_lib, Array::Handle(), Array::Handle())); | |
5889 isolate->object_store()->set_core_library(core_lib); | 5873 isolate->object_store()->set_core_library(core_lib); |
5890 const String& core_impl_lib_url = | |
5891 String::Handle(Symbols::New("dart:coreimpl")); | |
5892 const Library& core_impl_lib = | |
5893 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); | |
5894 isolate->object_store()->set_core_impl_library(core_impl_lib); | |
5895 core_impl_lib.Register(); | |
5896 const Namespace& impl_ns = Namespace::Handle( | |
5897 Namespace::New(core_impl_lib, Array::Handle(), Array::Handle())); | |
5898 core_lib.AddImport(impl_ns); | |
5899 core_impl_lib.AddImport(core_ns); | |
5900 Library::InitMathLibrary(isolate); | 5874 Library::InitMathLibrary(isolate); |
5901 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 5875 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
5902 const Namespace& math_ns = Namespace::Handle( | 5876 const Namespace& math_ns = Namespace::Handle( |
5903 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | 5877 Namespace::New(math_lib, Array::Handle(), Array::Handle())); |
5904 Library::InitCollectionLibrary(isolate); | 5878 Library::InitCollectionLibrary(isolate); |
5905 const Library& collection_lib = | 5879 const Library& collection_lib = |
5906 Library::Handle(Library::CollectionLibrary()); | 5880 Library::Handle(Library::CollectionLibrary()); |
5907 const Namespace& collection_ns = Namespace::Handle( | 5881 const Namespace& collection_ns = Namespace::Handle( |
5908 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); | 5882 Namespace::New(collection_lib, Array::Handle(), Array::Handle())); |
5909 core_lib.AddImport(math_ns); | 5883 core_lib.AddImport(math_ns); |
5910 core_impl_lib.AddImport(math_ns); | |
5911 core_lib.AddImport(collection_ns); | 5884 core_lib.AddImport(collection_ns); |
5912 core_impl_lib.AddImport(collection_ns); | |
5913 isolate->object_store()->set_root_library(Library::Handle()); | 5885 isolate->object_store()->set_root_library(Library::Handle()); |
5914 | 5886 |
5915 // Hook up predefined classes without setting their library pointers. These | 5887 // Hook up predefined classes without setting their library pointers. These |
5916 // classes are coming from the VM isolate, and are shared between multiple | 5888 // classes are coming from the VM isolate, and are shared between multiple |
5917 // isolates so setting their library pointers would be wrong. | 5889 // isolates so setting their library pointers would be wrong. |
5918 const Class& cls = Class::Handle(Object::dynamic_class()); | 5890 const Class& cls = Class::Handle(Object::dynamic_class()); |
5919 core_lib.AddObject(cls, String::Handle(cls.Name())); | 5891 core_lib.AddObject(cls, String::Handle(cls.Name())); |
5920 } | 5892 } |
5921 | 5893 |
5922 | 5894 |
5923 void Library::InitCollectionLibrary(Isolate* isolate) { | 5895 void Library::InitCollectionLibrary(Isolate* isolate) { |
5924 const String& url = String::Handle(Symbols::New("dart:collection")); | 5896 const String& url = String::Handle(Symbols::New("dart:collection")); |
5925 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5897 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5926 lib.Register(); | 5898 lib.Register(); |
5927 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 5899 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
5928 const Namespace& math_ns = Namespace::Handle( | 5900 const Namespace& math_ns = Namespace::Handle( |
5929 Namespace::New(math_lib, Array::Handle(), Array::Handle())); | 5901 Namespace::New(math_lib, Array::Handle(), Array::Handle())); |
5930 lib.AddImport(math_ns); | 5902 lib.AddImport(math_ns); |
5931 isolate->object_store()->set_collection_library(lib); | 5903 isolate->object_store()->set_collection_library(lib); |
5932 } | 5904 } |
5933 | 5905 |
5934 | 5906 |
5935 void Library::InitMathLibrary(Isolate* isolate) { | 5907 void Library::InitMathLibrary(Isolate* isolate) { |
5936 const String& url = String::Handle(Symbols::New("dart:math")); | 5908 const String& url = String::Handle(Symbols::New("dart:math")); |
5937 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5909 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5938 lib.Register(); | 5910 lib.Register(); |
5939 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | |
5940 const Namespace& impl_ns = Namespace::Handle( | |
5941 Namespace::New(core_impl_lib, Array::Handle(), Array::Handle())); | |
5942 lib.AddImport(impl_ns); | |
5943 isolate->object_store()->set_math_library(lib); | 5911 isolate->object_store()->set_math_library(lib); |
5944 } | 5912 } |
5945 | 5913 |
5946 | 5914 |
5947 void Library::InitIsolateLibrary(Isolate* isolate) { | 5915 void Library::InitIsolateLibrary(Isolate* isolate) { |
5948 const String& url = String::Handle(Symbols::New("dart:isolate")); | 5916 const String& url = String::Handle(Symbols::New("dart:isolate")); |
5949 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); | 5917 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
5950 lib.Register(); | 5918 lib.Register(); |
5951 isolate->object_store()->set_isolate_library(lib); | 5919 isolate->object_store()->set_isolate_library(lib); |
5952 } | 5920 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6083 set_index(libs.Length()); | 6051 set_index(libs.Length()); |
6084 libs.Add(*this); | 6052 libs.Add(*this); |
6085 } | 6053 } |
6086 | 6054 |
6087 | 6055 |
6088 RawLibrary* Library::CoreLibrary() { | 6056 RawLibrary* Library::CoreLibrary() { |
6089 return Isolate::Current()->object_store()->core_library(); | 6057 return Isolate::Current()->object_store()->core_library(); |
6090 } | 6058 } |
6091 | 6059 |
6092 | 6060 |
6093 RawLibrary* Library::CoreImplLibrary() { | |
6094 return Isolate::Current()->object_store()->core_impl_library(); | |
6095 } | |
6096 | |
6097 | |
6098 RawLibrary* Library::CollectionLibrary() { | 6061 RawLibrary* Library::CollectionLibrary() { |
6099 return Isolate::Current()->object_store()->collection_library(); | 6062 return Isolate::Current()->object_store()->collection_library(); |
6100 } | 6063 } |
6101 | 6064 |
6102 | 6065 |
6103 RawLibrary* Library::MathLibrary() { | 6066 RawLibrary* Library::MathLibrary() { |
Ivan Posva
2012/11/13 18:26:28
Unless I am severely mistaken this code cannot com
Anders Johnsen
2012/11/13 18:40:26
This is not actually what happened, as I wrote in
| |
6104 return Isolate::Current()->object_store()->math_library(); | 6067 return Isolate::Current()->object_store()->math_library(); |
6105 } | 6068 } |
6106 | 6069 |
6107 | 6070 |
6108 RawLibrary* Library::IsolateLibrary() { | 6071 RawLibrary* Library::IsolateLibrary() { |
6109 return Isolate::Current()->object_store()->isolate_library(); | 6072 return Isolate::Current()->object_store()->isolate_library(); |
6110 } | 6073 } |
6111 | 6074 |
6112 | 6075 |
6113 RawLibrary* Library::MirrorsLibrary() { | 6076 RawLibrary* Library::MirrorsLibrary() { |
(...skipping 5906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12020 } | 11983 } |
12021 return result.raw(); | 11984 return result.raw(); |
12022 } | 11985 } |
12023 | 11986 |
12024 | 11987 |
12025 const char* WeakProperty::ToCString() const { | 11988 const char* WeakProperty::ToCString() const { |
12026 return "_WeakProperty"; | 11989 return "_WeakProperty"; |
12027 } | 11990 } |
12028 | 11991 |
12029 } // namespace dart | 11992 } // namespace dart |
OLD | NEW |