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 "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 const char* cname, | 392 const char* cname, |
393 const Script& script, | 393 const Script& script, |
394 const Library& lib) { | 394 const Library& lib) { |
395 const String& name = String::Handle(String::NewSymbol(cname)); | 395 const String& name = String::Handle(String::NewSymbol(cname)); |
396 cls.set_name(name); | 396 cls.set_name(name); |
397 cls.set_script(script); | 397 cls.set_script(script); |
398 lib.AddClass(cls); | 398 lib.AddClass(cls); |
399 } | 399 } |
400 | 400 |
401 | 401 |
402 RawError* Object::Init(Isolate* isolate) { | 402 void Object::Init(Isolate* isolate) { |
403 TIMERSCOPE(time_bootstrap); | 403 TIMERSCOPE(time_bootstrap); |
404 ObjectStore* object_store = isolate->object_store(); | 404 ObjectStore* object_store = isolate->object_store(); |
405 | 405 |
406 Class& cls = Class::Handle(); | 406 Class& cls = Class::Handle(); |
407 Type& type = Type::Handle(); | 407 Type& type = Type::Handle(); |
408 Array& array = Array::Handle(); | 408 Array& array = Array::Handle(); |
409 | 409 |
410 // All RawArray fields will be initialized to an empty array, therefore | 410 // All RawArray fields will be initialized to an empty array, therefore |
411 // initialize array class first. | 411 // initialize array class first. |
412 cls = Class::New<Array>(); | 412 cls = Class::New<Array>(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 bool_value = Bool::New(false); | 638 bool_value = Bool::New(false); |
639 object_store->set_false_value(bool_value); | 639 object_store->set_false_value(bool_value); |
640 | 640 |
641 // Setup some default native field classes which can be extended for | 641 // Setup some default native field classes which can be extended for |
642 // specifying native fields in dart classes. | 642 // specifying native fields in dart classes. |
643 Library::InitNativeWrappersLibrary(isolate); | 643 Library::InitNativeWrappersLibrary(isolate); |
644 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | 644 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); |
645 | 645 |
646 // Finish the initialization by compiling the bootstrap scripts containing the | 646 // Finish the initialization by compiling the bootstrap scripts containing the |
647 // base interfaces and the implementation of the internal classes. | 647 // base interfaces and the implementation of the internal classes. |
648 Error& error = Error::Handle(); | 648 Bootstrap::Compile(core_lib, script); |
649 error = Bootstrap::Compile(core_lib, script); | 649 Bootstrap::Compile(core_impl_lib, impl_script); |
650 if (!error.IsNull()) { | |
651 return error.raw(); | |
652 } | |
653 error = Bootstrap::Compile(core_impl_lib, impl_script); | |
654 if (!error.IsNull()) { | |
655 return error.raw(); | |
656 } | |
657 | 650 |
658 Bootstrap::SetupNativeResolver(); | 651 Bootstrap::SetupNativeResolver(); |
659 | 652 |
660 // Remove the Object superclass cycle by setting the super type to null (not | 653 // Remove the Object superclass cycle by setting the super type to null (not |
661 // to the type of null). | 654 // to the type of null). |
662 cls = object_store->object_class(); | 655 cls = object_store->object_class(); |
663 cls.set_super_type(Type::Handle()); | 656 cls.set_super_type(Type::Handle()); |
664 | 657 |
665 ClassFinalizer::VerifyBootstrapClasses(); | 658 ClassFinalizer::VerifyBootstrapClasses(); |
666 return Error::null(); | |
667 } | 659 } |
668 | 660 |
669 | 661 |
670 void Object::InitFromSnapshot(Isolate* isolate) { | 662 void Object::InitFromSnapshot(Isolate* isolate) { |
671 TIMERSCOPE(time_bootstrap); | 663 TIMERSCOPE(time_bootstrap); |
672 ObjectStore* object_store = isolate->object_store(); | 664 ObjectStore* object_store = isolate->object_store(); |
673 | 665 |
674 Class& cls = Class::Handle(); | 666 Class& cls = Class::Handle(); |
675 | 667 |
676 // Set up empty classes in the object store, these will get | 668 // Set up empty classes in the object store, these will get |
(...skipping 4017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4694 ASSERT(value.IsSymbol()); | 4686 ASSERT(value.IsSymbol()); |
4695 StorePointer(&raw_ptr()->name_, value.raw()); | 4687 StorePointer(&raw_ptr()->name_, value.raw()); |
4696 } | 4688 } |
4697 | 4689 |
4698 | 4690 |
4699 void LibraryPrefix::set_library(const Library& value) const { | 4691 void LibraryPrefix::set_library(const Library& value) const { |
4700 StorePointer(&raw_ptr()->library_, value.raw()); | 4692 StorePointer(&raw_ptr()->library_, value.raw()); |
4701 } | 4693 } |
4702 | 4694 |
4703 | 4695 |
4704 RawError* Library::CompileAll() { | 4696 void Library::CompileAll() { |
4705 Error& error = Error::Handle(); | |
4706 Library& lib = Library::Handle( | 4697 Library& lib = Library::Handle( |
4707 Isolate::Current()->object_store()->registered_libraries()); | 4698 Isolate::Current()->object_store()->registered_libraries()); |
4708 Class& cls = Class::Handle(); | 4699 Class& cls = Class::Handle(); |
4709 while (!lib.IsNull()) { | 4700 while (!lib.IsNull()) { |
4710 ClassDictionaryIterator it(lib); | 4701 ClassDictionaryIterator it(lib); |
4711 while (it.HasNext()) { | 4702 while (it.HasNext()) { |
4712 cls ^= it.GetNextClass(); | 4703 cls ^= it.GetNextClass(); |
4713 if (!cls.is_interface()) { | 4704 if (!cls.is_interface()) { |
4714 error = Compiler::CompileAllFunctions(cls); | 4705 Compiler::CompileAllFunctions(cls); |
4715 } | 4706 } |
4716 } | 4707 } |
4717 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); | 4708 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); |
4718 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { | 4709 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { |
4719 cls ^= anon_classes.At(i); | 4710 cls ^= anon_classes.At(i); |
4720 ASSERT(!cls.is_interface()); | 4711 ASSERT(!cls.is_interface()); |
4721 error = Compiler::CompileAllFunctions(cls); | 4712 Compiler::CompileAllFunctions(cls); |
4722 } | 4713 } |
4723 lib = lib.next_registered(); | 4714 lib = lib.next_registered(); |
4724 } | 4715 } |
4725 return error.raw(); | |
4726 } | 4716 } |
4727 | 4717 |
4728 | 4718 |
4729 RawInstructions* Instructions::New(intptr_t size) { | 4719 RawInstructions* Instructions::New(intptr_t size) { |
4730 const Class& instructions_class = Class::Handle(Object::instructions_class()); | 4720 const Class& instructions_class = Class::Handle(Object::instructions_class()); |
4731 Instructions& result = Instructions::Handle(); | 4721 Instructions& result = Instructions::Handle(); |
4732 { | 4722 { |
4733 uword aligned_size = Instructions::InstanceSize(size); | 4723 uword aligned_size = Instructions::InstanceSize(size); |
4734 RawObject* raw = Object::Allocate(instructions_class, | 4724 RawObject* raw = Object::Allocate(instructions_class, |
4735 aligned_size, | 4725 aligned_size, |
(...skipping 3200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7936 const String& str = String::Handle(pattern()); | 7926 const String& str = String::Handle(pattern()); |
7937 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7927 const char* format = "JSRegExp: pattern=%s flags=%s"; |
7938 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7928 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
7939 char* chars = reinterpret_cast<char*>( | 7929 char* chars = reinterpret_cast<char*>( |
7940 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7930 Isolate::Current()->current_zone()->Allocate(len + 1)); |
7941 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7931 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
7942 return chars; | 7932 return chars; |
7943 } | 7933 } |
7944 | 7934 |
7945 } // namespace dart | 7935 } // namespace dart |
OLD | NEW |