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

#include <object.h>

Inheritance diagram for dart::OneByteString:
dart::AllStatic

Classes

struct  ArrayTraits
 

Static Public Member Functions

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

Static Public Attributes

static constexpr intptr_t kBytesPerElement = 1
 
static constexpr intptr_t kMaxElements = String::kMaxElements
 
static constexpr intptr_t kMaxNewSpaceElements
 
static const ClassId kClassId = kOneByteStringCid
 

Friends

class Class
 
class FlowGraphSerializer
 
class ImageWriter
 
class String
 
class StringHasher
 
class Symbols
 
class Utf8
 
class OneByteStringMessageSerializationCluster
 
class Deserializer
 
class JSONWriter
 

Detailed Description

Definition at line 10502 of file object.h.

Member Function Documentation

◆ CharAt() [1/2]

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

Definition at line 10504 of file object.h.

10504 {
10505 ASSERT(str.IsOneByteString());
10506 return OneByteString::CharAt(static_cast<OneByteStringPtr>(str.ptr()),
10507 index);
10508 }
static uint16_t CharAt(const String &str, intptr_t index)
Definition object.h:10504
#define ASSERT(E)

◆ CharAt() [2/2]

static uint16_t dart::OneByteString::CharAt ( OneByteStringPtr  str,
intptr_t  index 
)
inlinestatic

Definition at line 10510 of file object.h.

10510 {
10511 ASSERT(index >= 0 && index < String::LengthOf(str));
10512 return str->untag()->data()[index];
10513 }
static intptr_t LengthOf(StringPtr obj)
Definition object.h:10190

◆ Concat()

OneByteStringPtr dart::OneByteString::Concat ( const String str1,
const String str2,
Heap::Space  space 
)
static

Definition at line 24540 of file object.cc.

24542 {
24543 intptr_t len1 = str1.Length();
24544 intptr_t len2 = str2.Length();
24545 intptr_t len = len1 + len2;
24546 const String& result = String::Handle(OneByteString::New(len, space));
24547 String::Copy(result, 0, str1, 0, len1);
24548 String::Copy(result, len1, str2, 0, len2);
24549 return OneByteString::raw(result);
24550}
static Object & Handle()
Definition object.h:407
static OneByteStringPtr New(intptr_t len, Heap::Space space)
Definition object.cc:24447
friend class String
Definition object.h:10632
static void Copy(const String &dst, intptr_t dst_offset, const uint8_t *characters, intptr_t len)
Definition object.cc:23871
GAsyncResult * result

◆ ConcatAll()

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

Definition at line 24552 of file object.cc.

24556 {
24557 ASSERT(!strings.IsNull());
24558 ASSERT(start >= 0);
24559 ASSERT(end <= strings.Length());
24560 const String& result = String::Handle(OneByteString::New(len, space));
24561 String& str = String::Handle();
24562 intptr_t pos = 0;
24563 for (intptr_t i = start; i < end; i++) {
24564 str ^= strings.At(i);
24565 const intptr_t str_len = str.Length();
24566 String::Copy(result, pos, str, 0, str_len);
24567 ASSERT((kMaxElements - pos) >= str_len);
24568 pos += str_len;
24569 }
24570 return OneByteString::raw(result);
24571}
SkPoint pos
static constexpr intptr_t kMaxElements
Definition object.h:10522
glong glong end
static float Length(float x, float y)
Definition SkPoint.cpp:79

◆ data_offset()

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

Definition at line 10533 of file object.h.

10533 {
10534 return OFFSET_OF_RETURNED_VALUE(UntaggedOneByteString, data);
10535 }
static int8_t data[kExtLength]
#define OFFSET_OF_RETURNED_VALUE(type, accessor)
Definition globals.h:143

◆ EscapeSpecialCharacters()

OneByteStringPtr dart::OneByteString::EscapeSpecialCharacters ( const String str)
static

Definition at line 24415 of file object.cc.

24415 {
24416 intptr_t len = str.Length();
24417 if (len > 0) {
24418 intptr_t num_escapes = 0;
24419 for (intptr_t i = 0; i < len; i++) {
24420 num_escapes += EscapeOverhead(CharAt(str, i));
24421 }
24422 const String& dststr =
24423 String::Handle(OneByteString::New(len + num_escapes, Heap::kNew));
24424 intptr_t index = 0;
24425 for (intptr_t i = 0; i < len; i++) {
24426 uint8_t ch = CharAt(str, i);
24427 if (IsSpecialCharacter(ch)) {
24428 SetCharAt(dststr, index, '\\');
24429 SetCharAt(dststr, index + 1, SpecialCharacter(ch));
24430 index += 2;
24431 } else if (IsAsciiNonprintable(ch)) {
24432 SetCharAt(dststr, index, '\\');
24433 SetCharAt(dststr, index + 1, 'x');
24434 SetCharAt(dststr, index + 2, GetHexCharacter(ch >> 4));
24435 SetCharAt(dststr, index + 3, GetHexCharacter(ch & 0xF));
24436 index += 4;
24437 } else {
24438 SetCharAt(dststr, index, ch);
24439 index += 1;
24440 }
24441 }
24442 return OneByteString::raw(dststr);
24443 }
24444 return OneByteString::raw(Symbols::Empty());
24445}
@ kNew
Definition heap.h:38
static void SetCharAt(const String &str, intptr_t index, uint8_t code_unit)
Definition object.h:10515
static const String & Empty()
Definition symbols.h:687
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::OneByteString::InstanceSize ( )
inlinestatic

