Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::TwoByteString Class Reference

#include <object.h>

Inheritance diagram for dart::TwoByteString:
dart::AllStatic

Classes

struct  ArrayTraits
 

Static Public Member Functions

static uint16_t CharAt (const String &str, intptr_t index)
 
static uint16_t CharAt (TwoByteStringPtr str, intptr_t index)
 
static void SetCharAt (const String &str, intptr_t index, uint16_t ch)
 
static TwoByteStringPtr EscapeSpecialCharacters (const String &str)
 
static intptr_t data_offset ()
 
static intptr_t UnroundedSize (TwoByteStringPtr str)
 
static intptr_t UnroundedSize (intptr_t len)
 
static intptr_t InstanceSize ()
 
static intptr_t InstanceSize (intptr_t len)
 
static TwoByteStringPtr New (intptr_t len, Heap::Space space)
 
static TwoByteStringPtr New (const uint16_t *characters, intptr_t len, Heap::Space space)
 
static TwoByteStringPtr New (intptr_t utf16_len, const int32_t *characters, intptr_t len, Heap::Space space)
 
static TwoByteStringPtr New (const String &str, Heap::Space space)
 
static TwoByteStringPtr New (const TypedDataBase &other_typed_data, intptr_t other_start_index, intptr_t other_len, Heap::Space space=Heap::kNew)
 
static TwoByteStringPtr Concat (const String &str1, const String &str2, Heap::Space space)
 
static TwoByteStringPtr ConcatAll (const Array &strings, intptr_t start, intptr_t end, intptr_t len, Heap::Space space)
 
static TwoByteStringPtr Transform (int32_t(*mapping)(int32_t ch), const String &str, Heap::Space space)
 
static TwoByteStringPtr null ()
 

Static Public Attributes

static constexpr intptr_t kBytesPerElement = 2
 
static constexpr intptr_t kMaxElements = String::kMaxElements
 
static constexpr intptr_t kMaxNewSpaceElements
 
static const ClassId kClassId = kTwoByteStringCid
 

Friends

class Class
 
class FlowGraphSerializer
 
class ImageWriter
 
class String
 
class StringHasher
 
class Symbols
 
class TwoByteStringMessageSerializationCluster
 
class JSONWriter
 

Detailed Description

Definition at line 10641 of file object.h.

Member Function Documentation

◆ CharAt() [1/2]

static uint16_t dart::TwoByteString::CharAt ( const String str,
intptr_t  index 
)
inlinestatic

Definition at line 10643 of file object.h.

10643 {
10644 ASSERT(str.IsTwoByteString());
10645 return TwoByteString::CharAt(static_cast<TwoByteStringPtr>(str.ptr()),
10646 index);
10647 }
static uint16_t CharAt(const String &str, intptr_t index)
Definition object.h:10643
#define ASSERT(E)

◆ CharAt() [2/2]

static uint16_t dart::TwoByteString::CharAt ( TwoByteStringPtr  str,
intptr_t  index 
)
inlinestatic

Definition at line 10649 of file object.h.

10649 {
10650 ASSERT(index >= 0 && index < String::LengthOf(str));
10651 return str->untag()->data()[index];
10652 }
static intptr_t LengthOf(StringPtr obj)
Definition object.h:10190

◆ Concat()

TwoByteStringPtr dart::TwoByteString::Concat ( const String str1,
const String str2,
Heap::Space  space 
)
static

Definition at line 24719 of file object.cc.

24721 {
24722 intptr_t len1 = str1.Length();
24723 intptr_t len2 = str2.Length();
24724 intptr_t len = len1 + len2;
24725 const String& result = String::Handle(TwoByteString::New(len, space));
24726 String::Copy(result, 0, str1, 0, len1);
24727 String::Copy(result, len1, str2, 0, len2);
24728 return TwoByteString::raw(result);
24729}
static Object & Handle()
Definition object.h:407
static void Copy(const String &dst, intptr_t dst_offset, const uint8_t *characters, intptr_t len)
Definition object.cc:23871
static TwoByteStringPtr New(intptr_t len, Heap::Space space)
Definition object.cc:24641
friend class String
Definition object.h:10755
GAsyncResult * result

