Flutter Engine
The Flutter Engine
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 10523 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 10525 of file object.h.

10525 {
10526 ASSERT(str.IsOneByteString());
10527 return OneByteString::CharAt(static_cast<OneByteStringPtr>(str.ptr()),
10528 index);
10529 }
static uint16_t CharAt(const String &str, intptr_t index)
Definition: object.h:10525
#define ASSERT(E)

◆ CharAt() [2/2]

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

Definition at line 10531 of file object.h.

10531 {
10532 ASSERT(index >= 0 && index < String::LengthOf(str));
10533 return str->untag()->data()[index];
10534 }
static intptr_t LengthOf(StringPtr obj)
Definition: object.h:10211

◆ Concat()

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

Definition at line 24461 of file object.cc.

24463 {
24464 intptr_t len1 = str1.Length();
24465 intptr_t len2 = str2.Length();
24466 intptr_t len = len1 + len2;
24468 String::Copy(result, 0, str1, 0, len1);
24469 String::Copy(result, len1, str2, 0, len2);
24470 return OneByteString::raw(result);
24471}
static Object & Handle()
Definition: object.h:407
static OneByteStringPtr New(intptr_t len, Heap::Space space)
Definition: object.cc:24368
friend class String
Definition: object.h:10653
static void Copy(const String &dst, intptr_t dst_offset, const uint8_t *characters, intptr_t len)
Definition: object.cc:23792
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 24473 of file object.cc.

24477 {
24478 ASSERT(!strings.IsNull());
24479 ASSERT(start >= 0);
24480 ASSERT(end <= strings.Length());
24482 String& str = String::Handle();
24483 intptr_t pos = 0;
24484 for (intptr_t i = start; i < end; i++) {
24485 str ^= strings.At(i);
24486 const intptr_t str_len = str.Length();
24487 String::Copy(result, pos, str, 0, str_len);
24488 ASSERT((kMaxElements - pos) >= str_len);
24489 pos += str_len;
24490 }
24491 return OneByteString::raw(result);
24492}
SkPoint pos
static constexpr intptr_t kMaxElements
Definition: object.h:10543
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 10554 of file object.h.

10554 {
10555 return OFFSET_OF_RETURNED_VALUE(UntaggedOneByteString, data);
10556 }
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 24336 of file object.cc.

24336 {
24337 intptr_t len = str.Length();
24338 if (len > 0) {
24339 intptr_t num_escapes = 0;
24340 for (intptr_t i = 0; i < len; i++) {
24341 num_escapes += EscapeOverhead(CharAt(str, i));
24342 }
24343 const String& dststr =
24345 intptr_t index = 0;
24346 for (intptr_t i = 0; i < len; i++) {
24347 uint8_t ch = CharAt(str, i);
24348 if (IsSpecialCharacter(ch)) {
24349 SetCharAt(dststr, index, '\\');
24350 SetCharAt(dststr, index + 1, SpecialCharacter(ch));
24351 index += 2;
24352 } else if (IsAsciiNonprintable(ch)) {
24353 SetCharAt(dststr, index, '\\');
24354 SetCharAt(dststr, index + 1, 'x');
24355 SetCharAt(dststr, index + 2, GetHexCharacter(ch >> 4));
24356 SetCharAt(dststr, index + 3, GetHexCharacter(ch & 0xF));
24357 index += 4;
24358 } else {
24359 SetCharAt(dststr, index, ch);
24360 index += 1;
24361 }
24362 }
24363 return OneByteString::raw(dststr);
24364 }
24365 return OneByteString::raw(Symbols::Empty());
24366}
@ kNew
Definition: heap.h:38
static void SetCharAt(const String &str, intptr_t index, uint8_t code_unit)
Definition: object.h:10536
static const String & Empty()
Definition: symbols.h:688
static type SpecialCharacter(type value)
Definition: object.cc:530
static int32_t GetHexCharacter(int32_t c)
Definition: object.cc:23896
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 10564 of file object.h.

10564 {
10565 ASSERT(sizeof(UntaggedOneByteString) ==
10566 OFFSET_OF_RETURNED_VALUE(UntaggedOneByteString, data));
10567 return 0;
10568 }

◆ InstanceSize() [2/2]

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

Definition at line 10569 of file object.h.

