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

Unified Diff: runtime/vm/object.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 26534)
+++ runtime/vm/object.cc (working copy)
@@ -13427,6 +13427,23 @@
}
+void OneByteString::SetPeer(const String& str,
+ void* peer,
+ Dart_PeerFinalizer cback) {
+ ASSERT(!str.IsNull() && str.IsOneByteString());
+ ASSERT(peer != NULL);
+ ExternalStringData<uint8_t>* ext_data =
+ new ExternalStringData<uint8_t>(NULL, peer, cback);
+ AddFinalizer(str, ext_data, OneByteString::Finalize);
+}
+
+
+void OneByteString::Finalize(Dart_WeakPersistentHandle handle, void* peer) {
+ delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer);
+ DeleteWeakPersistentHandle(handle);
+}
+
+
RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str) {
intptr_t len = str.Length();
if (len > 0) {
@@ -13579,6 +13596,23 @@
}
+void TwoByteString::SetPeer(const String& str,
+ void* peer,
+ Dart_PeerFinalizer cback) {
+ ASSERT(!str.IsNull() && str.IsTwoByteString());
+ ASSERT(peer != NULL);
+ ExternalStringData<uint16_t>* ext_data =
+ new ExternalStringData<uint16_t>(NULL, peer, cback);
+ AddFinalizer(str, ext_data, TwoByteString::Finalize);
+}
+
+
+void TwoByteString::Finalize(Dart_WeakPersistentHandle handle, void* peer) {
+ delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer);
+ DeleteWeakPersistentHandle(handle);
+}
+
+
RawExternalOneByteString* ExternalOneByteString::New(
const uint8_t* data,
intptr_t len,
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698