Definition at line 10543 of file object.h.

10543 {
10544 ASSERT(sizeof(UntaggedOneByteString) ==
10545 OFFSET_OF_RETURNED_VALUE(UntaggedOneByteString, data));
10546 return 0;
10547 }

◆ InstanceSize() [2/2]

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

Definition at line 10548 of file object.h.

10548 {
10549 ASSERT(sizeof(UntaggedOneByteString) == String::kSizeofRawString);
10550 ASSERT(0 <= len && len <= kMaxElements);
10552 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758
static intptr_t UnroundedSize(OneByteStringPtr str)
Definition object.h:10537
static constexpr intptr_t kSizeofRawString
Definition object.h:10149

◆ New() [1/8]

static OneByteStringPtr dart::OneByteString::New ( const char *  c_string,
Heap::Space  space = Heap::kNew 
)
inlinestatic

Definition at line 10555 of file object.h.

10556 {
10557 return New(reinterpret_cast<const uint8_t*>(c_string), strlen(c_string),
10558 space);
10559 }

◆ New() [2/8]

OneByteStringPtr dart::OneByteString::New ( const int32_t *  characters,
intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24492 of file object.cc.

24494 {
24495 const String& result = String::Handle(OneByteString::New(len, space));
24496 NoSafepointScope no_safepoint;
24497 for (intptr_t i = 0; i < len; ++i) {
24498 ASSERT(Utf::IsLatin1(characters[i]));
24499 *CharAddr(result, i) = characters[i];
24500 }
24501 return OneByteString::raw(result);
24502}
static bool IsLatin1(int32_t code_point)
Definition unicode.h:23

◆ New() [3/8]

OneByteStringPtr dart::OneByteString::New ( const String other_one_byte_string,
intptr_t  other_start_index,
intptr_t  other_len,
Heap::Space  space 
)
static

Definition at line 24511 of file object.cc.

24514 {
24515 const String& result = String::Handle(OneByteString::New(other_len, space));
24516 ASSERT(other_one_byte_string.IsOneByteString());
24517 if (other_len > 0) {
24518 NoSafepointScope no_safepoint;
24519 memmove(OneByteString::DataStart(result),
24520 OneByteString::CharAddr(other_one_byte_string, other_start_index),
24521 other_len);
24522 }
24523 return OneByteString::raw(result);
24524}

◆ New() [4/8]

OneByteStringPtr dart::OneByteString::New ( const String str,
Heap::Space  space 
)
static

Definition at line 24504 of file object.cc.

24504 {
24505 intptr_t len = str.Length();
24506 const String& result = String::Handle(OneByteString::New(len, space));
24507 String::Copy(result, 0, str, 0, len);
24508 return OneByteString::raw(result);
24509}

◆ New() [5/8]

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

Definition at line 24526 of file object.cc.

24529 {
24530 const String& result = String::Handle(OneByteString::New(other_len, space));
24531 ASSERT(other_typed_data.ElementSizeInBytes() == 1);
24532 if (other_len > 0) {
24533 NoSafepointScope no_safepoint;
24534 memmove(OneByteString::DataStart(result),
24535 other_typed_data.DataAddr(other_start_index), other_len);
24536 }
24537 return OneByteString::raw(result);
24538}

◆ New() [6/8]

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

Definition at line 24480 of file object.cc.

24482 {
24483 const String& result = String::Handle(OneByteString::New(len, space));
24484 NoSafepointScope no_safepoint;
24485 for (intptr_t i = 0; i < len; ++i) {
24486 ASSERT(Utf::IsLatin1(characters[i]));
24487 *CharAddr(result, i) = characters[i];
24488 }
24489 return OneByteString::raw(result);
24490}

◆ New() [7/8]

OneByteStringPtr dart::OneByteString::New ( const uint8_t *  characters,
intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24469 of file object.cc.

24471 {
24472 const String& result = String::Handle(OneByteString::New(len, space));
24473 if (len > 0) {
24474 NoSafepointScope no_safepoint;
24475 memmove(DataStart(result), characters, len);
24476 }
24477 return OneByteString::raw(result);
24478}

◆ New() [8/8]

OneByteStringPtr dart::OneByteString::New ( intptr_t  len,
Heap::Space  space 
)
static

Definition at line 24447 of file object.cc.

24447 {
24449 ((IsolateGroup::Current()->object_store() != nullptr) &&
24450 (IsolateGroup::Current()->object_store()->one_byte_string_class() !=
24451 Class::null())));
24452 if (len < 0 || len > kMaxElements) {
24453 // This should be caught before we reach here.
24454 FATAL("Fatal error in OneByteString::New: invalid len %" Pd "\n", len);
24455 }
24456 auto result = Object::Allocate<OneByteString>(space, len);
24457 NoSafepointScope no_safepoint;
24458 result->untag()->set_length(Smi::New(len));
24459#if !defined(HASH_IN_OBJECT_HEADER)
24460 result->untag()->set_hash(Smi::New(0));
24461#endif
24463 ASSERT(size <= result->untag()->HeapSize());
24464 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(result) + size), 0,
24465 result->untag()->HeapSize() - size);
24466 return result;
24467}
static IsolateGroup * vm_isolate_group()
Definition dart.h:69
static IsolateGroup * Current()
Definition isolate.h:534
static ObjectPtr null()
Definition object.h:433
static SmiPtr New(intptr_t value)
Definition object.h:9985
static uword ToAddr(const UntaggedObject *raw_obj)
Definition raw_object.h:501
#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

