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

Unified Diff: runtime/vm/object.cc

Issue 2997173002: [vm] Remove Dart_MakeExternalString and --support-externalizable-strings (Closed)
Patch Set: Update vm.status Created 3 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
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 7ec32463f79441d341e6206b1e5fa6a4544c6a07..3461f167c8df016266f1d9f648fccf879755a891 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -85,7 +85,6 @@ DECLARE_FLAG(bool, trace_deoptimization);
DECLARE_FLAG(bool, trace_deoptimization_verbose);
DECLARE_FLAG(bool, trace_reload);
DECLARE_FLAG(bool, write_protect_code);
-DECLARE_FLAG(bool, support_externalizable_strings);
static const char* const kGetterPrefix = "get:";
static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix);
@@ -8199,14 +8198,6 @@ const char* Field::GuardedPropertiesAsCString() const {
"<%s %s>", is_nullable() ? "nullable" : "not-nullable", class_name);
}
-bool Field::IsExternalizableCid(intptr_t cid) {
- if (FLAG_support_externalizable_strings) {
- return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid);
- } else {
- return false;
- }
-}
-
void Field::InitializeGuardedListLengthInObjectOffset() const {
ASSERT(IsOriginal());
if (needs_length_check() &&
@@ -20292,100 +20283,6 @@ static FinalizablePersistentHandle* AddFinalizer(
callback, external_size);
}
-RawString* String::MakeExternal(void* array,
- intptr_t external_size,
- void* peer,
- Dart_PeerFinalizer cback) const {
- ASSERT(FLAG_support_externalizable_strings);
- String& result = String::Handle();
- void* external_data;
- Dart_WeakPersistentHandleFinalizer finalizer;
- {
- NoSafepointScope no_safepoint;
- ASSERT(array != NULL);
- intptr_t str_length = this->Length();
- ASSERT(external_size >= (str_length * this->CharSize()));
- intptr_t class_id = raw()->GetClassId();
-
- ASSERT(!InVMHeap());
- if (class_id == kOneByteStringCid) {
- intptr_t used_size = ExternalOneByteString::InstanceSize();
- intptr_t original_size = OneByteString::InstanceSize(str_length);
- ASSERT(original_size >= used_size);
-
- // Copy the data into the external array.
- if (str_length > 0) {
- memmove(array, OneByteString::CharAddr(*this, 0), str_length);
- }
-
- // If there is any left over space fill it with either an Array object or
- // just a plain object (depending on the amount of left over space) so
- // that it can be traversed over successfully during garbage collection.
- Object::MakeUnusedSpaceTraversable(*this, original_size, used_size);
-
- // Update the class information of the object.
- const intptr_t class_id = kExternalOneByteStringCid;
- uint32_t tags = raw_ptr()->tags_;
- uint32_t old_tags;
- do {
- old_tags = tags;
- uint32_t new_tags = RawObject::SizeTag::update(used_size, old_tags);
- new_tags = RawObject::ClassIdTag::update(class_id, new_tags);
- tags = CompareAndSwapTags(old_tags, new_tags);
- } while (tags != old_tags);
- result = this->raw();
- const uint8_t* ext_array = reinterpret_cast<const uint8_t*>(array);
- ExternalStringData<uint8_t>* ext_data =
- new ExternalStringData<uint8_t>(ext_array, peer, cback);
- ASSERT(result.Length() == str_length);
- ASSERT(!result.HasHash() ||
- (result.Hash() == String::Hash(ext_array, str_length)));
- ExternalOneByteString::SetExternalData(result, ext_data);
- external_data = ext_data;
- finalizer = ExternalOneByteString::Finalize;
- } else {
- ASSERT(class_id == kTwoByteStringCid);
- intptr_t used_size = ExternalTwoByteString::InstanceSize();
- intptr_t original_size = TwoByteString::InstanceSize(str_length);
- ASSERT(original_size >= used_size);
-
- // Copy the data into the external array.
- if (str_length > 0) {
- memmove(array, TwoByteString::CharAddr(*this, 0),
- (str_length * kTwoByteChar));
- }
-
- // If there is any left over space fill it with either an Array object or
- // just a plain object (depending on the amount of left over space) so
- // that it can be traversed over successfully during garbage collection.
- Object::MakeUnusedSpaceTraversable(*this, original_size, used_size);
-
- // Update the class information of the object.
- const intptr_t class_id = kExternalTwoByteStringCid;
- uint32_t tags = raw_ptr()->tags_;
- uint32_t old_tags;
- do {
- old_tags = tags;
- uint32_t new_tags = RawObject::SizeTag::update(used_size, old_tags);
- new_tags = RawObject::ClassIdTag::update(class_id, new_tags);
- tags = CompareAndSwapTags(old_tags, new_tags);
- } while (tags != old_tags);
- result = this->raw();
- const uint16_t* ext_array = reinterpret_cast<const uint16_t*>(array);
- ExternalStringData<uint16_t>* ext_data =
- new ExternalStringData<uint16_t>(ext_array, peer, cback);
- ASSERT(result.Length() == str_length);
- ASSERT(!result.HasHash() ||
- (result.Hash() == String::Hash(ext_array, str_length)));
- ExternalTwoByteString::SetExternalData(result, ext_data);
- external_data = ext_data;
- finalizer = ExternalTwoByteString::Finalize;
- }
- } // NoSafepointScope
- AddFinalizer(result, external_data, finalizer, external_size);
- return this->raw();
-}
-
RawString* String::Transform(int32_t (*mapping)(int32_t ch),
const String& str,
Heap::Space space) {

Powered by Google App Engine
This is Rietveld 408576698