| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 const char* cname, | 387 const char* cname, |
| 388 const Script& script, | 388 const Script& script, |
| 389 const Library& lib) { | 389 const Library& lib) { |
| 390 const String& name = String::Handle(String::NewSymbol(cname)); | 390 const String& name = String::Handle(String::NewSymbol(cname)); |
| 391 cls.set_name(name); | 391 cls.set_name(name); |
| 392 cls.set_script(script); | 392 cls.set_script(script); |
| 393 lib.AddClass(cls); | 393 lib.AddClass(cls); |
| 394 } | 394 } |
| 395 | 395 |
| 396 | 396 |
| 397 void Object::Init(Isolate* isolate) { | 397 RawError* Object::Init(Isolate* isolate) { |
| 398 TIMERSCOPE(time_bootstrap); | 398 TIMERSCOPE(time_bootstrap); |
| 399 ObjectStore* object_store = isolate->object_store(); | 399 ObjectStore* object_store = isolate->object_store(); |
| 400 | 400 |
| 401 Class& cls = Class::Handle(); | 401 Class& cls = Class::Handle(); |
| 402 Type& type = Type::Handle(); | 402 Type& type = Type::Handle(); |
| 403 Array& array = Array::Handle(); | 403 Array& array = Array::Handle(); |
| 404 | 404 |
| 405 // All RawArray fields will be initialized to an empty array, therefore | 405 // All RawArray fields will be initialized to an empty array, therefore |
| 406 // initialize array class first. | 406 // initialize array class first. |
| 407 cls = Class::New<Array>(); | 407 cls = Class::New<Array>(); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 bool_value = Bool::New(false); | 622 bool_value = Bool::New(false); |
| 623 object_store->set_false_value(bool_value); | 623 object_store->set_false_value(bool_value); |
| 624 | 624 |
| 625 // Setup some default native field classes which can be extended for | 625 // Setup some default native field classes which can be extended for |
| 626 // specifying native fields in dart classes. | 626 // specifying native fields in dart classes. |
| 627 Library::InitNativeWrappersLibrary(isolate); | 627 Library::InitNativeWrappersLibrary(isolate); |
| 628 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); | 628 ASSERT(isolate->object_store()->native_wrappers_library() != Library::null()); |
| 629 | 629 |
| 630 // Finish the initialization by compiling the bootstrap scripts containing the | 630 // Finish the initialization by compiling the bootstrap scripts containing the |
| 631 // base interfaces and the implementation of the internal classes. | 631 // base interfaces and the implementation of the internal classes. |
| 632 Bootstrap::Compile(core_lib, script); | 632 Error& error = Error::Handle(); |
| 633 Bootstrap::Compile(core_impl_lib, impl_script); | 633 error = Bootstrap::Compile(core_lib, script); |
| 634 if (!error.IsNull()) { |
| 635 return error.raw(); |
| 636 } |
| 637 error = Bootstrap::Compile(core_impl_lib, impl_script); |
| 638 if (!error.IsNull()) { |
| 639 return error.raw(); |
| 640 } |
| 634 | 641 |
| 635 Bootstrap::SetupNativeResolver(); | 642 Bootstrap::SetupNativeResolver(); |
| 636 | 643 |
| 637 // Remove the Object superclass cycle by setting the super type to null (not | 644 // Remove the Object superclass cycle by setting the super type to null (not |
| 638 // to the type of null). | 645 // to the type of null). |
| 639 cls = object_store->object_class(); | 646 cls = object_store->object_class(); |
| 640 cls.set_super_type(Type::Handle()); | 647 cls.set_super_type(Type::Handle()); |
| 641 | 648 |
| 642 ClassFinalizer::VerifyBootstrapClasses(); | 649 ClassFinalizer::VerifyBootstrapClasses(); |
| 650 return Error::null(); |
| 643 } | 651 } |
| 644 | 652 |
| 645 | 653 |
| 646 void Object::InitFromSnapshot(Isolate* isolate) { | 654 void Object::InitFromSnapshot(Isolate* isolate) { |
| 647 TIMERSCOPE(time_bootstrap); | 655 TIMERSCOPE(time_bootstrap); |
| 648 ObjectStore* object_store = isolate->object_store(); | 656 ObjectStore* object_store = isolate->object_store(); |
| 649 | 657 |
| 650 Class& cls = Class::Handle(); | 658 Class& cls = Class::Handle(); |
| 651 | 659 |
| 652 // Set up empty classes in the object store, these will get | 660 // Set up empty classes in the object store, these will get |
| (...skipping 3807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4460 ASSERT(value.IsSymbol()); | 4468 ASSERT(value.IsSymbol()); |
| 4461 StorePointer(&raw_ptr()->name_, value.raw()); | 4469 StorePointer(&raw_ptr()->name_, value.raw()); |
| 4462 } | 4470 } |
| 4463 | 4471 |
| 4464 | 4472 |
| 4465 void LibraryPrefix::set_library(const Library& value) const { | 4473 void LibraryPrefix::set_library(const Library& value) const { |
| 4466 StorePointer(&raw_ptr()->library_, value.raw()); | 4474 StorePointer(&raw_ptr()->library_, value.raw()); |
| 4467 } | 4475 } |
| 4468 | 4476 |
| 4469 | 4477 |
| 4470 void Library::CompileAll() { | 4478 RawError* Library::CompileAll() { |
| 4479 Error& error = Error::Handle(); |
| 4471 Library& lib = Library::Handle( | 4480 Library& lib = Library::Handle( |
| 4472 Isolate::Current()->object_store()->registered_libraries()); | 4481 Isolate::Current()->object_store()->registered_libraries()); |
| 4473 Class& cls = Class::Handle(); | 4482 Class& cls = Class::Handle(); |
| 4474 while (!lib.IsNull()) { | 4483 while (!lib.IsNull()) { |
| 4475 ClassDictionaryIterator it(lib); | 4484 ClassDictionaryIterator it(lib); |
| 4476 while (it.HasNext()) { | 4485 while (it.HasNext()) { |
| 4477 cls ^= it.GetNextClass(); | 4486 cls ^= it.GetNextClass(); |
| 4478 if (!cls.is_interface()) { | 4487 if (!cls.is_interface()) { |
| 4479 Compiler::CompileAllFunctions(cls); | 4488 error = Compiler::CompileAllFunctions(cls); |
| 4480 } | 4489 } |
| 4481 } | 4490 } |
| 4482 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); | 4491 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); |
| 4483 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { | 4492 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { |
| 4484 cls ^= anon_classes.At(i); | 4493 cls ^= anon_classes.At(i); |
| 4485 ASSERT(!cls.is_interface()); | 4494 ASSERT(!cls.is_interface()); |
| 4486 Compiler::CompileAllFunctions(cls); | 4495 error = Compiler::CompileAllFunctions(cls); |
| 4487 } | 4496 } |
| 4488 lib = lib.next_registered(); | 4497 lib = lib.next_registered(); |
| 4489 } | 4498 } |
| 4499 return error.raw(); |
| 4490 } | 4500 } |
| 4491 | 4501 |
| 4492 | 4502 |
| 4493 RawInstructions* Instructions::New(intptr_t size) { | 4503 RawInstructions* Instructions::New(intptr_t size) { |
| 4494 const Class& instructions_class = Class::Handle(Object::instructions_class()); | 4504 const Class& instructions_class = Class::Handle(Object::instructions_class()); |
| 4495 Instructions& result = Instructions::Handle(); | 4505 Instructions& result = Instructions::Handle(); |
| 4496 { | 4506 { |
| 4497 uword aligned_size = Instructions::InstanceSize(size); | 4507 uword aligned_size = Instructions::InstanceSize(size); |
| 4498 RawObject* raw = Object::Allocate(instructions_class, | 4508 RawObject* raw = Object::Allocate(instructions_class, |
| 4499 aligned_size, | 4509 aligned_size, |
| (...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7623 const String& str = String::Handle(pattern()); | 7633 const String& str = String::Handle(pattern()); |
| 7624 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7634 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 7625 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7635 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 7626 char* chars = reinterpret_cast<char*>( | 7636 char* chars = reinterpret_cast<char*>( |
| 7627 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7637 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 7628 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7638 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 7629 return chars; | 7639 return chars; |
| 7630 } | 7640 } |
| 7631 | 7641 |
| 7632 } // namespace dart | 7642 } // namespace dart |
| OLD | NEW |