◆ null()

static OneByteStringPtr dart::OneByteString::null ( )
inlinestatic

Definition at line 10603 of file object.h.

10603 {
10604 return static_cast<OneByteStringPtr>(Object::null());
10605 }

◆ SetCharAt()

static void dart::OneByteString::SetCharAt ( const String str,
intptr_t  index,
uint8_t  code_unit 
)
inlinestatic

Definition at line 10515 of file object.h.

10515 {
10516 NoSafepointScope no_safepoint;
10517 *CharAddr(str, index) = code_unit;
10518 }

◆ SubStringUnchecked()

OneByteStringPtr dart::OneByteString::SubStringUnchecked ( const String str,
intptr_t  begin_index,
intptr_t  length,
Heap::Space  space 
)
static

Definition at line 24588 of file object.cc.

24591 {
24592 ASSERT(!str.IsNull() && str.IsOneByteString());
24593 ASSERT(begin_index >= 0);
24594 ASSERT(length >= 0);
24595 if (begin_index <= str.Length() && length == 0) {
24596 return OneByteString::raw(Symbols::Empty());
24597 }
24598 ASSERT(begin_index < str.Length());
24599 OneByteStringPtr result = OneByteString::New(length, space);
24600 NoSafepointScope no_safepoint;
24601 if (length > 0) {
24602 uint8_t* dest = &result->untag()->data()[0];
24603 const uint8_t* src = &untag(str)->data()[begin_index];
24604 memmove(dest, src, length);
24605 }
24606 return result;
24607}
size_t length
dest
Definition zip.py:79

◆ Transform()

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

Definition at line 24573 of file object.cc.

24575 {
24576 ASSERT(!str.IsNull());
24577 intptr_t len = str.Length();
24578 const String& result = String::Handle(OneByteString::New(len, space));
24579 NoSafepointScope no_safepoint;
24580 for (intptr_t i = 0; i < len; ++i) {
24581 int32_t ch = mapping(str.CharAt(i));
24582 ASSERT(Utf::IsLatin1(ch));
24583 *CharAddr(result, i) = ch;
24584 }
24585 return OneByteString::raw(result);
24586}

◆ UnroundedSize() [1/2]

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

Definition at line 10540 of file object.h.

10540 {
10541 return sizeof(UntaggedOneByteString) + (len * kBytesPerElement);
10542 }
static constexpr intptr_t kBytesPerElement
Definition object.h:10521

◆ UnroundedSize() [2/2]

static intptr_t dart::OneByteString::UnroundedSize ( OneByteStringPtr  str)
inlinestatic

Definition at line 10537 of file object.h.

10537 {
10538 return UnroundedSize(Smi::Value(str->untag()->length()));
10539 }
intptr_t Value() const
Definition object.h:9969

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 10629 of file object.h.

◆ Deserializer

friend class Deserializer
friend

Definition at line 10637 of file object.h.

◆ FlowGraphSerializer

friend class FlowGraphSerializer
friend

Definition at line 10630 of file object.h.

◆ ImageWriter

friend class ImageWriter
friend

Definition at line 10631 of file object.h.

◆ JSONWriter

friend class JSONWriter
friend

Definition at line 10638 of file object.h.

◆ OneByteStringMessageSerializationCluster

Definition at line 10636 of file object.h.

◆ String

friend class String
friend

Definition at line 10632 of file object.h.

◆ StringHasher

friend class StringHasher
friend

Definition at line 10633 of file object.h.

◆ Symbols

friend class Symbols
friend

Definition at line 10634 of file object.h.

◆ Utf8

friend class Utf8
friend

Definition at line 10635 of file object.h.

Member Data Documentation

◆ kBytesPerElement

constexpr intptr_t dart::OneByteString::kBytesPerElement = 1
staticconstexpr

Definition at line 10521 of file object.h.

◆ kClassId

const ClassId dart::OneByteString::kClassId = kOneByteStringCid
static

Definition at line 10601 of file object.h.

◆ kMaxElements

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

Definition at line 10522 of file object.h.

◆ kMaxNewSpaceElements

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

Definition at line 10523 of file object.h.


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