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 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3893 const String& str_; | 3893 const String& str_; |
3894 int32_t ch_; | 3894 int32_t ch_; |
3895 intptr_t index_; | 3895 intptr_t index_; |
3896 intptr_t end_; | 3896 intptr_t end_; |
3897 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); | 3897 DISALLOW_IMPLICIT_CONSTRUCTORS(CodePointIterator); |
3898 }; | 3898 }; |
3899 | 3899 |
3900 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 3900 intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } |
3901 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 3901 static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } |
3902 | 3902 |
3903 virtual intptr_t Hash() const; | 3903 virtual intptr_t Hash() const { |
Ivan Posva
2013/01/15 06:05:15
Can you explain to me why Hash() is a virtual in t
srdjan
2013/01/15 18:58:28
Apparently, the reason is historical. There is no
| |
3904 return StringHash(); | |
3905 } | |
3906 | |
3907 // Non-virtual, higher performance when type is known. | |
3908 intptr_t StringHash() const { | |
3909 intptr_t result = Smi::Value(raw_ptr()->hash_); | |
3910 if (result != 0) { | |
3911 return result; | |
3912 } | |
3913 result = String::Hash(*this, 0, this->Length()); | |
3914 this->SetHash(result); | |
3915 return result; | |
3916 } | |
3917 | |
3904 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3918 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } |
3905 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3919 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); |
3906 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3920 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
3907 static intptr_t Hash(const uint16_t* characters, intptr_t len); | 3921 static intptr_t Hash(const uint16_t* characters, intptr_t len); |
3908 static intptr_t Hash(const int32_t* characters, intptr_t len); | 3922 static intptr_t Hash(const int32_t* characters, intptr_t len); |
3909 | 3923 |
3910 int32_t CharAt(intptr_t index) const; | 3924 int32_t CharAt(intptr_t index) const; |
3911 | 3925 |
3912 intptr_t CharSize() const; | 3926 intptr_t CharSize() const; |
3913 | 3927 |
(...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6253 | 6267 |
6254 | 6268 |
6255 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6269 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6256 intptr_t index) { | 6270 intptr_t index) { |
6257 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6271 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6258 } | 6272 } |
6259 | 6273 |
6260 } // namespace dart | 6274 } // namespace dart |
6261 | 6275 |
6262 #endif // VM_OBJECT_H_ | 6276 #endif // VM_OBJECT_H_ |
OLD | NEW |