Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #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 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3636 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 3636 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } |
| 3637 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 3637 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } |
| 3638 | 3638 |
| 3639 virtual intptr_t Hash() const; | 3639 virtual intptr_t Hash() const; |
| 3640 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3640 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
| 3641 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3641 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
| 3642 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3642 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| 3643 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 3643 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
| 3644 static intptr_t Hash(const uint32_t* characters, intptr_t len); | 3644 static intptr_t Hash(const uint32_t* characters, intptr_t len); |
| 3645 | 3645 |
| 3646 virtual int32_t CharAt(intptr_t index) const; | 3646 int32_t CharAt(intptr_t index) const; |
| 3647 | 3647 |
| 3648 virtual intptr_t CharSize() const; | 3648 intptr_t CharSize() const; |
| 3649 | 3649 |
| 3650 inline bool Equals(const String& str) const; | 3650 inline bool Equals(const String& str) const; |
| 3651 inline bool Equals(const String& str, | 3651 inline bool Equals(const String& str, |
| 3652 intptr_t begin_index, // begin index on 'str'. | 3652 intptr_t begin_index, // begin index on 'str'. |
| 3653 intptr_t len) const; // len on 'str'. | 3653 intptr_t len) const; // len on 'str'. |
| 3654 bool Equals(const char* str) const; | 3654 bool Equals(const char* str) const; |
| 3655 bool Equals(const uint8_t* characters, intptr_t len) const; | 3655 bool Equals(const uint8_t* characters, intptr_t len) const; |
| 3656 bool Equals(const uint16_t* characters, intptr_t len) const; | 3656 bool Equals(const uint16_t* characters, intptr_t len) const; |
| 3657 bool Equals(const uint32_t* characters, intptr_t len) const; | 3657 bool Equals(const uint32_t* characters, intptr_t len) const; |
| 3658 | 3658 |
| 3659 virtual bool Equals(const Instance& other) const; | 3659 virtual bool Equals(const Instance& other) const; |
| 3660 | 3660 |
| 3661 intptr_t CompareTo(const String& other) const; | 3661 intptr_t CompareTo(const String& other) const; |
| 3662 | 3662 |
| 3663 bool StartsWith(const String& other) const; | 3663 bool StartsWith(const String& other) const; |
| 3664 | 3664 |
| 3665 virtual RawInstance* Canonicalize() const; | 3665 virtual RawInstance* Canonicalize() const; |
| 3666 | 3666 |
| 3667 bool IsSymbol() const { return raw()->IsCanonical(); } | 3667 bool IsSymbol() const { return raw()->IsCanonical(); } |
| 3668 | 3668 |
| 3669 virtual bool IsExternal() const { return false; } | 3669 bool IsOneByteString() const { |
| 3670 virtual void* GetPeer() const { | 3670 return raw()->GetClassId() == kOneByteStringCid; |
| 3671 UNREACHABLE(); | |
| 3672 return NULL; | |
| 3673 } | 3671 } |
| 3674 | 3672 |
| 3673 bool IsTwoByteString() const { | |
| 3674 return raw()->GetClassId() == kTwoByteStringCid; | |
| 3675 } | |
| 3676 | |
| 3677 bool IsExternalOneByteString() const { | |
| 3678 return raw()->GetClassId() == kExternalOneByteStringCid; | |
| 3679 } | |
| 3680 | |
| 3681 bool IsExternalTwoByteString() const { | |
| 3682 return raw()->GetClassId() == kExternalTwoByteStringCid; | |
| 3683 } | |
| 3684 | |
| 3685 bool IsExternal() const; | |
|
siva
2012/11/02 01:15:25
why not inline this too:
{
return IsExternalOneB
Tom Ball
2012/11/02 23:31:50
Good idea -- I also found that RawObject::IsExtern
| |
| 3686 | |
| 3687 void* GetPeer() const; | |
| 3688 | |
| 3675 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; | 3689 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; |
| 3676 | 3690 |
| 3677 // Creates a new String object from a C string that is assumed to contain | 3691 // Creates a new String object from a C string that is assumed to contain |
| 3678 // UTF-8 encoded characters and '\0' is considered a termination character. | 3692 // UTF-8 encoded characters and '\0' is considered a termination character. |
| 3679 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); | 3693 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); |
| 3680 | 3694 |
| 3681 // Creates a new String object from an array of UTF-8 encoded characters. | 3695 // Creates a new String object from an array of UTF-8 encoded characters. |
| 3682 static RawString* New(const uint8_t* utf8_array, | 3696 static RawString* New(const uint8_t* utf8_array, |
| 3683 intptr_t array_len, | 3697 intptr_t array_len, |
| 3684 Heap::Space space = Heap::kNew); | 3698 Heap::Space space = Heap::kNew); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3768 } | 3782 } |
| 3769 | 3783 |
| 3770 void SetHash(intptr_t value) const { | 3784 void SetHash(intptr_t value) const { |
| 3771 // This is only safe because we create a new Smi, which does not cause | 3785 // This is only safe because we create a new Smi, which does not cause |
| 3772 // heap allocation. | 3786 // heap allocation. |
| 3773 raw_ptr()->hash_ = Smi::New(value); | 3787 raw_ptr()->hash_ = Smi::New(value); |
| 3774 } | 3788 } |
| 3775 | 3789 |
| 3776 template<typename HandleType, typename ElementType> | 3790 template<typename HandleType, typename ElementType> |
| 3777 static void ReadFromImpl(SnapshotReader* reader, | 3791 static void ReadFromImpl(SnapshotReader* reader, |
| 3778 HandleType* str_obj, | 3792 String* str_obj, |
| 3779 intptr_t len, | 3793 intptr_t len, |
| 3780 intptr_t tags, | 3794 intptr_t tags, |
| 3781 Snapshot::Kind kind); | 3795 Snapshot::Kind kind); |
| 3782 | 3796 |
| 3783 HEAP_OBJECT_IMPLEMENTATION(String, Instance); | 3797 HEAP_OBJECT_IMPLEMENTATION(String, Instance); |
| 3784 | 3798 |
| 3785 friend class Symbols; | 3799 friend class Symbols; |
| 3800 friend class OneByteString; | |
| 3801 friend class TwoByteString; | |
| 3802 friend class ExternalOneByteString; | |
| 3803 friend class ExternalTwoByteString; | |
| 3786 }; | 3804 }; |
| 3787 | 3805 |
| 3788 | 3806 |
| 3789 class OneByteString : public String { | 3807 class OneByteString : public String { |
|
siva
2012/11/02 01:15:25
We does this have to inherit from String
Shouldn'
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3790 public: | 3808 public: |
| 3791 virtual int32_t CharAt(intptr_t index) const { | 3809 static int32_t CharAt(const String& str, intptr_t index) { |
| 3792 return *CharAddr(index); | 3810 return *CharAddr(str, index); |
| 3793 } | 3811 } |
| 3794 | 3812 |
| 3795 virtual intptr_t CharSize() const { | 3813 static RawOneByteString* EscapeSpecialCharacters(const String& str, |
| 3796 return kOneByteChar; | 3814 bool raw_str); |
| 3797 } | |
| 3798 | 3815 |
| 3799 RawOneByteString* EscapeSpecialCharacters(bool raw_str) const; | 3816 static bool EqualsIgnoringPrivateKey(const String& str1, |
| 3800 | 3817 const String& str2); |
| 3801 bool EqualsIgnoringPrivateKey(const OneByteString& str) const; | |
| 3802 | 3818 |
| 3803 // We use the same maximum elements for all strings. | 3819 // We use the same maximum elements for all strings. |
| 3804 static const intptr_t kBytesPerElement = 1; | 3820 static const intptr_t kBytesPerElement = 1; |
| 3805 static const intptr_t kMaxElements = String::kMaxElements; | 3821 static const intptr_t kMaxElements = String::kMaxElements; |
| 3806 | 3822 |
| 3807 static intptr_t data_offset() { return OFFSET_OF(RawOneByteString, data_); } | 3823 static intptr_t data_offset() { return OFFSET_OF(RawOneByteString, data_); } |
| 3808 | 3824 |
| 3809 static intptr_t InstanceSize() { | 3825 static intptr_t InstanceSize() { |
| 3810 ASSERT(sizeof(RawOneByteString) == OFFSET_OF(RawOneByteString, data_)); | 3826 ASSERT(sizeof(RawOneByteString) == OFFSET_OF(RawOneByteString, data_)); |
| 3811 return 0; | 3827 return 0; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3842 const String& str2, | 3858 const String& str2, |
| 3843 Heap::Space space); | 3859 Heap::Space space); |
| 3844 static RawOneByteString* ConcatAll(const Array& strings, | 3860 static RawOneByteString* ConcatAll(const Array& strings, |
| 3845 intptr_t len, | 3861 intptr_t len, |
| 3846 Heap::Space space); | 3862 Heap::Space space); |
| 3847 | 3863 |
| 3848 static RawOneByteString* Transform(int32_t (*mapping)(int32_t ch), | 3864 static RawOneByteString* Transform(int32_t (*mapping)(int32_t ch), |
| 3849 const String& str, | 3865 const String& str, |
| 3850 Heap::Space space); | 3866 Heap::Space space); |
| 3851 | 3867 |
| 3852 private: | 3868 static RawOneByteString* ReadFrom(SnapshotReader* reader, |
| 3853 uint8_t* CharAddr(intptr_t index) const { | 3869 intptr_t object_id, |
| 3854 // TODO(iposva): Determine if we should throw an exception here. | 3870 intptr_t tags, |
| 3855 ASSERT((index >= 0) && (index < Length())); | 3871 Snapshot::Kind kind); |
|
siva
2012/11/02 01:15:25
Why is this a public method for all other classes
Tom Ball
2012/11/02 23:31:50
Made private for all four string classes.
| |
| 3856 return &raw_ptr()->data_[index]; | 3872 |
| 3873 static const ClassId kClassId = kOneByteStringCid; | |
| 3874 | |
| 3875 static RawOneByteString* null() { | |
| 3876 return reinterpret_cast<RawOneByteString*>(Object::null()); | |
| 3857 } | 3877 } |
| 3858 | 3878 |
| 3859 HEAP_OBJECT_IMPLEMENTATION(OneByteString, String); | 3879 private: |
| 3880 static uint8_t* CharAddr(const String& str, intptr_t index) { | |
|
siva
2012/11/02 01:15:25
The index assertion seems to have been dropped..
Tom Ball
2012/11/02 23:31:50
Restored old assertion and added new one.
| |
| 3881 NoGCScope no_gc; | |
| 3882 RawOneByteString* raw_str = | |
| 3883 reinterpret_cast<RawOneByteString*>(str.raw_ptr()); | |
| 3884 return &raw_str->data_[index]; | |
| 3885 } | |
| 3886 | |
| 3860 friend class Class; | 3887 friend class Class; |
| 3861 friend class String; | 3888 friend class String; |
| 3862 }; | 3889 }; |
| 3863 | 3890 |
| 3864 | 3891 |
| 3865 class TwoByteString : public String { | 3892 class TwoByteString : public String { |
|
siva
2012/11/02 01:15:25
Ditto comment about this inheriting from String.
S
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3866 public: | 3893 public: |
| 3867 virtual int32_t CharAt(intptr_t index) const { | 3894 static int32_t CharAt(const String& str, intptr_t index) { |
| 3868 return *CharAddr(index); | 3895 return *CharAddr(str, index); |
| 3869 } | 3896 } |
| 3870 | 3897 |
| 3871 virtual intptr_t CharSize() const { | 3898 static RawTwoByteString* EscapeSpecialCharacters(const String& str, |
| 3872 return kTwoByteChar; | 3899 bool raw_str); |
| 3873 } | |
| 3874 | |
| 3875 RawTwoByteString* EscapeSpecialCharacters(bool raw_str) const; | |
| 3876 | 3900 |
| 3877 // We use the same maximum elements for all strings. | 3901 // We use the same maximum elements for all strings. |
| 3878 static const intptr_t kBytesPerElement = 2; | 3902 static const intptr_t kBytesPerElement = 2; |
| 3879 static const intptr_t kMaxElements = String::kMaxElements; | 3903 static const intptr_t kMaxElements = String::kMaxElements; |
| 3880 | 3904 |
| 3881 static intptr_t InstanceSize() { | 3905 static intptr_t InstanceSize() { |
| 3882 ASSERT(sizeof(RawTwoByteString) == OFFSET_OF(RawTwoByteString, data_)); | 3906 ASSERT(sizeof(RawTwoByteString) == OFFSET_OF(RawTwoByteString, data_)); |
| 3883 return 0; | 3907 return 0; |
| 3884 } | 3908 } |
| 3885 | 3909 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3906 const String& str2, | 3930 const String& str2, |
| 3907 Heap::Space space); | 3931 Heap::Space space); |
| 3908 static RawTwoByteString* ConcatAll(const Array& strings, | 3932 static RawTwoByteString* ConcatAll(const Array& strings, |
| 3909 intptr_t len, | 3933 intptr_t len, |
| 3910 Heap::Space space); | 3934 Heap::Space space); |
| 3911 | 3935 |
| 3912 static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), | 3936 static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), |
| 3913 const String& str, | 3937 const String& str, |
| 3914 Heap::Space space); | 3938 Heap::Space space); |
| 3915 | 3939 |
| 3916 private: | 3940 static RawTwoByteString* ReadFrom(SnapshotReader* reader, |
| 3917 uint16_t* CharAddr(intptr_t index) const { | 3941 intptr_t object_id, |
| 3918 ASSERT((index >= 0) && (index < Length())); | 3942 intptr_t tags, |
| 3919 return &raw_ptr()->data_[index]; | 3943 Snapshot::Kind kind); |
|
siva
2012/11/02 01:15:25
Ditto comment about this being a public method.
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3944 | |
| 3945 static RawTwoByteString* null() { | |
| 3946 return reinterpret_cast<RawTwoByteString*>(Object::null()); | |
| 3920 } | 3947 } |
| 3921 | 3948 |
| 3922 HEAP_OBJECT_IMPLEMENTATION(TwoByteString, String); | 3949 static const ClassId kClassId = kTwoByteStringCid; |
| 3950 | |
| 3951 private: | |
| 3952 static uint16_t* CharAddr(const String& str, intptr_t index) { | |
|
siva
2012/11/02 01:15:25
The index assertion seems to have been dropped.
A
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3953 NoGCScope no_gc; | |
| 3954 RawTwoByteString* raw_str = | |
| 3955 reinterpret_cast<RawTwoByteString*>(str.raw_ptr()); | |
| 3956 return &raw_str->data_[index]; | |
| 3957 } | |
| 3958 | |
| 3923 friend class Class; | 3959 friend class Class; |
| 3924 friend class String; | 3960 friend class String; |
| 3925 }; | 3961 }; |
| 3926 | 3962 |
| 3927 | 3963 |
| 3928 class ExternalOneByteString : public String { | 3964 class ExternalOneByteString : public String { |
|
siva
2012/11/02 01:15:25
Ditto comment about inheriting from String, should
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3929 public: | 3965 private: |
| 3930 virtual int32_t CharAt(intptr_t index) const { | 3966 static RawExternalOneByteString* raw_str(const String& str) { |
| 3931 return *CharAddr(index); | 3967 return reinterpret_cast<RawExternalOneByteString*>(str.raw_ptr()); |
| 3932 } | 3968 } |
| 3933 | 3969 |
| 3934 virtual intptr_t CharSize() const { | 3970 public: |
| 3935 return kOneByteChar; | 3971 static int32_t CharAt(const String& str, intptr_t index) { |
| 3972 return *CharAddr(str, index); | |
| 3936 } | 3973 } |
| 3937 | 3974 |
| 3938 virtual bool IsExternal() const { return true; } | 3975 static void* GetPeer(const String& str) { |
| 3939 virtual void* GetPeer() const { | 3976 return raw_str(str)->external_data_->peer(); |
| 3940 return raw_ptr()->external_data_->peer(); | |
| 3941 } | 3977 } |
| 3942 | 3978 |
| 3943 // We use the same maximum elements for all strings. | 3979 // We use the same maximum elements for all strings. |
| 3944 static const intptr_t kBytesPerElement = 1; | 3980 static const intptr_t kBytesPerElement = 1; |
| 3945 static const intptr_t kMaxElements = String::kMaxElements; | 3981 static const intptr_t kMaxElements = String::kMaxElements; |
| 3946 | 3982 |
| 3947 static intptr_t InstanceSize() { | 3983 static intptr_t InstanceSize() { |
| 3948 return RoundedAllocationSize(sizeof(RawExternalOneByteString)); | 3984 return RoundedAllocationSize(sizeof(RawExternalOneByteString)); |
| 3949 } | 3985 } |
| 3950 | 3986 |
| 3951 static RawExternalOneByteString* New(const uint8_t* characters, | 3987 static RawExternalOneByteString* New(const uint8_t* characters, |
| 3952 intptr_t len, | 3988 intptr_t len, |
| 3953 void* peer, | 3989 void* peer, |
| 3954 Dart_PeerFinalizer callback, | 3990 Dart_PeerFinalizer callback, |
| 3955 Heap::Space space); | 3991 Heap::Space space); |
| 3956 | 3992 |
| 3957 private: | 3993 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, |
| 3958 const uint8_t* CharAddr(intptr_t index) const { | 3994 intptr_t object_id, |
| 3959 // TODO(iposva): Determine if we should throw an exception here. | 3995 intptr_t tags, |
| 3960 ASSERT((index >= 0) && (index < Length())); | 3996 Snapshot::Kind kind); |
|
siva
2012/11/02 01:15:25
Ditto comment about this being a public method.
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3961 return &(raw_ptr()->external_data_->data()[index]); | 3997 |
| 3998 static RawExternalOneByteString* null() { | |
| 3999 return reinterpret_cast<RawExternalOneByteString*>(Object::null()); | |
| 3962 } | 4000 } |
| 3963 | 4001 |
| 3964 void SetExternalData(ExternalStringData<uint8_t>* data) { | 4002 static const ClassId kClassId = kExternalOneByteStringCid; |
| 3965 raw_ptr()->external_data_ = data; | 4003 |
| 4004 private: | |
| 4005 static const uint8_t* CharAddr(const String& str, intptr_t index) { | |
| 4006 ASSERT((index >= 0) && (index < str.Length())); | |
|
siva
2012/11/02 01:15:25
ASSERT(str.IsExternalOneByteString());
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 4007 NoGCScope no_gc; | |
| 4008 return &(raw_str(str)->external_data_->data()[index]); | |
| 4009 } | |
| 4010 | |
| 4011 static void SetExternalData(const String& str, | |
| 4012 ExternalStringData<uint8_t>* data) { | |
|
siva
2012/11/02 01:15:25
ASSERT(str.IsExternalOneByteString());
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 4013 NoGCScope no_gc; | |
| 4014 raw_str(str)->external_data_ = data; | |
| 3966 } | 4015 } |
| 3967 | 4016 |
| 3968 static void Finalize(Dart_Handle handle, void* peer); | 4017 static void Finalize(Dart_Handle handle, void* peer); |
| 3969 | 4018 |
| 3970 HEAP_OBJECT_IMPLEMENTATION(ExternalOneByteString, String); | |
| 3971 friend class Class; | 4019 friend class Class; |
| 3972 friend class String; | 4020 friend class String; |
| 3973 }; | 4021 }; |
| 3974 | 4022 |
| 3975 | 4023 |
| 3976 class ExternalTwoByteString : public String { | 4024 class ExternalTwoByteString : public String { |
|
siva
2012/11/02 01:15:25
Ditto comment about inheriting from AllStatic not
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 3977 public: | 4025 private: |
| 3978 virtual int32_t CharAt(intptr_t index) const { | 4026 static RawExternalTwoByteString* raw_str(const String& str) { |
| 3979 return *CharAddr(index); | 4027 return reinterpret_cast<RawExternalTwoByteString*>(str.raw_ptr()); |
| 3980 } | 4028 } |
| 3981 | 4029 |
| 3982 virtual intptr_t CharSize() const { | 4030 public: |
| 3983 return kTwoByteChar; | 4031 static int32_t CharAt(const String& str, intptr_t index) { |
| 4032 return *CharAddr(str, index); | |
| 3984 } | 4033 } |
| 3985 | 4034 |
| 3986 virtual bool IsExternal() const { return true; } | 4035 static void* GetPeer(const String& str) { |
| 3987 virtual void* GetPeer() const { | 4036 return raw_str(str)->external_data_->peer(); |
| 3988 return raw_ptr()->external_data_->peer(); | |
| 3989 } | 4037 } |
| 3990 | 4038 |
| 3991 // We use the same maximum elements for all strings. | 4039 // We use the same maximum elements for all strings. |
| 3992 static const intptr_t kBytesPerElement = 2; | 4040 static const intptr_t kBytesPerElement = 2; |
| 3993 static const intptr_t kMaxElements = String::kMaxElements; | 4041 static const intptr_t kMaxElements = String::kMaxElements; |
| 3994 | 4042 |
| 3995 static intptr_t InstanceSize() { | 4043 static intptr_t InstanceSize() { |
| 3996 return RoundedAllocationSize(sizeof(RawExternalTwoByteString)); | 4044 return RoundedAllocationSize(sizeof(RawExternalTwoByteString)); |
| 3997 } | 4045 } |
| 3998 | 4046 |
| 3999 static RawExternalTwoByteString* New(const uint16_t* characters, | 4047 static RawExternalTwoByteString* New(const uint16_t* characters, |
| 4000 intptr_t len, | 4048 intptr_t len, |
| 4001 void* peer, | 4049 void* peer, |
| 4002 Dart_PeerFinalizer callback, | 4050 Dart_PeerFinalizer callback, |
| 4003 Heap::Space space = Heap::kNew); | 4051 Heap::Space space = Heap::kNew); |
| 4004 | 4052 |
| 4005 private: | 4053 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, |
| 4006 const uint16_t* CharAddr(intptr_t index) const { | 4054 intptr_t object_id, |
| 4007 // TODO(iposva): Determine if we should throw an exception here. | 4055 intptr_t tags, |
| 4008 ASSERT((index >= 0) && (index < Length())); | 4056 Snapshot::Kind kind); |
|
siva
2012/11/02 01:15:25
Ditto comment about being public.
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 4009 return &(raw_ptr()->external_data_->data()[index]); | 4057 |
| 4058 static RawExternalTwoByteString* null() { | |
| 4059 return reinterpret_cast<RawExternalTwoByteString*>(Object::null()); | |
| 4010 } | 4060 } |
| 4011 | 4061 |
| 4012 void SetExternalData(ExternalStringData<uint16_t>* data) { | 4062 static const ClassId kClassId = kExternalTwoByteStringCid; |
| 4013 raw_ptr()->external_data_ = data; | 4063 |
| 4064 private: | |
| 4065 static const uint16_t* CharAddr(const String& str, intptr_t index) { | |
| 4066 ASSERT((index >= 0) && (index < str.Length())); | |
|
siva
2012/11/02 01:15:25
ASSERT(str.IsExternalTwoByteString());
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 4067 NoGCScope no_gc; | |
| 4068 return &(raw_str(str)->external_data_->data()[index]); | |
| 4069 } | |
| 4070 | |
| 4071 static void SetExternalData(const String& str, | |
| 4072 ExternalStringData<uint16_t>* data) { | |
|
siva
2012/11/02 01:15:25
ASSERT(str.IsExternalTwoByteString());
NoGCScope n
Tom Ball
2012/11/02 23:31:50
Done.
| |
| 4073 raw_str(str)->external_data_ = data; | |
| 4014 } | 4074 } |
| 4015 | 4075 |
| 4016 static void Finalize(Dart_Handle handle, void* peer); | 4076 static void Finalize(Dart_Handle handle, void* peer); |
| 4017 | 4077 |
| 4018 HEAP_OBJECT_IMPLEMENTATION(ExternalTwoByteString, String); | |
| 4019 friend class Class; | 4078 friend class Class; |
| 4020 friend class String; | 4079 friend class String; |
| 4021 }; | 4080 }; |
| 4022 | 4081 |
| 4023 | 4082 |
| 4024 // Class Bool implements Dart core class bool. | 4083 // Class Bool implements Dart core class bool. |
| 4025 class Bool : public Instance { | 4084 class Bool : public Instance { |
| 4026 public: | 4085 public: |
| 4027 bool value() const { | 4086 bool value() const { |
| 4028 return raw_ptr()->value_; | 4087 return raw_ptr()->value_; |
| (...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5731 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5790 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5732 return false; | 5791 return false; |
| 5733 } | 5792 } |
| 5734 } | 5793 } |
| 5735 return true; | 5794 return true; |
| 5736 } | 5795 } |
| 5737 | 5796 |
| 5738 } // namespace dart | 5797 } // namespace dart |
| 5739 | 5798 |
| 5740 #endif // VM_OBJECT_H_ | 5799 #endif // VM_OBJECT_H_ |
| OLD | NEW |