Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: vm/object.h

Issue 11360114: - Add functionality to morph a string into an external string (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 return unhandled_exception_class_; 293 return unhandled_exception_class_;
294 } 294 }
295 static RawClass* unwind_error_class() { return unwind_error_class_; } 295 static RawClass* unwind_error_class() { return unwind_error_class_; }
296 static RawClass* icdata_class() { return icdata_class_; } 296 static RawClass* icdata_class() { return icdata_class_; }
297 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; } 297 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; }
298 298
299 static RawError* Init(Isolate* isolate); 299 static RawError* Init(Isolate* isolate);
300 static void InitFromSnapshot(Isolate* isolate); 300 static void InitFromSnapshot(Isolate* isolate);
301 static void InitOnce(); 301 static void InitOnce();
302 static void RegisterSingletonClassNames(); 302 static void RegisterSingletonClassNames();
303 static void MakeUnusedSpaceTraversable(const Object& obj,
304 intptr_t original_size,
305 intptr_t used_size);
303 306
304 static intptr_t InstanceSize() { 307 static intptr_t InstanceSize() {
305 return RoundedAllocationSize(sizeof(RawObject)); 308 return RoundedAllocationSize(sizeof(RawObject));
306 } 309 }
307 310
308 static const ClassId kClassId = kObjectCid; 311 static const ClassId kClassId = kObjectCid;
309 312
310 // Different kinds of type tests. 313 // Different kinds of type tests.
311 enum TypeTestKind { 314 enum TypeTestKind {
312 kIsSubtypeOf = 0, 315 kIsSubtypeOf = 0,
(...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 } 3722 }
3720 3723
3721 bool IsExternal() const { 3724 bool IsExternal() const {
3722 return RawObject::IsExternalStringClassId(raw()->GetClassId()); 3725 return RawObject::IsExternalStringClassId(raw()->GetClassId());
3723 } 3726 }
3724 3727
3725 void* GetPeer() const; 3728 void* GetPeer() const;
3726 3729
3727 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; 3730 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const;
3728 3731
3732 // Copies the string characters into the provided external array
3733 // and morphs the string object into an external string object.
3734 // The remaining unused part of the original string object is marked as
3735 // an Array object or a regular Object so that it can be traversed during
3736 // garbage collection.
3737 RawString* MakeExternal(void* array,
3738 intptr_t length,
3739 void* peer,
3740 Dart_PeerFinalizer cback) const;
3741
3742
3729 // Creates a new String object from a C string that is assumed to contain 3743 // Creates a new String object from a C string that is assumed to contain
3730 // UTF-8 encoded characters and '\0' is considered a termination character. 3744 // UTF-8 encoded characters and '\0' is considered a termination character.
3731 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); 3745 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew);
3732 3746
3733 // Creates a new String object from an array of UTF-8 encoded characters. 3747 // Creates a new String object from an array of UTF-8 encoded characters.
3734 static RawString* New(const uint8_t* utf8_array, 3748 static RawString* New(const uint8_t* utf8_array,
3735 intptr_t array_len, 3749 intptr_t array_len,
3736 Heap::Space space = Heap::kNew); 3750 Heap::Space space = Heap::kNew);
3737 3751
3738 // Creates a new String object from an array of UTF-16 encoded characters. 3752 // Creates a new String object from an array of UTF-16 encoded characters.
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
4264 } 4278 }
4265 4279
4266 void SetLength(intptr_t value) const { 4280 void SetLength(intptr_t value) const {
4267 // This is only safe because we create a new Smi, which does not cause 4281 // This is only safe because we create a new Smi, which does not cause
4268 // heap allocation. 4282 // heap allocation.
4269 raw_ptr()->length_ = Smi::New(value); 4283 raw_ptr()->length_ = Smi::New(value);
4270 } 4284 }
4271 4285
4272 HEAP_OBJECT_IMPLEMENTATION(Array, Instance); 4286 HEAP_OBJECT_IMPLEMENTATION(Array, Instance);
4273 friend class Class; 4287 friend class Class;
4288 friend class String;
4274 }; 4289 };
4275 4290
4276 4291
4277 class ImmutableArray : public Array { 4292 class ImmutableArray : public Array {
4278 public: 4293 public:
4279 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); 4294 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew);
4280 4295
4281 private: 4296 private:
4282 HEAP_OBJECT_IMPLEMENTATION(ImmutableArray, Array); 4297 HEAP_OBJECT_IMPLEMENTATION(ImmutableArray, Array);
4283 friend class Class; 4298 friend class Class;
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
5856 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5871 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5857 return false; 5872 return false;
5858 } 5873 }
5859 } 5874 }
5860 return true; 5875 return true;
5861 } 5876 }
5862 5877
5863 } // namespace dart 5878 } // namespace dart
5864 5879
5865 #endif // VM_OBJECT_H_ 5880 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698