Lines Matching defs:string
5 #include "src/objects/string-table.h"
20 #include "src/objects/string-inl.h"
21 #include "src/objects/string-table-inl.h"
73 bool KeyIsMatch(IsolateT* isolate, StringTableKey* key, String string) {
74 if (string.hash() != key->hash()) return false;
75 if (string.length() != key->length()) return false;
76 return key->IsMatch(isolate, string);
81 // Data holds the actual data of the string table, including capacity and number
153 String string, String source,
240 String string = String::cast(element);
241 uint32_t hash = string.hash();
244 new_data->Set(insertion_index, string);
265 String string = String::cast(element);
266 if (KeyIsMatch(isolate, key, string)) return entry;
308 String string = String::cast(element);
309 if (KeyIsMatch(isolate, key, string)) return entry;
344 // InternalizedStringKey carries a string/internalized-string object as key.
347 explicit InternalizedStringKey(Handle<String> string)
348 : StringTableKey(0, string->length()), string_(string) {
349 // When sharing the string table, it's possible that another thread already
352 DCHECK_IMPLIES(!FLAG_shared_string_table, !string->IsInternalizedString());
353 DCHECK(string->IsFlat());
355 string->EnsureHash();
356 set_raw_hash_field(string->raw_hash_field());
359 bool IsMatch(Isolate* isolate, String string) {
360 DCHECK(!SharedStringAccessGuardIfNeeded::IsNeeded(string));
361 return string_->SlowEquals(string);
373 // are sure that we are going to insert the string into the table.
377 // string table and allowing concurrent internalization.
382 // Copying the string here is always threadsafe, as no instance type
400 // Otherwise allocate a new internalized string.
408 // When preparing the string, the strategy was to in-place migrate it.
411 // is another thread migrated the string to internalized already.
418 // We prepared an internalized copy for the string or the string was already
422 // in-place migrate the original string instead of internalizing the copy
423 // and migrating the original string to a ThinString. This scenario doesn't
434 Handle<String> string) {
435 // When sharing the string table, internalization is allowed to be concurrent
452 // - In-place internalizable strings do not incur a copy regardless of string
458 // For lookup misses, the internalized string map is the same map in RO space
464 string = String::Flatten(isolate, string);
465 if (string->IsInternalizedString()) return string;
467 InternalizedStringKey key(string);
470 if (!string->IsInternalizedString()) {
471 string->MakeThin(isolate, *result);
483 // - All writes to the string table are guarded by the Isolate string table
485 // - Resizes of the string table first copies the old contents to the new
486 // table, and only then sets the new string table pointer to the new
488 // - Only GCs can remove elements from the string table.
496 // This is because we _know_ that if we find an entry in the string table, any
498 // for strong consistency of internalized string equality implying reference
501 // We therefore try to optimistically read from the string table without
507 // the string table lock. This applies to both allocation of new strings, and
508 // re-allocation of the string table on resize. So, we optimistically allocate
513 // Load the current string table data, in case another thread updates the
517 // First try to find the string in the table. This is safe to do even if the
520 // string is dead, in which case it will die in this table too and worst
530 // No entry found, so adding new string.
559 // Return the existing string as a handle.
618 // acquire-loaded by other threads. This string table becomes the owner of
630 String string,
640 int length = string.length();
675 // A string that's not an array index, and not in the string table,
681 // string can be internalized here, if another thread internalized it.
682 // If we found and entry in the string table and string is not internalized,
685 if (!string.IsInternalizedString()) {
686 string.MakeThin(isolate, internalized);
696 String string = String::cast(Object(raw_string));
697 if (string.IsInternalizedString()) {
698 // string could be internalized, if the string table is shared and another
712 String source = string;
722 if (string.length() == source.length()) {
729 isolate, string, source, start);
732 isolate, string, source, start);