◆ ConcatAll()

TwoByteStringPtr dart::TwoByteString::ConcatAll ( const Array strings,
intptr_t  start,
intptr_t  end,
intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24731 of file object.cc.

24735 {
24736 ASSERT(!strings.IsNull());
24737 ASSERT(start >= 0);
24738 ASSERT(end <= strings.Length());
24739 const String& result = String::Handle(TwoByteString::New(len, space));
24740 String& str = String::Handle();
24741 intptr_t pos = 0;
24742 for (intptr_t i = start; i < end; i++) {
24743 str ^= strings.At(i);
24744 const intptr_t str_len = str.Length();
24745 String::Copy(result, pos, str, 0, str_len);
24746 ASSERT((kMaxElements - pos) >= str_len);
24747 pos += str_len;
24748 }
24749 return TwoByteString::raw(result);
24750}
SkPoint pos
static constexpr intptr_t kMaxElements
Definition object.h:10663
glong glong end
static float Length(float x, float y)
Definition SkPoint.cpp:79

◆ data_offset()

static intptr_t dart::TwoByteString::data_offset ( )
inlinestatic

Definition at line 10674 of file object.h.

10674 {
10675 return OFFSET_OF_RETURNED_VALUE(UntaggedTwoByteString, data);
10676 }
static int8_t data[kExtLength]
#define OFFSET_OF_RETURNED_VALUE(type, accessor)
Definition globals.h:143

◆ EscapeSpecialCharacters()

TwoByteStringPtr dart::TwoByteString::EscapeSpecialCharacters ( const String str)
static

Definition at line 24609 of file object.cc.

24609 {
24610 intptr_t len = str.Length();
24611 if (len > 0) {
24612 intptr_t num_escapes = 0;
24613 for (intptr_t i = 0; i < len; i++) {
24614 num_escapes += EscapeOverhead(CharAt(str, i));
24615 }
24616 const String& dststr =
24617 String::Handle(TwoByteString::New(len + num_escapes, Heap::kNew));
24618 intptr_t index = 0;
24619 for (intptr_t i = 0; i < len; i++) {
24620 uint16_t ch = CharAt(str, i);
24621 if (IsSpecialCharacter(ch)) {
24622 SetCharAt(dststr, index, '\\');
24623 SetCharAt(dststr, index + 1, SpecialCharacter(ch));
24624 index += 2;
24625 } else if (IsAsciiNonprintable(ch)) {
24626 SetCharAt(dststr, index, '\\');
24627 SetCharAt(dststr, index + 1, 'x');
24628 SetCharAt(dststr, index + 2, GetHexCharacter(ch >> 4));
24629 SetCharAt(dststr, index + 3, GetHexCharacter(ch & 0xF));
24630 index += 4;
24631 } else {
24632 SetCharAt(dststr, index, ch);
24633 index += 1;
24634 }
24635 }
24636 return TwoByteString::raw(dststr);
24637 }
24638 return TwoByteString::New(0, Heap::kNew);
24639}
@ kNew
Definition heap.h:38
static void SetCharAt(const String &str, intptr_t index, uint16_t ch)
Definition object.h:10654
static type SpecialCharacter(type value)
Definition object.cc:530
static int32_t GetHexCharacter(int32_t c)
Definition object.cc:23975
static int32_t EscapeOverhead(int32_t c)
Definition object.cc:520
static bool IsSpecialCharacter(type value)
Definition object.cc:510
static bool IsAsciiNonprintable(int32_t c)
Definition object.cc:516

◆ InstanceSize() [1/2]

static intptr_t dart::TwoByteString::InstanceSize ( )
inlinestatic

Definition at line 10683 of file object.h.

10683 {
10684 ASSERT(sizeof(UntaggedTwoByteString) ==
10685 OFFSET_OF_RETURNED_VALUE(UntaggedTwoByteString, data));
10686 return 0;
10687 }

◆ InstanceSize() [2/2]

static intptr_t dart::TwoByteString::InstanceSize ( intptr_t  len)
inlinestatic

Definition at line 10688 of file object.h.

10688 {
10689 ASSERT(sizeof(UntaggedTwoByteString) == String::kSizeofRawString);
10690 ASSERT(0 <= len && len <= kMaxElements);
10692 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758
static constexpr intptr_t kSizeofRawString
Definition object.h:10149
static intptr_t UnroundedSize(TwoByteStringPtr str)
Definition object.h:10677

◆ New() [1/5]

TwoByteStringPtr dart::TwoByteString::New ( const String str,
Heap::Space  space 
)
static

Definition at line 24698 of file object.cc.

24698 {
24699 intptr_t len = str.Length();
24700 const String& result = String::Handle(TwoByteString::New(len, space));
24701 String::Copy(result, 0, str, 0, len);
24702 return TwoByteString::raw(result);
24703}

◆ New() [2/5]

TwoByteStringPtr dart::TwoByteString::New ( const TypedDataBase other_typed_data,
intptr_t  other_start_index,
intptr_t  other_len,
Heap::Space  space = Heap::kNew 
)
static

Definition at line 24705 of file object.cc.

24708 {
24709 const String& result = String::Handle(TwoByteString::New(other_len, space));
24710 if (other_len > 0) {
24711 NoSafepointScope no_safepoint;
24712 memmove(TwoByteString::DataStart(result),
24713 other_typed_data.DataAddr(other_start_index),
24714 other_len * sizeof(uint16_t));
24715 }
24716 return TwoByteString::raw(result);
24717}

◆ New() [3/5]

TwoByteStringPtr dart::TwoByteString::New ( const uint16_t *  characters,
intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24661 of file object.cc.

24663 {
24664 ASSERT(array_len > 0);
24665 const String& result = String::Handle(TwoByteString::New(array_len, space));
24666 {
24667 NoSafepointScope no_safepoint;
24668 memmove(reinterpret_cast<void*>(DataStart(result)),
24669 reinterpret_cast<const void*>(utf16_array), (array_len * 2));
24670 }
24671 return TwoByteString::raw(result);
24672}

◆ New() [4/5]

TwoByteStringPtr dart::TwoByteString::New ( intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24641 of file object.cc.

24641 {
24642 ASSERT(IsolateGroup::Current()->object_store()->two_byte_string_class() !=
24643 nullptr);
24644 if (len < 0 || len > kMaxElements) {
24645 // This should be caught before we reach here.
24646 FATAL("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len);
24647 }
24648 auto s = Object::Allocate<TwoByteString>(space, len);
24649 NoSafepointScope no_safepoint;
24650 s->untag()->set_length(Smi::New(len));
24651#if !defined(HASH_IN_OBJECT_HEADER)
24652 s->untag()->set_hash(Smi::New(0));
24653#endif
24655 ASSERT(size <= s->untag()->HeapSize());
24656 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(s) + size), 0,
24657 s->untag()->HeapSize() - size);
24658 return s;
24659}
static IsolateGroup * Current()
Definition isolate.h:534
static SmiPtr New(intptr_t value)
Definition object.h:9985
static uword ToAddr(const UntaggedObject *raw_obj)
Definition raw_object.h:501
struct MyStruct s
#define FATAL(error)
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
#define Pd
Definition globals.h:408

◆ New() [5/5]

TwoByteStringPtr dart::TwoByteString::New ( intptr_t  utf16_len,
const int32_t *  characters,
intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24674 of file object.cc.

24677 {
24678 ASSERT((array_len > 0) && (utf16_len >= array_len));
24679 const String& result = String::Handle(TwoByteString::New(utf16_len, space));
24680 {
24681 NoSafepointScope no_safepoint;
24682 intptr_t j = 0;
24683 for (intptr_t i = 0; i < array_len; ++i) {
24684 if (Utf::IsSupplementary(utf32_array[i])) {
24685 ASSERT(j < (utf16_len - 1));
24686 Utf16::Encode(utf32_array[i], CharAddr(result, j));
24687 j += 2;
24688 } else {
24689 ASSERT(j < utf16_len);
24690 *CharAddr(result, j) = utf32_array[i];
24691 j += 1;
24692 }
24693 }
24694 }
24695 return TwoByteString::raw(result);
24696}
static void Encode(int32_t codepoint, uint16_t *dst)
Definition unicode.cc:273
static bool IsSupplementary(int32_t code_point)
Definition unicode.h:31

◆ null()

static TwoByteStringPtr dart::TwoByteString::null ( )
inlinestatic

Definition at line 10722 of file object.h.

10722 {
10723 return static_cast<TwoByteStringPtr>(Object::null());
10724 }
static ObjectPtr null()
Definition object.h:433

◆ SetCharAt()

static void dart::TwoByteString::SetCharAt ( const String str,
intptr_t  index,
uint16_t  ch 
)
inlinestatic

Definition at line 10654 of file object.h.

10654 {
10655 NoSafepointScope no_safepoint;
10656 *CharAddr(str, index) = ch;
10657 }

◆ Transform()

TwoByteStringPtr dart::TwoByteString::Transform ( int32_t(*)(int32_t ch)  mapping,
const String str,
Heap::Space  space 
)
static

Definition at line 24752 of file object.cc.

24754 {
24755 ASSERT(!str.IsNull());
24756 intptr_t len = str.Length();
24757 const String& result = String::Handle(TwoByteString::New(len, space));
24758 String::CodePointIterator it(str);
24759 intptr_t i = 0;
24760 NoSafepointScope no_safepoint;
24761 while (it.Next()) {
24762 int32_t src = it.Current();
24763 int32_t dst = mapping(src);
24764 ASSERT(dst >= 0 && dst <= 0x10FFFF);
24765 intptr_t len = Utf16::Length(dst);
24766 if (len == 1) {
24767 *CharAddr(result, i) = dst;
24768 } else {
24769 ASSERT(len == 2);
24770 Utf16::Encode(dst, CharAddr(result, i));
24771 }
24772 i += len;
24773 }
24774 return TwoByteString::raw(result);
24775}
static intptr_t Length(int32_t ch)
Definition unicode.h:118
dst
Definition cp.py:12

◆ UnroundedSize() [1/2]

static intptr_t dart::TwoByteString::UnroundedSize ( intptr_t  len)
inlinestatic

Definition at line 10680 of file object.h.

10680 {
10681 return sizeof(UntaggedTwoByteString) + (len * kBytesPerElement);
10682 }
static constexpr intptr_t kBytesPerElement
Definition object.h:10662

◆ UnroundedSize() [2/2]

static intptr_t dart::TwoByteString::UnroundedSize ( TwoByteStringPtr  str)
inlinestatic

Definition at line 10677 of file object.h.

10677 {
10678 return UnroundedSize(Smi::Value(str->untag()->length()));
10679 }
intptr_t Value() const
Definition object.h:9969

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 10752 of file object.h.

◆ FlowGraphSerializer

friend class FlowGraphSerializer
friend

Definition at line 10753 of file object.h.

◆ ImageWriter

friend class ImageWriter
friend

Definition at line 10754 of file object.h.

◆ JSONWriter

friend class JSONWriter
friend

Definition at line 10759 of file object.h.

◆ String

friend class String
friend

Definition at line 10755 of file object.h.

◆ StringHasher

friend class StringHasher
friend

Definition at line 10756 of file object.h.

◆ Symbols

friend class Symbols
friend

Definition at line 10757 of file object.h.

◆ TwoByteStringMessageSerializationCluster

Definition at line 10758 of file object.h.

Member Data Documentation

◆ kBytesPerElement

constexpr intptr_t dart::TwoByteString::kBytesPerElement = 2
staticconstexpr

Definition at line 10662 of file object.h.

◆ kClassId

const ClassId dart::TwoByteString::kClassId = kTwoByteStringCid
static

Definition at line 10726 of file object.h.

◆ kMaxElements

constexpr intptr_t dart::TwoByteString::kMaxElements = String::kMaxElements
staticconstexpr

Definition at line 10663 of file object.h.

◆ kMaxNewSpaceElements

constexpr intptr_t dart::TwoByteString::kMaxNewSpaceElements
staticconstexpr
Initial value:
=
(kNewAllocatableSize - sizeof(UntaggedTwoByteString)) / kBytesPerElement
static constexpr intptr_t kNewAllocatableSize
Definition spaces.h:54

Definition at line 10664 of file object.h.


The documentation for this class was generated from the following files: