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

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 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 } 3761 }
3759 3762
3760 bool IsExternal() const { 3763 bool IsExternal() const {
3761 return RawObject::IsExternalStringClassId(raw()->GetClassId()); 3764 return RawObject::IsExternalStringClassId(raw()->GetClassId());
3762 } 3765 }
3763 3766
3764 void* GetPeer() const; 3767 void* GetPeer() const;
3765 3768
3766 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const; 3769 void ToUTF8(uint8_t* utf8_array, intptr_t array_len) const;
3767 3770
3771 // Copies the string characters into the provided external array
3772 // and morphs the string object into an external string object.
3773 // The remaining unused part of the original string object is marked as
3774 // an Array object or a regular Object so that it can be traversed during
3775 // garbage collection.
3776 RawString* MakeExternal(void* array,
3777 intptr_t length,
3778 void* peer,
3779 Dart_PeerFinalizer cback) const;
3780
3781
3768 // Creates a new String object from a C string that is assumed to contain 3782 // Creates a new String object from a C string that is assumed to contain
3769 // UTF-8 encoded characters and '\0' is considered a termination character. 3783 // UTF-8 encoded characters and '\0' is considered a termination character.
3770 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); 3784 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew);
3771 3785
3772 // Creates a new String object from an array of UTF-8 encoded characters. 3786 // Creates a new String object from an array of UTF-8 encoded characters.
3773 static RawString* New(const uint8_t* utf8_array, 3787 static RawString* New(const uint8_t* utf8_array,
3774 intptr_t array_len, 3788 intptr_t array_len,
3775 Heap::Space space = Heap::kNew); 3789 Heap::Space space = Heap::kNew);
3776 3790
3777 // Creates a new String object from an array of UTF-16 encoded characters. 3791 // 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
4303 } 4317 }
4304 4318
4305 void SetLength(intptr_t value) const { 4319 void SetLength(intptr_t value) const {
4306 // This is only safe because we create a new Smi, which does not cause 4320 // This is only safe because we create a new Smi, which does not cause
4307 // heap allocation. 4321 // heap allocation.
4308 raw_ptr()->length_ = Smi::New(value); 4322 raw_ptr()->length_ = Smi::New(value);
4309 } 4323 }
4310 4324
4311 HEAP_OBJECT_IMPLEMENTATION(Array, Instance); 4325 HEAP_OBJECT_IMPLEMENTATION(Array, Instance);
4312 friend class Class; 4326 friend class Class;
4327 friend class String;
4313 }; 4328 };
4314 4329
4315 4330
4316 class ImmutableArray : public Array { 4331 class ImmutableArray : public Array {
4317 public: 4332 public:
4318 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); 4333 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew);
4319 4334
4320 private: 4335 private:
4321 HEAP_OBJECT_IMPLEMENTATION(ImmutableArray, Array); 4336 HEAP_OBJECT_IMPLEMENTATION(ImmutableArray, Array);
4322 friend class Class; 4337 friend class Class;
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after
5907 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5922 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5908 return false; 5923 return false;
5909 } 5924 }
5910 } 5925 }
5911 return true; 5926 return true;
5912 } 5927 }
5913 5928
5914 } // namespace dart 5929 } // namespace dart
5915 5930
5916 #endif // VM_OBJECT_H_ 5931 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698