10569 {
10570 ASSERT(sizeof(UntaggedOneByteString) == String::kSizeofRawString);
10571 ASSERT(0 <= len && len <= kMaxElements);
10573 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758
static intptr_t UnroundedSize(OneByteStringPtr str)
Definition: object.h:10558
static constexpr intptr_t kSizeofRawString
Definition: object.h:10170

◆ New() [1/8]

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

Definition at line 10576 of file object.h.

10577 {
10578 return New(reinterpret_cast<const uint8_t*>(c_string), strlen(c_string),
10579 space);
10580 }

◆ New() [2/8]

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

Definition at line 24413 of file object.cc.

24415 {
24417 NoSafepointScope no_safepoint;
24418 for (intptr_t i = 0; i < len; ++i) {
24419 ASSERT(Utf::IsLatin1(characters[i]));
24420 *CharAddr(result, i) = characters[i];
24421 }
24422 return OneByteString::raw(result);
24423}
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 24432 of file object.cc.

24435 {
24436 const String& result = String::Handle(OneByteString::New(other_len, space));
24437 ASSERT(other_one_byte_string.IsOneByteString());
24438 if (other_len > 0) {
24439 NoSafepointScope no_safepoint;
24440 memmove(OneByteString::DataStart(result),
24441 OneByteString::CharAddr(other_one_byte_string, other_start_index),
24442 other_len);
24443 }
24444 return OneByteString::raw(result);
24445}

◆ New() [4/8]

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

Definition at line 24425 of file object.cc.

24425 {
24426 intptr_t len = str.Length();
24428 String::Copy(result, 0, str, 0, len);
24429 return OneByteString::raw(result);
24430}

◆ 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 24447 of file object.cc.

24450 {
24451 const String& result = String::Handle(OneByteString::New(other_len, space));
24452 ASSERT(other_typed_data.ElementSizeInBytes() == 1);
24453 if (other_len > 0) {
24454 NoSafepointScope no_safepoint;
24455 memmove(OneByteString::DataStart(result),
24456 other_typed_data.DataAddr(other_start_index), other_len);
24457 }
24458 return OneByteString::raw(result);
24459}

◆ New() [6/8]

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

Definition at line 24401 of file object.cc.

24403 {
24405 NoSafepointScope no_safepoint;
24406 for (intptr_t i = 0; i < len; ++i) {
24407 ASSERT(Utf::IsLatin1(characters[i]));
24408 *CharAddr(result, i) = characters[i];
24409 }
24410 return OneByteString::raw(result);
24411}

◆ New() [7/8]

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

Definition at line 24390 of file object.cc.

24392 {
24394 if (len > 0) {
24395 NoSafepointScope no_safepoint;
24396 memmove(DataStart(result), characters, len);
24397 }
24398 return OneByteString::raw(result);
24399}

◆ New() [8/8]

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

Definition at line 24368 of file object.cc.

24368 {
24370 ((IsolateGroup::Current()->object_store() != nullptr) &&
24371 (IsolateGroup::Current()->object_store()->one_byte_string_class() !=
24372 Class::null())));
24373 if (len < 0 || len > kMaxElements) {
24374 // This should be caught before we reach here.
24375 FATAL("Fatal error in OneByteString::New: invalid len %" Pd "\n", len);
24376 }
24377 auto result = Object::Allocate<OneByteString>(space, len);
24378 NoSafepointScope no_safepoint;
24379 result->untag()->set_length(Smi::New(len));
24380#if !defined(HASH_IN_OBJECT_HEADER)
24381 result->untag()->set_hash(Smi::New(0));
24382#endif
24384 ASSERT(size <= result->untag()->HeapSize());
24385 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(result) + size), 0,
24386 result->untag()->HeapSize() - size);
24387 return result;
24388}
static IsolateGroup * vm_isolate_group()
Definition: dart.h:69
static IsolateGroup * Current()
Definition: isolate.h:539
static ObjectPtr null()
Definition: object.h:433
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static uword ToAddr(const UntaggedObject *raw_obj)
Definition: raw_object.h:522
#define FATAL(error)
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 10624 of file object.h.

10624 {
10625 return static_cast<OneByteStringPtr>(Object::null());
10626 }

◆ SetCharAt()

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

Definition at line 10536 of file object.h.

10536 {
10537 NoSafepointScope no_safepoint;
10538 *CharAddr(str, index) = code_unit;
10539 }

◆ SubStringUnchecked()

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

Definition at line 24509 of file object.cc.

24512 {
24513 ASSERT(!str.IsNull() && str.IsOneByteString());
24514 ASSERT(begin_index >= 0);
24515 ASSERT(length >= 0);
24516 if (begin_index <= str.Length() && length == 0) {
24517 return OneByteString::raw(Symbols::Empty());
24518 }
24519 ASSERT(begin_index < str.Length());
24520 OneByteStringPtr result = OneByteString::New(length, space);
24521 NoSafepointScope no_safepoint;
24522 if (length > 0) {
24523 uint8_t* dest = &result->untag()->data()[0];
24524 const uint8_t* src = &untag(str)->data()[begin_index];
24525 memmove(dest, src, length);
24526 }
24527 return result;
24528}
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 24494 of file object.cc.

24496 {
24497 ASSERT(!str.IsNull());
24498 intptr_t len = str.Length();
24500 NoSafepointScope no_safepoint;
24501 for (intptr_t i = 0; i < len; ++i) {
24502 int32_t ch = mapping(str.CharAt(i));
24503 ASSERT(Utf::IsLatin1(ch));
24504 *CharAddr(result, i) = ch;
24505 }
24506 return OneByteString::raw(result);
24507}

◆ UnroundedSize() [1/2]

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

Definition at line 10561 of file object.h.

10561 {
10562 return sizeof(UntaggedOneByteString) + (len * kBytesPerElement);
10563 }
static constexpr intptr_t kBytesPerElement
Definition: object.h:10542

◆ UnroundedSize() [2/2]

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

Definition at line 10558 of file object.h.

10558 {
10559 return UnroundedSize(Smi::Value(str->untag()->length()));
10560 }
intptr_t Value() const
Definition: object.h:9990

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 10650 of file object.h.

◆ Deserializer

friend class Deserializer
friend

Definition at line 10658 of file object.h.

◆ FlowGraphSerializer

friend class FlowGraphSerializer
friend

Definition at line 10651 of file object.h.

◆ ImageWriter

friend class ImageWriter
friend

Definition at line 10652 of file object.h.

◆ JSONWriter

friend class JSONWriter
friend

Definition at line 10659 of file object.h.

◆ OneByteStringMessageSerializationCluster

Definition at line 10657 of file object.h.

◆ String

friend class String
friend

Definition at line 10653 of file object.h.

◆ StringHasher

friend class StringHasher
friend

Definition at line 10654 of file object.h.

◆ Symbols

friend class Symbols
friend

Definition at line 10655 of file object.h.

◆ Utf8

friend class Utf8
friend

Definition at line 10656 of file object.h.

Member Data Documentation

◆ kBytesPerElement

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

Definition at line 10542 of file object.h.

◆ kClassId

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

Definition at line 10622 of file object.h.

◆ kMaxElements

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

Definition at line 10543 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 10544 of file object.h.


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