| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 *addr = value; | 586 *addr = value; |
| 587 // Filter stores based on source and target. | 587 // Filter stores based on source and target. |
| 588 if (!value->IsHeapObject()) return; | 588 if (!value->IsHeapObject()) return; |
| 589 if (value->IsNewObject() && raw()->IsOldObject() && | 589 if (value->IsNewObject() && raw()->IsOldObject() && |
| 590 !raw()->IsRemembered()) { | 590 !raw()->IsRemembered()) { |
| 591 raw()->SetRememberedBit(); | 591 raw()->SetRememberedBit(); |
| 592 Isolate::Current()->store_buffer()->AddObject(raw()); | 592 Isolate::Current()->store_buffer()->AddObject(raw()); |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 // Use for storing into an explicitly Smi-typed field of an object |
| 597 // (i.e., both the previous and new value are Smis). |
| 598 void StoreSmi(RawSmi** addr, RawSmi* value) const { |
| 599 // Can't use Contains, as array length is initialized through this method. |
| 600 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(raw())); |
| 601 *addr = value; |
| 602 } |
| 603 |
| 604 // Needs two template arguments to allow assigning enums to fixed-size ints. |
| 605 template<typename FieldType, typename ValueType> |
| 606 void StoreNonPointer(FieldType* addr, ValueType value) const { |
| 607 // Can't use Contains, as it uses tags_, which is set through this method. |
| 608 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(raw())); |
| 609 *addr = value; |
| 610 } |
| 611 |
| 612 // Fail at link time if StoreNonPointer is called with an object pointer. |
| 613 #define STORE_NON_POINTER_ILLEGAL_TYPE(type) \ |
| 614 template<typename ValueType> \ |
| 615 void StoreNonPointer(Raw##type** addr, ValueType value) const { \ |
| 616 UnimplementedMethod(); \ |
| 617 } |
| 618 CLASS_LIST(STORE_NON_POINTER_ILLEGAL_TYPE); |
| 619 void UnimplementedMethod() const; |
| 620 #undef STORE_NON_POINTER_ILLEGAL_TYPE |
| 621 |
| 596 RawObject* raw_; // The raw object reference. | 622 RawObject* raw_; // The raw object reference. |
| 597 | 623 |
| 598 protected: | 624 protected: |
| 599 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; | 625 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; |
| 600 | 626 |
| 601 private: | 627 private: |
| 602 static intptr_t NextFieldOffset() { | 628 static intptr_t NextFieldOffset() { |
| 603 // Indicates this class cannot be extended by dart code. | 629 // Indicates this class cannot be extended by dart code. |
| 604 return -kWordSize; | 630 return -kWordSize; |
| 605 } | 631 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 intptr_t instance_size() const { | 790 intptr_t instance_size() const { |
| 765 ASSERT(is_finalized() || is_prefinalized()); | 791 ASSERT(is_finalized() || is_prefinalized()); |
| 766 return (raw_ptr()->instance_size_in_words_ * kWordSize); | 792 return (raw_ptr()->instance_size_in_words_ * kWordSize); |
| 767 } | 793 } |
| 768 void set_instance_size(intptr_t value_in_bytes) const { | 794 void set_instance_size(intptr_t value_in_bytes) const { |
| 769 ASSERT(kWordSize != 0); | 795 ASSERT(kWordSize != 0); |
| 770 set_instance_size_in_words(value_in_bytes / kWordSize); | 796 set_instance_size_in_words(value_in_bytes / kWordSize); |
| 771 } | 797 } |
| 772 void set_instance_size_in_words(intptr_t value) const { | 798 void set_instance_size_in_words(intptr_t value) const { |
| 773 ASSERT(Utils::IsAligned((value * kWordSize), kObjectAlignment)); | 799 ASSERT(Utils::IsAligned((value * kWordSize), kObjectAlignment)); |
| 774 raw_ptr()->instance_size_in_words_ = value; | 800 StoreNonPointer(&raw_ptr()->instance_size_in_words_, value); |
| 775 } | 801 } |
| 776 | 802 |
| 777 intptr_t next_field_offset() const { | 803 intptr_t next_field_offset() const { |
| 778 return raw_ptr()->next_field_offset_in_words_ * kWordSize; | 804 return raw_ptr()->next_field_offset_in_words_ * kWordSize; |
| 779 } | 805 } |
| 780 void set_next_field_offset(intptr_t value_in_bytes) const { | 806 void set_next_field_offset(intptr_t value_in_bytes) const { |
| 781 ASSERT(kWordSize != 0); | 807 ASSERT(kWordSize != 0); |
| 782 set_next_field_offset_in_words(value_in_bytes / kWordSize); | 808 set_next_field_offset_in_words(value_in_bytes / kWordSize); |
| 783 } | 809 } |
| 784 void set_next_field_offset_in_words(intptr_t value) const { | 810 void set_next_field_offset_in_words(intptr_t value) const { |
| 785 ASSERT((value == -1) || | 811 ASSERT((value == -1) || |
| 786 (Utils::IsAligned((value * kWordSize), kObjectAlignment) && | 812 (Utils::IsAligned((value * kWordSize), kObjectAlignment) && |
| 787 (value == raw_ptr()->instance_size_in_words_)) || | 813 (value == raw_ptr()->instance_size_in_words_)) || |
| 788 (!Utils::IsAligned((value * kWordSize), kObjectAlignment) && | 814 (!Utils::IsAligned((value * kWordSize), kObjectAlignment) && |
| 789 ((value + 1) == raw_ptr()->instance_size_in_words_))); | 815 ((value + 1) == raw_ptr()->instance_size_in_words_))); |
| 790 raw_ptr()->next_field_offset_in_words_ = value; | 816 StoreNonPointer(&raw_ptr()->next_field_offset_in_words_, value); |
| 791 } | 817 } |
| 792 | 818 |
| 793 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } | 819 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } |
| 794 void set_handle_vtable(cpp_vtable value) const { | 820 void set_handle_vtable(cpp_vtable value) const { |
| 795 raw_ptr()->handle_vtable_ = value; | 821 StoreNonPointer(&raw_ptr()->handle_vtable_, value); |
| 796 } | 822 } |
| 797 | 823 |
| 798 static bool is_valid_id(intptr_t value) { | 824 static bool is_valid_id(intptr_t value) { |
| 799 return RawObject::ClassIdTag::is_valid(value); | 825 return RawObject::ClassIdTag::is_valid(value); |
| 800 } | 826 } |
| 801 intptr_t id() const { return raw_ptr()->id_; } | 827 intptr_t id() const { return raw_ptr()->id_; } |
| 802 void set_id(intptr_t value) const { | 828 void set_id(intptr_t value) const { |
| 803 ASSERT(is_valid_id(value)); | 829 ASSERT(is_valid_id(value)); |
| 804 raw_ptr()->id_ = value; | 830 StoreNonPointer(&raw_ptr()->id_, value); |
| 805 } | 831 } |
| 806 | 832 |
| 807 RawString* Name() const; | 833 RawString* Name() const; |
| 808 RawString* PrettyName() const; | 834 RawString* PrettyName() const; |
| 809 RawString* UserVisibleName() const; | 835 RawString* UserVisibleName() const; |
| 810 | 836 |
| 811 virtual RawString* DictionaryName() const { return Name(); } | 837 virtual RawString* DictionaryName() const { return Name(); } |
| 812 | 838 |
| 813 RawScript* script() const { return raw_ptr()->script_; } | 839 RawScript* script() const { return raw_ptr()->script_; } |
| 814 void set_script(const Script& value) const; | 840 void set_script(const Script& value) const; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 intptr_t value; | 920 intptr_t value; |
| 895 if (value_in_bytes == kNoTypeArguments) { | 921 if (value_in_bytes == kNoTypeArguments) { |
| 896 value = kNoTypeArguments; | 922 value = kNoTypeArguments; |
| 897 } else { | 923 } else { |
| 898 ASSERT(kWordSize != 0); | 924 ASSERT(kWordSize != 0); |
| 899 value = value_in_bytes / kWordSize; | 925 value = value_in_bytes / kWordSize; |
| 900 } | 926 } |
| 901 set_type_arguments_field_offset_in_words(value); | 927 set_type_arguments_field_offset_in_words(value); |
| 902 } | 928 } |
| 903 void set_type_arguments_field_offset_in_words(intptr_t value) const { | 929 void set_type_arguments_field_offset_in_words(intptr_t value) const { |
| 904 raw_ptr()->type_arguments_field_offset_in_words_ = value; | 930 StoreNonPointer(&raw_ptr()->type_arguments_field_offset_in_words_, value); |
| 905 } | 931 } |
| 906 static intptr_t type_arguments_field_offset_in_words_offset() { | 932 static intptr_t type_arguments_field_offset_in_words_offset() { |
| 907 return OFFSET_OF(RawClass, type_arguments_field_offset_in_words_); | 933 return OFFSET_OF(RawClass, type_arguments_field_offset_in_words_); |
| 908 } | 934 } |
| 909 | 935 |
| 910 RawType* CanonicalType() const { | 936 RawType* CanonicalType() const { |
| 911 if ((NumTypeArguments() == 0) && !IsSignatureClass()) { | 937 if ((NumTypeArguments() == 0) && !IsSignatureClass()) { |
| 912 return reinterpret_cast<RawType*>(raw_ptr()->canonical_types_); | 938 return reinterpret_cast<RawType*>(raw_ptr()->canonical_types_); |
| 913 } | 939 } |
| 914 return reinterpret_cast<RawType*>(Object::null()); | 940 return reinterpret_cast<RawType*>(Object::null()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 | 1154 |
| 1129 bool is_cycle_free() const { | 1155 bool is_cycle_free() const { |
| 1130 return CycleFreeBit::decode(raw_ptr()->state_bits_); | 1156 return CycleFreeBit::decode(raw_ptr()->state_bits_); |
| 1131 } | 1157 } |
| 1132 void set_is_cycle_free() const; | 1158 void set_is_cycle_free() const; |
| 1133 | 1159 |
| 1134 uint16_t num_native_fields() const { | 1160 uint16_t num_native_fields() const { |
| 1135 return raw_ptr()->num_native_fields_; | 1161 return raw_ptr()->num_native_fields_; |
| 1136 } | 1162 } |
| 1137 void set_num_native_fields(uint16_t value) const { | 1163 void set_num_native_fields(uint16_t value) const { |
| 1138 raw_ptr()->num_native_fields_ = value; | 1164 StoreNonPointer(&raw_ptr()->num_native_fields_, value); |
| 1139 } | 1165 } |
| 1140 | 1166 |
| 1141 RawCode* allocation_stub() const { | 1167 RawCode* allocation_stub() const { |
| 1142 return raw_ptr()->allocation_stub_; | 1168 return raw_ptr()->allocation_stub_; |
| 1143 } | 1169 } |
| 1144 void set_allocation_stub(const Code& value) const; | 1170 void set_allocation_stub(const Code& value) const; |
| 1145 | 1171 |
| 1146 void DisableAllocationStub() const; | 1172 void DisableAllocationStub() const; |
| 1147 | 1173 |
| 1148 RawArray* constants() const; | 1174 RawArray* constants() const; |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 return false; | 1823 return false; |
| 1798 } | 1824 } |
| 1799 } | 1825 } |
| 1800 bool IsInFactoryScope() const; | 1826 bool IsInFactoryScope() const; |
| 1801 | 1827 |
| 1802 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 1828 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 1803 void set_token_pos(intptr_t value) const; | 1829 void set_token_pos(intptr_t value) const; |
| 1804 | 1830 |
| 1805 intptr_t end_token_pos() const { return raw_ptr()->end_token_pos_; } | 1831 intptr_t end_token_pos() const { return raw_ptr()->end_token_pos_; } |
| 1806 void set_end_token_pos(intptr_t value) const { | 1832 void set_end_token_pos(intptr_t value) const { |
| 1807 raw_ptr()->end_token_pos_ = value; | 1833 StoreNonPointer(&raw_ptr()->end_token_pos_, value); |
| 1808 } | 1834 } |
| 1809 | 1835 |
| 1810 intptr_t num_fixed_parameters() const { | 1836 intptr_t num_fixed_parameters() const { |
| 1811 return raw_ptr()->num_fixed_parameters_; | 1837 return raw_ptr()->num_fixed_parameters_; |
| 1812 } | 1838 } |
| 1813 void set_num_fixed_parameters(intptr_t value) const; | 1839 void set_num_fixed_parameters(intptr_t value) const; |
| 1814 | 1840 |
| 1815 bool HasOptionalParameters() const { | 1841 bool HasOptionalParameters() const { |
| 1816 return raw_ptr()->num_optional_parameters_ != 0; | 1842 return raw_ptr()->num_optional_parameters_ != 0; |
| 1817 } | 1843 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1841 | 1867 |
| 1842 intptr_t NumImplicitParameters() const; | 1868 intptr_t NumImplicitParameters() const; |
| 1843 | 1869 |
| 1844 static intptr_t usage_counter_offset() { | 1870 static intptr_t usage_counter_offset() { |
| 1845 return OFFSET_OF(RawFunction, usage_counter_); | 1871 return OFFSET_OF(RawFunction, usage_counter_); |
| 1846 } | 1872 } |
| 1847 intptr_t usage_counter() const { | 1873 intptr_t usage_counter() const { |
| 1848 return raw_ptr()->usage_counter_; | 1874 return raw_ptr()->usage_counter_; |
| 1849 } | 1875 } |
| 1850 void set_usage_counter(intptr_t value) const { | 1876 void set_usage_counter(intptr_t value) const { |
| 1851 raw_ptr()->usage_counter_ = value; | 1877 StoreNonPointer(&raw_ptr()->usage_counter_, value); |
| 1852 } | 1878 } |
| 1853 | 1879 |
| 1854 int16_t deoptimization_counter() const { | 1880 int16_t deoptimization_counter() const { |
| 1855 return raw_ptr()->deoptimization_counter_; | 1881 return raw_ptr()->deoptimization_counter_; |
| 1856 } | 1882 } |
| 1857 void set_deoptimization_counter(int16_t value) const { | 1883 void set_deoptimization_counter(int16_t value) const { |
| 1858 raw_ptr()->deoptimization_counter_ = value; | 1884 StoreNonPointer(&raw_ptr()->deoptimization_counter_, value); |
| 1859 } | 1885 } |
| 1860 | 1886 |
| 1861 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; | 1887 static const intptr_t kMaxInstructionCount = (1 << 16) - 1; |
| 1862 intptr_t optimized_instruction_count() const { | 1888 intptr_t optimized_instruction_count() const { |
| 1863 return raw_ptr()->optimized_instruction_count_; | 1889 return raw_ptr()->optimized_instruction_count_; |
| 1864 } | 1890 } |
| 1865 void set_optimized_instruction_count(intptr_t value) const { | 1891 void set_optimized_instruction_count(intptr_t value) const { |
| 1866 ASSERT(value >= 0); | 1892 ASSERT(value >= 0); |
| 1867 if (value > kMaxInstructionCount) { | 1893 if (value > kMaxInstructionCount) { |
| 1868 value = kMaxInstructionCount; | 1894 value = kMaxInstructionCount; |
| 1869 } | 1895 } |
| 1870 raw_ptr()->optimized_instruction_count_ = static_cast<uint16_t>(value); | 1896 StoreNonPointer(&raw_ptr()->optimized_instruction_count_, |
| 1897 static_cast<uint16_t>(value)); |
| 1871 } | 1898 } |
| 1872 | 1899 |
| 1873 intptr_t optimized_call_site_count() const { | 1900 intptr_t optimized_call_site_count() const { |
| 1874 return raw_ptr()->optimized_call_site_count_; | 1901 return raw_ptr()->optimized_call_site_count_; |
| 1875 } | 1902 } |
| 1876 void set_optimized_call_site_count(intptr_t value) const { | 1903 void set_optimized_call_site_count(intptr_t value) const { |
| 1877 ASSERT(value >= 0); | 1904 ASSERT(value >= 0); |
| 1878 if (value > kMaxInstructionCount) { | 1905 if (value > kMaxInstructionCount) { |
| 1879 value = kMaxInstructionCount; | 1906 value = kMaxInstructionCount; |
| 1880 } | 1907 } |
| 1881 raw_ptr()->optimized_call_site_count_ = static_cast<uint16_t>(value); | 1908 StoreNonPointer(&raw_ptr()->optimized_call_site_count_, |
| 1909 static_cast<uint16_t>(value)); |
| 1882 } | 1910 } |
| 1883 | 1911 |
| 1884 bool IsOptimizable() const; | 1912 bool IsOptimizable() const; |
| 1885 bool IsNativeAutoSetupScope() const; | 1913 bool IsNativeAutoSetupScope() const; |
| 1886 void SetIsOptimizable(bool value) const; | 1914 void SetIsOptimizable(bool value) const; |
| 1887 void SetIsNativeAutoSetupScope(bool value) const; | 1915 void SetIsNativeAutoSetupScope(bool value) const; |
| 1888 | 1916 |
| 1889 bool is_async_closure() const { | 1917 bool is_async_closure() const { |
| 1890 return AsyncClosureBit::decode(raw_ptr()->kind_tag_); | 1918 return AsyncClosureBit::decode(raw_ptr()->kind_tag_); |
| 1891 } | 1919 } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 set_kind_bits(HasInitializerBit::update(has_initializer, | 2370 set_kind_bits(HasInitializerBit::update(has_initializer, |
| 2343 raw_ptr()->kind_bits_)); | 2371 raw_ptr()->kind_bits_)); |
| 2344 } | 2372 } |
| 2345 | 2373 |
| 2346 // Return class id that any non-null value read from this field is guaranteed | 2374 // Return class id that any non-null value read from this field is guaranteed |
| 2347 // to have or kDynamicCid if such class id is not known. | 2375 // to have or kDynamicCid if such class id is not known. |
| 2348 // Stores to this field must update this information hence the name. | 2376 // Stores to this field must update this information hence the name. |
| 2349 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } | 2377 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } |
| 2350 | 2378 |
| 2351 void set_guarded_cid(intptr_t cid) const { | 2379 void set_guarded_cid(intptr_t cid) const { |
| 2352 raw_ptr()->guarded_cid_ = cid; | 2380 StoreNonPointer(&raw_ptr()->guarded_cid_, cid); |
| 2353 } | 2381 } |
| 2354 static intptr_t guarded_cid_offset() { | 2382 static intptr_t guarded_cid_offset() { |
| 2355 return OFFSET_OF(RawField, guarded_cid_); | 2383 return OFFSET_OF(RawField, guarded_cid_); |
| 2356 } | 2384 } |
| 2357 // Return the list length that any list stored in this field is guaranteed | 2385 // Return the list length that any list stored in this field is guaranteed |
| 2358 // to have. If length is kUnknownFixedLength the length has not | 2386 // to have. If length is kUnknownFixedLength the length has not |
| 2359 // been determined. If length is kNoFixedLength this field has multiple | 2387 // been determined. If length is kNoFixedLength this field has multiple |
| 2360 // list lengths associated with it and cannot be predicted. | 2388 // list lengths associated with it and cannot be predicted. |
| 2361 intptr_t guarded_list_length() const; | 2389 intptr_t guarded_list_length() const; |
| 2362 void set_guarded_list_length(intptr_t list_length) const; | 2390 void set_guarded_list_length(intptr_t list_length) const; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 }; | 2432 }; |
| 2405 // Returns false if any value read from this field is guaranteed to be | 2433 // Returns false if any value read from this field is guaranteed to be |
| 2406 // not null. | 2434 // not null. |
| 2407 // Internally we is_nullable_ field contains either kNullCid (nullable) or | 2435 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 2408 // any other value (non-nullable) instead of boolean. This is done to simplify | 2436 // any other value (non-nullable) instead of boolean. This is done to simplify |
| 2409 // guarding sequence in the generated code. | 2437 // guarding sequence in the generated code. |
| 2410 bool is_nullable() const { | 2438 bool is_nullable() const { |
| 2411 return raw_ptr()->is_nullable_ == kNullCid; | 2439 return raw_ptr()->is_nullable_ == kNullCid; |
| 2412 } | 2440 } |
| 2413 void set_is_nullable(bool val) const { | 2441 void set_is_nullable(bool val) const { |
| 2414 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; | 2442 StoreNonPointer(&raw_ptr()->is_nullable_, val ? kNullCid : kIllegalCid); |
| 2415 } | 2443 } |
| 2416 static intptr_t is_nullable_offset() { | 2444 static intptr_t is_nullable_offset() { |
| 2417 return OFFSET_OF(RawField, is_nullable_); | 2445 return OFFSET_OF(RawField, is_nullable_); |
| 2418 } | 2446 } |
| 2419 | 2447 |
| 2420 // Record store of the given value into this field. May trigger | 2448 // Record store of the given value into this field. May trigger |
| 2421 // deoptimization of dependent optimized code. | 2449 // deoptimization of dependent optimized code. |
| 2422 void RecordStore(const Object& value) const; | 2450 void RecordStore(const Object& value) const; |
| 2423 | 2451 |
| 2424 void InitializeGuardedListLengthInObjectOffset() const; | 2452 void InitializeGuardedListLengthInObjectOffset() const; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 void set_is_const(bool value) const { | 2512 void set_is_const(bool value) const { |
| 2485 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); | 2513 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); |
| 2486 } | 2514 } |
| 2487 void set_is_synthetic(bool value) const { | 2515 void set_is_synthetic(bool value) const { |
| 2488 set_kind_bits(SyntheticBit::update(value, raw_ptr()->kind_bits_)); | 2516 set_kind_bits(SyntheticBit::update(value, raw_ptr()->kind_bits_)); |
| 2489 } | 2517 } |
| 2490 void set_owner(const Object& value) const { | 2518 void set_owner(const Object& value) const { |
| 2491 StorePointer(&raw_ptr()->owner_, value.raw()); | 2519 StorePointer(&raw_ptr()->owner_, value.raw()); |
| 2492 } | 2520 } |
| 2493 void set_token_pos(intptr_t token_pos) const { | 2521 void set_token_pos(intptr_t token_pos) const { |
| 2494 raw_ptr()->token_pos_ = token_pos; | 2522 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
| 2495 } | 2523 } |
| 2496 void set_kind_bits(intptr_t value) const { | 2524 void set_kind_bits(intptr_t value) const { |
| 2497 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value); | 2525 StoreNonPointer(&raw_ptr()->kind_bits_, static_cast<uint8_t>(value)); |
| 2498 } | 2526 } |
| 2499 | 2527 |
| 2500 static RawField* New(); | 2528 static RawField* New(); |
| 2501 | 2529 |
| 2502 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); | 2530 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); |
| 2503 friend class Class; | 2531 friend class Class; |
| 2504 friend class HeapProfiler; | 2532 friend class HeapProfiler; |
| 2505 }; | 2533 }; |
| 2506 | 2534 |
| 2507 | 2535 |
| 2508 class LiteralToken : public Object { | 2536 class LiteralToken : public Object { |
| 2509 public: | 2537 public: |
| 2510 Token::Kind kind() const { return raw_ptr()->kind_; } | 2538 Token::Kind kind() const { return raw_ptr()->kind_; } |
| 2511 RawString* literal() const { return raw_ptr()->literal_; } | 2539 RawString* literal() const { return raw_ptr()->literal_; } |
| 2512 RawObject* value() const { return raw_ptr()->value_; } | 2540 RawObject* value() const { return raw_ptr()->value_; } |
| 2513 | 2541 |
| 2514 static intptr_t InstanceSize() { | 2542 static intptr_t InstanceSize() { |
| 2515 return RoundedAllocationSize(sizeof(RawLiteralToken)); | 2543 return RoundedAllocationSize(sizeof(RawLiteralToken)); |
| 2516 } | 2544 } |
| 2517 | 2545 |
| 2518 static RawLiteralToken* New(); | 2546 static RawLiteralToken* New(); |
| 2519 static RawLiteralToken* New(Token::Kind kind, const String& literal); | 2547 static RawLiteralToken* New(Token::Kind kind, const String& literal); |
| 2520 | 2548 |
| 2521 private: | 2549 private: |
| 2522 void set_kind(Token::Kind kind) const { raw_ptr()->kind_ = kind; } | 2550 void set_kind(Token::Kind kind) const { |
| 2551 StoreNonPointer(&raw_ptr()->kind_, kind); |
| 2552 } |
| 2523 void set_literal(const String& literal) const; | 2553 void set_literal(const String& literal) const; |
| 2524 void set_value(const Object& value) const; | 2554 void set_value(const Object& value) const; |
| 2525 | 2555 |
| 2526 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object); | 2556 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object); |
| 2527 friend class Class; | 2557 friend class Class; |
| 2528 }; | 2558 }; |
| 2529 | 2559 |
| 2530 | 2560 |
| 2531 class TokenStream : public Object { | 2561 class TokenStream : public Object { |
| 2532 public: | 2562 public: |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2838 bool ImportsCorelib() const; | 2868 bool ImportsCorelib() const; |
| 2839 | 2869 |
| 2840 RawFunction* LookupFunctionInScript(const Script& script, | 2870 RawFunction* LookupFunctionInScript(const Script& script, |
| 2841 intptr_t token_pos) const; | 2871 intptr_t token_pos) const; |
| 2842 | 2872 |
| 2843 // Resolving native methods for script loaded in the library. | 2873 // Resolving native methods for script loaded in the library. |
| 2844 Dart_NativeEntryResolver native_entry_resolver() const { | 2874 Dart_NativeEntryResolver native_entry_resolver() const { |
| 2845 return raw_ptr()->native_entry_resolver_; | 2875 return raw_ptr()->native_entry_resolver_; |
| 2846 } | 2876 } |
| 2847 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { | 2877 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { |
| 2848 raw_ptr()->native_entry_resolver_ = value; | 2878 StoreNonPointer(&raw_ptr()->native_entry_resolver_, value); |
| 2849 } | 2879 } |
| 2850 Dart_NativeEntrySymbol native_entry_symbol_resolver() const { | 2880 Dart_NativeEntrySymbol native_entry_symbol_resolver() const { |
| 2851 return raw_ptr()->native_entry_symbol_resolver_; | 2881 return raw_ptr()->native_entry_symbol_resolver_; |
| 2852 } | 2882 } |
| 2853 void set_native_entry_symbol_resolver( | 2883 void set_native_entry_symbol_resolver( |
| 2854 Dart_NativeEntrySymbol native_symbol_resolver) const { | 2884 Dart_NativeEntrySymbol native_symbol_resolver) const { |
| 2855 raw_ptr()->native_entry_symbol_resolver_ = native_symbol_resolver; | 2885 StoreNonPointer(&raw_ptr()->native_entry_symbol_resolver_, |
| 2886 native_symbol_resolver); |
| 2856 } | 2887 } |
| 2857 | 2888 |
| 2858 RawError* Patch(const Script& script) const; | 2889 RawError* Patch(const Script& script) const; |
| 2859 | 2890 |
| 2860 RawString* PrivateName(const String& name) const; | 2891 RawString* PrivateName(const String& name) const; |
| 2861 | 2892 |
| 2862 intptr_t index() const { return raw_ptr()->index_; } | 2893 intptr_t index() const { return raw_ptr()->index_; } |
| 2863 void set_index(intptr_t value) const { | 2894 void set_index(intptr_t value) const { |
| 2864 raw_ptr()->index_ = value; | 2895 StoreNonPointer(&raw_ptr()->index_, value); |
| 2865 } | 2896 } |
| 2866 | 2897 |
| 2867 void Register() const; | 2898 void Register() const; |
| 2868 | 2899 |
| 2869 bool IsDebuggable() const { | 2900 bool IsDebuggable() const { |
| 2870 return raw_ptr()->debuggable_; | 2901 return raw_ptr()->debuggable_; |
| 2871 } | 2902 } |
| 2872 void set_debuggable(bool value) const { | 2903 void set_debuggable(bool value) const { |
| 2873 raw_ptr()->debuggable_ = value; | 2904 StoreNonPointer(&raw_ptr()->debuggable_, value); |
| 2874 } | 2905 } |
| 2875 | 2906 |
| 2876 bool is_dart_scheme() const { | 2907 bool is_dart_scheme() const { |
| 2877 return raw_ptr()->is_dart_scheme_; | 2908 return raw_ptr()->is_dart_scheme_; |
| 2878 } | 2909 } |
| 2879 void set_is_dart_scheme(bool value) const { | 2910 void set_is_dart_scheme(bool value) const { |
| 2880 raw_ptr()->is_dart_scheme_ = value; | 2911 StoreNonPointer(&raw_ptr()->is_dart_scheme_, value); |
| 2881 } | 2912 } |
| 2882 | 2913 |
| 2883 bool IsCoreLibrary() const { | 2914 bool IsCoreLibrary() const { |
| 2884 return raw() == CoreLibrary(); | 2915 return raw() == CoreLibrary(); |
| 2885 } | 2916 } |
| 2886 | 2917 |
| 2887 inline intptr_t UrlHash() const; | 2918 inline intptr_t UrlHash() const; |
| 2888 | 2919 |
| 2889 static RawLibrary* LookupLibrary(const String& url); | 2920 static RawLibrary* LookupLibrary(const String& url); |
| 2890 static RawLibrary* GetLibrary(intptr_t index); | 2921 static RawLibrary* GetLibrary(intptr_t index); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2931 // the library-specific key. | 2962 // the library-specific key. |
| 2932 static const char kPrivateKeySeparator = '@'; | 2963 static const char kPrivateKeySeparator = '@'; |
| 2933 | 2964 |
| 2934 private: | 2965 private: |
| 2935 static const int kInitialImportsCapacity = 4; | 2966 static const int kInitialImportsCapacity = 4; |
| 2936 static const int kImportsCapacityIncrement = 8; | 2967 static const int kImportsCapacityIncrement = 8; |
| 2937 | 2968 |
| 2938 static RawLibrary* New(); | 2969 static RawLibrary* New(); |
| 2939 | 2970 |
| 2940 void set_num_imports(intptr_t value) const { | 2971 void set_num_imports(intptr_t value) const { |
| 2941 raw_ptr()->num_imports_ = value; | 2972 StoreNonPointer(&raw_ptr()->num_imports_, value); |
| 2942 } | 2973 } |
| 2943 bool HasExports() const; | 2974 bool HasExports() const; |
| 2944 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } | 2975 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } |
| 2945 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } | 2976 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } |
| 2946 RawArray* dictionary() const { return raw_ptr()->dictionary_; } | 2977 RawArray* dictionary() const { return raw_ptr()->dictionary_; } |
| 2947 void InitClassDictionary() const; | 2978 void InitClassDictionary() const; |
| 2948 | 2979 |
| 2949 RawArray* resolved_names() const { return raw_ptr()->resolved_names_; } | 2980 RawArray* resolved_names() const { return raw_ptr()->resolved_names_; } |
| 2950 void InitResolvedNamesCache(intptr_t size) const; | 2981 void InitResolvedNamesCache(intptr_t size) const; |
| 2951 void GrowResolvedNamesCache() const; | 2982 void GrowResolvedNamesCache() const; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 return Utils::RoundUp(sizeof(RawInstructions), alignment); | 3084 return Utils::RoundUp(sizeof(RawInstructions), alignment); |
| 3054 } | 3085 } |
| 3055 | 3086 |
| 3056 static RawInstructions* FromEntryPoint(uword entry_point) { | 3087 static RawInstructions* FromEntryPoint(uword entry_point) { |
| 3057 return reinterpret_cast<RawInstructions*>( | 3088 return reinterpret_cast<RawInstructions*>( |
| 3058 entry_point - HeaderSize() + kHeapObjectTag); | 3089 entry_point - HeaderSize() + kHeapObjectTag); |
| 3059 } | 3090 } |
| 3060 | 3091 |
| 3061 private: | 3092 private: |
| 3062 void set_size(intptr_t size) const { | 3093 void set_size(intptr_t size) const { |
| 3063 raw_ptr()->size_ = size; | 3094 StoreNonPointer(&raw_ptr()->size_, size); |
| 3064 } | 3095 } |
| 3065 void set_code(RawCode* code) const { | 3096 void set_code(RawCode* code) const { |
| 3066 raw_ptr()->code_ = code; | 3097 StorePointer(&raw_ptr()->code_, code); |
| 3067 } | 3098 } |
| 3068 void set_object_pool(RawArray* object_pool) const { | 3099 void set_object_pool(RawArray* object_pool) const { |
| 3069 StorePointer(&raw_ptr()->object_pool_, object_pool); | 3100 StorePointer(&raw_ptr()->object_pool_, object_pool); |
| 3070 } | 3101 } |
| 3071 | 3102 |
| 3072 // New is a private method as RawInstruction and RawCode objects should | 3103 // New is a private method as RawInstruction and RawCode objects should |
| 3073 // only be created using the Code::FinalizeCode method. This method creates | 3104 // only be created using the Code::FinalizeCode method. This method creates |
| 3074 // the RawInstruction and RawCode objects, sets up the pointer offsets | 3105 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 3075 // and links the two in a GC safe manner. | 3106 // and links the two in a GC safe manner. |
| 3076 static RawInstructions* New(intptr_t size); | 3107 static RawInstructions* New(intptr_t size); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 bool IsObject(intptr_t index) const { | 3299 bool IsObject(intptr_t index) const { |
| 3269 ASSERT(InRange(index)); | 3300 ASSERT(InRange(index)); |
| 3270 return GetBit(index); | 3301 return GetBit(index); |
| 3271 } | 3302 } |
| 3272 | 3303 |
| 3273 intptr_t Length() const { return raw_ptr()->length_; } | 3304 intptr_t Length() const { return raw_ptr()->length_; } |
| 3274 | 3305 |
| 3275 uint32_t PcOffset() const { return raw_ptr()->pc_offset_; } | 3306 uint32_t PcOffset() const { return raw_ptr()->pc_offset_; } |
| 3276 void SetPcOffset(uint32_t value) const { | 3307 void SetPcOffset(uint32_t value) const { |
| 3277 ASSERT(value <= kMaxUint32); | 3308 ASSERT(value <= kMaxUint32); |
| 3278 raw_ptr()->pc_offset_ = value; | 3309 StoreNonPointer(&raw_ptr()->pc_offset_, value); |
| 3279 } | 3310 } |
| 3280 | 3311 |
| 3281 intptr_t RegisterBitCount() const { return raw_ptr()->register_bit_count_; } | 3312 intptr_t RegisterBitCount() const { return raw_ptr()->register_bit_count_; } |
| 3282 void SetRegisterBitCount(intptr_t register_bit_count) const { | 3313 void SetRegisterBitCount(intptr_t register_bit_count) const { |
| 3283 ASSERT(register_bit_count < kMaxInt32); | 3314 ASSERT(register_bit_count < kMaxInt32); |
| 3284 raw_ptr()->register_bit_count_ = register_bit_count; | 3315 StoreNonPointer(&raw_ptr()->register_bit_count_, register_bit_count); |
| 3285 } | 3316 } |
| 3286 | 3317 |
| 3287 static const intptr_t kMaxLengthInBytes = kSmiMax; | 3318 static const intptr_t kMaxLengthInBytes = kSmiMax; |
| 3288 | 3319 |
| 3289 static intptr_t InstanceSize() { | 3320 static intptr_t InstanceSize() { |
| 3290 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); | 3321 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); |
| 3291 return 0; | 3322 return 0; |
| 3292 } | 3323 } |
| 3293 static intptr_t InstanceSize(intptr_t length) { | 3324 static intptr_t InstanceSize(intptr_t length) { |
| 3294 ASSERT(length >= 0); | 3325 ASSERT(length >= 0); |
| 3295 // The stackmap payload is in an array of bytes. | 3326 // The stackmap payload is in an array of bytes. |
| 3296 intptr_t payload_size = | 3327 intptr_t payload_size = |
| 3297 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | 3328 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
| 3298 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size); | 3329 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size); |
| 3299 } | 3330 } |
| 3300 static RawStackmap* New(intptr_t pc_offset, | 3331 static RawStackmap* New(intptr_t pc_offset, |
| 3301 BitmapBuilder* bmap, | 3332 BitmapBuilder* bmap, |
| 3302 intptr_t register_bit_count); | 3333 intptr_t register_bit_count); |
| 3303 | 3334 |
| 3304 private: | 3335 private: |
| 3305 void SetLength(intptr_t length) const { raw_ptr()->length_ = length; } | 3336 void SetLength(intptr_t length) const { |
| 3337 StoreNonPointer(&raw_ptr()->length_, length); |
| 3338 } |
| 3306 | 3339 |
| 3307 bool InRange(intptr_t index) const { return index < Length(); } | 3340 bool InRange(intptr_t index) const { return index < Length(); } |
| 3308 | 3341 |
| 3309 bool GetBit(intptr_t bit_index) const; | 3342 bool GetBit(intptr_t bit_index) const; |
| 3310 void SetBit(intptr_t bit_index, bool value) const; | 3343 void SetBit(intptr_t bit_index, bool value) const; |
| 3311 | 3344 |
| 3312 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); | 3345 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); |
| 3313 friend class BitmapBuilder; | 3346 friend class BitmapBuilder; |
| 3314 friend class Class; | 3347 friend class Class; |
| 3315 }; | 3348 }; |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 | 3977 |
| 3945 private: | 3978 private: |
| 3946 const uword pc_; | 3979 const uword pc_; |
| 3947 | 3980 |
| 3948 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor); | 3981 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor); |
| 3949 }; | 3982 }; |
| 3950 | 3983 |
| 3951 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT | 3984 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT |
| 3952 | 3985 |
| 3953 void set_compile_timestamp(int64_t timestamp) const { | 3986 void set_compile_timestamp(int64_t timestamp) const { |
| 3954 raw_ptr()->compile_timestamp_ = timestamp; | 3987 StoreNonPointer(&raw_ptr()->compile_timestamp_, timestamp); |
| 3955 } | 3988 } |
| 3956 | 3989 |
| 3957 void set_instructions(RawInstructions* instructions) { | 3990 void set_instructions(RawInstructions* instructions) { |
| 3958 // RawInstructions are never allocated in New space and hence a | 3991 // RawInstructions are never allocated in New space and hence a |
| 3959 // store buffer update is not needed here. | 3992 // store buffer update is not needed here. |
| 3960 raw_ptr()->instructions_ = instructions; | 3993 StorePointer(&raw_ptr()->instructions_, instructions); |
| 3961 } | 3994 } |
| 3962 | 3995 |
| 3963 void set_pointer_offsets_length(intptr_t value) { | 3996 void set_pointer_offsets_length(intptr_t value) { |
| 3964 // The number of fixups is limited to 1-billion. | 3997 // The number of fixups is limited to 1-billion. |
| 3965 ASSERT(Utils::IsUint(30, value)); | 3998 ASSERT(Utils::IsUint(30, value)); |
| 3966 set_state_bits(PtrOffBits::update(value, raw_ptr()->state_bits_)); | 3999 set_state_bits(PtrOffBits::update(value, raw_ptr()->state_bits_)); |
| 3967 } | 4000 } |
| 3968 int32_t* PointerOffsetAddrAt(int index) const { | 4001 int32_t* PointerOffsetAddrAt(int index) const { |
| 3969 ASSERT(index >= 0); | 4002 ASSERT(index >= 0); |
| 3970 ASSERT(index < pointer_offsets_length()); | 4003 ASSERT(index < pointer_offsets_length()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4038 static RawContext* New(intptr_t num_variables, | 4071 static RawContext* New(intptr_t num_variables, |
| 4039 Heap::Space space = Heap::kNew); | 4072 Heap::Space space = Heap::kNew); |
| 4040 | 4073 |
| 4041 private: | 4074 private: |
| 4042 RawInstance** InstanceAddr(intptr_t context_index) const { | 4075 RawInstance** InstanceAddr(intptr_t context_index) const { |
| 4043 ASSERT((context_index >= 0) && (context_index < num_variables())); | 4076 ASSERT((context_index >= 0) && (context_index < num_variables())); |
| 4044 return &raw_ptr()->data()[context_index]; | 4077 return &raw_ptr()->data()[context_index]; |
| 4045 } | 4078 } |
| 4046 | 4079 |
| 4047 void set_isolate(Isolate* isolate) const { | 4080 void set_isolate(Isolate* isolate) const { |
| 4048 raw_ptr()->isolate_ = isolate; | 4081 StoreNonPointer(&raw_ptr()->isolate_, isolate); |
| 4049 } | 4082 } |
| 4050 | 4083 |
| 4051 void set_num_variables(intptr_t num_variables) const { | 4084 void set_num_variables(intptr_t num_variables) const { |
| 4052 raw_ptr()->num_variables_ = num_variables; | 4085 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); |
| 4053 } | 4086 } |
| 4054 | 4087 |
| 4055 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); | 4088 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); |
| 4056 friend class Class; | 4089 friend class Class; |
| 4057 }; | 4090 }; |
| 4058 | 4091 |
| 4059 | 4092 |
| 4060 // The ContextScope class makes it possible to delay the compilation of a local | 4093 // The ContextScope class makes it possible to delay the compilation of a local |
| 4061 // function until it is invoked. A ContextScope instance collects the local | 4094 // function until it is invoked. A ContextScope instance collects the local |
| 4062 // variables that are referenced by the local function to be compiled and that | 4095 // variables that are referenced by the local function to be compiled and that |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4107 static intptr_t InstanceSize(intptr_t len) { | 4140 static intptr_t InstanceSize(intptr_t len) { |
| 4108 ASSERT(0 <= len && len <= kMaxElements); | 4141 ASSERT(0 <= len && len <= kMaxElements); |
| 4109 return RoundedAllocationSize( | 4142 return RoundedAllocationSize( |
| 4110 sizeof(RawContextScope) + (len * kBytesPerElement)); | 4143 sizeof(RawContextScope) + (len * kBytesPerElement)); |
| 4111 } | 4144 } |
| 4112 | 4145 |
| 4113 static RawContextScope* New(intptr_t num_variables); | 4146 static RawContextScope* New(intptr_t num_variables); |
| 4114 | 4147 |
| 4115 private: | 4148 private: |
| 4116 void set_num_variables(intptr_t num_variables) const { | 4149 void set_num_variables(intptr_t num_variables) const { |
| 4117 raw_ptr()->num_variables_ = num_variables; | 4150 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); |
| 4118 } | 4151 } |
| 4119 | 4152 |
| 4120 RawContextScope::VariableDesc* VariableDescAddr(intptr_t index) const { | 4153 RawContextScope::VariableDesc* VariableDescAddr(intptr_t index) const { |
| 4121 ASSERT((index >= 0) && (index < num_variables())); | 4154 ASSERT((index >= 0) && (index < num_variables())); |
| 4122 uword raw_addr = reinterpret_cast<uword>(raw_ptr()); | 4155 uword raw_addr = reinterpret_cast<uword>(raw_ptr()); |
| 4123 raw_addr += sizeof(RawContextScope) + | 4156 raw_addr += sizeof(RawContextScope) + |
| 4124 (index * sizeof(RawContextScope::VariableDesc)); | 4157 (index * sizeof(RawContextScope::VariableDesc)); |
| 4125 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); | 4158 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); |
| 4126 } | 4159 } |
| 4127 | 4160 |
| (...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5727 protected: | 5760 protected: |
| 5728 // These two operate on an array of Latin-1 encoded characters. | 5761 // These two operate on an array of Latin-1 encoded characters. |
| 5729 // They are protected to avoid mistaking Latin-1 for UTF-8, but used | 5762 // They are protected to avoid mistaking Latin-1 for UTF-8, but used |
| 5730 // by friendly templated code (e.g., Symbols). | 5763 // by friendly templated code (e.g., Symbols). |
| 5731 bool Equals(const uint8_t* characters, intptr_t len) const; | 5764 bool Equals(const uint8_t* characters, intptr_t len) const; |
| 5732 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 5765 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| 5733 | 5766 |
| 5734 void SetLength(intptr_t value) const { | 5767 void SetLength(intptr_t value) const { |
| 5735 // This is only safe because we create a new Smi, which does not cause | 5768 // This is only safe because we create a new Smi, which does not cause |
| 5736 // heap allocation. | 5769 // heap allocation. |
| 5737 raw_ptr()->length_ = Smi::New(value); | 5770 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 5738 } | 5771 } |
| 5739 | 5772 |
| 5740 void SetHash(intptr_t value) const { | 5773 void SetHash(intptr_t value) const { |
| 5741 // This is only safe because we create a new Smi, which does not cause | 5774 // This is only safe because we create a new Smi, which does not cause |
| 5742 // heap allocation. | 5775 // heap allocation. |
| 5743 raw_ptr()->hash_ = Smi::New(value); | 5776 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 5744 } | 5777 } |
| 5745 | 5778 |
| 5746 template<typename HandleType, typename ElementType, typename CallbackType> | 5779 template<typename HandleType, typename ElementType, typename CallbackType> |
| 5747 static void ReadFromImpl(SnapshotReader* reader, | 5780 static void ReadFromImpl(SnapshotReader* reader, |
| 5748 String* str_obj, | 5781 String* str_obj, |
| 5749 intptr_t len, | 5782 intptr_t len, |
| 5750 intptr_t tags, | 5783 intptr_t tags, |
| 5751 CallbackType new_symbol, | 5784 CallbackType new_symbol, |
| 5752 Snapshot::Kind kind); | 5785 Snapshot::Kind kind); |
| 5753 | 5786 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6043 ASSERT((index >= 0) && (index < str.Length())); | 6076 ASSERT((index >= 0) && (index < str.Length())); |
| 6044 ASSERT(str.IsExternalOneByteString()); | 6077 ASSERT(str.IsExternalOneByteString()); |
| 6045 NoGCScope no_gc; | 6078 NoGCScope no_gc; |
| 6046 return &(raw_ptr(str)->external_data_->data()[index]); | 6079 return &(raw_ptr(str)->external_data_->data()[index]); |
| 6047 } | 6080 } |
| 6048 | 6081 |
| 6049 static void SetExternalData(const String& str, | 6082 static void SetExternalData(const String& str, |
| 6050 ExternalStringData<uint8_t>* data) { | 6083 ExternalStringData<uint8_t>* data) { |
| 6051 ASSERT(str.IsExternalOneByteString()); | 6084 ASSERT(str.IsExternalOneByteString()); |
| 6052 NoGCScope no_gc; | 6085 NoGCScope no_gc; |
| 6053 raw_ptr(str)->external_data_ = data; | 6086 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
| 6054 } | 6087 } |
| 6055 | 6088 |
| 6056 static void Finalize(void* isolate_callback_data, | 6089 static void Finalize(void* isolate_callback_data, |
| 6057 Dart_WeakPersistentHandle handle, | 6090 Dart_WeakPersistentHandle handle, |
| 6058 void* peer); | 6091 void* peer); |
| 6059 | 6092 |
| 6060 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, | 6093 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, |
| 6061 intptr_t object_id, | 6094 intptr_t object_id, |
| 6062 intptr_t tags, | 6095 intptr_t tags, |
| 6063 Snapshot::Kind kind); | 6096 Snapshot::Kind kind); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6116 ASSERT((index >= 0) && (index < str.Length())); | 6149 ASSERT((index >= 0) && (index < str.Length())); |
| 6117 ASSERT(str.IsExternalTwoByteString()); | 6150 ASSERT(str.IsExternalTwoByteString()); |
| 6118 NoGCScope no_gc; | 6151 NoGCScope no_gc; |
| 6119 return &(raw_ptr(str)->external_data_->data()[index]); | 6152 return &(raw_ptr(str)->external_data_->data()[index]); |
| 6120 } | 6153 } |
| 6121 | 6154 |
| 6122 static void SetExternalData(const String& str, | 6155 static void SetExternalData(const String& str, |
| 6123 ExternalStringData<uint16_t>* data) { | 6156 ExternalStringData<uint16_t>* data) { |
| 6124 ASSERT(str.IsExternalTwoByteString()); | 6157 ASSERT(str.IsExternalTwoByteString()); |
| 6125 NoGCScope no_gc; | 6158 NoGCScope no_gc; |
| 6126 raw_ptr(str)->external_data_ = data; | 6159 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
| 6127 } | 6160 } |
| 6128 | 6161 |
| 6129 static void Finalize(void* isolate_callback_data, | 6162 static void Finalize(void* isolate_callback_data, |
| 6130 Dart_WeakPersistentHandle handle, | 6163 Dart_WeakPersistentHandle handle, |
| 6131 void* peer); | 6164 void* peer); |
| 6132 | 6165 |
| 6133 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, | 6166 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, |
| 6134 intptr_t object_id, | 6167 intptr_t object_id, |
| 6135 intptr_t tags, | 6168 intptr_t tags, |
| 6136 Snapshot::Kind kind); | 6169 Snapshot::Kind kind); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6163 | 6196 |
| 6164 static const Bool& False() { | 6197 static const Bool& False() { |
| 6165 return Object::bool_false(); | 6198 return Object::bool_false(); |
| 6166 } | 6199 } |
| 6167 | 6200 |
| 6168 static const Bool& Get(bool value) { | 6201 static const Bool& Get(bool value) { |
| 6169 return value ? Bool::True() : Bool::False(); | 6202 return value ? Bool::True() : Bool::False(); |
| 6170 } | 6203 } |
| 6171 | 6204 |
| 6172 private: | 6205 private: |
| 6173 void set_value(bool value) const { raw_ptr()->value_ = value; } | 6206 void set_value(bool value) const { |
| 6207 StoreNonPointer(&raw_ptr()->value_, value); |
| 6208 } |
| 6174 | 6209 |
| 6175 // New should only be called to initialize the two legal bool values. | 6210 // New should only be called to initialize the two legal bool values. |
| 6176 static RawBool* New(bool value); | 6211 static RawBool* New(bool value); |
| 6177 | 6212 |
| 6178 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); | 6213 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); |
| 6179 friend class Class; | 6214 friend class Class; |
| 6180 friend class Object; // To initialize the true and false values. | 6215 friend class Object; // To initialize the true and false values. |
| 6181 }; | 6216 }; |
| 6182 | 6217 |
| 6183 | 6218 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6277 private: | 6312 private: |
| 6278 RawObject** ObjectAddr(intptr_t index) const { | 6313 RawObject** ObjectAddr(intptr_t index) const { |
| 6279 // TODO(iposva): Determine if we should throw an exception here. | 6314 // TODO(iposva): Determine if we should throw an exception here. |
| 6280 ASSERT((index >= 0) && (index < Length())); | 6315 ASSERT((index >= 0) && (index < Length())); |
| 6281 return &raw_ptr()->data()[index]; | 6316 return &raw_ptr()->data()[index]; |
| 6282 } | 6317 } |
| 6283 | 6318 |
| 6284 void SetLength(intptr_t value) const { | 6319 void SetLength(intptr_t value) const { |
| 6285 // This is only safe because we create a new Smi, which does not cause | 6320 // This is only safe because we create a new Smi, which does not cause |
| 6286 // heap allocation. | 6321 // heap allocation. |
| 6287 raw_ptr()->length_ = Smi::New(value); | 6322 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 6288 } | 6323 } |
| 6289 | 6324 |
| 6290 FINAL_HEAP_OBJECT_IMPLEMENTATION(Array, Instance); | 6325 FINAL_HEAP_OBJECT_IMPLEMENTATION(Array, Instance); |
| 6291 friend class Class; | 6326 friend class Class; |
| 6292 friend class ImmutableArray; | 6327 friend class ImmutableArray; |
| 6293 friend class Object; | 6328 friend class Object; |
| 6294 friend class String; | 6329 friend class String; |
| 6295 }; | 6330 }; |
| 6296 | 6331 |
| 6297 | 6332 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6335 ASSERT(!IsNull()); | 6370 ASSERT(!IsNull()); |
| 6336 return Smi::Value(DataArray()->length_); | 6371 return Smi::Value(DataArray()->length_); |
| 6337 } | 6372 } |
| 6338 intptr_t Length() const { | 6373 intptr_t Length() const { |
| 6339 ASSERT(!IsNull()); | 6374 ASSERT(!IsNull()); |
| 6340 return Smi::Value(raw_ptr()->length_); | 6375 return Smi::Value(raw_ptr()->length_); |
| 6341 } | 6376 } |
| 6342 void SetLength(intptr_t value) const { | 6377 void SetLength(intptr_t value) const { |
| 6343 // This is only safe because we create a new Smi, which does not cause | 6378 // This is only safe because we create a new Smi, which does not cause |
| 6344 // heap allocation. | 6379 // heap allocation. |
| 6345 raw_ptr()->length_ = Smi::New(value); | 6380 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 6346 } | 6381 } |
| 6347 | 6382 |
| 6348 RawArray* data() const { return raw_ptr()->data_; } | 6383 RawArray* data() const { return raw_ptr()->data_; } |
| 6349 void SetData(const Array& value) const { | 6384 void SetData(const Array& value) const { |
| 6350 StorePointer(&raw_ptr()->data_, value.raw()); | 6385 StorePointer(&raw_ptr()->data_, value.raw()); |
| 6351 } | 6386 } |
| 6352 | 6387 |
| 6353 RawObject* At(intptr_t index) const { | 6388 RawObject* At(intptr_t index) const { |
| 6354 NoGCScope no_gc; | 6389 NoGCScope no_gc; |
| 6355 ASSERT(!IsNull()); | 6390 ASSERT(!IsNull()); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6734 static bool IsTypedData(const Instance& obj) { | 6769 static bool IsTypedData(const Instance& obj) { |
| 6735 ASSERT(!obj.IsNull()); | 6770 ASSERT(!obj.IsNull()); |
| 6736 intptr_t cid = obj.raw()->GetClassId(); | 6771 intptr_t cid = obj.raw()->GetClassId(); |
| 6737 return RawObject::IsTypedDataClassId(cid); | 6772 return RawObject::IsTypedDataClassId(cid); |
| 6738 } | 6773 } |
| 6739 | 6774 |
| 6740 static RawTypedData* EmptyUint32Array(Isolate* isolate); | 6775 static RawTypedData* EmptyUint32Array(Isolate* isolate); |
| 6741 | 6776 |
| 6742 protected: | 6777 protected: |
| 6743 void SetLength(intptr_t value) const { | 6778 void SetLength(intptr_t value) const { |
| 6744 raw_ptr()->length_ = Smi::New(value); | 6779 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 6745 } | 6780 } |
| 6746 | 6781 |
| 6747 private: | 6782 private: |
| 6748 static const intptr_t element_size[]; | 6783 static const intptr_t element_size[]; |
| 6749 | 6784 |
| 6750 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance); | 6785 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance); |
| 6751 friend class Class; | 6786 friend class Class; |
| 6752 friend class ExternalTypedData; | 6787 friend class ExternalTypedData; |
| 6753 friend class TypedDataView; | 6788 friend class TypedDataView; |
| 6754 }; | 6789 }; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6842 Heap::Space space = Heap::kNew); | 6877 Heap::Space space = Heap::kNew); |
| 6843 | 6878 |
| 6844 static bool IsExternalTypedData(const Instance& obj) { | 6879 static bool IsExternalTypedData(const Instance& obj) { |
| 6845 ASSERT(!obj.IsNull()); | 6880 ASSERT(!obj.IsNull()); |
| 6846 intptr_t cid = obj.raw()->GetClassId(); | 6881 intptr_t cid = obj.raw()->GetClassId(); |
| 6847 return RawObject::IsExternalTypedDataClassId(cid); | 6882 return RawObject::IsExternalTypedDataClassId(cid); |
| 6848 } | 6883 } |
| 6849 | 6884 |
| 6850 protected: | 6885 protected: |
| 6851 void SetLength(intptr_t value) const { | 6886 void SetLength(intptr_t value) const { |
| 6852 raw_ptr()->length_ = Smi::New(value); | 6887 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 6853 } | 6888 } |
| 6854 | 6889 |
| 6855 void SetData(uint8_t* data) const { | 6890 void SetData(uint8_t* data) const { |
| 6856 raw_ptr()->data_ = data; | 6891 StoreNonPointer(&raw_ptr()->data_, data); |
| 6857 } | 6892 } |
| 6858 | 6893 |
| 6859 private: | 6894 private: |
| 6860 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); | 6895 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); |
| 6861 friend class Class; | 6896 friend class Class; |
| 6862 }; | 6897 }; |
| 6863 | 6898 |
| 6864 | 6899 |
| 6865 class TypedDataView : public AllStatic { | 6900 class TypedDataView : public AllStatic { |
| 6866 public: | 6901 public: |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7194 static intptr_t InstanceSize(intptr_t len) { | 7229 static intptr_t InstanceSize(intptr_t len) { |
| 7195 ASSERT(0 <= len && len <= kMaxElements); | 7230 ASSERT(0 <= len && len <= kMaxElements); |
| 7196 return RoundedAllocationSize( | 7231 return RoundedAllocationSize( |
| 7197 sizeof(RawJSRegExp) + (len * kBytesPerElement)); | 7232 sizeof(RawJSRegExp) + (len * kBytesPerElement)); |
| 7198 } | 7233 } |
| 7199 | 7234 |
| 7200 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 7235 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
| 7201 | 7236 |
| 7202 private: | 7237 private: |
| 7203 void set_type(RegExType type) const { | 7238 void set_type(RegExType type) const { |
| 7204 raw_ptr()->type_flags_ = TypeBits::update(type, raw_ptr()->type_flags_); | 7239 StoreNonPointer(&raw_ptr()->type_flags_, |
| 7240 TypeBits::update(type, raw_ptr()->type_flags_)); |
| 7205 } | 7241 } |
| 7206 void set_flags(intptr_t value) const { | 7242 void set_flags(intptr_t value) const { |
| 7207 raw_ptr()->type_flags_ = FlagsBits::update(value, raw_ptr()->type_flags_); | 7243 StoreNonPointer(&raw_ptr()->type_flags_, |
| 7244 FlagsBits::update(value, raw_ptr()->type_flags_)); |
| 7208 } | 7245 } |
| 7209 | 7246 |
| 7210 RegExType type() const { | 7247 RegExType type() const { |
| 7211 return TypeBits::decode(raw_ptr()->type_flags_); | 7248 return TypeBits::decode(raw_ptr()->type_flags_); |
| 7212 } | 7249 } |
| 7213 intptr_t flags() const { | 7250 intptr_t flags() const { |
| 7214 return FlagsBits::decode(raw_ptr()->type_flags_); | 7251 return FlagsBits::decode(raw_ptr()->type_flags_); |
| 7215 } | 7252 } |
| 7216 | 7253 |
| 7217 void SetLength(intptr_t value) const { | 7254 void SetLength(intptr_t value) const { |
| 7218 // This is only safe because we create a new Smi, which does not cause | 7255 // This is only safe because we create a new Smi, which does not cause |
| 7219 // heap allocation. | 7256 // heap allocation. |
| 7220 raw_ptr()->data_length_ = Smi::New(value); | 7257 StoreSmi(&raw_ptr()->data_length_, Smi::New(value)); |
| 7221 } | 7258 } |
| 7222 | 7259 |
| 7223 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 7260 FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
| 7224 friend class Class; | 7261 friend class Class; |
| 7225 }; | 7262 }; |
| 7226 | 7263 |
| 7227 | 7264 |
| 7228 class WeakProperty : public Instance { | 7265 class WeakProperty : public Instance { |
| 7229 public: | 7266 public: |
| 7230 RawObject* key() const { | 7267 RawObject* key() const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7294 friend class Class; | 7331 friend class Class; |
| 7295 }; | 7332 }; |
| 7296 | 7333 |
| 7297 | 7334 |
| 7298 class UserTag : public Instance { | 7335 class UserTag : public Instance { |
| 7299 public: | 7336 public: |
| 7300 uword tag() const { return raw_ptr()->tag(); } | 7337 uword tag() const { return raw_ptr()->tag(); } |
| 7301 void set_tag(uword t) const { | 7338 void set_tag(uword t) const { |
| 7302 ASSERT(t >= UserTags::kUserTagIdOffset); | 7339 ASSERT(t >= UserTags::kUserTagIdOffset); |
| 7303 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); | 7340 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); |
| 7304 raw_ptr()->tag_ = t; | 7341 StoreNonPointer(&raw_ptr()->tag_, t); |
| 7305 } | 7342 } |
| 7306 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); } | 7343 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); } |
| 7307 | 7344 |
| 7308 RawString* label() const { | 7345 RawString* label() const { |
| 7309 return raw_ptr()->label_; | 7346 return raw_ptr()->label_; |
| 7310 } | 7347 } |
| 7311 | 7348 |
| 7312 void MakeActive() const; | 7349 void MakeActive() const; |
| 7313 | 7350 |
| 7314 static intptr_t InstanceSize() { | 7351 static intptr_t InstanceSize() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7376 intptr_t Field::Offset() const { | 7413 intptr_t Field::Offset() const { |
| 7377 ASSERT(!is_static()); // Offset is valid only for instance fields. | 7414 ASSERT(!is_static()); // Offset is valid only for instance fields. |
| 7378 intptr_t value = Smi::Value(reinterpret_cast<RawSmi*>(raw_ptr()->value_)); | 7415 intptr_t value = Smi::Value(reinterpret_cast<RawSmi*>(raw_ptr()->value_)); |
| 7379 return (value * kWordSize); | 7416 return (value * kWordSize); |
| 7380 } | 7417 } |
| 7381 | 7418 |
| 7382 | 7419 |
| 7383 void Field::SetOffset(intptr_t value_in_bytes) const { | 7420 void Field::SetOffset(intptr_t value_in_bytes) const { |
| 7384 ASSERT(!is_static()); // SetOffset is valid only for instance fields. | 7421 ASSERT(!is_static()); // SetOffset is valid only for instance fields. |
| 7385 ASSERT(kWordSize != 0); | 7422 ASSERT(kWordSize != 0); |
| 7386 raw_ptr()->value_ = Smi::New(value_in_bytes / kWordSize); | 7423 StorePointer(&raw_ptr()->value_, |
| 7424 static_cast<RawInstance*>(Smi::New(value_in_bytes / kWordSize))); |
| 7387 } | 7425 } |
| 7388 | 7426 |
| 7389 | 7427 |
| 7390 void Context::SetAt(intptr_t index, const Instance& value) const { | 7428 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 7391 StorePointer(InstanceAddr(index), value.raw()); | 7429 StorePointer(InstanceAddr(index), value.raw()); |
| 7392 } | 7430 } |
| 7393 | 7431 |
| 7394 | 7432 |
| 7395 intptr_t Instance::GetNativeField(int index) const { | 7433 intptr_t Instance::GetNativeField(int index) const { |
| 7396 ASSERT(IsValidNativeIndex(index)); | 7434 ASSERT(IsValidNativeIndex(index)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7475 | 7513 |
| 7476 | 7514 |
| 7477 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7515 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7478 intptr_t index) { | 7516 intptr_t index) { |
| 7479 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7517 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7480 } | 7518 } |
| 7481 | 7519 |
| 7482 } // namespace dart | 7520 } // namespace dart |
| 7483 | 7521 |
| 7484 #endif // VM_OBJECT_H_ | 7522 #endif // VM_OBJECT_H_ |
| OLD | NEW |