| 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 const char* cname, | 446 const char* cname, |
| 447 const Script& script, | 447 const Script& script, |
| 448 const Library& lib) { | 448 const Library& lib) { |
| 449 const String& name = String::Handle(String::NewSymbol(cname)); | 449 const String& name = String::Handle(String::NewSymbol(cname)); |
| 450 cls.set_name(name); | 450 cls.set_name(name); |
| 451 cls.set_script(script); | 451 cls.set_script(script); |
| 452 lib.AddClass(cls); | 452 lib.AddClass(cls); |
| 453 } | 453 } |
| 454 | 454 |
| 455 | 455 |
| 456 void Object::RegisterPrivateClass(const Class& cls, | |
| 457 const char* public_class_name, | |
| 458 const Script& script, | |
| 459 const Library& lib) { | |
| 460 String& str = String::Handle(); | |
| 461 str ^= String::NewSymbol(public_class_name); | |
| 462 str ^= lib.PrivateName(str); | |
| 463 cls.set_name(str); | |
| 464 cls.set_script(script); | |
| 465 lib.AddClass(cls); | |
| 466 } | |
| 467 | |
| 468 | |
| 469 RawError* Object::Init(Isolate* isolate) { | 456 RawError* Object::Init(Isolate* isolate) { |
| 470 TIMERSCOPE(time_bootstrap); | 457 TIMERSCOPE(time_bootstrap); |
| 471 ObjectStore* object_store = isolate->object_store(); | 458 ObjectStore* object_store = isolate->object_store(); |
| 472 | 459 |
| 473 Class& cls = Class::Handle(); | 460 Class& cls = Class::Handle(); |
| 474 Type& type = Type::Handle(); | 461 Type& type = Type::Handle(); |
| 475 Array& array = Array::Handle(); | 462 Array& array = Array::Handle(); |
| 476 | 463 |
| 477 // All RawArray fields will be initialized to an empty array, therefore | 464 // All RawArray fields will be initialized to an empty array, therefore |
| 478 // initialize array class first. | 465 // initialize array class first. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 // Super type set below, after Object is allocated. | 597 // Super type set below, after Object is allocated. |
| 611 | 598 |
| 612 cls = Class::New<JSRegExp>(); | 599 cls = Class::New<JSRegExp>(); |
| 613 object_store->set_jsregexp_class(cls); | 600 object_store->set_jsregexp_class(cls); |
| 614 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); | 601 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); |
| 615 pending_classes.Add(cls, Heap::kOld); | 602 pending_classes.Add(cls, Heap::kOld); |
| 616 | 603 |
| 617 // Initialize the base interfaces used by the core VM classes. | 604 // Initialize the base interfaces used by the core VM classes. |
| 618 const Script& script = Script::Handle(Bootstrap::LoadScript()); | 605 const Script& script = Script::Handle(Bootstrap::LoadScript()); |
| 619 | 606 |
| 620 // Allocate and initialize the Object class and type. The Object | 607 // Allocate and initialize the Object class and type. |
| 621 // class and ByteArray subclasses are the only pre-allocated, | 608 // The Object and ExternalByteArray classes are the only pre-allocated |
| 622 // non-interface classes in the core library. | 609 // non-interface classes in the core library. |
| 623 cls = Class::New<Instance>(); | 610 cls = Class::New<Instance>(); |
| 624 object_store->set_object_class(cls); | 611 object_store->set_object_class(cls); |
| 625 cls.set_name(String::Handle(String::NewSymbol("Object"))); | 612 cls.set_name(String::Handle(String::NewSymbol("Object"))); |
| 626 cls.set_script(script); | 613 cls.set_script(script); |
| 627 cls.set_class_state(RawClass::kPreFinalized); | 614 cls.set_class_state(RawClass::kPreFinalized); |
| 628 core_lib.AddClass(cls); | 615 core_lib.AddClass(cls); |
| 629 pending_classes.Add(cls, Heap::kOld); | 616 pending_classes.Add(cls, Heap::kOld); |
| 630 type = Type::NewNonParameterizedType(cls); | 617 type = Type::NewNonParameterizedType(cls); |
| 631 object_store->set_object_type(type); | 618 object_store->set_object_type(type); |
| 632 | 619 |
| 633 cls = Class::New<Int8Array>(); | 620 cls = Class::New<InternalByteArray>(); |
| 634 object_store->set_int8_array_class(cls); | 621 object_store->set_internal_byte_array_class(cls); |
| 635 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); | 622 String& public_class_name = String::Handle(); |
| 623 public_class_name = String::New("_InternalByteArray"); |
| 624 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); |
| 625 cls.set_script(script); |
| 626 core_lib.AddClass(cls); |
| 636 | 627 |
| 637 cls = Class::New<Uint8Array>(); | 628 cls = Class::New<ExternalByteArray>(); |
| 638 object_store->set_uint8_array_class(cls); | 629 object_store->set_external_byte_array_class(cls); |
| 639 RegisterPrivateClass(cls, "_Uint8Array", script, core_lib); | 630 public_class_name = String::New("_ExternalByteArray"); |
| 640 | 631 cls.set_name(String::Handle(core_lib.PrivateName(public_class_name))); |
| 641 cls = Class::New<Int16Array>(); | 632 cls.set_script(script); |
| 642 object_store->set_int16_array_class(cls); | 633 core_lib.AddClass(cls); |
| 643 RegisterPrivateClass(cls, "_Int16Array", script, core_lib); | |
| 644 | |
| 645 cls = Class::New<Uint16Array>(); | |
| 646 object_store->set_uint16_array_class(cls); | |
| 647 RegisterPrivateClass(cls, "_Uint16Array", script, core_lib); | |
| 648 | |
| 649 cls = Class::New<Int32Array>(); | |
| 650 object_store->set_int32_array_class(cls); | |
| 651 RegisterPrivateClass(cls, "_Int32Array", script, core_lib); | |
| 652 | |
| 653 cls = Class::New<Uint32Array>(); | |
| 654 object_store->set_uint32_array_class(cls); | |
| 655 RegisterPrivateClass(cls, "_Uint32Array", script, core_lib); | |
| 656 | |
| 657 cls = Class::New<Int64Array>(); | |
| 658 object_store->set_int64_array_class(cls); | |
| 659 RegisterPrivateClass(cls, "_Int64Array", script, core_lib); | |
| 660 | |
| 661 cls = Class::New<Uint64Array>(); | |
| 662 object_store->set_uint64_array_class(cls); | |
| 663 RegisterPrivateClass(cls, "_Uint64Array", script, core_lib); | |
| 664 | |
| 665 cls = Class::New<Float32Array>(); | |
| 666 object_store->set_float32_array_class(cls); | |
| 667 RegisterPrivateClass(cls, "_Float32Array", script, core_lib); | |
| 668 | |
| 669 cls = Class::New<Float64Array>(); | |
| 670 object_store->set_float64_array_class(cls); | |
| 671 RegisterPrivateClass(cls, "_Float64Array", script, core_lib); | |
| 672 | |
| 673 cls = Class::New<ExternalInt8Array>(); | |
| 674 object_store->set_external_int8_array_class(cls); | |
| 675 RegisterPrivateClass(cls, "_ExternalInt8Array", script, core_lib); | |
| 676 | |
| 677 cls = Class::New<ExternalUint8Array>(); | |
| 678 object_store->set_external_uint8_array_class(cls); | |
| 679 RegisterPrivateClass(cls, "_ExternalUint8Array", script, core_lib); | |
| 680 | |
| 681 cls = Class::New<ExternalInt16Array>(); | |
| 682 object_store->set_external_int16_array_class(cls); | |
| 683 RegisterPrivateClass(cls, "_ExternalInt16Array", script, core_lib); | |
| 684 | |
| 685 cls = Class::New<ExternalUint16Array>(); | |
| 686 object_store->set_external_uint16_array_class(cls); | |
| 687 RegisterPrivateClass(cls, "_ExternalUint16Array", script, core_lib); | |
| 688 | |
| 689 cls = Class::New<ExternalInt32Array>(); | |
| 690 object_store->set_external_int32_array_class(cls); | |
| 691 RegisterPrivateClass(cls, "_ExternalInt32Array", script, core_lib); | |
| 692 | |
| 693 cls = Class::New<ExternalUint32Array>(); | |
| 694 object_store->set_external_uint32_array_class(cls); | |
| 695 RegisterPrivateClass(cls, "_ExternalUint32Array", script, core_lib); | |
| 696 | |
| 697 cls = Class::New<ExternalInt64Array>(); | |
| 698 object_store->set_external_int64_array_class(cls); | |
| 699 RegisterPrivateClass(cls, "_ExternalInt64Array", script, core_lib); | |
| 700 | |
| 701 cls = Class::New<ExternalUint64Array>(); | |
| 702 object_store->set_external_uint64_array_class(cls); | |
| 703 RegisterPrivateClass(cls, "_ExternalUint64Array", script, core_lib); | |
| 704 | |
| 705 cls = Class::New<ExternalFloat32Array>(); | |
| 706 object_store->set_external_float32_array_class(cls); | |
| 707 RegisterPrivateClass(cls, "_ExternalFloat32Array", script, core_lib); | |
| 708 | |
| 709 cls = Class::New<ExternalFloat64Array>(); | |
| 710 object_store->set_external_float64_array_class(cls); | |
| 711 RegisterPrivateClass(cls, "_ExternalFloat64Array", script, core_lib); | |
| 712 | 634 |
| 713 // Set the super type of class Stacktrace to Object type so that the | 635 // Set the super type of class Stacktrace to Object type so that the |
| 714 // 'toString' method is implemented. | 636 // 'toString' method is implemented. |
| 715 cls = object_store->stacktrace_class(); | 637 cls = object_store->stacktrace_class(); |
| 716 cls.set_super_type(type); | 638 cls.set_super_type(type); |
| 717 | 639 |
| 718 cls = CreateAndRegisterInterface("Function", script, core_lib); | 640 cls = CreateAndRegisterInterface("Function", script, core_lib); |
| 719 pending_classes.Add(cls, Heap::kOld); | 641 pending_classes.Add(cls, Heap::kOld); |
| 720 type = Type::NewNonParameterizedType(cls); | 642 type = Type::NewNonParameterizedType(cls); |
| 721 object_store->set_function_interface(type); | 643 object_store->set_function_interface(type); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 Array& empty_array = Array::Handle(); | 764 Array& empty_array = Array::Handle(); |
| 843 empty_array = Array::New(0); | 765 empty_array = Array::New(0); |
| 844 object_store->set_empty_array(empty_array); | 766 object_store->set_empty_array(empty_array); |
| 845 | 767 |
| 846 cls = Class::New<ImmutableArray>(); | 768 cls = Class::New<ImmutableArray>(); |
| 847 object_store->set_immutable_array_class(cls); | 769 object_store->set_immutable_array_class(cls); |
| 848 | 770 |
| 849 cls = Class::New<GrowableObjectArray>(); | 771 cls = Class::New<GrowableObjectArray>(); |
| 850 object_store->set_growable_object_array_class(cls); | 772 object_store->set_growable_object_array_class(cls); |
| 851 | 773 |
| 852 cls = Class::New<Int8Array>(); | 774 cls = Class::New<InternalByteArray>(); |
| 853 object_store->set_int8_array_class(cls); | 775 object_store->set_internal_byte_array_class(cls); |
| 854 | 776 |
| 855 cls = Class::New<Uint8Array>(); | 777 cls = Class::New<ExternalByteArray>(); |
| 856 object_store->set_uint8_array_class(cls); | 778 object_store->set_external_byte_array_class(cls); |
| 857 | |
| 858 cls = Class::New<Int16Array>(); | |
| 859 object_store->set_int16_array_class(cls); | |
| 860 | |
| 861 cls = Class::New<Uint16Array>(); | |
| 862 object_store->set_uint16_array_class(cls); | |
| 863 | |
| 864 cls = Class::New<Int32Array>(); | |
| 865 object_store->set_int32_array_class(cls); | |
| 866 | |
| 867 cls = Class::New<Uint32Array>(); | |
| 868 object_store->set_uint32_array_class(cls); | |
| 869 | |
| 870 cls = Class::New<Int64Array>(); | |
| 871 object_store->set_int64_array_class(cls); | |
| 872 | |
| 873 cls = Class::New<Uint64Array>(); | |
| 874 object_store->set_uint64_array_class(cls); | |
| 875 | |
| 876 cls = Class::New<Float32Array>(); | |
| 877 object_store->set_float32_array_class(cls); | |
| 878 | |
| 879 cls = Class::New<Float64Array>(); | |
| 880 object_store->set_float64_array_class(cls); | |
| 881 | |
| 882 cls = Class::New<ExternalInt8Array>(); | |
| 883 object_store->set_external_int8_array_class(cls); | |
| 884 | |
| 885 cls = Class::New<ExternalUint8Array>(); | |
| 886 object_store->set_external_uint8_array_class(cls); | |
| 887 | |
| 888 cls = Class::New<ExternalInt16Array>(); | |
| 889 object_store->set_external_int16_array_class(cls); | |
| 890 | |
| 891 cls = Class::New<ExternalUint16Array>(); | |
| 892 object_store->set_external_uint16_array_class(cls); | |
| 893 | |
| 894 cls = Class::New<ExternalInt32Array>(); | |
| 895 object_store->set_external_int32_array_class(cls); | |
| 896 | |
| 897 cls = Class::New<ExternalUint32Array>(); | |
| 898 object_store->set_external_uint32_array_class(cls); | |
| 899 | |
| 900 cls = Class::New<ExternalInt64Array>(); | |
| 901 object_store->set_external_int64_array_class(cls); | |
| 902 | |
| 903 cls = Class::New<ExternalUint64Array>(); | |
| 904 object_store->set_external_uint64_array_class(cls); | |
| 905 | |
| 906 cls = Class::New<ExternalFloat32Array>(); | |
| 907 object_store->set_external_float32_array_class(cls); | |
| 908 | |
| 909 cls = Class::New<ExternalFloat64Array>(); | |
| 910 object_store->set_external_float64_array_class(cls); | |
| 911 | 779 |
| 912 cls = Class::New<Smi>(); | 780 cls = Class::New<Smi>(); |
| 913 object_store->set_smi_class(cls); | 781 object_store->set_smi_class(cls); |
| 914 | 782 |
| 915 cls = Class::New<Mint>(); | 783 cls = Class::New<Mint>(); |
| 916 object_store->set_mint_class(cls); | 784 object_store->set_mint_class(cls); |
| 917 | 785 |
| 918 cls = Class::New<Double>(); | 786 cls = Class::New<Double>(); |
| 919 object_store->set_double_class(cls); | 787 object_store->set_double_class(cls); |
| 920 | 788 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 // TODO(srdjan): Make functions_cache growable and start with a smaller size. | 956 // TODO(srdjan): Make functions_cache growable and start with a smaller size. |
| 1089 Array& fcache = | 957 Array& fcache = |
| 1090 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld)); | 958 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld)); |
| 1091 StorePointer(&raw_ptr()->functions_cache_, fcache.raw()); | 959 StorePointer(&raw_ptr()->functions_cache_, fcache.raw()); |
| 1092 StorePointer(&raw_ptr()->constants_, empty_array.raw()); | 960 StorePointer(&raw_ptr()->constants_, empty_array.raw()); |
| 1093 StorePointer(&raw_ptr()->canonical_types_, empty_array.raw()); | 961 StorePointer(&raw_ptr()->canonical_types_, empty_array.raw()); |
| 1094 StorePointer(&raw_ptr()->functions_, empty_array.raw()); | 962 StorePointer(&raw_ptr()->functions_, empty_array.raw()); |
| 1095 StorePointer(&raw_ptr()->fields_, empty_array.raw()); | 963 StorePointer(&raw_ptr()->fields_, empty_array.raw()); |
| 1096 } | 964 } |
| 1097 | 965 |
| 1098 | |
| 1099 bool Class::HasInstanceFields() const { | |
| 1100 const Array& field_array = Array::Handle(fields()); | |
| 1101 Field& field = Field::Handle(); | |
| 1102 for (intptr_t i = 0; i < field_array.Length(); ++i) { | |
| 1103 field ^= field_array.At(i); | |
| 1104 if (!field.is_static()) { | |
| 1105 return true; | |
| 1106 } | |
| 1107 } | |
| 1108 return false; | |
| 1109 } | |
| 1110 | |
| 1111 void Class::SetFunctions(const Array& value) const { | 966 void Class::SetFunctions(const Array& value) const { |
| 1112 ASSERT(!value.IsNull()); | 967 ASSERT(!value.IsNull()); |
| 1113 // Bind all the functions in the array to this class. | 968 // Bind all the functions in the array to this class. |
| 1114 Function& func = Function::Handle(); | 969 Function& func = Function::Handle(); |
| 1115 intptr_t len = value.Length(); | 970 intptr_t len = value.Length(); |
| 1116 for (intptr_t i = 0; i < len; i++) { | 971 for (intptr_t i = 0; i < len; i++) { |
| 1117 func ^= value.At(i); | 972 func ^= value.At(i); |
| 1118 func.set_owner(*this); | 973 func.set_owner(*this); |
| 1119 } | 974 } |
| 1120 StorePointer(&raw_ptr()->functions_, value.raw()); | 975 StorePointer(&raw_ptr()->functions_, value.raw()); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 return object_store->bool_class(); | 1386 return object_store->bool_class(); |
| 1532 case kArray: | 1387 case kArray: |
| 1533 ASSERT(object_store->array_class() != Class::null()); | 1388 ASSERT(object_store->array_class() != Class::null()); |
| 1534 return object_store->array_class(); | 1389 return object_store->array_class(); |
| 1535 case kImmutableArray: | 1390 case kImmutableArray: |
| 1536 ASSERT(object_store->immutable_array_class() != Class::null()); | 1391 ASSERT(object_store->immutable_array_class() != Class::null()); |
| 1537 return object_store->immutable_array_class(); | 1392 return object_store->immutable_array_class(); |
| 1538 case kGrowableObjectArray: | 1393 case kGrowableObjectArray: |
| 1539 ASSERT(object_store->growable_object_array_class() != Class::null()); | 1394 ASSERT(object_store->growable_object_array_class() != Class::null()); |
| 1540 return object_store->growable_object_array_class(); | 1395 return object_store->growable_object_array_class(); |
| 1541 case kInt8Array: | 1396 case kInternalByteArray: |
| 1542 ASSERT(object_store->int8_array_class() != Class::null()); | 1397 ASSERT(object_store->internal_byte_array_class() != Class::null()); |
| 1543 return object_store->int8_array_class(); | 1398 return object_store->internal_byte_array_class(); |
| 1544 case kUint8Array: | 1399 case kExternalByteArray: |
| 1545 ASSERT(object_store->uint8_array_class() != Class::null()); | 1400 ASSERT(object_store->external_byte_array_class() != Class::null()); |
| 1546 return object_store->uint8_array_class(); | 1401 return object_store->external_byte_array_class(); |
| 1547 case kInt16Array: | |
| 1548 ASSERT(object_store->int16_array_class() != Class::null()); | |
| 1549 return object_store->int16_array_class(); | |
| 1550 case kUint16Array: | |
| 1551 ASSERT(object_store->uint16_array_class() != Class::null()); | |
| 1552 return object_store->uint16_array_class(); | |
| 1553 case kInt32Array: | |
| 1554 ASSERT(object_store->int32_array_class() != Class::null()); | |
| 1555 return object_store->int32_array_class(); | |
| 1556 case kUint32Array: | |
| 1557 ASSERT(object_store->uint32_array_class() != Class::null()); | |
| 1558 return object_store->uint32_array_class(); | |
| 1559 case kInt64Array: | |
| 1560 ASSERT(object_store->int64_array_class() != Class::null()); | |
| 1561 return object_store->int64_array_class(); | |
| 1562 case kUint64Array: | |
| 1563 ASSERT(object_store->uint64_array_class() != Class::null()); | |
| 1564 return object_store->uint64_array_class(); | |
| 1565 case kFloat32Array: | |
| 1566 ASSERT(object_store->float32_array_class() != Class::null()); | |
| 1567 return object_store->float32_array_class(); | |
| 1568 case kFloat64Array: | |
| 1569 ASSERT(object_store->float64_array_class() != Class::null()); | |
| 1570 return object_store->float64_array_class(); | |
| 1571 case kExternalInt8Array: | |
| 1572 ASSERT(object_store->external_int8_array_class() != Class::null()); | |
| 1573 return object_store->external_int8_array_class(); | |
| 1574 case kExternalUint8Array: | |
| 1575 ASSERT(object_store->external_uint8_array_class() != Class::null()); | |
| 1576 return object_store->external_uint8_array_class(); | |
| 1577 case kExternalInt16Array: | |
| 1578 ASSERT(object_store->external_int16_array_class() != Class::null()); | |
| 1579 return object_store->external_int16_array_class(); | |
| 1580 case kExternalUint16Array: | |
| 1581 ASSERT(object_store->external_uint16_array_class() != Class::null()); | |
| 1582 return object_store->external_uint16_array_class(); | |
| 1583 case kExternalInt32Array: | |
| 1584 ASSERT(object_store->external_int32_array_class() != Class::null()); | |
| 1585 return object_store->external_int32_array_class(); | |
| 1586 case kExternalUint32Array: | |
| 1587 ASSERT(object_store->external_uint32_array_class() != Class::null()); | |
| 1588 return object_store->external_uint32_array_class(); | |
| 1589 case kExternalInt64Array: | |
| 1590 ASSERT(object_store->external_int64_array_class() != Class::null()); | |
| 1591 return object_store->external_int64_array_class(); | |
| 1592 case kExternalUint64Array: | |
| 1593 ASSERT(object_store->external_uint64_array_class() != Class::null()); | |
| 1594 return object_store->external_uint64_array_class(); | |
| 1595 case kExternalFloat32Array: | |
| 1596 ASSERT(object_store->external_float32_array_class() != Class::null()); | |
| 1597 return object_store->external_float32_array_class(); | |
| 1598 case kExternalFloat64Array: | |
| 1599 ASSERT(object_store->external_float64_array_class() != Class::null()); | |
| 1600 return object_store->external_float64_array_class(); | |
| 1601 case kStacktrace: | 1402 case kStacktrace: |
| 1602 ASSERT(object_store->stacktrace_class() != Class::null()); | 1403 ASSERT(object_store->stacktrace_class() != Class::null()); |
| 1603 return object_store->stacktrace_class(); | 1404 return object_store->stacktrace_class(); |
| 1604 case kJSRegExp: | 1405 case kJSRegExp: |
| 1605 ASSERT(object_store->jsregexp_class() != Class::null()); | 1406 ASSERT(object_store->jsregexp_class() != Class::null()); |
| 1606 return object_store->jsregexp_class(); | 1407 return object_store->jsregexp_class(); |
| 1607 case kClosure: | 1408 case kClosure: |
| 1608 return Class::New<Closure>(); | 1409 return Class::New<Closure>(); |
| 1609 case kInstance: | 1410 case kInstance: |
| 1610 return Class::New<Instance>(); | 1411 return Class::New<Instance>(); |
| (...skipping 7495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9106 } | 8907 } |
| 9107 return result.raw(); | 8908 return result.raw(); |
| 9108 } | 8909 } |
| 9109 | 8910 |
| 9110 | 8911 |
| 9111 const char* GrowableObjectArray::ToCString() const { | 8912 const char* GrowableObjectArray::ToCString() const { |
| 9112 return "GrowableObjectArray"; | 8913 return "GrowableObjectArray"; |
| 9113 } | 8914 } |
| 9114 | 8915 |
| 9115 | 8916 |
| 9116 void ByteArray::Copy(void* dst, | 8917 intptr_t ByteArray::Length() const { |
| 8918 // ByteArray is an abstract class. |
| 8919 UNREACHABLE(); |
| 8920 return 0; |
| 8921 } |
| 8922 |
| 8923 |
| 8924 void ByteArray::Copy(uint8_t* dst, |
| 9117 const ByteArray& src, | 8925 const ByteArray& src, |
| 9118 intptr_t src_offset, | 8926 intptr_t src_offset, |
| 9119 intptr_t length) { | 8927 intptr_t length) { |
| 9120 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); | 8928 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); |
| 9121 { | 8929 { |
| 9122 NoGCScope no_gc; | 8930 NoGCScope no_gc; |
| 9123 if (length > 0) { | 8931 if (length > 0) { |
| 9124 memmove(dst, src.ByteAddr(src_offset), length); | 8932 memmove(dst, src.ByteAddr(src_offset), length); |
| 9125 } | 8933 } |
| 9126 } | 8934 } |
| 9127 } | 8935 } |
| 9128 | 8936 |
| 9129 | 8937 |
| 9130 void ByteArray::Copy(const ByteArray& dst, | 8938 void ByteArray::Copy(const ByteArray& dst, |
| 9131 intptr_t dst_offset, | 8939 intptr_t dst_offset, |
| 9132 const void* src, | 8940 const uint8_t* src, |
| 9133 intptr_t length) { | 8941 intptr_t length) { |
| 9134 ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength())); | 8942 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); |
| 9135 { | 8943 { |
| 9136 NoGCScope no_gc; | 8944 NoGCScope no_gc; |
| 9137 if (length > 0) { | 8945 if (length > 0) { |
| 9138 memmove(dst.ByteAddr(dst_offset), src, length); | 8946 memmove(dst.ByteAddr(dst_offset), src, length); |
| 9139 } | 8947 } |
| 9140 } | 8948 } |
| 9141 } | 8949 } |
| 9142 | 8950 |
| 9143 | 8951 |
| 9144 void ByteArray::Copy(const ByteArray& dst, | 8952 void ByteArray::Copy(const ByteArray& dst, |
| 9145 intptr_t dst_offset, | 8953 intptr_t dst_offset, |
| 9146 const ByteArray& src, | 8954 const ByteArray& src, |
| 9147 intptr_t src_offset, | 8955 intptr_t src_offset, |
| 9148 intptr_t length) { | 8956 intptr_t length) { |
| 9149 ASSERT(Utils::RangeCheck(src_offset, length, src.ByteLength())); | 8957 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); |
| 9150 ASSERT(Utils::RangeCheck(dst_offset, length, dst.ByteLength())); | 8958 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); |
| 9151 { | 8959 { |
| 9152 NoGCScope no_gc; | 8960 NoGCScope no_gc; |
| 9153 if (length > 0) { | 8961 if (length > 0) { |
| 9154 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length); | 8962 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length); |
| 9155 } | 8963 } |
| 9156 } | 8964 } |
| 9157 } | 8965 } |
| 9158 | 8966 |
| 9159 | 8967 |
| 9160 template<typename T> | |
| 9161 static void ExternalByteArrayFinalize(Dart_Handle handle, void* peer) { | |
| 9162 delete reinterpret_cast<ExternalByteArrayData<T>*>(peer); | |
| 9163 DeleteWeakPersistentHandle(handle); | |
| 9164 } | |
| 9165 | |
| 9166 | |
| 9167 template<typename HandleT, typename RawT, typename ElementT> | |
| 9168 RawT* ByteArray::NewExternalImpl(const Class& cls, | |
| 9169 ElementT* data, | |
| 9170 intptr_t len, | |
| 9171 void* peer, | |
| 9172 Dart_PeerFinalizer callback, | |
| 9173 Heap::Space space) { | |
| 9174 HandleT& result = HandleT::Handle(); | |
| 9175 ExternalByteArrayData<ElementT>* external_data = | |
| 9176 new ExternalByteArrayData<ElementT>(data, peer, callback); | |
| 9177 { | |
| 9178 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(), space); | |
| 9179 NoGCScope no_gc; | |
| 9180 result ^= raw; | |
| 9181 result.SetLength(len); | |
| 9182 result.SetExternalData(external_data); | |
| 9183 } | |
| 9184 AddFinalizer(result, external_data, ExternalByteArrayFinalize<ElementT>); | |
| 9185 return result.raw(); | |
| 9186 } | |
| 9187 | |
| 9188 | |
| 9189 intptr_t ByteArray::ByteLength() const { | |
| 9190 // ByteArray is an abstract class. | |
| 9191 UNREACHABLE(); | |
| 9192 return 0; | |
| 9193 } | |
| 9194 | |
| 9195 | |
| 9196 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const { | 8968 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const { |
| 9197 // ByteArray is an abstract class. | 8969 // ByteArray is an abstract class. |
| 9198 UNREACHABLE(); | 8970 UNREACHABLE(); |
| 9199 return NULL; | 8971 return NULL; |
| 9200 } | 8972 } |
| 9201 | 8973 |
| 9202 | 8974 |
| 9203 const char* ByteArray::ToCString() const { | 8975 const char* ByteArray::ToCString() const { |
| 9204 // ByteArray is an abstract class. | 8976 // ByteArray is an abstract class. |
| 9205 UNREACHABLE(); | 8977 UNREACHABLE(); |
| 9206 return "ByteArray"; | 8978 return "ByteArray"; |
| 9207 } | 8979 } |
| 9208 | 8980 |
| 9209 | 8981 |
| 9210 template<typename HandleT, typename RawT> | 8982 RawInternalByteArray* InternalByteArray::New(intptr_t len, |
| 9211 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { | 8983 Heap::Space space) { |
| 9212 HandleT& result = HandleT::Handle(); | 8984 Isolate* isolate = Isolate::Current(); |
| 8985 const Class& internal_byte_array_class = |
| 8986 Class::Handle(isolate->object_store()->internal_byte_array_class()); |
| 8987 InternalByteArray& result = InternalByteArray::Handle(); |
| 9213 { | 8988 { |
| 9214 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); | 8989 RawObject* raw = Object::Allocate(internal_byte_array_class, |
| 8990 InternalByteArray::InstanceSize(len), |
| 8991 space); |
| 9215 NoGCScope no_gc; | 8992 NoGCScope no_gc; |
| 9216 result ^= raw; | 8993 result ^= raw; |
| 9217 result.SetLength(len); | 8994 result.SetLength(len); |
| 9218 if (len > 0) { | 8995 if (len > 0) { |
| 9219 memset(result.ByteAddr(0), 0, result.ByteLength()); | 8996 memset(result.Addr<uint8_t>(0), 0, len); |
| 9220 } | 8997 } |
| 9221 } | 8998 } |
| 9222 return result.raw(); | 8999 return result.raw(); |
| 9223 } | 9000 } |
| 9224 | 9001 |
| 9225 | 9002 |
| 9226 template<typename HandleT, typename RawT, typename ElementT> | 9003 RawInternalByteArray* InternalByteArray::New(const uint8_t* data, |
| 9227 RawT* ByteArray::NewImpl(const Class& cls, | 9004 intptr_t len, |
| 9228 const ElementT* data, | 9005 Heap::Space space) { |
| 9229 intptr_t len, | 9006 InternalByteArray& result = |
| 9230 Heap::Space space) { | 9007 InternalByteArray::Handle(InternalByteArray::New(len, space)); |
| 9231 HandleT& result = HandleT::Handle(); | |
| 9232 { | 9008 { |
| 9233 RawObject* raw = Object::Allocate(cls, HandleT::InstanceSize(len), space); | |
| 9234 NoGCScope no_gc; | 9009 NoGCScope no_gc; |
| 9235 result ^= raw; | |
| 9236 result.SetLength(len); | |
| 9237 if (len > 0) { | 9010 if (len > 0) { |
| 9238 memmove(result.ByteAddr(0), data, result.ByteLength()); | 9011 memmove(result.Addr<uint8_t>(0), data, len); |
| 9239 } | 9012 } |
| 9240 } | 9013 } |
| 9241 return result.raw(); | 9014 return result.raw(); |
| 9242 } | 9015 } |
| 9243 | 9016 |
| 9244 | 9017 |
| 9245 RawInt8Array* Int8Array::New(intptr_t len, Heap::Space space) { | 9018 const char* InternalByteArray::ToCString() const { |
| 9246 Isolate* isolate = Isolate::Current(); | 9019 return "_InternalByteArray"; |
| 9247 const Class& cls = | |
| 9248 Class::Handle(isolate->object_store()->int8_array_class()); | |
| 9249 return NewImpl<Int8Array, RawInt8Array>(cls, len, space); | |
| 9250 } | 9020 } |
| 9251 | 9021 |
| 9252 | 9022 |
| 9253 RawInt8Array* Int8Array::New(const int8_t* data, | 9023 void ExternalByteArray::Finalize(Dart_Handle handle, void* peer) { |
| 9254 intptr_t len, | 9024 delete reinterpret_cast<ExternalByteArrayData*>(peer); |
| 9255 Heap::Space space) { | 9025 DeleteWeakPersistentHandle(handle); |
| 9256 Isolate* isolate = Isolate::Current(); | |
| 9257 const Class& cls = | |
| 9258 Class::Handle(isolate->object_store()->int8_array_class()); | |
| 9259 return NewImpl<Int8Array, RawInt8Array>(cls, data, len, space); | |
| 9260 } | 9026 } |
| 9261 | 9027 |
| 9262 | 9028 |
| 9263 const char* Int8Array::ToCString() const { | 9029 RawExternalByteArray* ExternalByteArray::New(uint8_t* data, |
| 9264 return "_Int8Array"; | |
| 9265 } | |
| 9266 | |
| 9267 | |
| 9268 RawUint8Array* Uint8Array::New(intptr_t len, Heap::Space space) { | |
| 9269 Isolate* isolate = Isolate::Current(); | |
| 9270 const Class& cls = | |
| 9271 Class::Handle(isolate->object_store()->uint8_array_class()); | |
| 9272 return NewImpl<Uint8Array, RawUint8Array>(cls, len, space); | |
| 9273 } | |
| 9274 | |
| 9275 | |
| 9276 RawUint8Array* Uint8Array::New(const uint8_t* data, | |
| 9277 intptr_t len, | |
| 9278 Heap::Space space) { | |
| 9279 Isolate* isolate = Isolate::Current(); | |
| 9280 const Class& cls = | |
| 9281 Class::Handle(isolate->object_store()->uint8_array_class()); | |
| 9282 return NewImpl<Uint8Array, RawUint8Array>(cls, data, len, space); | |
| 9283 } | |
| 9284 | |
| 9285 | |
| 9286 const char* Uint8Array::ToCString() const { | |
| 9287 return "_Uint8Array"; | |
| 9288 } | |
| 9289 | |
| 9290 | |
| 9291 RawInt16Array* Int16Array::New(intptr_t len, Heap::Space space) { | |
| 9292 Isolate* isolate = Isolate::Current(); | |
| 9293 const Class& cls = | |
| 9294 Class::Handle(isolate->object_store()->int16_array_class()); | |
| 9295 return NewImpl<Int16Array, RawInt16Array>(cls, len, space); | |
| 9296 } | |
| 9297 | |
| 9298 | |
| 9299 RawInt16Array* Int16Array::New(const int16_t* data, | |
| 9300 intptr_t len, | |
| 9301 Heap::Space space) { | |
| 9302 Isolate* isolate = Isolate::Current(); | |
| 9303 const Class& cls = | |
| 9304 Class::Handle(isolate->object_store()->int16_array_class()); | |
| 9305 return NewImpl<Int16Array, RawInt16Array>(cls, data, len, space); | |
| 9306 } | |
| 9307 | |
| 9308 | |
| 9309 const char* Int16Array::ToCString() const { | |
| 9310 return "_Int16Array"; | |
| 9311 } | |
| 9312 | |
| 9313 | |
| 9314 RawUint16Array* Uint16Array::New(intptr_t len, Heap::Space space) { | |
| 9315 Isolate* isolate = Isolate::Current(); | |
| 9316 const Class& cls = | |
| 9317 Class::Handle(isolate->object_store()->uint16_array_class()); | |
| 9318 return NewImpl<Uint16Array, RawUint16Array>(cls, len, space); | |
| 9319 } | |
| 9320 | |
| 9321 | |
| 9322 RawUint16Array* Uint16Array::New(const uint16_t* data, | |
| 9323 intptr_t len, | |
| 9324 Heap::Space space) { | |
| 9325 Isolate* isolate = Isolate::Current(); | |
| 9326 const Class& cls = | |
| 9327 Class::Handle(isolate->object_store()->uint16_array_class()); | |
| 9328 return NewImpl<Uint16Array, RawUint16Array>(cls, data, len, space); | |
| 9329 } | |
| 9330 | |
| 9331 | |
| 9332 const char* Uint16Array::ToCString() const { | |
| 9333 return "_Uint16Array"; | |
| 9334 } | |
| 9335 | |
| 9336 | |
| 9337 RawInt32Array* Int32Array::New(intptr_t len, Heap::Space space) { | |
| 9338 Isolate* isolate = Isolate::Current(); | |
| 9339 const Class& cls = | |
| 9340 Class::Handle(isolate->object_store()->int32_array_class()); | |
| 9341 return NewImpl<Int32Array, RawInt32Array>(cls, len, space); | |
| 9342 } | |
| 9343 | |
| 9344 | |
| 9345 RawInt32Array* Int32Array::New(const int32_t* data, | |
| 9346 intptr_t len, | |
| 9347 Heap::Space space) { | |
| 9348 Isolate* isolate = Isolate::Current(); | |
| 9349 const Class& cls = | |
| 9350 Class::Handle(isolate->object_store()->int32_array_class()); | |
| 9351 return NewImpl<Int32Array, RawInt32Array>(cls, data, len, space); | |
| 9352 } | |
| 9353 | |
| 9354 | |
| 9355 const char* Int32Array::ToCString() const { | |
| 9356 return "_Int32Array"; | |
| 9357 } | |
| 9358 | |
| 9359 | |
| 9360 RawUint32Array* Uint32Array::New(intptr_t len, Heap::Space space) { | |
| 9361 Isolate* isolate = Isolate::Current(); | |
| 9362 const Class& cls = | |
| 9363 Class::Handle(isolate->object_store()->uint32_array_class()); | |
| 9364 return NewImpl<Uint32Array, RawUint32Array>(cls, len, space); | |
| 9365 } | |
| 9366 | |
| 9367 | |
| 9368 RawUint32Array* Uint32Array::New(const uint32_t* data, | |
| 9369 intptr_t len, | |
| 9370 Heap::Space space) { | |
| 9371 Isolate* isolate = Isolate::Current(); | |
| 9372 const Class& cls = | |
| 9373 Class::Handle(isolate->object_store()->uint32_array_class()); | |
| 9374 return NewImpl<Uint32Array, RawUint32Array>(cls, data, len, space); | |
| 9375 } | |
| 9376 | |
| 9377 | |
| 9378 const char* Uint32Array::ToCString() const { | |
| 9379 return "_Uint32Array"; | |
| 9380 } | |
| 9381 | |
| 9382 | |
| 9383 RawInt64Array* Int64Array::New(intptr_t len, Heap::Space space) { | |
| 9384 Isolate* isolate = Isolate::Current(); | |
| 9385 const Class& cls = | |
| 9386 Class::Handle(isolate->object_store()->int64_array_class()); | |
| 9387 return NewImpl<Int64Array, RawInt64Array>(cls, len, space); | |
| 9388 } | |
| 9389 | |
| 9390 | |
| 9391 RawInt64Array* Int64Array::New(const int64_t* data, | |
| 9392 intptr_t len, | |
| 9393 Heap::Space space) { | |
| 9394 Isolate* isolate = Isolate::Current(); | |
| 9395 const Class& cls = | |
| 9396 Class::Handle(isolate->object_store()->int64_array_class()); | |
| 9397 return NewImpl<Int64Array, RawInt64Array>(cls, data, len, space); | |
| 9398 } | |
| 9399 | |
| 9400 | |
| 9401 const char* Int64Array::ToCString() const { | |
| 9402 return "_Int64Array"; | |
| 9403 } | |
| 9404 | |
| 9405 | |
| 9406 RawUint64Array* Uint64Array::New(intptr_t len, Heap::Space space) { | |
| 9407 Isolate* isolate = Isolate::Current(); | |
| 9408 const Class& cls = | |
| 9409 Class::Handle(isolate->object_store()->uint64_array_class()); | |
| 9410 return NewImpl<Uint64Array, RawUint64Array>(cls, len, space); | |
| 9411 } | |
| 9412 | |
| 9413 | |
| 9414 RawUint64Array* Uint64Array::New(const uint64_t* data, | |
| 9415 intptr_t len, | |
| 9416 Heap::Space space) { | |
| 9417 Isolate* isolate = Isolate::Current(); | |
| 9418 const Class& cls = | |
| 9419 Class::Handle(isolate->object_store()->uint64_array_class()); | |
| 9420 return NewImpl<Uint64Array, RawUint64Array>(cls, data, len, space); | |
| 9421 } | |
| 9422 | |
| 9423 | |
| 9424 const char* Uint64Array::ToCString() const { | |
| 9425 return "_Uint64Array"; | |
| 9426 } | |
| 9427 | |
| 9428 | |
| 9429 RawFloat32Array* Float32Array::New(intptr_t len, Heap::Space space) { | |
| 9430 Isolate* isolate = Isolate::Current(); | |
| 9431 const Class& cls = | |
| 9432 Class::Handle(isolate->object_store()->float32_array_class()); | |
| 9433 return NewImpl<Float32Array, RawFloat32Array>(cls, len, space); | |
| 9434 } | |
| 9435 | |
| 9436 | |
| 9437 RawFloat32Array* Float32Array::New(const float* data, | |
| 9438 intptr_t len, | |
| 9439 Heap::Space space) { | |
| 9440 Isolate* isolate = Isolate::Current(); | |
| 9441 const Class& cls = | |
| 9442 Class::Handle(isolate->object_store()->float32_array_class()); | |
| 9443 return NewImpl<Float32Array, RawFloat32Array>(cls, data, len, space); | |
| 9444 } | |
| 9445 | |
| 9446 | |
| 9447 const char* Float32Array::ToCString() const { | |
| 9448 return "_Float32Array"; | |
| 9449 } | |
| 9450 | |
| 9451 | |
| 9452 RawFloat64Array* Float64Array::New(intptr_t len, Heap::Space space) { | |
| 9453 Isolate* isolate = Isolate::Current(); | |
| 9454 const Class& cls = | |
| 9455 Class::Handle(isolate->object_store()->float64_array_class()); | |
| 9456 return NewImpl<Float64Array, RawFloat64Array>(cls, len, space); | |
| 9457 } | |
| 9458 | |
| 9459 | |
| 9460 RawFloat64Array* Float64Array::New(const double* data, | |
| 9461 intptr_t len, | |
| 9462 Heap::Space space) { | |
| 9463 Isolate* isolate = Isolate::Current(); | |
| 9464 const Class& cls = | |
| 9465 Class::Handle(isolate->object_store()->float64_array_class()); | |
| 9466 return NewImpl<Float64Array, RawFloat64Array>(cls, data, len, space); | |
| 9467 } | |
| 9468 | |
| 9469 | |
| 9470 const char* Float64Array::ToCString() const { | |
| 9471 return "_Float64Array"; | |
| 9472 } | |
| 9473 | |
| 9474 | |
| 9475 RawExternalInt8Array* ExternalInt8Array::New(int8_t* data, | |
| 9476 intptr_t len, | 9030 intptr_t len, |
| 9477 void* peer, | 9031 void* peer, |
| 9478 Dart_PeerFinalizer callback, | 9032 Dart_PeerFinalizer callback, |
| 9479 Heap::Space space) { | 9033 Heap::Space space) { |
| 9480 Isolate* isolate = Isolate::Current(); | 9034 Isolate* isolate = Isolate::Current(); |
| 9481 const Class& cls = | 9035 const Class& external_byte_array_class = |
| 9482 Class::Handle(isolate->object_store()->external_int8_array_class()); | 9036 Class::Handle(isolate->object_store()->external_byte_array_class()); |
| 9483 return NewExternalImpl<ExternalInt8Array, RawExternalInt8Array>( | 9037 ExternalByteArray& result = ExternalByteArray::Handle(); |
| 9484 cls, data, len, peer, callback, space); | 9038 ExternalByteArrayData* external_data = |
| 9039 new ExternalByteArrayData(data, peer, callback); |
| 9040 { |
| 9041 RawObject* raw = Object::Allocate(external_byte_array_class, |
| 9042 ExternalByteArray::InstanceSize(), |
| 9043 space); |
| 9044 NoGCScope no_gc; |
| 9045 result ^= raw; |
| 9046 result.SetLength(len); |
| 9047 result.SetExternalData(external_data); |
| 9048 } |
| 9049 AddFinalizer(result, external_data, ExternalByteArray::Finalize); |
| 9050 return result.raw(); |
| 9485 } | 9051 } |
| 9486 | 9052 |
| 9487 | 9053 |
| 9488 const char* ExternalInt8Array::ToCString() const { | 9054 const char* ExternalByteArray::ToCString() const { |
| 9489 return "_ExternalInt8Array"; | 9055 return "_ExternalByteArray"; |
| 9490 } | 9056 } |
| 9491 | 9057 |
| 9492 | 9058 |
| 9493 RawExternalUint8Array* ExternalUint8Array::New(uint8_t* data, | |
| 9494 intptr_t len, | |
| 9495 void* peer, | |
| 9496 Dart_PeerFinalizer callback, | |
| 9497 Heap::Space space) { | |
| 9498 Isolate* isolate = Isolate::Current(); | |
| 9499 const Class& cls = | |
| 9500 Class::Handle(isolate->object_store()->external_uint8_array_class()); | |
| 9501 return NewExternalImpl<ExternalUint8Array, RawExternalUint8Array>( | |
| 9502 cls, data, len, peer, callback, space); | |
| 9503 } | |
| 9504 | |
| 9505 | |
| 9506 const char* ExternalUint8Array::ToCString() const { | |
| 9507 return "_ExternalUint8Array"; | |
| 9508 } | |
| 9509 | |
| 9510 | |
| 9511 RawExternalInt16Array* ExternalInt16Array::New(int16_t* data, | |
| 9512 intptr_t len, | |
| 9513 void* peer, | |
| 9514 Dart_PeerFinalizer callback, | |
| 9515 Heap::Space space) { | |
| 9516 Isolate* isolate = Isolate::Current(); | |
| 9517 const Class& cls = | |
| 9518 Class::Handle(isolate->object_store()->external_int16_array_class()); | |
| 9519 return NewExternalImpl<ExternalInt16Array, RawExternalInt16Array>( | |
| 9520 cls, data, len, peer, callback, space); | |
| 9521 } | |
| 9522 | |
| 9523 | |
| 9524 const char* ExternalInt16Array::ToCString() const { | |
| 9525 return "_ExternalInt16Array"; | |
| 9526 } | |
| 9527 | |
| 9528 | |
| 9529 RawExternalUint16Array* ExternalUint16Array::New(uint16_t* data, | |
| 9530 intptr_t len, | |
| 9531 void* peer, | |
| 9532 Dart_PeerFinalizer callback, | |
| 9533 Heap::Space space) { | |
| 9534 Isolate* isolate = Isolate::Current(); | |
| 9535 const Class& cls = | |
| 9536 Class::Handle(isolate->object_store()->external_uint16_array_class()); | |
| 9537 return NewExternalImpl<ExternalUint16Array, RawExternalUint16Array>( | |
| 9538 cls, data, len, peer, callback, space); | |
| 9539 } | |
| 9540 | |
| 9541 | |
| 9542 const char* ExternalUint16Array::ToCString() const { | |
| 9543 return "_ExternalUint16Array"; | |
| 9544 } | |
| 9545 | |
| 9546 | |
| 9547 RawExternalInt32Array* ExternalInt32Array::New(int32_t* data, | |
| 9548 intptr_t len, | |
| 9549 void* peer, | |
| 9550 Dart_PeerFinalizer callback, | |
| 9551 Heap::Space space) { | |
| 9552 Isolate* isolate = Isolate::Current(); | |
| 9553 const Class& cls = | |
| 9554 Class::Handle(isolate->object_store()->external_int32_array_class()); | |
| 9555 return NewExternalImpl<ExternalInt32Array, RawExternalInt32Array>( | |
| 9556 cls, data, len, peer, callback, space); | |
| 9557 } | |
| 9558 | |
| 9559 | |
| 9560 const char* ExternalInt32Array::ToCString() const { | |
| 9561 return "_ExternalInt32Array"; | |
| 9562 } | |
| 9563 | |
| 9564 | |
| 9565 RawExternalUint32Array* ExternalUint32Array::New(uint32_t* data, | |
| 9566 intptr_t len, | |
| 9567 void* peer, | |
| 9568 Dart_PeerFinalizer callback, | |
| 9569 Heap::Space space) { | |
| 9570 Isolate* isolate = Isolate::Current(); | |
| 9571 const Class& cls = | |
| 9572 Class::Handle(isolate->object_store()->external_uint32_array_class()); | |
| 9573 return NewExternalImpl<ExternalUint32Array, RawExternalUint32Array>( | |
| 9574 cls, data, len, peer, callback, space); | |
| 9575 } | |
| 9576 | |
| 9577 | |
| 9578 const char* ExternalUint32Array::ToCString() const { | |
| 9579 return "_ExternalUint32Array"; | |
| 9580 } | |
| 9581 | |
| 9582 | |
| 9583 RawExternalInt64Array* ExternalInt64Array::New(int64_t* data, | |
| 9584 intptr_t len, | |
| 9585 void* peer, | |
| 9586 Dart_PeerFinalizer callback, | |
| 9587 Heap::Space space) { | |
| 9588 Isolate* isolate = Isolate::Current(); | |
| 9589 const Class& cls = | |
| 9590 Class::Handle(isolate->object_store()->external_int64_array_class()); | |
| 9591 return NewExternalImpl<ExternalInt64Array, RawExternalInt64Array>( | |
| 9592 cls, data, len, peer, callback, space); | |
| 9593 } | |
| 9594 | |
| 9595 | |
| 9596 const char* ExternalInt64Array::ToCString() const { | |
| 9597 return "_ExternalInt64Array"; | |
| 9598 } | |
| 9599 | |
| 9600 | |
| 9601 RawExternalUint64Array* ExternalUint64Array::New(uint64_t* data, | |
| 9602 intptr_t len, | |
| 9603 void* peer, | |
| 9604 Dart_PeerFinalizer callback, | |
| 9605 Heap::Space space) { | |
| 9606 Isolate* isolate = Isolate::Current(); | |
| 9607 const Class& cls = | |
| 9608 Class::Handle(isolate->object_store()->external_uint64_array_class()); | |
| 9609 return NewExternalImpl<ExternalUint64Array, RawExternalUint64Array>( | |
| 9610 cls, data, len, peer, callback, space); | |
| 9611 } | |
| 9612 | |
| 9613 | |
| 9614 const char* ExternalUint64Array::ToCString() const { | |
| 9615 return "_ExternalUint64Array"; | |
| 9616 } | |
| 9617 | |
| 9618 | |
| 9619 RawExternalFloat32Array* ExternalFloat32Array::New(float* data, | |
| 9620 intptr_t len, | |
| 9621 void* peer, | |
| 9622 Dart_PeerFinalizer callback, | |
| 9623 Heap::Space space) { | |
| 9624 Isolate* isolate = Isolate::Current(); | |
| 9625 const Class& cls = | |
| 9626 Class::Handle(isolate->object_store()->external_float32_array_class()); | |
| 9627 return NewExternalImpl<ExternalFloat32Array, RawExternalFloat32Array>( | |
| 9628 cls, data, len, peer, callback, space); | |
| 9629 } | |
| 9630 | |
| 9631 | |
| 9632 const char* ExternalFloat32Array::ToCString() const { | |
| 9633 return "_ExternalFloat32Array"; | |
| 9634 } | |
| 9635 | |
| 9636 | |
| 9637 RawExternalFloat64Array* ExternalFloat64Array::New(double* data, | |
| 9638 intptr_t len, | |
| 9639 void* peer, | |
| 9640 Dart_PeerFinalizer callback, | |
| 9641 Heap::Space space) { | |
| 9642 Isolate* isolate = Isolate::Current(); | |
| 9643 const Class& cls = | |
| 9644 Class::Handle(isolate->object_store()->external_float64_array_class()); | |
| 9645 return NewExternalImpl<ExternalFloat64Array, RawExternalFloat64Array>( | |
| 9646 cls, data, len, peer, callback, space); | |
| 9647 } | |
| 9648 | |
| 9649 | |
| 9650 const char* ExternalFloat64Array::ToCString() const { | |
| 9651 return "_ExternalFloat64Array"; | |
| 9652 } | |
| 9653 | |
| 9654 | |
| 9655 | |
| 9656 RawClosure* Closure::New(const Function& function, | 9059 RawClosure* Closure::New(const Function& function, |
| 9657 const Context& context, | 9060 const Context& context, |
| 9658 Heap::Space space) { | 9061 Heap::Space space) { |
| 9659 Isolate* isolate = Isolate::Current(); | 9062 Isolate* isolate = Isolate::Current(); |
| 9660 ASSERT(context.isolate() == isolate); | 9063 ASSERT(context.isolate() == isolate); |
| 9661 | 9064 |
| 9662 const Class& cls = Class::Handle(function.signature_class()); | 9065 const Class& cls = Class::Handle(function.signature_class()); |
| 9663 Closure& result = Closure::Handle(); | 9066 Closure& result = Closure::Handle(); |
| 9664 { | 9067 { |
| 9665 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); | 9068 RawObject* raw = Object::Allocate(cls, Closure::InstanceSize(), space); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9965 const String& str = String::Handle(pattern()); | 9368 const String& str = String::Handle(pattern()); |
| 9966 const char* format = "JSRegExp: pattern=%s flags=%s"; | 9369 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 9967 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 9370 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 9968 char* chars = reinterpret_cast<char*>( | 9371 char* chars = reinterpret_cast<char*>( |
| 9969 Isolate::Current()->current_zone()->Allocate(len + 1)); | 9372 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 9970 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 9373 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 9971 return chars; | 9374 return chars; |
| 9972 } | 9375 } |
| 9973 | 9376 |
| 9974 } // namespace dart | 9377 } // namespace dart |
| OLD | NEW |