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

Side by Side Diff: runtime/vm/object.h

Issue 22980022: Setup a peer for read only strings that are not externalized in (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months 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 4564 matching lines...) Expand 10 before | Expand all | Expand 10 after
4575 // Copies the string characters into the provided external array 4575 // Copies the string characters into the provided external array
4576 // and morphs the string object into an external string object. 4576 // and morphs the string object into an external string object.
4577 // The remaining unused part of the original string object is marked as 4577 // The remaining unused part of the original string object is marked as
4578 // an Array object or a regular Object so that it can be traversed during 4578 // an Array object or a regular Object so that it can be traversed during
4579 // garbage collection. 4579 // garbage collection.
4580 RawString* MakeExternal(void* array, 4580 RawString* MakeExternal(void* array,
4581 intptr_t length, 4581 intptr_t length,
4582 void* peer, 4582 void* peer,
4583 Dart_PeerFinalizer cback) const; 4583 Dart_PeerFinalizer cback) const;
4584 4584
4585
4586 // Creates a new String object from a C string that is assumed to contain 4585 // Creates a new String object from a C string that is assumed to contain
4587 // UTF-8 encoded characters and '\0' is considered a termination character. 4586 // UTF-8 encoded characters and '\0' is considered a termination character.
4588 // TODO(7123) - Rename this to FromCString(....). 4587 // TODO(7123) - Rename this to FromCString(....).
4589 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); 4588 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew);
4590 4589
4591 // Creates a new String object from an array of UTF-8 encoded characters. 4590 // Creates a new String object from an array of UTF-8 encoded characters.
4592 static RawString* FromUTF8(const uint8_t* utf8_array, 4591 static RawString* FromUTF8(const uint8_t* utf8_array,
4593 intptr_t array_len, 4592 intptr_t array_len,
4594 Heap::Space space = Heap::kNew); 4593 Heap::Space space = Heap::kNew);
4595 4594
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 const String& str, 4774 const String& str,
4776 Heap::Space space); 4775 Heap::Space space);
4777 4776
4778 // High performance version of substring for one-byte strings. 4777 // High performance version of substring for one-byte strings.
4779 // "str" must be OneByteString. 4778 // "str" must be OneByteString.
4780 static RawOneByteString* SubStringUnchecked(const String& str, 4779 static RawOneByteString* SubStringUnchecked(const String& str,
4781 intptr_t begin_index, 4780 intptr_t begin_index,
4782 intptr_t length, 4781 intptr_t length,
4783 Heap::Space space); 4782 Heap::Space space);
4784 4783
4784 static void SetPeer(const String& str,
4785 void* peer,
4786 Dart_PeerFinalizer cback);
4787
4788 static void Finalize(Dart_WeakPersistentHandle handle, void* peer);
4789
4785 static const ClassId kClassId = kOneByteStringCid; 4790 static const ClassId kClassId = kOneByteStringCid;
4786 4791
4787 static RawOneByteString* null() { 4792 static RawOneByteString* null() {
4788 return reinterpret_cast<RawOneByteString*>(Object::null()); 4793 return reinterpret_cast<RawOneByteString*>(Object::null());
4789 } 4794 }
4790 4795
4791 private: 4796 private:
4792 static RawOneByteString* raw(const String& str) { 4797 static RawOneByteString* raw(const String& str) {
4793 return reinterpret_cast<RawOneByteString*>(str.raw()); 4798 return reinterpret_cast<RawOneByteString*>(str.raw());
4794 } 4799 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 const String& str2, 4862 const String& str2,
4858 Heap::Space space); 4863 Heap::Space space);
4859 static RawTwoByteString* ConcatAll(const Array& strings, 4864 static RawTwoByteString* ConcatAll(const Array& strings,
4860 intptr_t len, 4865 intptr_t len,
4861 Heap::Space space); 4866 Heap::Space space);
4862 4867
4863 static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), 4868 static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch),
4864 const String& str, 4869 const String& str,
4865 Heap::Space space); 4870 Heap::Space space);
4866 4871
4872 static void SetPeer(const String& str,
4873 void* peer,
4874 Dart_PeerFinalizer cback);
4875
4876 static void Finalize(Dart_WeakPersistentHandle handle, void* peer);
4877
4867 static RawTwoByteString* null() { 4878 static RawTwoByteString* null() {
4868 return reinterpret_cast<RawTwoByteString*>(Object::null()); 4879 return reinterpret_cast<RawTwoByteString*>(Object::null());
4869 } 4880 }
4870 4881
4871 4882
4872 static const ClassId kClassId = kTwoByteStringCid; 4883 static const ClassId kClassId = kTwoByteStringCid;
4873 4884
4874 private: 4885 private:
4875 static RawTwoByteString* raw(const String& str) { 4886 static RawTwoByteString* raw(const String& str) {
4876 return reinterpret_cast<RawTwoByteString*>(str.raw()); 4887 return reinterpret_cast<RawTwoByteString*>(str.raw());
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
6079 6090
6080 6091
6081 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6092 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6082 intptr_t index) { 6093 intptr_t index) {
6083 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6094 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6084 } 6095 }
6085 6096
6086 } // namespace dart 6097 } // namespace dart
6087 6098
6088 #endif // VM_OBJECT_H_ 6099 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698