Lines Matching defs:string
54 #include "src/string-builder.h"
55 #include "src/string-search.h"
56 #include "src/string-stream.h"
139 return String::ToNumber(Handle<String>::cast(input));
193 MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
196 return Handle<String>::cast(input);
206 String);
214 String);
239 if (IsString()) return String::cast(this)->length() != 0;
292 String::Compare(Handle<String>::cast(x), Handle<String>::cast(y)));
315 return Just(NumberEquals(x, String::ToNumber(Handle<String>::cast(y))));
327 String::Equals(Handle<String>::cast(x), Handle<String>::cast(y)));
329 x = String::ToNumber(Handle<String>::cast(x));
332 x = String::ToNumber(Handle<String>::cast(x));
348 y = String::ToNumber(Handle<String>::cast(y));
406 return String::cast(this)->Equals(String::cast(that));
416 Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
473 return isolate->factory()->NewConsString(Handle<String>::cast(lhs),
474 Handle<String>::cast(rhs));
483 return isolate->factory()->NewConsString(Handle<String>::cast(lhs),
484 Handle<String>::cast(rhs));
983 Handle<String> name = class_name->IsString()
984 ? Handle<String>::cast(class_name)
1074 Handle<String> trap_name = isolate->factory()->getPrototypeOf_string();
1605 Handle<String>::cast(name));
1666 // The object is either a number, a string, a symbol, a boolean, a SIMD value,
1762 return String::cast(this)->Equals(String::cast(other));
1798 return String::cast(this)->Equals(String::cast(other));
1911 static bool AnWord(String* str) {
1930 Handle<String> String::SlowFlatten(Handle<ConsString> cons,
1960 bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
1967 // Assert that the resource and the string are equivalent.
1970 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
1976 int size = this->Size(); // Byte size of the original string.
1983 // Morph the string to an external string by replacing the map and
1985 // string occupies is too small for a regular external string.
1986 // Instead, we resort to a short external string instead, omitting
2006 // Byte size of the external String object.
2024 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
2031 // Assert that the resource and the string are equivalent.
2035 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
2036 DCHECK(String::IsOneByte(smart_chars.start(), this->length()));
2039 String::WriteToFlat(this, smart_chars.start(), 0, this->length());
2045 int size = this->Size(); // Byte size of the original string.
2051 // Morph the string to an external string by replacing the map and
2053 // string occupies is too small for a regular external string.
2054 // Instead, we resort to a short external string instead, omitting
2068 // Byte size of the external String object.
2085 void String::StringShortPrint(StringStream* accumulator, bool show_details) {
2088 accumulator->Add("<Very long string[%u]>", len);
2093 accumulator->Add("<Invalid String>");
2114 if (show_details) accumulator->Add("<String[%u]: ", length());
2120 // Backslash indicates that the string contains control
2122 if (show_details) accumulator->Add("<String[%u]\\: ", length());
2148 void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
2191 String* str = String::cast(fun_name);
2205 String* str = String::cast(source_name);
2245 String* str = String::cast(constructor_name);
2315 String::cast(name)->PrintOn(file);
2335 String::cast(name)->PrintOn(file);
2379 String::cast(o->GetKey(i))->PrintOn(file);
2385 String::cast(name)->PrintOn(file);
2413 String::cast(this)->StringShortPrint(&accumulator);
2621 Handle<String> Simd128Value::ToString(Handle<Simd128Value> input) {
2627 return Handle<String>::null();
2632 Handle<String> Float32x4::ToString(Handle<Float32x4> input) {
2638 << std::string(DoubleToCString(input->get_lane(0), buffer)) << ", "
2639 << std::string(DoubleToCString(input->get_lane(1), buffer)) << ", "
2640 << std::string(DoubleToCString(input->get_lane(2), buffer)) << ", "
2641 << std::string(DoubleToCString(input->get_lane(3), buffer)) << ")";
2647 Handle<String> Type::ToString(Handle<Type> input) { \
2665 Handle<String> Type::ToString(Handle<Type> input) { \
2714 String* JSReceiver::class_name() {
2721 return String::cast(constructor->shared()->instance_class_name());
2729 Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) {
2741 String* name = String::cast(constructor->shared()->name());
2752 if (maybe_tag->IsString()) return Handle<String>::cast(maybe_tag);
2760 Handle<String> result = isolate->factory()->Object_string();
2763 String* name = String::cast(constructor->shared()->name());
4827 Handle<String> key =
4829 Handle<String>(String::cast(entry->name())));
5191 Handle<String> trap_name = factory->set_string();
5262 Handle<String> trap_name = factory->deleteProperty_string();
5352 MaybeHandle<String> JSBoundFunction::GetName(Isolate* isolate,
5354 Handle<String> prefix = isolate->factory()->bound__string();
5361 return factory->NewConsString(prefix, Handle<String>::cast(target_name));
6209 // 1. Let key be ToPrimitive(argument, hint String).
6238 Handle<String> fun_name =
6270 Handle<String> fun_name =
6749 if (value->IsString()) return String::cast(*value)->AsArrayIndex(length);
6767 // TODO(jkummerow): Check if we need slow string comparison.
6833 Handle<String>::cast(length_object)->AsArrayIndex(output)) {
6959 Handle<String> trap_name = isolate->factory()->defineProperty_string();
7177 Handle<String> trap_name =
7537 Handle<String> trap_name = factory->preventExtensions_string();
7639 Handle<String> trap_name = factory->isExtensible_string();
8138 Handle<String> method_names[2];
8149 for (Handle<String> name : method_names) {
8224 if (String::cast(JSValue::cast(object)->value())->length() > 0) {
8269 // Wrapped string elements aren't explicitly stored in the elements backing
8270 // store, but are loaded indirectly from the underlying string.
8427 // String wrappers have non-configurable, non-writable elements.
10263 Handle<String> String::Trim(Handle<String> string, TrimMode mode) {
10264 Isolate* const isolate = string->GetIsolate();
10265 string = String::Flatten(string);
10266 int const length = string->length();
10273 unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(left))) {
10283 unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(right - 1))) {
10288 return isolate->factory()->NewSubString(string, left, right);
10291 bool String::LooksValid() {
10298 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) {
10299 if (name->IsString()) return Handle<String>::cast(name);
10308 builder.AppendString(Handle<String>::cast(description));
10314 MaybeHandle<String> Name::ToFunctionName(Handle<Name> name,
10315 Handle<String> prefix) {
10316 Handle<String> name_string;
10319 String);
10354 Handle<Object> String::ToNumber(Handle<String> subject) {
10357 // Flatten {subject} string first.
10358 subject = String::Flatten(subject);
10379 // Fast check for a junk value. A valid string may start from a
10387 // The maximal/minimal smi has 10 digits. If the string has less digits
10393 } else if (!subject->HasHashCode() && len <= String::kMaxArrayIndexSize &&
10395 // String hash is not calculated yet but all the data are present.
10416 String::FlatContent String::GetFlatContent() {
10420 String* string = this;
10423 ConsString* cons = ConsString::cast(string);
10427 string = cons->first();
10428 shape = StringShape(string);
10431 SlicedString* slice = SlicedString::cast(string);
10433 string = slice->parent();
10434 shape = StringShape(string);
10441 start = SeqOneByteString::cast(string)->GetChars();
10443 start = ExternalOneByteString::cast(string)->GetChars();
10450 start = SeqTwoByteString::cast(string)->GetChars();
10452 start = ExternalTwoByteString::cast(string)->GetChars();
10459 base::SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
10466 // Negative length means the to the end of the string.
10469 // Compute the size of the UTF-8 string. Start at the specified offset.
10486 // Convert the UTF-16 string to a UTF-8 buffer. Start at the specified offset.
10505 base::SmartArrayPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
10512 const uc16* String::GetTwoByteData(unsigned start) {
10590 FlatStringReader::FlatStringReader(Isolate* isolate, Handle<String> str)
10608 Handle<String> str(str_);
10612 String::FlatContent content = str->GetFlatContent();
10634 String* ConsStringIterator::Continue(int* offset_out) {
10638 String* string = NULL;
10640 if (!blew_stack) string = NextLeaf(&blew_stack);
10643 DCHECK(string == NULL);
10644 string = Search(offset_out);
10647 if (string == NULL) Reset(NULL);
10648 return string;
10652 String* ConsStringIterator::Search(int* offset_out) {
10654 // Reset the stack, pushing the root string.
10661 // Loop until the string is found which contains the target offset.
10662 String* string = cons_string->first();
10663 int length = string->length();
10668 type = string->map()->instance_type();
10670 cons_string = ConsString::cast(string);
10678 // Update progress through the string.
10681 string = cons_string->second();
10682 type = string->map()->instance_type();
10684 cons_string = ConsString::cast(string);
10688 // Need this to be updated for the current string.
10689 length = string->length();
10691 // This happens only if we have asked for an offset outside the string.
10706 return string;
10713 String* ConsStringIterator::NextLeaf(bool* blew_stack) {
10727 String* string = cons_string->second();
10728 int32_t type = string->map()->instance_type();
10732 int length = string->length();
10736 return string;
10738 cons_string = ConsString::cast(string);
10743 string = cons_string->first();
10744 type = string->map()->instance_type();
10747 int length = string->length();
10750 return string;
10752 cons_string = ConsString::cast(string);
10764 // Check for a flattened cons string
10766 String* left = first();
10770 String* string = String::cast(this);
10773 if (StringShape(string).IsCons()) {
10774 ConsString* cons_string = ConsString::cast(string);
10775 String* left = cons_string->first();
10777 string = left;
10780 string = cons_string->second();
10783 return string->Get(index);
10798 void String::WriteToFlat(String* src,
10802 String* source = src;
10836 String* first = cons_string->first();
10856 String* second = cons_string->second();
10857 // When repeatedly appending to a string, we get a cons string that
10915 Handle<FixedArray> String::CalculateLineEnds(Handle<String> src,
10925 String::FlatContent content = src->GetFlatContent();
10996 void Init(String* string) {
10997 ConsString* cons_string = String::VisitFlat(this, string);
11001 string = iter_.Next(&offset);
11002 String::VisitFlat(this, string, offset);
11032 String* next = iter_.Next(&offset);
11035 String::VisitFlat(this, next);
11060 bool Equals(String* string_1, String* string_2) {
11099 bool String::SlowEquals(String* other) {
11141 bool String::SlowEquals(Handle<String> one, Handle<String> two) {
11171 one = String::Flatten(one);
11172 two = String::Flatten(two);
11175 String::FlatContent flat1 = one->GetFlatContent();
11176 String::FlatContent flat2 = two->GetFlatContent();
11192 ComparisonResult String::Compare(Handle<String> x, Handle<String> y) {
11211 x = String::Flatten(x);
11212 y = String::Flatten(y);
11224 String::FlatContent x_content = x->GetFlatContent();
11225 String::FlatContent y_content = y->GetFlatContent();
11254 bool String::IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match) {
11284 bool String::IsOneByteEqualTo(Vector<const uint8_t> str) {
11300 bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
11315 uint32_t String::ComputeAndSetHash() {
11331 bool String::ComputeArrayIndex(uint32_t* index) {
11339 bool String::SlowAsArrayIndex(uint32_t* index) {
11353 Handle<String> SeqString::Truncate(Handle<SeqString> string, int new_length) {
11355 int old_length = string->length();
11356 if (old_length <= new_length) return string;
11358 if (string->IsSeqOneByteString()) {
11362 DCHECK(string->IsSeqTwoByteString());
11369 Address start_of_string = string->address();
11373 Heap* heap = string->GetHeap();
11378 heap->AdjustLiveBytes(*string, -delta, Heap::CONCURRENT_TO_SWEEPER);
11382 string->synchronized_set_length(new_length);
11385 return string;
11393 DCHECK(length <= String::kMaxArrayIndexSize);
11394 DCHECK(TenToThe(String::kMaxCachedArrayIndexLength) <
11395 (1 << String::kArrayIndexValueBits));
11397 value <<= String::ArrayIndexValueBits::kShift;
11398 value |= length << String::ArrayIndexLengthBits::kShift;
11400 DCHECK((value & String::kIsNotArrayIndexMask) == 0);
11401 DCHECK_EQ(length <= String::kMaxCachedArrayIndexLength,
11402 (value & String::kContainsCachedArrayIndexMask) == 0);
11408 if (length_ <= String::kMaxHashCalcLength) {
11412 return (GetHashCore(raw_running_hash_) << String::kHashShift) |
11413 String::kIsNotArrayIndexMask;
11415 return (length_ << String::kHashShift) | String::kIsNotArrayIndexMask;
11434 StringHasher hasher(String::kMaxArrayIndexSize, seed);
11449 if (utf16_length > String::kMaxHashCalcLength) continue;
11474 String* string;
11475 while (nullptr != (string = iter.Next(&offset))) {
11477 String::VisitFlat(this, string, 0);
11482 const int max_length = String::kMaxHashCalcLength;
11486 String::WriteToFlat(cons_string, buffer, 0, length);
11491 String::WriteToFlat(cons_string, buffer, 0, length);
11498 void String::PrintOn(FILE* file) {
12535 Handle<String> prototype_string = isolate->factory()->prototype_string();
12579 Handle<String> JSFunction::GetName(Handle<JSFunction> function) {
12583 if (name->IsString()) return Handle<String>::cast(name);
12588 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) {
12592 if (name->IsString()) return Handle<String>::cast(name);
12597 Handle<String> prefix) {
12599 Handle<String> function_name = Name::ToFunctionName(name).ToHandleChecked();
12618 Handle<String> NativeCodeFunctionSourceString(
12624 builder.AppendString(handle(String::cast(shared_info->name()), isolate));
12635 Handle<String> JSBoundFunction::ToString(Handle<JSBoundFunction> function) {
12642 Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
12658 Handle<String> script_source(
12659 String::cast(Script::cast(shared_info->script())->source()), isolate);
12690 builder.AppendString(handle(String::cast(shared_info->name()), isolate));
12693 builder.AppendString(Handle<String>::cast(shared_info->GetSourceCode()));
12700 Handle<String> internalized_to_string =
12702 Handle<String> internalized_type_of =
12764 Handle<String> src(String::cast(script->source()), isolate);
12766 Handle<FixedArray> array = String::CalculateLineEnds(src, true);
12829 Handle<String> src(String::cast(script->source()));
12881 String* source_string = String::cast(source());
12894 Handle<String> name_or_source_url_key =
13037 String* SharedFunctionInfo::DebugName() {
13039 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name();
13040 return String::cast(n);
13053 String* name = DebugName();
13088 Handle<String> source(String::cast(Script::cast(script())->source()));
13162 // Don't use String::cast because we don't want more assertion errors while
13164 String* script_source =
13165 reinterpret_cast<String*>(Script::cast(s->script())->source());
13172 if (name->IsString() && String::cast(name)->length() > 0) {
13173 String::cast(name)->PrintUC16(os);
15477 String::cast(k)->StringPrint(os);
15674 MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate,
15692 MAYBE_RETURN(is_array, MaybeHandle<String>());
15695 Handle<String> tag;
15701 String);
15703 tag = Handle<String>::cast(to_string_tag);
15778 String::cast(name())->StringShortPrint(&accumulator, false);
15790 StringSharedKey(Handle<String> source, Handle<SharedFunctionInfo> shared,
15813 String* source = String::cast(other_array->get(1));
15817 static uint32_t StringSharedHashHelper(String* source,
15829 hash ^= String::cast(script->source())->Hash();
15849 String* source = String::cast(other_array->get(1));
15869 Handle<String> source_;
15878 JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags, bool* success) {
15881 // A longer flags string cannot be valid.
15916 MaybeHandle<JSRegExp> JSRegExp::New(Handle<String> pattern, Flags flags) {
15934 inline int CountRequiredEscapes(Handle<String> source) {
15946 inline Handle<StringType> WriteEscapedRegExpSource(Handle<String> source,
15962 MaybeHandle<String> EscapeRegExpSource(Isolate* isolate,
15963 Handle<String> source) {
15964 String::Flatten(source);
15975 String);
15981 String);
15989 Handle<String> source,
15990 Handle<String> flags_string) {
16006 Handle<String
16009 // If source is the empty string we set it to "(?:)" instead as
16013 Handle<String> escaped_source;
16047 RegExpKey(Handle<String> string, JSRegExp::Flags flags)
16048 : string_(string), flags_(Smi::FromInt(flags)) {}
16056 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex)))
16071 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)),
16075 static uint32_t RegExpHash(String* string, Smi* flags) {
16076 return string->Hash() + flags->value();
16079 Handle<String> string_;
16103 bool SeqOneByteSubStringKey::IsMatch(Object* string) {
16105 return String::cast(string)->IsOneByteEqualTo(chars);
16109 // InternalizedStringKey carries a string/internalized-string object as key.
16112 explicit InternalizedStringKey(Handle<String> string)
16113 : string_(String::Flatten(string)) {}
16115 bool IsMatch(Object* string) override {
16116 return String::cast(string)->Equals(*string_);
16122 return String::cast(other)->Hash();
16126 // Internalize the string if possible.
16135 // Otherwise allocate a new internalized string.
16141 return String::cast(obj)->Hash();
16144 Handle<String> string_;
16202 // internalized string with minimal performance penalty. It gives a chance
16695 int len = String::cast(Handle<JSValue>::cast(object)->value())->length();
16889 // This class is used for looking up two character strings in the string table.
16891 // string hash calculation loop here for speed. Doesn't work if the two
16911 if ((hash & String::kHashBitMask) == 0) hash = StringHasher::kZeroHash;
16915 // version of the string hashing algorithm above. One reason could be
16920 hash = (hash << String::kHashShift) | String::kIsNotArrayIndexMask;
16927 String* other = String::cast(o);
16936 return String::cast(key)->Hash();
16940 // The TwoCharHashTableKey is only used for looking in the string
16953 MaybeHandle<String> StringTable::InternalizeStringIfExists(
16955 Handle<String> string) {
16956 if (string->IsInternalizedString()) {
16957 return string;
16959 return LookupStringIfExists(isolate, string);
16963 MaybeHandle<String> StringTable::LookupStringIfExists(
16965 Handle<String> string) {
16967 InternalizedStringKey key(string);
16970 return MaybeHandle<String>();
16972 Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
16979 MaybeHandle<String> StringTable::LookupTwoCharsStringIfExists(
16987 return MaybeHandle<String>();
16989 Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
17006 Handle<String> StringTable::LookupString(Isolate* isolate,
17007 Handle<String> string) {
17008 if (string->IsConsString() && string->IsFlat()) {
17009 string = String::Flatten(string);
17010 if (string->IsInternalizedString()) return string;
17013 InternalizedStringKey key(string);
17014 Handle<String> result = LookupKey(isolate, &key);
17016 if (string->IsConsString()) {
17017 Handle<ConsString> cons = Handle<ConsString>::cast(string);
17020 } else if (string->IsSlicedString()) {
17026 string->set_map(*map);
17027 Handle<ConsString> cons = Handle<ConsString>::cast(string);
17035 Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) {
17039 // String already in table.
17041 return handle(String::cast(table->KeyAt(entry)), isolate);
17044 // Adding new string. Grow table if needed.
17047 // Create string object.
17048 Handle<Object> string = key->AsHandle(isolate);
17051 CHECK(!string.is_null());
17053 // Add the new string and return it along with the string table.
17055 table->set(EntryToIndex(entry), *string);
17059 return Handle<String>::cast(string);
17063 String* StringTable::LookupKeyIfExists(Isolate* isolate, HashTableKey* key) {
17066 if (entry != kNotFound) return String::cast(table->KeyAt(entry));
17075 Handle<String> name) {
17086 bool StringSet::Has(Handle<String> name) {
17090 Handle<Object> CompilationCacheTable::Lookup(Handle<String> src,
17105 Handle<String> src, Handle<SharedFunctionInfo> outer_info,
17119 Handle<Object> CompilationCacheTable::LookupRegExp(Handle<String> src,
17131 Handle<CompilationCacheTable> cache, Handle<String> src,
17147 Handle<CompilationCacheTable> cache, Handle<String> src,
17175 Handle<CompilationCacheTable> cache, Handle<String> src,
18644 Handle<String> hint_string = Handle<String>::cast(hint);