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

Side by Side Diff: runtime/vm/object.cc

Issue 10919267: Introduce a VM-only dart:scalarlist library for byte arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move init call for scalarlist lib Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('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 "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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 name = Symbols::Bigint(); 680 name = Symbols::Bigint();
681 RegisterPrivateClass(cls, name, core_lib); 681 RegisterPrivateClass(cls, name, core_lib);
682 pending_classes.Add(cls, Heap::kOld); 682 pending_classes.Add(cls, Heap::kOld);
683 683
684 cls = Class::New<Double>(); 684 cls = Class::New<Double>();
685 object_store->set_double_class(cls); 685 object_store->set_double_class(cls);
686 name = Symbols::Double(); 686 name = Symbols::Double();
687 RegisterPrivateClass(cls, name, core_lib); 687 RegisterPrivateClass(cls, name, core_lib);
688 pending_classes.Add(cls, Heap::kOld); 688 pending_classes.Add(cls, Heap::kOld);
689 689
690 cls = Class::New<Int8Array>();
691 object_store->set_int8_array_class(cls);
692 name = Symbols::_Int8Array();
693 RegisterPrivateClass(cls, name, core_lib);
694
695 cls = Class::New<Uint8Array>();
696 object_store->set_uint8_array_class(cls);
697 name = Symbols::_Uint8Array();
698 RegisterPrivateClass(cls, name, core_lib);
699
700 cls = Class::New<Int16Array>();
701 object_store->set_int16_array_class(cls);
702 name = Symbols::_Int16Array();
703 RegisterPrivateClass(cls, name, core_lib);
704
705 cls = Class::New<Uint16Array>();
706 object_store->set_uint16_array_class(cls);
707 name = Symbols::_Uint16Array();
708 RegisterPrivateClass(cls, name, core_lib);
709
710 cls = Class::New<Int32Array>();
711 object_store->set_int32_array_class(cls);
712 name = Symbols::_Int32Array();
713 RegisterPrivateClass(cls, name, core_lib);
714
715 cls = Class::New<Uint32Array>();
716 object_store->set_uint32_array_class(cls);
717 name = Symbols::_Uint32Array();
718 RegisterPrivateClass(cls, name, core_lib);
719
720 cls = Class::New<Int64Array>();
721 object_store->set_int64_array_class(cls);
722 name = Symbols::_Int64Array();
723 RegisterPrivateClass(cls, name, core_lib);
724
725 cls = Class::New<Uint64Array>();
726 object_store->set_uint64_array_class(cls);
727 name = Symbols::_Uint64Array();
728 RegisterPrivateClass(cls, name, core_lib);
729
730 cls = Class::New<Float32Array>();
731 object_store->set_float32_array_class(cls);
732 name = Symbols::_Float32Array();
733 RegisterPrivateClass(cls, name, core_lib);
734
735 cls = Class::New<Float64Array>();
736 object_store->set_float64_array_class(cls);
737 name = Symbols::_Float64Array();
738 RegisterPrivateClass(cls, name, core_lib);
739
740 cls = Class::New<ExternalInt8Array>();
741 object_store->set_external_int8_array_class(cls);
742 name = Symbols::_ExternalInt8Array();
743 RegisterPrivateClass(cls, name, core_lib);
744
745 cls = Class::New<ExternalUint8Array>();
746 object_store->set_external_uint8_array_class(cls);
747 name = Symbols::_ExternalUint8Array();
748 RegisterPrivateClass(cls, name, core_lib);
749
750 cls = Class::New<ExternalInt16Array>();
751 object_store->set_external_int16_array_class(cls);
752 name = Symbols::_ExternalInt16Array();
753 RegisterPrivateClass(cls, name, core_lib);
754
755 cls = Class::New<ExternalUint16Array>();
756 object_store->set_external_uint16_array_class(cls);
757 name = Symbols::_ExternalUint16Array();
758 RegisterPrivateClass(cls, name, core_lib);
759
760 cls = Class::New<ExternalInt32Array>();
761 object_store->set_external_int32_array_class(cls);
762 name = Symbols::_ExternalInt32Array();
763 RegisterPrivateClass(cls, name, core_lib);
764
765 cls = Class::New<ExternalUint32Array>();
766 object_store->set_external_uint32_array_class(cls);
767 name = Symbols::_ExternalUint32Array();
768 RegisterPrivateClass(cls, name, core_lib);
769
770 cls = Class::New<ExternalInt64Array>();
771 object_store->set_external_int64_array_class(cls);
772 name = Symbols::_ExternalInt64Array();
773 RegisterPrivateClass(cls, name, core_lib);
774
775 cls = Class::New<ExternalUint64Array>();
776 object_store->set_external_uint64_array_class(cls);
777 name = Symbols::_ExternalUint64Array();
778 RegisterPrivateClass(cls, name, core_lib);
779
780 cls = Class::New<ExternalFloat32Array>();
781 object_store->set_external_float32_array_class(cls);
782 name = Symbols::_ExternalFloat32Array();
783 RegisterPrivateClass(cls, name, core_lib);
784
785 cls = Class::New<ExternalFloat64Array>();
786 object_store->set_external_float64_array_class(cls);
787 name = Symbols::_ExternalFloat64Array();
788 RegisterPrivateClass(cls, name, core_lib);
789
790 cls = Class::New<WeakProperty>(); 690 cls = Class::New<WeakProperty>();
791 object_store->set_weak_property_class(cls); 691 object_store->set_weak_property_class(cls);
792 name = Symbols::_WeakProperty(); 692 name = Symbols::_WeakProperty();
793 RegisterPrivateClass(cls, name, core_lib); 693 RegisterPrivateClass(cls, name, core_lib);
794 694
695 Library::InitScalarlistLibrary(isolate);
696 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary());
697
698 cls = Class::New<Int8Array>();
699 object_store->set_int8_array_class(cls);
700 name = Symbols::_Int8Array();
701 RegisterPrivateClass(cls, name, scalarlist_lib);
702
703 cls = Class::New<Uint8Array>();
704 object_store->set_uint8_array_class(cls);
705 name = Symbols::_Uint8Array();
706 RegisterPrivateClass(cls, name, scalarlist_lib);
707
708 cls = Class::New<Int16Array>();
709 object_store->set_int16_array_class(cls);
710 name = Symbols::_Int16Array();
711 RegisterPrivateClass(cls, name, scalarlist_lib);
712
713 cls = Class::New<Uint16Array>();
714 object_store->set_uint16_array_class(cls);
715 name = Symbols::_Uint16Array();
716 RegisterPrivateClass(cls, name, scalarlist_lib);
717
718 cls = Class::New<Int32Array>();
719 object_store->set_int32_array_class(cls);
720 name = Symbols::_Int32Array();
721 RegisterPrivateClass(cls, name, scalarlist_lib);
722
723 cls = Class::New<Uint32Array>();
724 object_store->set_uint32_array_class(cls);
725 name = Symbols::_Uint32Array();
726 RegisterPrivateClass(cls, name, scalarlist_lib);
727
728 cls = Class::New<Int64Array>();
729 object_store->set_int64_array_class(cls);
730 name = Symbols::_Int64Array();
731 RegisterPrivateClass(cls, name, scalarlist_lib);
732
733 cls = Class::New<Uint64Array>();
734 object_store->set_uint64_array_class(cls);
735 name = Symbols::_Uint64Array();
736 RegisterPrivateClass(cls, name, scalarlist_lib);
737
738 cls = Class::New<Float32Array>();
739 object_store->set_float32_array_class(cls);
740 name = Symbols::_Float32Array();
741 RegisterPrivateClass(cls, name, scalarlist_lib);
742
743 cls = Class::New<Float64Array>();
744 object_store->set_float64_array_class(cls);
745 name = Symbols::_Float64Array();
746 RegisterPrivateClass(cls, name, scalarlist_lib);
747
748 cls = Class::New<ExternalInt8Array>();
749 object_store->set_external_int8_array_class(cls);
750 name = Symbols::_ExternalInt8Array();
751 RegisterPrivateClass(cls, name, scalarlist_lib);
752
753 cls = Class::New<ExternalUint8Array>();
754 object_store->set_external_uint8_array_class(cls);
755 name = Symbols::_ExternalUint8Array();
756 RegisterPrivateClass(cls, name, scalarlist_lib);
757
758 cls = Class::New<ExternalInt16Array>();
759 object_store->set_external_int16_array_class(cls);
760 name = Symbols::_ExternalInt16Array();
761 RegisterPrivateClass(cls, name, scalarlist_lib);
762
763 cls = Class::New<ExternalUint16Array>();
764 object_store->set_external_uint16_array_class(cls);
765 name = Symbols::_ExternalUint16Array();
766 RegisterPrivateClass(cls, name, scalarlist_lib);
767
768 cls = Class::New<ExternalInt32Array>();
769 object_store->set_external_int32_array_class(cls);
770 name = Symbols::_ExternalInt32Array();
771 RegisterPrivateClass(cls, name, scalarlist_lib);
772
773 cls = Class::New<ExternalUint32Array>();
774 object_store->set_external_uint32_array_class(cls);
775 name = Symbols::_ExternalUint32Array();
776 RegisterPrivateClass(cls, name, scalarlist_lib);
777
778 cls = Class::New<ExternalInt64Array>();
779 object_store->set_external_int64_array_class(cls);
780 name = Symbols::_ExternalInt64Array();
781 RegisterPrivateClass(cls, name, scalarlist_lib);
782
783 cls = Class::New<ExternalUint64Array>();
784 object_store->set_external_uint64_array_class(cls);
785 name = Symbols::_ExternalUint64Array();
786 RegisterPrivateClass(cls, name, scalarlist_lib);
787
788 cls = Class::New<ExternalFloat32Array>();
789 object_store->set_external_float32_array_class(cls);
790 name = Symbols::_ExternalFloat32Array();
791 RegisterPrivateClass(cls, name, scalarlist_lib);
792
793 cls = Class::New<ExternalFloat64Array>();
794 object_store->set_external_float64_array_class(cls);
795 name = Symbols::_ExternalFloat64Array();
796 RegisterPrivateClass(cls, name, scalarlist_lib);
797
795 // Set the super type of class Stacktrace to Object type so that the 798 // Set the super type of class Stacktrace to Object type so that the
796 // 'toString' method is implemented. 799 // 'toString' method is implemented.
797 cls = object_store->stacktrace_class(); 800 cls = object_store->stacktrace_class();
798 cls.set_super_type(type); 801 cls.set_super_type(type);
799 802
800 // Note: The abstract class Function is represented by VM class 803 // Note: The abstract class Function is represented by VM class
801 // DartFunction, not VM class Function. 804 // DartFunction, not VM class Function.
802 name = Symbols::Function(); 805 name = Symbols::Function();
803 cls = Class::New<DartFunction>(); 806 cls = Class::New<DartFunction>();
804 RegisterClass(cls, name, core_lib); 807 RegisterClass(cls, name, core_lib);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 ASSERT(!mirrors_lib.IsNull()); 943 ASSERT(!mirrors_lib.IsNull());
941 error = Bootstrap::Compile(mirrors_lib, mirrors_script); 944 error = Bootstrap::Compile(mirrors_lib, mirrors_script);
942 if (!error.IsNull()) { 945 if (!error.IsNull()) {
943 return error.raw(); 946 return error.raw();
944 } 947 }
945 patch_script = Bootstrap::LoadMirrorsScript(true); 948 patch_script = Bootstrap::LoadMirrorsScript(true);
946 error = mirrors_lib.Patch(patch_script); 949 error = mirrors_lib.Patch(patch_script);
947 if (!error.IsNull()) { 950 if (!error.IsNull()) {
948 return error.raw(); 951 return error.raw();
949 } 952 }
953 const Script& scalarlist_script = Script::Handle(
954 Bootstrap::LoadScalarlistScript(false));
955 ASSERT(!scalarlist_lib.IsNull());
956 error = Bootstrap::Compile(scalarlist_lib, scalarlist_script);
957 if (!error.IsNull()) {
958 return error.raw();
959 }
960 patch_script = Bootstrap::LoadScalarlistScript(true);
961 error = scalarlist_lib.Patch(patch_script);
962 if (!error.IsNull()) {
963 return error.raw();
964 }
950 Bootstrap::SetupNativeResolver(); 965 Bootstrap::SetupNativeResolver();
951 966
952 // Remove the Object superclass cycle by setting the super type to null (not 967 // Remove the Object superclass cycle by setting the super type to null (not
953 // to the type of null). 968 // to the type of null).
954 cls = object_store->object_class(); 969 cls = object_store->object_class();
955 cls.set_super_type(Type::Handle()); 970 cls.set_super_type(Type::Handle());
956 971
957 ClassFinalizer::VerifyBootstrapClasses(); 972 ClassFinalizer::VerifyBootstrapClasses();
958 return Error::null(); 973 return Error::null();
959 } 974 }
(...skipping 5639 matching lines...) Expand 10 before | Expand all | Expand 10 after
6599 lib.Register(); 6614 lib.Register();
6600 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 6615 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
6601 lib.AddImport(isolate_lib); 6616 lib.AddImport(isolate_lib);
6602 const Library& wrappers_lib = 6617 const Library& wrappers_lib =
6603 Library::Handle(Library::NativeWrappersLibrary()); 6618 Library::Handle(Library::NativeWrappersLibrary());
6604 lib.AddImport(wrappers_lib); 6619 lib.AddImport(wrappers_lib);
6605 isolate->object_store()->set_mirrors_library(lib); 6620 isolate->object_store()->set_mirrors_library(lib);
6606 } 6621 }
6607 6622
6608 6623
6624 void Library::InitScalarlistLibrary(Isolate* isolate) {
6625 const String& url = String::Handle(Symbols::New("dart:scalarlist"));
6626 const Library& lib = Library::Handle(Library::New(url));
6627 lib.Register();
6628 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
6629 lib.AddImport(core_impl_lib);
6630 isolate->object_store()->set_scalarlist_library(lib);
6631 }
6632
6633
6609 void Library::InitNativeWrappersLibrary(Isolate* isolate) { 6634 void Library::InitNativeWrappersLibrary(Isolate* isolate) {
6610 static const int kNumNativeWrappersClasses = 4; 6635 static const int kNumNativeWrappersClasses = 4;
6611 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); 6636 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10);
6612 const String& native_flds_lib_url = String::Handle( 6637 const String& native_flds_lib_url = String::Handle(
6613 Symbols::New("dart:nativewrappers")); 6638 Symbols::New("dart:nativewrappers"));
6614 const Library& native_flds_lib = Library::Handle( 6639 const Library& native_flds_lib = Library::Handle(
6615 Library::NewLibraryHelper(native_flds_lib_url, false)); 6640 Library::NewLibraryHelper(native_flds_lib_url, false));
6616 native_flds_lib.Register(); 6641 native_flds_lib.Register();
6617 isolate->object_store()->set_native_wrappers_library(native_flds_lib); 6642 isolate->object_store()->set_native_wrappers_library(native_flds_lib);
6618 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; 6643 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6727 RawLibrary* Library::IsolateLibrary() { 6752 RawLibrary* Library::IsolateLibrary() {
6728 return Isolate::Current()->object_store()->isolate_library(); 6753 return Isolate::Current()->object_store()->isolate_library();
6729 } 6754 }
6730 6755
6731 6756
6732 RawLibrary* Library::MirrorsLibrary() { 6757 RawLibrary* Library::MirrorsLibrary() {
6733 return Isolate::Current()->object_store()->mirrors_library(); 6758 return Isolate::Current()->object_store()->mirrors_library();
6734 } 6759 }
6735 6760
6736 6761
6762 RawLibrary* Library::ScalarlistLibrary() {
6763 return Isolate::Current()->object_store()->scalarlist_library();
6764 }
6765
6766
6737 RawLibrary* Library::NativeWrappersLibrary() { 6767 RawLibrary* Library::NativeWrappersLibrary() {
6738 return Isolate::Current()->object_store()->native_wrappers_library(); 6768 return Isolate::Current()->object_store()->native_wrappers_library();
6739 } 6769 }
6740 6770
6741 6771
6742 const char* Library::ToCString() const { 6772 const char* Library::ToCString() const {
6743 const char* kFormat = "Library:'%s'"; 6773 const char* kFormat = "Library:'%s'";
6744 const String& name = String::Handle(url()); 6774 const String& name = String::Handle(url());
6745 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 6775 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
6746 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6776 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
(...skipping 5036 matching lines...) Expand 10 before | Expand all | Expand 10 after
11783 } 11813 }
11784 return result.raw(); 11814 return result.raw();
11785 } 11815 }
11786 11816
11787 11817
11788 const char* WeakProperty::ToCString() const { 11818 const char* WeakProperty::ToCString() const {
11789 return "_WeakProperty"; 11819 return "_WeakProperty";
11790 } 11820 }
11791 11821
11792 } // namespace dart 11822 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698