Chromium Code Reviews| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 const char* cname, | 437 const char* cname, |
| 438 const Script& script, | 438 const Script& script, |
| 439 const Library& lib) { | 439 const Library& lib) { |
| 440 const String& name = String::Handle(String::NewSymbol(cname)); | 440 const String& name = String::Handle(String::NewSymbol(cname)); |
| 441 cls.set_name(name); | 441 cls.set_name(name); |
| 442 cls.set_script(script); | 442 cls.set_script(script); |
| 443 lib.AddClass(cls); | 443 lib.AddClass(cls); |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 void Object::RegisterPrivateClass(const Class& cls, | |
| 448 const char* public_class_name, | |
| 449 const Script& script, | |
| 450 const Library& lib) { | |
| 451 String& str = String::Handle(); | |
| 452 str ^= String::NewSymbol(public_class_name); | |
| 453 str ^= lib.PrivateName(str); | |
| 454 cls.set_name(str); | |
| 455 cls.set_script(script); | |
| 456 lib.AddClass(cls); | |
| 457 } | |
| 458 | |
| 459 | |
| 447 RawError* Object::Init(Isolate* isolate) { | 460 RawError* Object::Init(Isolate* isolate) { |
| 448 TIMERSCOPE(time_bootstrap); | 461 TIMERSCOPE(time_bootstrap); |
| 449 ObjectStore* object_store = isolate->object_store(); | 462 ObjectStore* object_store = isolate->object_store(); |
| 450 | 463 |
| 451 Class& cls = Class::Handle(); | 464 Class& cls = Class::Handle(); |
| 452 Type& type = Type::Handle(); | 465 Type& type = Type::Handle(); |
| 453 Array& array = Array::Handle(); | 466 Array& array = Array::Handle(); |
| 454 | 467 |
| 455 // All RawArray fields will be initialized to an empty array, therefore | 468 // All RawArray fields will be initialized to an empty array, therefore |
| 456 // initialize array class first. | 469 // initialize array class first. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 // Super type set below, after Object is allocated. | 601 // Super type set below, after Object is allocated. |
| 589 | 602 |
| 590 cls = Class::New<JSRegExp>(); | 603 cls = Class::New<JSRegExp>(); |
| 591 object_store->set_jsregexp_class(cls); | 604 object_store->set_jsregexp_class(cls); |
| 592 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); | 605 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); |
| 593 pending_classes.Add(cls, Heap::kOld); | 606 pending_classes.Add(cls, Heap::kOld); |
| 594 | 607 |
| 595 // Initialize the base interfaces used by the core VM classes. | 608 // Initialize the base interfaces used by the core VM classes. |
| 596 const Script& script = Script::Handle(Bootstrap::LoadScript()); | 609 const Script& script = Script::Handle(Bootstrap::LoadScript()); |
| 597 | 610 |
| 598 // Allocate and initialize the Object class and type. | 611 // Allocate and initialize the Object class and type. The Object |
| 599 // The Object and ExternalByteArray classes are the only pre-allocated | 612 // class and ByteArray subclasses are the only pre-allocated, |
| 600 // non-interface classes in the core library. | 613 // non-interface classes in the core library. |
| 601 cls = Class::New<Instance>(); | 614 cls = Class::New<Instance>(); |
| 602 object_store->set_object_class(cls); | 615 object_store->set_object_class(cls); |
| 603 cls.set_name(String::Handle(String::NewSymbol("Object"))); | 616 cls.set_name(String::Handle(String::NewSymbol("Object"))); |
| 604 cls.set_script(script); | 617 cls.set_script(script); |
| 605 cls.set_class_state(RawClass::kPreFinalized); | 618 cls.set_class_state(RawClass::kPreFinalized); |
| 606 core_lib.AddClass(cls); | 619 core_lib.AddClass(cls); |
| 607 pending_classes.Add(cls, Heap::kOld); | 620 pending_classes.Add(cls, Heap::kOld); |
| 608 type = Type::NewNonParameterizedType(cls); | 621 type = Type::NewNonParameterizedType(cls); |
| 609 object_store->set_object_type(type); | 622 object_store->set_object_type(type); |
| 610 | 623 |
| 611 cls = Class::New<InternalByteArray>(); | 624 cls = Class::New<Int8Array>(); |
| 612 object_store->set_internal_byte_array_class(cls); | 625 object_store->set_int8_array_class(cls); |
| 613 String& public_class_name = String::Handle(); | 626 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); |
| 614 public_class_name = String::New("_InternalByteArray"); | 627 // String& public_class_name = String::Handle(); |
|
Ivan Posva
2012/05/03 05:53:19
Comments?
cshapiro
2012/05/04 04:42:04
Sorry, you weren't supposed to see that. Fixed!
| |
| 615 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | 628 // public_class_name = String::New("_Int8Array"); |
| 616 cls.set_script(script); | 629 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); |
| 617 core_lib.AddClass(cls); | 630 // cls.set_script(script); |
| 631 // core_lib.AddClass(cls); | |
| 618 | 632 |
| 619 cls = Class::New<ExternalByteArray>(); | 633 cls = Class::New<Uint8Array>(); |
| 620 object_store->set_external_byte_array_class(cls); | 634 object_store->set_uint8_array_class(cls); |
| 621 public_class_name = String::New("_ExternalByteArray"); | 635 RegisterPrivateClass(cls, "_Uint8Array", script, core_lib); |
| 622 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | 636 // public_class_name = String::New("_Uint8Array"); |
| 623 cls.set_script(script); | 637 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); |
| 624 core_lib.AddClass(cls); | 638 // cls.set_script(script); |
| 639 // core_lib.AddClass(cls); | |
| 640 | |
| 641 cls = Class::New<Int16Array>(); | |
| 642 object_store->set_int16_array_class(cls); | |
| 643 RegisterPrivateClass(cls, "_Int16Array", script, core_lib); | |
| 644 // public_class_name = String::New("_Int16Array"); | |
| 645 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 646 // cls.set_script(script); | |
| 647 // core_lib.AddClass(cls); | |
| 648 | |
| 649 cls = Class::New<Uint16Array>(); | |
| 650 object_store->set_uint16_array_class(cls); | |
| 651 RegisterPrivateClass(cls, "_Uint16Array", script, core_lib); | |
| 652 // public_class_name = String::New("_Uint16Array"); | |
| 653 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 654 // cls.set_script(script); | |
| 655 // core_lib.AddClass(cls); | |
| 656 | |
| 657 cls = Class::New<Int32Array>(); | |
| 658 object_store->set_int32_array_class(cls); | |
| 659 RegisterPrivateClass(cls, "_Int32Array", script, core_lib); | |
| 660 // public_class_name = String::New("_Int32Array"); | |
| 661 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 662 // cls.set_script(script); | |
| 663 // core_lib.AddClass(cls); | |
| 664 | |
| 665 cls = Class::New<Uint32Array>(); | |
| 666 object_store->set_uint32_array_class(cls); | |
| 667 RegisterPrivateClass(cls, "_Uint32Array", script, core_lib); | |
| 668 // public_class_name = String::New("_Uint32Array"); | |
| 669 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 670 // cls.set_script(script); | |
| 671 // core_lib.AddClass(cls); | |
| 672 | |
| 673 cls = Class::New<Int64Array>(); | |
| 674 object_store->set_int64_array_class(cls); | |
| 675 RegisterPrivateClass(cls, "_Int64Array", script, core_lib); | |
| 676 // public_class_name = String::New("_Int64Array"); | |
| 677 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 678 // cls.set_script(script); | |
| 679 // core_lib.AddClass(cls); | |
| 680 | |
| 681 cls = Class::New<Uint64Array>(); | |
| 682 object_store->set_uint64_array_class(cls); | |
| 683 RegisterPrivateClass(cls, "_Uint64Array", script, core_lib); | |
| 684 // public_class_name = String::New("_Uint64Array"); | |
| 685 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 686 // cls.set_script(script); | |
| 687 // core_lib.AddClass(cls); | |
| 688 | |
| 689 cls = Class::New<Float32Array>(); | |
| 690 object_store->set_float32_array_class(cls); | |
| 691 RegisterPrivateClass(cls, "_Float32Array", script, core_lib); | |
| 692 // public_class_name = String::New("_Float32Array"); | |
| 693 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 694 // cls.set_script(script); | |
| 695 // core_lib.AddClass(cls); | |
| 696 | |
| 697 cls = Class::New<Float64Array>(); | |
| 698 object_store->set_float64_array_class(cls); | |
| 699 RegisterPrivateClass(cls, "_Float64Array", script, core_lib); | |
| 700 // public_class_name = String::New("_Float64Array"); | |
| 701 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 702 // cls.set_script(script); | |
| 703 // core_lib.AddClass(cls); | |
| 704 | |
| 705 cls = Class::New<ExternalInt8Array>(); | |
| 706 object_store->set_external_int8_array_class(cls); | |
| 707 RegisterPrivateClass(cls, "_ExternalInt8Array", script, core_lib); | |
| 708 // public_class_name = String::New("_ExternalInt8Array"); | |
| 709 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 710 // cls.set_script(script); | |
| 711 // core_lib.AddClass(cls); | |
| 712 | |
| 713 cls = Class::New<ExternalUint8Array>(); | |
| 714 object_store->set_external_uint8_array_class(cls); | |
| 715 RegisterPrivateClass(cls, "_ExternalUint8Array", script, core_lib); | |
| 716 // public_class_name = String::New("_ExternalUint8Array"); | |
| 717 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 718 // cls.set_script(script); | |
| 719 // core_lib.AddClass(cls); | |
| 720 | |
| 721 cls = Class::New<ExternalInt16Array>(); | |
| 722 object_store->set_external_int16_array_class(cls); | |
| 723 RegisterPrivateClass(cls, "_ExternalInt16Array", script, core_lib); | |
| 724 // public_class_name = String::New("_ExternalInt16Array"); | |
| 725 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 726 // cls.set_script(script); | |
| 727 // core_lib.AddClass(cls); | |
| 728 | |
| 729 cls = Class::New<ExternalUint16Array>(); | |
| 730 object_store->set_external_uint16_array_class(cls); | |
| 731 RegisterPrivateClass(cls, "_ExternalUint16Array", script, core_lib); | |
| 732 // public_class_name = String::New("_ExternalUint16Array"); | |
| 733 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 734 // cls.set_script(script); | |
| 735 // core_lib.AddClass(cls); | |
| 736 | |
| 737 cls = Class::New<ExternalInt32Array>(); | |
| 738 object_store->set_external_int32_array_class(cls); | |
| 739 RegisterPrivateClass(cls, "_ExternalInt32Array", script, core_lib); | |
| 740 // public_class_name = String::New("_ExternalInt32Array"); | |
| 741 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 742 // cls.set_script(script); | |
| 743 // core_lib.AddClass(cls); | |
| 744 | |
| 745 cls = Class::New<ExternalUint32Array>(); | |
| 746 object_store->set_external_uint32_array_class(cls); | |
| 747 RegisterPrivateClass(cls, "_ExternalUint32Array", script, core_lib); | |
| 748 // public_class_name = String::New("_ExternalUint32Array"); | |
| 749 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 750 // cls.set_script(script); | |
| 751 // core_lib.AddClass(cls); | |
| 752 | |
| 753 cls = Class::New<ExternalInt64Array>(); | |
| 754 object_store->set_external_int64_array_class(cls); | |
| 755 RegisterPrivateClass(cls, "_ExternalInt64Array", script, core_lib); | |
| 756 // public_class_name = String::New("_ExternalInt64Array"); | |
| 757 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 758 // cls.set_script(script); | |
| 759 // core_lib.AddClass(cls); | |
| 760 | |
| 761 cls = Class::New<ExternalUint64Array>(); | |
| 762 object_store->set_external_uint64_array_class(cls); | |
| 763 RegisterPrivateClass(cls, "_ExternalUint64Array", script, core_lib); | |
| 764 // public_class_name = String::New("_ExternalUint64Array"); | |
| 765 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 766 // cls.set_script(script); | |
| 767 // core_lib.AddClass(cls); | |
| 768 | |
| 769 cls = Class::New<ExternalFloat32Array>(); | |
| 770 object_store->set_external_float32_array_class(cls); | |
| 771 RegisterPrivateClass(cls, "_ExternalFloat32Array", script, core_lib); | |
| 772 // public_class_name = String::New("_ExternalFloat32Array"); | |
| 773 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 774 // cls.set_script(script); | |
| 775 // core_lib.AddClass(cls); | |
| 776 | |
| 777 cls = Class::New<ExternalFloat64Array>(); | |
| 778 object_store->set_external_float64_array_class(cls); | |
| 779 RegisterPrivateClass(cls, "_ExternalFloat64Array", script, core_lib); | |
| 780 // public_class_name = String::New("_ExternalFloat64Array"); | |
| 781 // cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); | |
| 782 // cls.set_script(script); | |
| 783 // core_lib.AddClass(cls); | |
| 625 | 784 |
| 626 // Set the super type of class Stacktrace to Object type so that the | 785 // Set the super type of class Stacktrace to Object type so that the |
| 627 // 'toString' method is implemented. | 786 // 'toString' method is implemented. |
| 628 cls = object_store->stacktrace_class(); | 787 cls = object_store->stacktrace_class(); |
| 629 cls.set_super_type(type); | 788 cls.set_super_type(type); |
| 630 | 789 |
| 631 cls = CreateAndRegisterInterface("Function", script, core_lib); | 790 cls = CreateAndRegisterInterface("Function", script, core_lib); |
| 632 pending_classes.Add(cls, Heap::kOld); | 791 pending_classes.Add(cls, Heap::kOld); |
| 633 type = Type::NewNonParameterizedType(cls); | 792 type = Type::NewNonParameterizedType(cls); |
| 634 object_store->set_function_interface(type); | 793 object_store->set_function_interface(type); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 Array& empty_array = Array::Handle(); | 914 Array& empty_array = Array::Handle(); |
| 756 empty_array = Array::New(0); | 915 empty_array = Array::New(0); |
| 757 object_store->set_empty_array(empty_array); | 916 object_store->set_empty_array(empty_array); |
| 758 | 917 |
| 759 cls = Class::New<ImmutableArray>(); | 918 cls = Class::New<ImmutableArray>(); |
| 760 object_store->set_immutable_array_class(cls); | 919 object_store->set_immutable_array_class(cls); |
| 761 | 920 |
| 762 cls = Class::New<GrowableObjectArray>(); | 921 cls = Class::New<GrowableObjectArray>(); |
| 763 object_store->set_growable_object_array_class(cls); | 922 object_store->set_growable_object_array_class(cls); |
| 764 | 923 |
| 765 cls = Class::New<InternalByteArray>(); | 924 cls = Class::New<Int8Array>(); |
| 766 object_store->set_internal_byte_array_class(cls); | 925 object_store->set_int8_array_class(cls); |
| 767 | 926 |
| 768 cls = Class::New<ExternalByteArray>(); | 927 cls = Class::New<Uint8Array>(); |
| 769 object_store->set_external_byte_array_class(cls); | 928 object_store->set_uint8_array_class(cls); |
| 929 | |
| 930 cls = Class::New<Int16Array>(); | |
| 931 object_store->set_int16_array_class(cls); | |
| 932 | |
| 933 cls = Class::New<Uint16Array>(); | |
| 934 object_store->set_uint16_array_class(cls); | |
| 935 | |
| 936 cls = Class::New<Int32Array>(); | |
| 937 object_store->set_int32_array_class(cls); | |
| 938 | |
| 939 cls = Class::New<Uint32Array>(); | |
| 940 object_store->set_uint32_array_class(cls); | |
| 941 | |
| 942 cls = Class::New<Int64Array>(); | |
| 943 object_store->set_int64_array_class(cls); | |
| 944 | |
| 945 cls = Class::New<Uint64Array>(); | |
| 946 object_store->set_uint64_array_class(cls); | |
| 947 | |
| 948 cls = Class::New<Float32Array>(); | |
| 949 object_store->set_float32_array_class(cls); | |
| 950 | |
| 951 cls = Class::New<Float64Array>(); | |
| 952 object_store->set_float64_array_class(cls); | |
| 953 | |
| 954 cls = Class::New<ExternalInt8Array>(); | |
| 955 object_store->set_external_int8_array_class(cls); | |
| 956 | |
| 957 cls = Class::New<ExternalUint8Array>(); | |
| 958 object_store->set_external_uint8_array_class(cls); | |
| 959 | |
| 960 cls = Class::New<ExternalInt16Array>(); | |
| 961 object_store->set_external_int16_array_class(cls); | |
| 962 | |
| 963 cls = Class::New<ExternalUint16Array>(); | |
| 964 object_store->set_external_uint16_array_class(cls); | |
| 965 | |
| 966 cls = Class::New<ExternalInt32Array>(); | |
| 967 object_store->set_external_int32_array_class(cls); | |
| 968 | |
| 969 cls = Class::New<ExternalUint32Array>(); | |
| 970 object_store->set_external_uint32_array_class(cls); | |
| 971 | |
| 972 cls = Class::New<ExternalInt64Array>(); | |
| 973 object_store->set_external_int64_array_class(cls); | |
| 974 | |
| 975 cls = Class::New<ExternalUint64Array>(); | |
| 976 object_store->set_external_uint64_array_class(cls); | |
| 977 | |
| 978 cls = Class::New<ExternalFloat32Array>(); | |
| 979 object_store->set_external_float32_array_class(cls); | |
| 980 | |
| 981 cls = Class::New<ExternalFloat64Array>(); | |
| 982 object_store->set_external_float64_array_class(cls); | |
| 770 | 983 |
| 771 cls = Class::New<Smi>(); | 984 cls = Class::New<Smi>(); |
| 772 object_store->set_smi_class(cls); | 985 object_store->set_smi_class(cls); |
| 773 | 986 |
| 774 cls = Class::New<Mint>(); | 987 cls = Class::New<Mint>(); |
| 775 object_store->set_mint_class(cls); | 988 object_store->set_mint_class(cls); |
| 776 | 989 |
| 777 cls = Class::New<Double>(); | 990 cls = Class::New<Double>(); |
| 778 object_store->set_double_class(cls); | 991 object_store->set_double_class(cls); |
| 779 | 992 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 // TODO(srdjan): Make functions_cache growable and start with a smaller size. | 1160 // TODO(srdjan): Make functions_cache growable and start with a smaller size. |
| 948 Array& fcache = | 1161 Array& fcache = |
| 949 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld)); | 1162 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld)); |
| 950 StorePointer(&raw_ptr()->functions_cache_, fcache.raw()); | 1163 StorePointer(&raw_ptr()->functions_cache_, fcache.raw()); |
| 951 StorePointer(&raw_ptr()->constants_, empty_array.raw()); | 1164 StorePointer(&raw_ptr()->constants_, empty_array.raw()); |
| 952 StorePointer(&raw_ptr()->canonical_types_, empty_array.raw()); | 1165 StorePointer(&raw_ptr()->canonical_types_, empty_array.raw()); |
| 953 StorePointer(&raw_ptr()->functions_, empty_array.raw()); | 1166 StorePointer(&raw_ptr()->functions_, empty_array.raw()); |
| 954 StorePointer(&raw_ptr()->fields_, empty_array.raw()); | 1167 StorePointer(&raw_ptr()->fields_, empty_array.raw()); |
| 955 } | 1168 } |
| 956 | 1169 |
| 1170 | |
| 1171 bool Class::HasInstanceFields() const { | |
| 1172 const Array& field_array = Array::Handle(fields()); | |
| 1173 Field& field = Field::Handle(); | |
| 1174 for (intptr_t i = 0; i < field_array.Length(); ++i) { | |
| 1175 field ^= field_array.At(i); | |
| 1176 if (!field.is_static()) { | |
| 1177 return true; | |
| 1178 } | |
| 1179 } | |
| 1180 return false; | |
| 1181 } | |
| 1182 | |
| 957 void Class::SetFunctions(const Array& value) const { | 1183 void Class::SetFunctions(const Array& value) const { |
| 958 ASSERT(!value.IsNull()); | 1184 ASSERT(!value.IsNull()); |
| 959 // Bind all the functions in the array to this class. | 1185 // Bind all the functions in the array to this class. |
| 960 Function& func = Function::Handle(); | 1186 Function& func = Function::Handle(); |
| 961 intptr_t len = value.Length(); | 1187 intptr_t len = value.Length(); |
| 962 for (intptr_t i = 0; i < len; i++) { | 1188 for (intptr_t i = 0; i < len; i++) { |
| 963 func ^= value.At(i); | 1189 func ^= value.At(i); |
| 964 func.set_owner(*this); | 1190 func.set_owner(*this); |
| 965 } | 1191 } |
| 966 StorePointer(&raw_ptr()->functions_, value.raw()); | 1192 StorePointer(&raw_ptr()->functions_, value.raw()); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1377 return object_store->bool_class(); | 1603 return object_store->bool_class(); |
| 1378 case kArray: | 1604 case kArray: |
| 1379 ASSERT(object_store->array_class() != Class::null()); | 1605 ASSERT(object_store->array_class() != Class::null()); |
| 1380 return object_store->array_class(); | 1606 return object_store->array_class(); |
| 1381 case kImmutableArray: | 1607 case kImmutableArray: |
| 1382 ASSERT(object_store->immutable_array_class() != Class::null()); | 1608 ASSERT(object_store->immutable_array_class() != Class::null()); |
| 1383 return object_store->immutable_array_class(); | 1609 return object_store->immutable_array_class(); |
| 1384 case kGrowableObjectArray: | 1610 case kGrowableObjectArray: |
| 1385 ASSERT(object_store->growable_object_array_class() != Class::null()); | 1611 ASSERT(object_store->growable_object_array_class() != Class::null()); |
| 1386 return object_store->growable_object_array_class(); | 1612 return object_store->growable_object_array_class(); |
| 1387 case kInternalByteArray: | 1613 case kInt8Array: |
| 1388 ASSERT(object_store->internal_byte_array_class() != Class::null()); | 1614 ASSERT(object_store->int8_array_class() != Class::null()); |
| 1389 return object_store->internal_byte_array_class(); | 1615 return object_store->int8_array_class(); |
| 1390 case kExternalByteArray: | 1616 case kUint8Array: |
| 1391 ASSERT(object_store->external_byte_array_class() != Class::null()); | 1617 ASSERT(object_store->uint8_array_class() != Class::null()); |
| 1392 return object_store->external_byte_array_class(); | 1618 return object_store->uint8_array_class(); |
| 1619 case kInt16Array: | |
| 1620 ASSERT(object_store->int16_array_class() != Class::null()); | |
| 1621 return object_store->int16_array_class(); | |
| 1622 case kUint16Array: | |
| 1623 ASSERT(object_store->uint16_array_class() != Class::null()); | |
| 1624 return object_store->uint16_array_class(); | |
| 1625 case kInt32Array: | |
| 1626 ASSERT(object_store->int32_array_class() != Class::null()); | |
| 1627 return object_store->int32_array_class(); | |
| 1628 case kUint32Array: | |
| 1629 ASSERT(object_store->uint32_array_class() != Class::null()); | |
| 1630 return object_store->uint32_array_class(); | |
| 1631 case kInt64Array: | |
| 1632 ASSERT(object_store->int64_array_class() != Class::null()); | |
| 1633 return object_store->int64_array_class(); | |
| 1634 case kUint64Array: | |
| 1635 ASSERT(object_store->uint64_array_class() != Class::null()); | |
| 1636 return object_store->uint64_array_class(); | |
| 1637 case kFloat32Array: | |
| 1638 ASSERT(object_store->float32_array_class() != Class::null()); | |
| 1639 return object_store->float32_array_class(); | |
| 1640 case kFloat64Array: | |
| 1641 ASSERT(object_store->float64_array_class() != Class::null()); | |
| 1642 return object_store->float64_array_class(); | |
| 1643 case kExternalInt8Array: | |
| 1644 ASSERT(object_store->external_int8_array_class() != Class::null()); | |
| 1645 return object_store->external_int8_array_class(); | |
| 1646 case kExternalUint8Array: | |
| 1647 ASSERT(object_store->external_uint8_array_class() != Class::null()); | |
| 1648 return object_store->external_uint8_array_class(); | |
| 1649 case kExternalInt16Array: | |
| 1650 ASSERT(object_store->external_int16_array_class() != Class::null()); | |
| 1651 return object_store->external_int16_array_class(); | |
| 1652 case kExternalUint16Array: | |
| 1653 ASSERT(object_store->external_uint16_array_class() != Class::null()); | |
| 1654 return object_store->external_uint16_array_class(); | |
| 1655 case kExternalInt32Array: | |
| 1656 ASSERT(object_store->external_int32_array_class() != Class::null()); | |
| 1657 return object_store->external_int32_array_class(); | |
| 1658 case kExternalUint32Array: | |
| 1659 ASSERT(object_store->external_uint32_array_class() != Class::null()); | |
| 1660 return object_store->external_uint32_array_class(); | |
| 1661 case kExternalInt64Array: | |
| 1662 ASSERT(object_store->external_int64_array_class() != Class::null()); | |
| 1663 return object_store->external_int64_array_class(); | |
| 1664 case kExternalUint64Array: | |
| 1665 ASSERT(object_store->external_uint64_array_class() != Class::null()); | |
| 1666 return object_store->external_uint64_array_class(); | |
| 1667 case kExternalFloat32Array: | |
| 1668 ASSERT(object_store->external_float32_array_class() != Class::null()); | |
| 1669 return object_store->external_float32_array_class(); | |
| 1670 case kExternalFloat64Array: | |
| 1671 ASSERT(object_store->external_float64_array_class() != Class::null()); | |
| 1672 return object_store->external_float64_array_class(); | |
| 1393 case kStacktrace: | 1673 case kStacktrace: |
| 1394 ASSERT(object_store->stacktrace_class() != Class::null()); | 1674 ASSERT(object_store->stacktrace_class() != Class::null()); |
| 1395 return object_store->stacktrace_class(); | 1675 return object_store->stacktrace_class(); |
| 1396 case kJSRegExp: | 1676 case kJSRegExp: |
| 1397 ASSERT(object_store->jsregexp_class() != Class::null()); | 1677 ASSERT(object_store->jsregexp_class() != Class::null()); |
| 1398 return object_store->jsregexp_class(); | 1678 return object_store->jsregexp_class(); |
| 1399 case kClosure: | 1679 case kClosure: |
| 1400 return Class::New<Closure>(); | 1680 return Class::New<Closure>(); |
| 1401 case kInstance: | 1681 case kInstance: |
| 1402 return Class::New<Instance>(); | 1682 return Class::New<Instance>(); |
| (...skipping 7440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8843 } | 9123 } |
| 8844 return result.raw(); | 9124 return result.raw(); |
| 8845 } | 9125 } |
| 8846 | 9126 |
| 8847 | 9127 |
| 8848 const char* GrowableObjectArray::ToCString() const { | 9128 const char* GrowableObjectArray::ToCString() const { |
| 8849 return "GrowableObjectArray"; | 9129 return "GrowableObjectArray"; |
| 8850 } | 9130 } |
| 8851 | 9131 |
| 8852 | 9132 |
| 8853 intptr_t ByteArray::Length() const { | 9133 void ByteArray::Copy(void* dst, |
| 8854 // ByteArray is an abstract class. | |
| 8855 UNREACHABLE(); | |
| 8856 return 0; | |
| 8857 } | |
| 8858 | |
| 8859 | |
| 8860 void ByteArray::Copy(uint8_t* dst, | |
| 8861 const ByteArray& src, | 9134 const ByteArray& src, |
| 8862 intptr_t src_offset, | 9135 intptr_t src_offset, |
| 8863 intptr_t length) { | 9136 intptr_t length) { |
| 8864 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); | 9137 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); |
| 8865 { | 9138 { |
| 8866 NoGCScope no_gc; | 9139 NoGCScope no_gc; |
| 8867 if (length > 0) { | 9140 if (length > 0) { |
| 8868 memmove(dst, src.ByteAddr(src_offset), length); | 9141 memmove(dst, src.ByteAddr(src_offset), length); |
| 8869 } | 9142 } |
| 8870 } | 9143 } |
| 8871 } | 9144 } |
| 8872 | 9145 |
| 8873 | 9146 |
| 8874 void ByteArray::Copy(const ByteArray& dst, | 9147 void ByteArray::Copy(const ByteArray& dst, |
| 8875 intptr_t dst_offset, | 9148 intptr_t dst_offset, |
| 8876 const uint8_t* src, | 9149 const void* src, |
| 8877 intptr_t length) { | 9150 intptr_t length) { |
| 8878 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); | 9151 ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength())); |
| 8879 { | 9152 { |
| 8880 NoGCScope no_gc; | 9153 NoGCScope no_gc; |
| 8881 if (length > 0) { | 9154 if (length > 0) { |
| 8882 memmove(dst.ByteAddr(dst_offset), src, length); | 9155 memmove(dst.ByteAddr(dst_offset), src, length); |
| 8883 } | 9156 } |
| 8884 } | 9157 } |
| 8885 } | 9158 } |
| 8886 | 9159 |
| 8887 | 9160 |
| 8888 void ByteArray::Copy(const ByteArray& dst, | 9161 void ByteArray::Copy(const ByteArray& dst, |
| 8889 intptr_t dst_offset, | 9162 intptr_t dst_offset, |
| 8890 const ByteArray& src, | 9163 const ByteArray& src, |
| 8891 intptr_t src_offset, | 9164 intptr_t src_offset, |
| 8892 intptr_t length) { | 9165 intptr_t length) { |
| 8893 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); | 9166 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); |
| 8894 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); | 9167 ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength())); |
| 8895 { | 9168 { |
| 8896 NoGCScope no_gc; | 9169 NoGCScope no_gc; |
| 8897 if (length > 0) { | 9170 if (length > 0) { |
| 8898 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length); | 9171 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length); |
| 8899 } | 9172 } |
| 8900 } | 9173 } |
| 8901 } | 9174 } |
| 8902 | 9175 |
| 8903 | 9176 |
| 9177 template<typename T> | |
| 9178 static void ExternalByteArrayFinalize(Dart_Handle handle, void* peer) { | |
| 9179 delete reinterpret_cast<ExternalByteArrayData<T>*>(peer); | |
| 9180 DeleteWeakPersistentHandle(handle); | |
| 9181 } | |
| 9182 | |
| 9183 | |
| 9184 template<typename HandleT, typename RawT, typename ElementT> | |
| 9185 RawT* ByteArray::NewExternalImpl(const Class& cls, | |
| 9186 ElementT* data, | |
| 9187 intptr_t len, | |
| 9188 void* peer, | |
| 9189 Dart_PeerFinalizer callback, | |
| 9190 Heap::Space space) { | |
| 9191 HandleT& result = HandleT::Handle(); | |
| 9192 ExternalByteArrayData<ElementT>* external_data = | |
| 9193 new ExternalByteArrayData<ElementT>(data, peer, callback); | |
| 9194 { | |
| 9195 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(), space); | |
| 9196 NoGCScope no_gc; | |
| 9197 result ^= raw; | |
| 9198 result.SetLength(len); | |
| 9199 result.SetExternalData(external_data); | |
| 9200 } | |
| 9201 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>); | |
| 9202 return result.raw(); | |
| 9203 } | |
| 9204 | |
| 9205 | |
| 9206 intptr_t ByteArray::ByteLength() const { | |
| 9207 // ByteArray is an abstract class. | |
| 9208 UNREACHABLE(); | |
| 9209 return 0; | |
| 9210 } | |
| 9211 | |
| 9212 | |
| 8904 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const { | 9213 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const { |
| 8905 // ByteArray is an abstract class. | 9214 // ByteArray is an abstract class. |
| 8906 UNREACHABLE(); | 9215 UNREACHABLE(); |
| 8907 return NULL; | 9216 return NULL; |
| 8908 } | 9217 } |
| 8909 | 9218 |
| 8910 | 9219 |
| 8911 const char* ByteArray::ToCString() const { | 9220 const char* ByteArray::ToCString() const { |
| 8912 // ByteArray is an abstract class. | 9221 // ByteArray is an abstract class. |
| 8913 UNREACHABLE(); | 9222 UNREACHABLE(); |
| 8914 return "ByteArray"; | 9223 return "ByteArray"; |
| 8915 } | 9224 } |
| 8916 | 9225 |
| 8917 | 9226 |
| 8918 RawInternalByteArray* InternalByteArray::New(intptr_t len, | 9227 template<typename HandleT, typename RawT> |
| 8919 Heap::Space space) { | 9228 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { |
| 8920 Isolate* isolate = Isolate::Current(); | 9229 HandleT& result = HandleT::Handle(); |
| 8921 const Class& internal_byte_array_class = | |
| 8922 Class::Handle(isolate->object_store()->internal_byte_array_class()); | |
| 8923 InternalByteArray& result = InternalByteArray::Handle(); | |
| 8924 { | 9230 { |
| 8925 RawObject* raw = Object::Allocate(internal_byte_array_class, | 9231 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); |
| 8926 InternalByteArray::InstanceSize(len), | |
| 8927 space); | |
| 8928 NoGCScope no_gc; | 9232 NoGCScope no_gc; |
| 8929 result ^= raw; | 9233 result ^= raw; |
| 8930 result.SetLength(len); | 9234 result.SetLength(len); |
| 8931 if (len > 0) { | 9235 if (len > 0) { |
| 8932 memset(result.Addr<uint8_t>(0), 0, len); | 9236 memset(result.ByteAddr(0), 0, result.ByteLength()); |
| 8933 } | 9237 } |
| 8934 } | 9238 } |
| 8935 return result.raw(); | 9239 return result.raw(); |
| 8936 } | 9240 } |
| 8937 | 9241 |
| 8938 | 9242 |
| 8939 RawInternalByteArray* InternalByteArray::New(const uint8_t* data, | 9243 template<typename HandleT, typename RawT, typename ElementT> |
| 8940 intptr_t len, | 9244 RawT* ByteArray::NewImpl(const Class& cls, |
| 8941 Heap::Space space) { | 9245 const ElementT* data, |
| 8942 InternalByteArray& result = | 9246 intptr_t len, |
| 8943 InternalByteArray::Handle(InternalByteArray::New(len, space)); | 9247 Heap::Space space) { |
| 9248 HandleT& result = HandleT::Handle(); | |
| 8944 { | 9249 { |
| 9250 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); | |
| 8945 NoGCScope no_gc; | 9251 NoGCScope no_gc; |
| 9252 result ^= raw; | |
| 9253 result.SetLength(len); | |
| 8946 if (len > 0) { | 9254 if (len > 0) { |
| 8947 memmove(result.Addr<uint8_t>(0), data, len); | 9255 memmove(result.ByteAddr(0), data, result.ByteLength()); |
| 8948 } | 9256 } |
| 8949 } | 9257 } |
| 8950 return result.raw(); | 9258 return result.raw(); |
| 8951 } | 9259 } |
| 8952 | 9260 |
| 8953 | 9261 |
| 8954 const char* InternalByteArray::ToCString() const { | 9262 RawInt8Array* Int8Array::New(intptr_t len, Heap::Space space) { |
| 8955 return "_InternalByteArray"; | 9263 Isolate* isolate = Isolate::Current(); |
| 8956 } | 9264 const Class& cls = |
| 8957 | 9265 Class::Handle(isolate->object_store()->int8_array_class()); |
| 8958 | 9266 return NewImpl<Int8Array, RawInt8Array>(cls, len, space); |
| 8959 void ExternalByteArray::Finalize(Dart_Handle handle, void* peer) { | 9267 } |
| 8960 delete reinterpret_cast<ExternalByteArrayData*>(peer); | 9268 |
| 8961 DeleteWeakPersistentHandle(handle); | 9269 |
| 8962 } | 9270 RawInt8Array* Int8Array::New(const int8_t* data, |
| 8963 | 9271 intptr_t len, |
| 8964 | 9272 Heap::Space space) { |
| 8965 RawExternalByteArray* ExternalByteArray::New(uint8_t* data, | 9273 Isolate* isolate = Isolate::Current(); |
| 9274 const Class& cls = | |
| 9275 Class::Handle(isolate->object_store()->int8_array_class()); | |
| 9276 return NewImpl<Int8Array, RawInt8Array>(cls, data, len, space); | |
| 9277 } | |
| 9278 | |
| 9279 | |
| 9280 const char* Int8Array::ToCString() const { | |
| 9281 return "_Int8Array"; | |
| 9282 } | |
| 9283 | |
| 9284 | |
| 9285 RawUint8Array* Uint8Array::New(intptr_t len, Heap::Space space) { | |
| 9286 Isolate* isolate = Isolate::Current(); | |
| 9287 const Class& cls = | |
| 9288 Class::Handle(isolate->object_store()->uint8_array_class()); | |
| 9289 return NewImpl<Uint8Array, RawUint8Array>(cls, len, space); | |
| 9290 } | |
| 9291 | |
| 9292 | |
| 9293 RawUint8Array* Uint8Array::New(const uint8_t* data, | |
| 9294 intptr_t len, | |
| 9295 Heap::Space space) { | |
| 9296 Isolate* isolate = Isolate::Current(); | |
| 9297 const Class& cls = | |
| 9298 Class::Handle(isolate->object_store()->uint8_array_class()); | |
| 9299 return NewImpl<Uint8Array, RawUint8Array>(cls, data, len, space); | |
| 9300 } | |
| 9301 | |
| 9302 | |
| 9303 const char* Uint8Array::ToCString() const { | |
| 9304 return "_Uint8Array"; | |
| 9305 } | |
| 9306 | |
| 9307 | |
| 9308 RawInt16Array* Int16Array::New(intptr_t len, Heap::Space space) { | |
| 9309 Isolate* isolate = Isolate::Current(); | |
| 9310 const Class& cls = | |
| 9311 Class::Handle(isolate->object_store()->int16_array_class()); | |
| 9312 return NewImpl<Int16Array, RawInt16Array>(cls, len, space); | |
| 9313 } | |
| 9314 | |
| 9315 | |
| 9316 RawInt16Array* Int16Array::New(const int16_t* data, | |
| 9317 intptr_t len, | |
| 9318 Heap::Space space) { | |
| 9319 Isolate* isolate = Isolate::Current(); | |
| 9320 const Class& cls = | |
| 9321 Class::Handle(isolate->object_store()->int16_array_class()); | |
| 9322 return NewImpl<Int16Array, RawInt16Array>(cls, data, len, space); | |
| 9323 } | |
| 9324 | |
| 9325 | |
| 9326 const char* Int16Array::ToCString() const { | |
| 9327 return "_Int16Array"; | |
| 9328 } | |
| 9329 | |
| 9330 | |
| 9331 RawUint16Array* Uint16Array::New(intptr_t len, Heap::Space space) { | |
| 9332 Isolate* isolate = Isolate::Current(); | |
| 9333 const Class& cls = | |
| 9334 Class::Handle(isolate->object_store()->uint16_array_class()); | |
| 9335 return NewImpl<Uint16Array, RawUint16Array>(cls, len, space); | |
| 9336 } | |
| 9337 | |
| 9338 | |
| 9339 RawUint16Array* Uint16Array::New(const uint16_t* data, | |
| 9340 intptr_t len, | |
| 9341 Heap::Space space) { | |
| 9342 Isolate* isolate = Isolate::Current(); | |
| 9343 const Class& cls = | |
| 9344 Class::Handle(isolate->object_store()->uint16_array_class()); | |
| 9345 return NewImpl<Uint16Array, RawUint16Array>(cls, data, len, space); | |
| 9346 } | |
| 9347 | |
| 9348 | |
| 9349 const char* Uint16Array::ToCString() const { | |
| 9350 return "_Uint16Array"; | |
| 9351 } | |
| 9352 | |
| 9353 | |
| 9354 RawInt32Array* Int32Array::New(intptr_t len, Heap::Space space) { | |
| 9355 Isolate* isolate = Isolate::Current(); | |
| 9356 const Class& cls = | |
| 9357 Class::Handle(isolate->object_store()->int32_array_class()); | |
| 9358 return NewImpl<Int32Array, RawInt32Array>(cls, len, space); | |
| 9359 } | |
| 9360 | |
| 9361 | |
| 9362 RawInt32Array* Int32Array::New(const int32_t* data, | |
| 9363 intptr_t len, | |
| 9364 Heap::Space space) { | |
| 9365 Isolate* isolate = Isolate::Current(); | |
| 9366 const Class& cls = | |
| 9367 Class::Handle(isolate->object_store()->int32_array_class()); | |
| 9368 return NewImpl<Int32Array, RawInt32Array>(cls, data, len, space); | |
| 9369 } | |
| 9370 | |
| 9371 | |
| 9372 const char* Int32Array::ToCString() const { | |
| 9373 return "_Int32Array"; | |
| 9374 } | |
| 9375 | |
| 9376 | |
| 9377 RawUint32Array* Uint32Array::New(intptr_t len, Heap::Space space) { | |
| 9378 Isolate* isolate = Isolate::Current(); | |
| 9379 const Class& cls = | |
| 9380 Class::Handle(isolate->object_store()->uint32_array_class()); | |
| 9381 return NewImpl<Uint32Array, RawUint32Array>(cls, len, space); | |
| 9382 } | |
| 9383 | |
| 9384 | |
| 9385 RawUint32Array* Uint32Array::New(const uint32_t* data, | |
| 9386 intptr_t len, | |
| 9387 Heap::Space space) { | |
| 9388 Isolate* isolate = Isolate::Current(); | |
| 9389 const Class& cls = | |
| 9390 Class::Handle(isolate->object_store()->uint32_array_class()); | |
| 9391 return NewImpl<Uint32Array, RawUint32Array>(cls, data, len, space); | |
| 9392 } | |
| 9393 | |
| 9394 | |
| 9395 const char* Uint32Array::ToCString() const { | |
| 9396 return "_Uint32Array"; | |
| 9397 } | |
| 9398 | |
| 9399 | |
| 9400 RawInt64Array* Int64Array::New(intptr_t len, Heap::Space space) { | |
| 9401 Isolate* isolate = Isolate::Current(); | |
| 9402 const Class& cls = | |
| 9403 Class::Handle(isolate->object_store()->int64_array_class()); | |
| 9404 return NewImpl<Int64Array, RawInt64Array>(cls, len, space); | |
| 9405 } | |
| 9406 | |
| 9407 | |
| 9408 RawInt64Array* Int64Array::New(const int64_t* data, | |
| 9409 intptr_t len, | |
| 9410 Heap::Space space) { | |
| 9411 Isolate* isolate = Isolate::Current(); | |
| 9412 const Class& cls = | |
| 9413 Class::Handle(isolate->object_store()->int64_array_class()); | |
| 9414 return NewImpl<Int64Array, RawInt64Array>(cls, data, len, space); | |
| 9415 } | |
| 9416 | |
| 9417 | |
| 9418 const char* Int64Array::ToCString() const { | |
| 9419 return "_Int64Array"; | |
| 9420 } | |
| 9421 | |
| 9422 | |
| 9423 RawUint64Array* Uint64Array::New(intptr_t len, Heap::Space space) { | |
| 9424 Isolate* isolate = Isolate::Current(); | |
| 9425 const Class& cls = | |
| 9426 Class::Handle(isolate->object_store()->uint64_array_class()); | |
| 9427 return NewImpl<Uint64Array, RawUint64Array>(cls, len, space); | |
| 9428 } | |
| 9429 | |
| 9430 | |
| 9431 RawUint64Array* Uint64Array::New(const uint64_t* data, | |
| 9432 intptr_t len, | |
| 9433 Heap::Space space) { | |
| 9434 Isolate* isolate = Isolate::Current(); | |
| 9435 const Class& cls = | |
| 9436 Class::Handle(isolate->object_store()->uint64_array_class()); | |
| 9437 return NewImpl<Uint64Array, RawUint64Array>(cls, data, len, space); | |
| 9438 } | |
| 9439 | |
| 9440 | |
| 9441 const char* Uint64Array::ToCString() const { | |
| 9442 return "_Uint64Array"; | |
| 9443 } | |
| 9444 | |
| 9445 | |
| 9446 RawFloat32Array* Float32Array::New(intptr_t len, Heap::Space space) { | |
| 9447 Isolate* isolate = Isolate::Current(); | |
| 9448 const Class& cls = | |
| 9449 Class::Handle(isolate->object_store()->float32_array_class()); | |
| 9450 return NewImpl<Float32Array, RawFloat32Array>(cls, len, space); | |
| 9451 } | |
| 9452 | |
| 9453 | |
| 9454 RawFloat32Array* Float32Array::New(const float* data, | |
| 9455 intptr_t len, | |
| 9456 Heap::Space space) { | |
| 9457 Isolate* isolate = Isolate::Current(); | |
| 9458 const Class& cls = | |
| 9459 Class::Handle(isolate->object_store()->float32_array_class()); | |
| 9460 return NewImpl<Float32Array, RawFloat32Array>(cls, data, len, space); | |
| 9461 } | |
| 9462 | |
| 9463 | |
| 9464 const char* Float32Array::ToCString() const { | |
| 9465 return "_Float32Array"; | |
| 9466 } | |
| 9467 | |
| 9468 | |
| 9469 RawFloat64Array* Float64Array::New(intptr_t len, Heap::Space space) { | |
| 9470 Isolate* isolate = Isolate::Current(); | |
| 9471 const Class& cls = | |
| 9472 Class::Handle(isolate->object_store()->float64_array_class()); | |
| 9473 return NewImpl<Float64Array, RawFloat64Array>(cls, len, space); | |
| 9474 } | |
| 9475 | |
| 9476 | |
| 9477 RawFloat64Array* Float64Array::New(const double* data, | |
| 9478 intptr_t len, | |
| 9479 Heap::Space space) { | |
| 9480 Isolate* isolate = Isolate::Current(); | |
| 9481 const Class& cls = | |
| 9482 Class::Handle(isolate->object_store()->float64_array_class()); | |
| 9483 return NewImpl<Float64Array, RawFloat64Array>(cls, data, len, space); | |
| 9484 } | |
| 9485 | |
| 9486 | |
| 9487 const char* Float64Array::ToCString() const { | |
| 9488 return "_Float64Array"; | |
| 9489 } | |
| 9490 | |
| 9491 | |
| 9492 RawExternalInt8Array* ExternalInt8Array::New(int8_t* data, | |
| 8966 intptr_t len, | 9493 intptr_t len, |
| 8967 void* peer, | 9494 void* peer, |
| 8968 Dart_PeerFinalizer callback, | 9495 Dart_PeerFinalizer callback, |
| 8969 Heap::Space space) { | 9496 Heap::Space space) { |
| 8970 Isolate* isolate = Isolate::Current(); | 9497 Isolate* isolate = Isolate::Current(); |
| 8971 const Class& external_byte_array_class = | 9498 const Class& cls = |
| 8972 Class::Handle(isolate->object_store()->external_byte_array_class()); | 9499 Class::Handle(isolate->object_store()->external_int8_array_class()); |
| 8973 ExternalByteArray& result = ExternalByteArray::Handle(); | 9500 return NewExternalImpl<ExternalInt8Array, RawExternalInt8Array>( |
| 8974 ExternalByteArrayData* external_data = | 9501 cls, data, len, peer, callback, space); |
| 8975 new ExternalByteArrayData(data, peer, callback); | 9502 } |
| 8976 { | 9503 |
| 8977 RawObject* raw = Object::Allocate(external_byte_array_class, | 9504 |
| 8978 ExternalByteArray::InstanceSize(), | 9505 const char* ExternalInt8Array::ToCString() const { |
| 8979 space); | 9506 return "_ExternalInt8Array"; |
| 8980 NoGCScope no_gc; | 9507 } |
| 8981 result ^= raw; | 9508 |
| 8982 result.SetLength(len); | 9509 |
| 8983 result.SetExternalData(external_data); | 9510 RawExternalUint8Array* ExternalUint8Array::New(uint8_t* data, |
| 8984 } | 9511 intptr_t len, |
| 8985 AddFinalizer(result, external_data, ExternalByteArray::Finalize); | 9512 void* peer, |
| 8986 return result.raw(); | 9513 Dart_PeerFinalizer callback, |
| 8987 } | 9514 Heap::Space space) { |
| 8988 | 9515 Isolate* isolate = Isolate::Current(); |
| 8989 | 9516 const Class& cls = |
| 8990 const char* ExternalByteArray::ToCString() const { | 9517 Class::Handle(isolate->object_store()->external_uint8_array_class()); |
| 8991 return "_ExternalByteArray"; | 9518 return NewExternalImpl<ExternalUint8Array, RawExternalUint8Array>( |
| 8992 } | 9519 cls, data, len, peer, callback, space); |
| 9520 } | |
| 9521 | |
| 9522 | |
| 9523 const char* ExternalUint8Array::ToCString() const { | |
| 9524 return "_ExternalUint8Array"; | |
| 9525 } | |
| 9526 | |
| 9527 | |
| 9528 RawExternalInt16Array* ExternalInt16Array::New(int16_t* data, | |
| 9529 intptr_t len, | |
| 9530 void* peer, | |
| 9531 Dart_PeerFinalizer callback, | |
| 9532 Heap::Space space) { | |
| 9533 Isolate* isolate = Isolate::Current(); | |
| 9534 const Class& cls = | |
| 9535 Class::Handle(isolate->object_store()->external_int16_array_class()); | |
| 9536 return NewExternalImpl<ExternalInt16Array, RawExternalInt16Array>( | |
| 9537 cls, data, len, peer, callback, space); | |
| 9538 } | |
| 9539 | |
| 9540 | |
| 9541 const char* ExternalInt16Array::ToCString() const { | |
| 9542 return "_ExternalInt16Array"; | |
| 9543 } | |
| 9544 | |
| 9545 | |
| 9546 RawExternalUint16Array* ExternalUint16Array::New(uint16_t* data, | |
| 9547 intptr_t len, | |
| 9548 void* peer, | |
| 9549 Dart_PeerFinalizer callback, | |
| 9550 Heap::Space space) { | |
| 9551 Isolate* isolate = Isolate::Current(); | |
| 9552 const Class& cls = | |
| 9553 Class::Handle(isolate->object_store()->external_uint16_array_class()); | |
| 9554 return NewExternalImpl<ExternalUint16Array, RawExternalUint16Array>( | |
| 9555 cls, data, len, peer, callback, space); | |
| 9556 } | |
| 9557 | |
| 9558 | |
| 9559 const char* ExternalUint16Array::ToCString() const { | |
| 9560 return "_ExternalUint16Array"; | |
| 9561 } | |
| 9562 | |
| 9563 | |
| 9564 RawExternalInt32Array* ExternalInt32Array::New(int32_t* data, | |
| 9565 intptr_t len, | |
| 9566 void* peer, | |
| 9567 Dart_PeerFinalizer callback, | |
| 9568 Heap::Space space) { | |
| 9569 Isolate* isolate = Isolate::Current(); | |
| 9570 const Class& cls = | |
| 9571 Class::Handle(isolate->object_store()->external_int32_array_class()); | |
| 9572 return NewExternalImpl<ExternalInt32Array, RawExternalInt32Array>( | |
| 9573 cls, data, len, peer, callback, space); | |
| 9574 } | |
| 9575 | |
| 9576 | |
| 9577 const char* ExternalInt32Array::ToCString() const { | |
| 9578 return "_ExternalInt32Array"; | |
| 9579 } | |
| 9580 | |
| 9581 | |
| 9582 RawExternalUint32Array* ExternalUint32Array::New(uint32_t* data, | |
| 9583 intptr_t len, | |
| 9584 void* peer, | |
| 9585 Dart_PeerFinalizer callback, | |
| 9586 Heap::Space space) { | |
| 9587 Isolate* isolate = Isolate::Current(); | |
| 9588 const Class& cls = | |
| 9589 Class::Handle(isolate->object_store()->external_uint32_array_class()); | |
| 9590 return NewExternalImpl<ExternalUint32Array, RawExternalUint32Array>( | |
| 9591 cls, data, len, peer, callback, space); | |
| 9592 } | |
| 9593 | |
| 9594 | |
| 9595 const char* ExternalUint32Array::ToCString() const { | |
| 9596 return "_ExternalUint32Array"; | |
| 9597 } | |
| 9598 | |
| 9599 | |
| 9600 RawExternalInt64Array* ExternalInt64Array::New(int64_t* data, | |
| 9601 intptr_t len, | |
| 9602 void* peer, | |
| 9603 Dart_PeerFinalizer callback, | |
| 9604 Heap::Space space) { | |
| 9605 Isolate* isolate = Isolate::Current(); | |
| 9606 const Class& cls = | |
| 9607 Class::Handle(isolate->object_store()->external_int64_array_class()); | |
| 9608 return NewExternalImpl<ExternalInt64Array, RawExternalInt64Array>( | |
| 9609 cls, data, len, peer, callback, space); | |
| 9610 } | |
| 9611 | |
| 9612 | |
| 9613 const char* ExternalInt64Array::ToCString() const { | |
| 9614 return "_ExternalInt64Array"; | |
| 9615 } | |
| 9616 | |
| 9617 | |
| 9618 RawExternalUint64Array* ExternalUint64Array::New(uint64_t* data, | |
| 9619 intptr_t len, | |
| 9620 void* peer, | |
| 9621 Dart_PeerFinalizer callback, | |
| 9622 Heap::Space space) { | |
| 9623 Isolate* isolate = Isolate::Current(); | |
| 9624 const Class& cls = | |
| 9625 Class::Handle(isolate->object_store()->external_uint64_array_class()); | |
| 9626 return NewExternalImpl<ExternalUint64Array, RawExternalUint64Array>( | |
| 9627 cls, data, len, peer, callback, space); | |
| 9628 } | |
| 9629 | |
| 9630 | |
| 9631 const char* ExternalUint64Array::ToCString() const { | |
| 9632 return "_ExternalUint64Array"; | |
| 9633 } | |
| 9634 | |
| 9635 | |
| 9636 RawExternalFloat32Array* ExternalFloat32Array::New(float* data, | |
| 9637 intptr_t len, | |
| 9638 void* peer, | |
| 9639 Dart_PeerFinalizer callback, | |
| 9640 Heap::Space space) { | |
| 9641 Isolate* isolate = Isolate::Current(); | |
| 9642 const Class& cls = | |
| 9643 Class::Handle(isolate->object_store()->external_float32_array_class()); | |
| 9644 return NewExternalImpl<ExternalFloat32Array, RawExternalFloat32Array>( | |
| 9645 cls, data, len, peer, callback, space); | |
| 9646 } | |
| 9647 | |
| 9648 | |
| 9649 const char* ExternalFloat32Array::ToCString() const { | |
| 9650 return "_ExternalFloat32Array"; | |
| 9651 } | |
| 9652 | |
| 9653 | |
| 9654 RawExternalFloat64Array* ExternalFloat64Array::New(double* data, | |
| 9655 intptr_t len, | |
| 9656 void* peer, | |
| 9657 Dart_PeerFinalizer callback, | |
| 9658 Heap::Space space) { | |
| 9659 Isolate* isolate = Isolate::Current(); | |
| 9660 const Class& cls = | |
| 9661 Class::Handle(isolate->object_store()->external_float64_array_class()); | |
| 9662 return NewExternalImpl<ExternalFloat64Array, RawExternalFloat64Array>( | |
| 9663 cls, data, len, peer, callback, space); | |
| 9664 } | |
| 9665 | |
| 9666 | |
| 9667 const char* ExternalFloat64Array::ToCString() const { | |
| 9668 return "_ExternalFloat64Array"; | |
| 9669 } | |
| 9670 | |
| 8993 | 9671 |
| 8994 | 9672 |
| 8995 RawClosure* Closure::New(const Function& function, | 9673 RawClosure* Closure::New(const Function& function, |
| 8996 const Context& context, | 9674 const Context& context, |
| 8997 Heap::Space space) { | 9675 Heap::Space space) { |
| 8998 Isolate* isolate = Isolate::Current(); | 9676 Isolate* isolate = Isolate::Current(); |
| 8999 ASSERT(context.isolate() == isolate); | 9677 ASSERT(context.isolate() == isolate); |
| 9000 | 9678 |
| 9001 const Class& cls = Class::Handle(function.signature_class()); | 9679 const Class& cls = Class::Handle(function.signature_class()); |
| 9002 Closure& result = Closure::Handle(); | 9680 Closure& result = Closure::Handle(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9304 const String& str = String::Handle(pattern()); | 9982 const String& str = String::Handle(pattern()); |
| 9305 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9983 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9306 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9984 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9307 char* chars = reinterpret_cast<char*>( | 9985 char* chars = reinterpret_cast<char*>( |
| 9308 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9986 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9309 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9987 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9310 return chars; | 9988 return chars; |
| 9311 } | 9989 } |
| 9312 | 9990 |
| 9313 } // namespace dart | 9991 } // namespace dart |
| OLD | NEW |