Lines Matching defs:string
5 #include "src/objects/string.h"
22 #include "src/objects/string-comparator.h"
23 #include "src/objects/string-inl.h"
25 #include "src/strings/string-builder-inl.h"
26 #include "src/strings/string-hasher.h"
27 #include "src/strings/string-search.h"
28 #include "src/strings/string-stream.h"
88 // the flat string, which could already be a copy or an existing string from
95 // A relaxed write is sufficient here, because at this point the string
140 void MigrateExternalString(Isolate* isolate, String string,
143 MigrateExternalStringResource(isolate, ExternalString::cast(string),
146 MigrateExternalStringResource(isolate, ExternalString::cast(string),
149 // If the external string is duped into an existing non-external
150 // internalized string, free its resource (it's about to be rewritten
152 isolate->heap()->FinalizeExternalString(string);
177 // Returns whether this thread successfully migrated the string or another
183 // map = string.map(kAcquireLoad);
185 // string.compare_and_swap_map(map, SENTINEL_MAP)) {
186 // // Lock acquired, i.e. the string's map is SENTINEL_MAP.
193 // reloaded_map = string.map(kAcquireLoad);
201 // - The lambda is passed the string and its initial (pre-migration)
214 // Map initial_map = string.map(kAcquireLoad);
216 // isolate, string, initial_map, target_map,
217 // [](Isolate* isolate, String string, StringShape initial_shape) {
218 // auto t = TargetStringType::unchecked_cast(string);
225 IsolateT* isolate, String string, Map initial_map, Map target_map,
233 // A string whose map is a sentinel map means that it is in the critical
239 // Try to acquire the migration lock by setting the string's map to the
243 !string.release_compare_and_swap_map_word(
246 // string. The string's map will be the sentinel map until the migration
251 Map reloaded_map = string.map(kAcquireLoad);
254 reloaded_map = string.map(kAcquireLoad);
264 // string was migrated to a different map than target_map.
274 update_representation(isolate, string, initial_shape);
279 // that all string map migrations are using this function, since to be in the
280 // migration critical section, the string's current map must be the sentinel
288 CHECK(string.release_compare_and_swap_map_word(
291 string.set_map_safe_transition(target_map, kReleaseStore);
306 // string to avoid reloading the map in case of parallel migrations. See
324 [=](IsolateT* isolate, String string, StringShape initial_shape) {
328 MigrateExternalString(isolate->AsIsolate(), string, internalized);
331 ThinString::unchecked_cast(string).set_actual(internalized);
367 // Disallow garbage collection to avoid possible GC vs string access deadlock.
376 // Assert that the resource and the string are equivalent.
384 int size = this->Size(); // Byte size of the original string.
388 // string.
401 // Morph the string to an external string by replacing the map and
403 // string occupies is too small for a regular external string. Instead, we
404 // resort to an uncached external string instead, omitting the field caching
446 // Disallow garbage collection to avoid possible GC vs string access deadlock.
455 // Assert that the resource and the string are equivalent.
468 int size = this->Size(); // Byte size of the original string.
472 // string.
485 // Morph the string to an external string by replacing the map and
487 // string occupies is too small for a regular external string. Instead, we
488 // resort to an uncached external string instead, omitting the field caching
539 // Already an external string.
691 // Flatten {subject} string first.
714 // Fast check for a junk value. A valid string may start from a
722 // The maximal/minimal smi has 10 digits. If the string has less digits
753 String string = *this;
754 StringShape shape(string, cage_base);
759 ConsString cons = ConsString::cast(string);
761 string = cons.first(cage_base);
762 shape = StringShape(string, cage_base);
764 SlicedString slice = SlicedString::cast(string);
766 string = slice.parent(cage_base);
767 shape = StringShape(string, cage_base);
775 ThinString thin = ThinString::cast(string);
776 string = thin.actual(cage_base);
777 shape = StringShape(string, cage_base);
781 return TryGetFlatContentFromDirectString(cage_base, no_gc, string, offset,
793 // Negative length means the to the end of the string.
796 // Compute the size of the UTF-8 string. Start at the specified offset.
813 // Convert the UTF-16 string to a UTF-8 buffer. Start at the specified offset.
908 // When repeatedly appending to a string, we get a cons string that
1391 // No closing bracket was found, treat '$<' as a string literal.
1591 uint32_t HashString(String string, size_t start, int length, uint64_t seed,
1603 if (string.IsConsString(cage_base)) {
1605 DCHECK(!string.IsFlat());
1607 String::WriteToFlat(string, buffer.get(), 0, length, cage_base,
1611 chars = string.GetChars<Char>(cage_base, no_gc, access_guard) + start;
1637 String string = *this;
1638 PtrComprCageBase cage_base = GetPtrComprCageBase(string);
1639 StringShape shape(string, cage_base);
1641 SlicedString sliced = SlicedString::cast(string);
1643 string = sliced.parent(cage_base);
1644 shape = StringShape(string, cage_base);
1646 if (shape.IsCons() && string.IsFlat(cage_base)) {
1647 string = ConsString::cast(string).first(cage_base);
1648 shape = StringShape(string, cage_base);
1651 string = ThinString::cast(string).actual(cage_base);
1652 shape = StringShape(string, cage_base);
1653 if (length() == string.length()) {
1654 set_raw_hash_field(string.raw_hash_field());
1660 ? HashString<uint8_t>(string, start, length(), seed, cage_base,
1662 : HashString<uint16_t>(string, start, length(), seed, cage_base,
1718 Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) {
1719 if (new_length == 0) return string->GetReadOnlyRoots().empty_string_handle();
1722 int old_length = string->length();
1723 if (old_length <= new_length) return string;
1725 if (string->IsSeqOneByteString()) {
1729 DCHECK(string->IsSeqTwoByteString());
1736 Address start_of_string = string->address();
1740 Heap* heap = Heap::FromWritableHeapObject(*string);
1741 if (!heap->IsLargeObject(*string)) {
1749 string->set_length(new_length, kReleaseStore);
1751 return string;
1771 // Check for a flattened cons string
1777 String string = String::cast(*this);
1780 if (StringShape(string, cage_base).IsCons()) {
1781 ConsString cons_string = ConsString::cast(string);
1784 string = left;
1787 string = cons_string.second(cage_base);
1790 return string.Get(index, cage_base, access_guard);
1851 String string;
1853 if (!blew_stack) string = NextLeaf(&blew_stack);
1856 DCHECK(string.is_null());
1857 string = Search(offset_out);
1860 if (string.is_null()) Reset(ConsString());
1861 return string;
1866 // Reset the stack, pushing the root string.
1873 // Loop until the string is found which contains the target offset.
1874 String string = cons_string.first();
1875 int length = string.length();
1880 type = string.map().instance_type();
1882 cons_string = ConsString::cast(string);
1890 // Update progress through the string.
1893 string = cons_string.second();
1894 type = string.map().instance_type();
1896 cons_string = ConsString::cast(string);
1900 // Need this to be updated for the current string.
1901 length = string.length();
1903 // This happens only if we have asked for an offset outside the string.
1918 return string;
1937 String string = cons_string.second();
1938 int32_t type = string.map().instance_type();
1942 int length = string.length();
1946 return string;
1948 cons_string = ConsString::cast(string);
1953 string = cons_string.first();
1954 type = string.map().instance_type();
1957 int length = string.length();
1960 return string;
1962 cons_string = ConsString::cast(string);
2022 // with the Torque-definition of string instance types in src/objects/string.tq.