| 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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
| 6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 7226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7237 private: | 7237 private: |
| 7238 static RawOneByteString* raw(const String& str) { | 7238 static RawOneByteString* raw(const String& str) { |
| 7239 return reinterpret_cast<RawOneByteString*>(str.raw()); | 7239 return reinterpret_cast<RawOneByteString*>(str.raw()); |
| 7240 } | 7240 } |
| 7241 | 7241 |
| 7242 static const RawOneByteString* raw_ptr(const String& str) { | 7242 static const RawOneByteString* raw_ptr(const String& str) { |
| 7243 return reinterpret_cast<const RawOneByteString*>(str.raw_ptr()); | 7243 return reinterpret_cast<const RawOneByteString*>(str.raw_ptr()); |
| 7244 } | 7244 } |
| 7245 | 7245 |
| 7246 static uint8_t* CharAddr(const String& str, intptr_t index) { | 7246 static uint8_t* CharAddr(const String& str, intptr_t index) { |
| 7247 ASSERT((index >= 0) && (index < str.Length())); | 7247 ASSERT(index == 0 || ((index >= 0) && (index < str.Length()))); |
| 7248 ASSERT(str.IsOneByteString()); | 7248 ASSERT(str.IsOneByteString()); |
| 7249 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; | 7249 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; |
| 7250 } | 7250 } |
| 7251 | 7251 |
| 7252 static RawOneByteString* ReadFrom(SnapshotReader* reader, | 7252 static RawOneByteString* ReadFrom(SnapshotReader* reader, |
| 7253 intptr_t object_id, | 7253 intptr_t object_id, |
| 7254 intptr_t tags, | 7254 intptr_t tags, |
| 7255 Snapshot::Kind kind, | 7255 Snapshot::Kind kind, |
| 7256 bool as_reference); | 7256 bool as_reference); |
| 7257 | 7257 |
| 7258 friend class Class; | 7258 friend class Class; |
| 7259 friend class String; | 7259 friend class String; |
| 7260 friend class Symbols; | 7260 friend class Symbols; |
| 7261 friend class ExternalOneByteString; | 7261 friend class ExternalOneByteString; |
| 7262 friend class SnapshotReader; | 7262 friend class SnapshotReader; |
| 7263 friend class StringHasher; | 7263 friend class StringHasher; |
| 7264 friend class Utf8; |
| 7264 }; | 7265 }; |
| 7265 | 7266 |
| 7266 | 7267 |
| 7267 class TwoByteString : public AllStatic { | 7268 class TwoByteString : public AllStatic { |
| 7268 public: | 7269 public: |
| 7269 static uint16_t CharAt(const String& str, intptr_t index) { | 7270 static uint16_t CharAt(const String& str, intptr_t index) { |
| 7270 ASSERT((index >= 0) && (index < str.Length())); | 7271 ASSERT((index >= 0) && (index < str.Length())); |
| 7271 ASSERT(str.IsTwoByteString()); | 7272 ASSERT(str.IsTwoByteString()); |
| 7272 return raw_ptr(str)->data()[index]; | 7273 return raw_ptr(str)->data()[index]; |
| 7273 } | 7274 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7423 private: | 7424 private: |
| 7424 static RawExternalOneByteString* raw(const String& str) { | 7425 static RawExternalOneByteString* raw(const String& str) { |
| 7425 return reinterpret_cast<RawExternalOneByteString*>(str.raw()); | 7426 return reinterpret_cast<RawExternalOneByteString*>(str.raw()); |
| 7426 } | 7427 } |
| 7427 | 7428 |
| 7428 static const RawExternalOneByteString* raw_ptr(const String& str) { | 7429 static const RawExternalOneByteString* raw_ptr(const String& str) { |
| 7429 return reinterpret_cast<const RawExternalOneByteString*>(str.raw_ptr()); | 7430 return reinterpret_cast<const RawExternalOneByteString*>(str.raw_ptr()); |
| 7430 } | 7431 } |
| 7431 | 7432 |
| 7432 static const uint8_t* CharAddr(const String& str, intptr_t index) { | 7433 static const uint8_t* CharAddr(const String& str, intptr_t index) { |
| 7433 ASSERT((index >= 0) && (index < str.Length())); | 7434 ASSERT(index == 0 || ((index >= 0) && (index < str.Length()))); |
| 7434 ASSERT(str.IsExternalOneByteString()); | 7435 ASSERT(str.IsExternalOneByteString()); |
| 7435 return &(raw_ptr(str)->external_data_->data()[index]); | 7436 return &(raw_ptr(str)->external_data_->data()[index]); |
| 7436 } | 7437 } |
| 7437 | 7438 |
| 7438 static void SetExternalData(const String& str, | 7439 static void SetExternalData(const String& str, |
| 7439 ExternalStringData<uint8_t>* data) { | 7440 ExternalStringData<uint8_t>* data) { |
| 7440 ASSERT(str.IsExternalOneByteString()); | 7441 ASSERT(str.IsExternalOneByteString()); |
| 7441 ASSERT(!Isolate::Current()->heap()->Contains( | 7442 ASSERT(!Isolate::Current()->heap()->Contains( |
| 7442 reinterpret_cast<uword>(data->data()))); | 7443 reinterpret_cast<uword>(data->data()))); |
| 7443 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); | 7444 str.StoreNonPointer(&raw_ptr(str)->external_data_, data); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7455 | 7456 |
| 7456 static intptr_t NextFieldOffset() { | 7457 static intptr_t NextFieldOffset() { |
| 7457 // Indicates this class cannot be extended by dart code. | 7458 // Indicates this class cannot be extended by dart code. |
| 7458 return -kWordSize; | 7459 return -kWordSize; |
| 7459 } | 7460 } |
| 7460 | 7461 |
| 7461 friend class Class; | 7462 friend class Class; |
| 7462 friend class String; | 7463 friend class String; |
| 7463 friend class SnapshotReader; | 7464 friend class SnapshotReader; |
| 7464 friend class Symbols; | 7465 friend class Symbols; |
| 7466 friend class Utf8; |
| 7465 }; | 7467 }; |
| 7466 | 7468 |
| 7467 | 7469 |
| 7468 class ExternalTwoByteString : public AllStatic { | 7470 class ExternalTwoByteString : public AllStatic { |
| 7469 public: | 7471 public: |
| 7470 static uint16_t CharAt(const String& str, intptr_t index) { | 7472 static uint16_t CharAt(const String& str, intptr_t index) { |
| 7471 NoSafepointScope no_safepoint; | 7473 NoSafepointScope no_safepoint; |
| 7472 return *CharAddr(str, index); | 7474 return *CharAddr(str, index); |
| 7473 } | 7475 } |
| 7474 | 7476 |
| (...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9067 | 9069 |
| 9068 inline void TypeArguments::SetHash(intptr_t value) const { | 9070 inline void TypeArguments::SetHash(intptr_t value) const { |
| 9069 // This is only safe because we create a new Smi, which does not cause | 9071 // This is only safe because we create a new Smi, which does not cause |
| 9070 // heap allocation. | 9072 // heap allocation. |
| 9071 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 9073 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 9072 } | 9074 } |
| 9073 | 9075 |
| 9074 } // namespace dart | 9076 } // namespace dart |
| 9075 | 9077 |
| 9076 #endif // RUNTIME_VM_OBJECT_H_ | 9078 #endif // RUNTIME_VM_OBJECT_H_ |
| OLD | NEW |