Flutter Engine
The Flutter Engine
Public Types | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::Symbols Class Reference

#include <symbols.h>

Inheritance diagram for dart::Symbols:
dart::AllStatic

Public Types

enum  { kMaxOneCharCodeSymbol = 0xFF }
 
enum  SymbolId { kIllegal = 0 , kTokenTableStart , DART_TOKEN_LIST , kMaxPredefinedId = kNullCharId + kMaxOneCharCodeSymbol + 1 }
 

Static Public Member Functions

static const StringSymbol (intptr_t index)
 
static const StringDot ()
 
static const StringEquals ()
 
static const StringPlus ()
 
static const StringMinus ()
 
static const StringBitOr ()
 
static const StringBitAnd ()
 
static const StringLAngleBracket ()
 
static const StringRAngleBracket ()
 
static const StringLParen ()
 
static const StringRParen ()
 
static const StringLBracket ()
 
static const StringRBracket ()
 
static const StringLBrace ()
 
static const StringRBrace ()
 
static const StringBlank ()
 
static const StringDollar ()
 
static const StringNewLine ()
 
static const StringDoubleQuote ()
 
static const StringSingleQuote ()
 
static const StringLowercaseR ()
 
static const StringDash ()
 
static const StringAmpersand ()
 
static const StringBacktick ()
 
static const StringSlash ()
 
static const StringAt ()
 
static const StringHashMark ()
 
static const StringSemicolon ()
 
static const StringStar ()
 
static const StringPercent ()
 
static const StringQuestionMark ()
 
static const StringCaret ()
 
static const StringTilde ()
 
static const StringEmpty ()
 
static const StringFalse ()
 
static const StringLibrary ()
 
static const StringSuper ()
 
static const StringThis ()
 
static const StringTrue ()
 
static const StringVoid ()
 
static const StringToken (Token::Kind token)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitFromSnapshot (IsolateGroup *isolate_group)
 
static void SetupSymbolTable (IsolateGroup *isolate_group)
 
static StringPtr New (Thread *thread, const char *cstr)
 
static StringPtr New (Thread *thread, const char *cstr, intptr_t length)
 
static StringPtr FromUTF8 (Thread *thread, const uint8_t *utf8_array, intptr_t len)
 
static StringPtr FromLatin1 (Thread *thread, const uint8_t *latin1_array, intptr_t len)
 
static StringPtr FromUTF16 (Thread *thread, const uint16_t *utf16_array, intptr_t len)
 
static StringPtr New (Thread *thread, const String &str)
 
static StringPtr New (Thread *thread, const String &str, intptr_t begin_index, intptr_t length)
 
static StringPtr NewFormatted (Thread *thread, const char *format,...) PRINTF_ATTRIBUTE(2
 
static StringPtr static StringPtr NewFormattedV (Thread *thread, const char *format, va_list args)
 
static StringPtr FromConcat (Thread *thread, const String &str1, const String &str2)
 
static StringPtr FromConcatAll (Thread *thread, const GrowableHandlePtrArray< const String > &strs)
 
static StringPtr FromGet (Thread *thread, const String &str)
 
static StringPtr FromSet (Thread *thread, const String &str)
 
static StringPtr FromDot (Thread *thread, const String &str)
 
static const char * Name (SymbolId symbol)
 
static StringPtr FromCharCode (Thread *thread, uint16_t char_code)
 
static StringPtr * PredefinedAddress ()
 
static void DumpStats (IsolateGroup *isolate_group)
 
static void DumpTable (IsolateGroup *isolate_group)
 
template<typename StringType >
static StringPtr Lookup (Thread *thread, const StringType &str)
 
static StringPtr LookupFromConcat (Thread *thread, const String &str1, const String &str2)
 
static StringPtr LookupFromGet (Thread *thread, const String &str)
 
static StringPtr LookupFromSet (Thread *thread, const String &str)
 
static StringPtr LookupFromDot (Thread *thread, const String &str)
 
static void GetStats (IsolateGroup *isolate_group, intptr_t *size, intptr_t *capacity)
 

Static Public Attributes

static constexpr int kNumberOfOneCharCodeSymbols
 
static constexpr int kNullCharCodeSymbolOffset = 0
 

Friends

class Dart
 
class String
 
class Serializer
 
class Deserializer
 

Detailed Description

Definition at line 575 of file symbols.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kMaxOneCharCodeSymbol 

Definition at line 577 of file symbols.h.

577{ kMaxOneCharCodeSymbol = 0xFF };
@ kMaxOneCharCodeSymbol
Definition: symbols.h:577

◆ SymbolId

Enumerator
kIllegal 
kTokenTableStart 
DART_TOKEN_LIST 
kMaxPredefinedId 

Definition at line 580 of file symbols.h.

580 {
581 // clang-format off
582 kIllegal = 0,
583
584#define DEFINE_SYMBOL_INDEX(symbol, literal) k##symbol##Id,
586#undef DEFINE_SYMBOL_INDEX
587
588 kTokenTableStart, // First token at kTokenTableStart + 1.
589
590#define DEFINE_TOKEN_SYMBOL_INDEX(t, s, p, a) t##Id,
593#undef DEFINE_TOKEN_SYMBOL_INDEX
594
595 kNullCharId, // One char code symbol starts here and takes up 256 entries.
596 kMaxPredefinedId = kNullCharId + kMaxOneCharCodeSymbol + 1,
597 // clang-format on
598 };
@ DART_TOKEN_LIST
Definition: symbols.h:591
@ kTokenTableStart
Definition: symbols.h:588
@ kMaxPredefinedId
Definition: symbols.h:596
#define PREDEFINED_SYMBOLS_LIST(V)
Definition: symbols.h:18
#define DEFINE_TOKEN_SYMBOL_INDEX(t, s, p, a)
Definition: symbols.h:590
#define DEFINE_SYMBOL_INDEX(symbol, literal)
Definition: symbols.h:584
#define DART_KEYWORD_LIST(KW)
Definition: token.h:159

Member Function Documentation

◆ Ampersand()

static const String & dart::Symbols::Ampersand ( )
inlinestatic

Definition at line 664 of file symbols.h.

664 {
665 return *(symbol_handles_[kNullCharId + '&']);
666 }

◆ At()

static const String & dart::Symbols::At ( )
inlinestatic

Definition at line 671 of file symbols.h.

671{ return *(symbol_handles_[kNullCharId + '@']); }

◆ Backtick()

static const String & dart::Symbols::Backtick ( )
inlinestatic

Definition at line 667 of file symbols.h.

667 {
668 return *(symbol_handles_[kNullCharId + '`']);
669 }

◆ BitAnd()

static const String & dart::Symbols::BitAnd ( )
inlinestatic

Definition at line 620 of file symbols.h.

620 {
621 return *(symbol_handles_[kNullCharId + '&']);
622 }

◆ BitOr()

static const String & dart::Symbols::BitOr ( )
inlinestatic

Definition at line 619 of file symbols.h.

619{ return *(symbol_handles_[kNullCharId + '|']); }

◆ Blank()

static const String & dart::Symbols::Blank ( )
inlinestatic

Definition at line 647 of file symbols.h.

647{ return *(symbol_handles_[kNullCharId + ' ']); }

◆ Caret()

static const String & dart::Symbols::Caret ( )
inlinestatic

Definition at line 685 of file symbols.h.

685{ return *(symbol_handles_[kNullCharId + '^']); }

◆ Dash()

static const String & dart::Symbols::Dash ( )
inlinestatic

Definition at line 663 of file symbols.h.

663{ return *(symbol_handles_[kNullCharId + '-']); }

◆ Dollar()

static const String & dart::Symbols::Dollar ( )
inlinestatic

Definition at line 648 of file symbols.h.

648 {
649 return *(symbol_handles_[kNullCharId + '$']);
650 }

◆ Dot()

static const String & dart::Symbols::Dot ( )
inlinestatic

Definition at line 613 of file symbols.h.

613{ return *(symbol_handles_[kNullCharId + '.']); }

◆ DoubleQuote()

static const String & dart::Symbols::DoubleQuote ( )
inlinestatic

Definition at line 654 of file symbols.h.

654 {
655 return *(symbol_handles_[kNullCharId + '"']);
656 }

◆ DumpStats()

void dart::Symbols::DumpStats ( IsolateGroup isolate_group)
static

Definition at line 481 of file symbols.cc.

481 {
482 intptr_t size = -1;
483 intptr_t capacity = -1;
484 // First dump VM symbol table stats.
485 GetStats(Dart::vm_isolate_group(), &size, &capacity);
486 OS::PrintErr("VM Isolate: Number of symbols : %" Pd "\n", size);
487 OS::PrintErr("VM Isolate: Symbol table capacity : %" Pd "\n", capacity);
488 // Now dump regular isolate symbol table stats.
489 GetStats(isolate_group, &size, &capacity);
490 OS::PrintErr("Isolate: Number of symbols : %" Pd "\n", size);
491 OS::PrintErr("Isolate: Symbol table capacity : %" Pd "\n", capacity);
492 // TODO(koda): Consider recording growth and collision stats in HashTable,
493 // in DEBUG mode.
494}
static IsolateGroup * vm_isolate_group()
Definition: dart.h:69
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static void GetStats(IsolateGroup *isolate_group, intptr_t *size, intptr_t *capacity)
Definition: symbols.cc:180
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

◆ DumpTable()

void dart::Symbols::DumpTable ( IsolateGroup isolate_group)
static

Definition at line 496 of file symbols.cc.

496 {
497 OS::PrintErr("symbols:\n");
498 CanonicalStringSet table(isolate_group->object_store()->symbol_table());
499 table.Dump();
500 table.Release();
501}
SI F table(const skcms_Curve *curve, F v)
UnorderedHashSet< SymbolTraits, WeakAcqRelStorageTraits > CanonicalStringSet

◆ Empty()

static const String & dart::Symbols::Empty ( )
inlinestatic

Definition at line 688 of file symbols.h.

688{ return *(symbol_handles_[kTokenTableStart]); }

◆ Equals()

static const String & dart::Symbols::Equals ( )
inlinestatic

Definition at line 614 of file symbols.h.

614 {
615 return *(symbol_handles_[kNullCharId + '=']);
616 }

◆ False()

static const String & dart::Symbols::False ( )
inlinestatic

Definition at line 689 of file symbols.h.

689{ return *(symbol_handles_[kFALSEId]); }

◆ FromCharCode()

StringPtr dart::Symbols::FromCharCode ( Thread thread,
uint16_t  char_code 
)
static

Definition at line 474 of file symbols.cc.

474 {
475 if (char_code > kMaxOneCharCodeSymbol) {
476 return FromUTF16(thread, &char_code, 1);
477 }
478 return predefined_[char_code];
479}
static StringPtr FromUTF16(Thread *thread, const uint16_t *utf16_array, intptr_t len)
Definition: symbols.cc:229

◆ FromConcat()

StringPtr dart::Symbols::FromConcat ( Thread thread,
const String str1,
const String str2 
)
static

Definition at line 235 of file symbols.cc.

237 {
238 if (str1.Length() == 0) {
239 return New(thread, str2);
240 } else if (str2.Length() == 0) {
241 return New(thread, str1);
242 } else {
243 return NewSymbol(thread, ConcatString(str1, str2));
244 }
245}
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723

◆ FromConcatAll()

StringPtr dart::Symbols::FromConcatAll ( Thread thread,
const GrowableHandlePtrArray< const String > &  strs 
)
static

Definition at line 262 of file symbols.cc.

264 {
265 const intptr_t strs_length = strs.length();
266 GrowableArray<intptr_t> lengths(strs_length);
267
268 intptr_t len_sum = 0;
269 const intptr_t kOneByteChar = 1;
270 intptr_t char_size = kOneByteChar;
271
272 for (intptr_t i = 0; i < strs_length; i++) {
273 const String& str = strs[i];
274 const intptr_t str_len = str.Length();
275 if ((String::kMaxElements - len_sum) < str_len) {
277 UNREACHABLE();
278 }
279 len_sum += str_len;
280 lengths.Add(str_len);
281 char_size = Utils::Maximum(char_size, str.CharSize());
282 }
283 const bool is_one_byte_string = char_size == kOneByteChar;
284
285 Zone* zone = thread->zone();
286 if (is_one_byte_string) {
287 uint8_t* buffer = zone->Alloc<uint8_t>(len_sum);
288 const uint8_t* const orig_buffer = buffer;
289 for (intptr_t i = 0; i < strs_length; i++) {
290 NoSafepointScope no_safepoint;
291 intptr_t str_len = lengths[i];
292 if (str_len > 0) {
293 const String& str = strs[i];
294 ASSERT(str.IsOneByteString());
295 const uint8_t* src_p = OneByteString::DataStart(str);
296 memmove(buffer, src_p, str_len);
297 buffer += str_len;
298 }
299 }
300 ASSERT(len_sum == buffer - orig_buffer);
301 return Symbols::FromLatin1(thread, orig_buffer, len_sum);
302 } else {
303 uint16_t* buffer = zone->Alloc<uint16_t>(len_sum);
304 const uint16_t* const orig_buffer = buffer;
305 for (intptr_t i = 0; i < strs_length; i++) {
306 NoSafepointScope no_safepoint;
307 intptr_t str_len = lengths[i];
308 if (str_len > 0) {
309 const String& str = strs[i];
310 if (str.IsTwoByteString()) {
311 memmove(buffer, TwoByteString::DataStart(str), str_len * 2);
312 } else {
313 // One-byte to two-byte string copy.
314 ASSERT(str.IsOneByteString());
315 const uint8_t* src_p = OneByteString::DataStart(str);
316 for (int n = 0; n < str_len; n++) {
317 buffer[n] = src_p[n];
318 }
319 }
320 buffer += str_len;
321 }
322 }
323 ASSERT(len_sum == buffer - orig_buffer);
324 return Symbols::FromUTF16(thread, orig_buffer, len_sum);
325 }
326}
static uint8_t src_p(uint8_t src, uint8_t dst)
#define UNREACHABLE()
Definition: assert.h:248
static DART_NORETURN void ThrowOOM()
Definition: exceptions.cc:1066
static constexpr intptr_t kMaxElements
Definition: object.h:10173
friend class String
Definition: symbols.h:811
static StringPtr FromLatin1(Thread *thread, const uint8_t *latin1_array, intptr_t len)
Definition: symbols.cc:223
static constexpr T Maximum(T x, T y)
Definition: utils.h:41
#define ASSERT(E)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ FromDot()

StringPtr dart::Symbols::FromDot ( Thread thread,
const String str 
)
static

Definition at line 255 of file symbols.cc.

255 {
256 return FromConcat(thread, str, Dot());
257}
static StringPtr FromConcat(Thread *thread, const String &str1, const String &str2)
Definition: symbols.cc:235
static const String & Dot()
Definition: symbols.h:613

◆ FromGet()

StringPtr dart::Symbols::FromGet ( Thread thread,
const String str 
)
static

Definition at line 247 of file symbols.cc.

247 {
248 return FromConcat(thread, GetterPrefix(), str);
249}

◆ FromLatin1()

StringPtr dart::Symbols::FromLatin1 ( Thread thread,
const uint8_t *  latin1_array,
intptr_t  len 
)
static

Definition at line 223 of file symbols.cc.

225 {
226 return NewSymbol(thread, Latin1Array(latin1_array, len));
227}
CharArray< uint8_t > Latin1Array

◆ FromSet()

StringPtr dart::Symbols::FromSet ( Thread thread,
const String str 
)
static

Definition at line 251 of file symbols.cc.

251 {
252 return FromConcat(thread, SetterPrefix(), str);
253}

◆ FromUTF16()

StringPtr dart::Symbols::FromUTF16 ( Thread thread,
const uint16_t *  utf16_array,
intptr_t  len 
)
static

Definition at line 229 of file symbols.cc.

231 {
232 return NewSymbol(thread, UTF16Array(utf16_array, len));
233}
CharArray< uint16_t > UTF16Array

◆ FromUTF8()

StringPtr dart::Symbols::FromUTF8 ( Thread thread,
const uint8_t *  utf8_array,
intptr_t  len 
)
static

Definition at line 196 of file symbols.cc.

198 {
199 if (array_len == 0 || utf8_array == nullptr) {
200 return FromLatin1(thread, static_cast<uint8_t*>(nullptr), 0);
201 }
203 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type);
204 ASSERT(len != 0);
205 Zone* zone = thread->zone();
206 if (type == Utf8::kLatin1) {
207 uint8_t* characters = zone->Alloc<uint8_t>(len);
208 if (!Utf8::DecodeToLatin1(utf8_array, array_len, characters, len)) {
209 Utf8::ReportInvalidByte(utf8_array, array_len, len);
210 return String::null();
211 }
212 return FromLatin1(thread, characters, len);
213 }
215 uint16_t* characters = zone->Alloc<uint16_t>(len);
216 if (!Utf8::DecodeToUTF16(utf8_array, array_len, characters, len)) {
217 Utf8::ReportInvalidByte(utf8_array, array_len, len);
218 return String::null();
219 }
220 return FromUTF16(thread, characters, len);
221}
GLenum type
static ObjectPtr null()
Definition: object.h:433
@ kSupplementary
Definition: unicode.h:46
@ kLatin1
Definition: unicode.h:44
static intptr_t CodeUnitCount(const uint8_t *utf8_array, intptr_t array_len, Type *type)
Definition: unicode.cc:46
static intptr_t ReportInvalidByte(const uint8_t *utf8_array, intptr_t array_len, intptr_t len)
Definition: unicode.cc:163
static bool DecodeToUTF16(const uint8_t *utf8_array, intptr_t array_len, uint16_t *dst, intptr_t len)
Definition: unicode.cc:217
static bool DecodeToLatin1(const uint8_t *utf8_array, intptr_t array_len, uint8_t *dst, intptr_t len)
Definition: unicode.cc:194

◆ GetStats()

void dart::Symbols::GetStats ( IsolateGroup isolate_group,
intptr_t *  size,
intptr_t *  capacity 
)
static

Definition at line 180 of file symbols.cc.

182 {
183 ASSERT(isolate_group != nullptr);
184 CanonicalStringSet table(isolate_group->object_store()->symbol_table());
185 *size = table.NumOccupied();
186 *capacity = table.NumEntries();
187 table.Release();
188}

◆ HashMark()

static const String & dart::Symbols::HashMark ( )
inlinestatic

Definition at line 672 of file symbols.h.

672 {
673 return *(symbol_handles_[kNullCharId + '#']);
674 }

◆ Init()

void dart::Symbols::Init ( IsolateGroup isolate_group)
static

Definition at line 80 of file symbols.cc.

80 {
81 // Should only be run by the vm isolate.
83 ASSERT(vm_isolate_group == Dart::vm_isolate_group());
84 Zone* zone = Thread::Current()->zone();
85
86 // Create and setup a symbol table in the vm isolate.
87 SetupSymbolTable(vm_isolate_group);
88
89 // Create all predefined symbols.
90 ASSERT((sizeof(names) / sizeof(const char*)) == Symbols::kNullCharId);
91
93 vm_isolate_group->object_store()->symbol_table());
94
95 // First set up all the predefined string symbols.
96 // Create symbols for language keywords. Some keywords are equal to
97 // symbols we already created, so use New() instead of Add() to ensure
98 // that the symbols are canonicalized.
99 for (intptr_t i = 1; i < Symbols::kNullCharId; i++) {
102 str->Hash();
103 *str ^= table.InsertOrGet(*str);
104 str->SetCanonical(); // Make canonical once entered.
105 symbol_handles_[i] = str;
106 }
107
108 // Add Latin1 characters as Symbols, so that Symbols::FromCharCode is fast.
109 for (intptr_t c = 0; c < kNumberOfOneCharCodeSymbols; c++) {
110 intptr_t idx = (kNullCharId + c);
113 uint8_t ch = static_cast<uint8_t>(c);
115 *str = OneByteString::New(&ch, 1, Heap::kOld);
116 str->Hash();
117 *str ^= table.InsertOrGet(*str);
118 ASSERT(predefined_[c] == nullptr);
119 str->SetCanonical(); // Make canonical once entered.
120 predefined_[c] = str->ptr();
121 symbol_handles_[idx] = str;
122 }
123
124 vm_isolate_group->object_store()->set_symbol_table(table.Release());
125}
@ kOld
Definition: heap.h:39
static IsolateGroup * Current()
Definition: isolate.h:539
static Object * ReadOnlyHandle()
Definition: object.h:431
static OneByteStringPtr New(intptr_t len, Heap::Space space)
Definition: object.cc:24368
static constexpr int kNumberOfOneCharCodeSymbols
Definition: symbols.h:601
static void SetupSymbolTable(IsolateGroup *isolate_group)
Definition: symbols.cc:168
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
static bool IsLatin1(int32_t code_point)
Definition: unicode.h:23
static const char *const names[]
Definition: symbols.cc:24

◆ InitFromSnapshot()

void dart::Symbols::InitFromSnapshot ( IsolateGroup isolate_group)
static

Definition at line 127 of file symbols.cc.

127 {
128 // Should only be run by the vm isolate.
130 ASSERT(vm_isolate_group == Dart::vm_isolate_group());
131 Zone* zone = Thread::Current()->zone();
132
134 vm_isolate_group->object_store()->symbol_table());
135
136 // Lookup all the predefined string symbols and language keyword symbols
137 // and cache them in the read only handles for fast access.
138 for (intptr_t i = 1; i < Symbols::kNullCharId; i++) {
140 const unsigned char* name =
141 reinterpret_cast<const unsigned char*>(names[i]);
142 *str ^= table.GetOrNull(Latin1Array(name, strlen(names[i])));
143 ASSERT(!str->IsNull());
144 ASSERT(str->HasHash());
145 ASSERT(str->IsCanonical());
146 symbol_handles_[i] = str;
147 }
148
149 // Lookup Latin1 character Symbols and cache them in read only handles,
150 // so that Symbols::FromCharCode is fast.
151 for (intptr_t c = 0; c < kNumberOfOneCharCodeSymbols; c++) {
152 intptr_t idx = (kNullCharId + c);
155 uint8_t ch = static_cast<uint8_t>(c);
157 *str ^= table.GetOrNull(Latin1Array(&ch, 1));
158 ASSERT(!str->IsNull());
159 ASSERT(str->HasHash());
160 ASSERT(str->IsCanonical());
161 predefined_[c] = str->ptr();
162 symbol_handles_[idx] = str;
163 }
164
165 vm_isolate_group->object_store()->set_symbol_table(table.Release());
166}
const char *const name

◆ LAngleBracket()

static const String & dart::Symbols::LAngleBracket ( )
inlinestatic

Definition at line 623 of file symbols.h.

623 {
624 return *(symbol_handles_[kNullCharId + '<']);
625 }

◆ LBrace()

static const String & dart::Symbols::LBrace ( )
inlinestatic

Definition at line 641 of file symbols.h.

641 {
642 return *(symbol_handles_[kNullCharId + '{']);
643 }

◆ LBracket()

static const String & dart::Symbols::LBracket ( )
inlinestatic

Definition at line 635 of file symbols.h.

635 {
636 return *(symbol_handles_[kNullCharId + '[']);
637 }

◆ Library()

static const String & dart::Symbols::Library ( )
inlinestatic

Definition at line 690 of file symbols.h.

690{ return *(symbol_handles_[kLIBRARYId]); }

◆ Lookup()

template<typename StringType >
StringPtr dart::Symbols::Lookup ( Thread thread,
const StringType &  str 
)
static

Definition at line 375 of file symbols.cc.

375 {
379 String& symbol = String::Handle(thread->zone());
380 dart::Object& key = thread->ObjectHandle();
381 Smi& value = thread->SmiHandle();
382 class WeakArray& data = thread->WeakArrayHandle();
383 {
384 auto vm_isolate_group = Dart::vm_isolate_group();
385 data = vm_isolate_group->object_store()->symbol_table();
387 symbol ^= table.GetOrNull(str);
388 table.Release();
389 }
390 if (symbol.IsNull()) {
391 IsolateGroup* group = thread->isolate_group();
392 ObjectStore* object_store = group->object_store();
393 // See `Symbols::NewSymbol` for more information why we separate the two
394 // cases.
395 if (thread->OwnsSafepoint()) {
396 data = object_store->symbol_table();
398 symbol ^= table.GetOrNull(str);
399 table.Release();
400 } else {
401 data = object_store->symbol_table();
403 symbol ^= table.GetOrNull(str);
404 table.Release();
405 }
406 }
407 ASSERT(symbol.IsNull() || symbol.IsSymbol());
408 ASSERT(symbol.IsNull() || symbol.HasHash());
409 return symbol.ptr();
410}
static Object & Handle()
Definition: object.h:407
uint8_t value
static int8_t data[kExtLength]
#define REUSABLE_ARRAY_HANDLESCOPE(thread)
#define REUSABLE_SMI_HANDLESCOPE(thread)
#define REUSABLE_OBJECT_HANDLESCOPE(thread)

◆ LookupFromConcat()

StringPtr dart::Symbols::LookupFromConcat ( Thread thread,
const String str1,
const String str2 
)
static

Definition at line 412 of file symbols.cc.

414 {
415 if (str1.Length() == 0) {
416 return Lookup(thread, str2);
417 } else if (str2.Length() == 0) {
418 return Lookup(thread, str1);
419 } else {
420 return Lookup(thread, ConcatString(str1, str2));
421 }
422}
static StringPtr Lookup(Thread *thread, const StringType &str)
Definition: symbols.cc:375

◆ LookupFromDot()

StringPtr dart::Symbols::LookupFromDot ( Thread thread,
const String str 
)
static

Definition at line 432 of file symbols.cc.

432 {
433 return LookupFromConcat(thread, str, Dot());
434}
static StringPtr LookupFromConcat(Thread *thread, const String &str1, const String &str2)
Definition: symbols.cc:412

◆ LookupFromGet()

StringPtr dart::Symbols::LookupFromGet ( Thread thread,
const String str 
)
static

Definition at line 424 of file symbols.cc.

424 {
425 return LookupFromConcat(thread, GetterPrefix(), str);
426}

◆ LookupFromSet()

StringPtr dart::Symbols::LookupFromSet ( Thread thread,
const String str 
)
static

Definition at line 428 of file symbols.cc.

428 {
429 return LookupFromConcat(thread, SetterPrefix(), str);
430}

◆ LowercaseR()

static const String & dart::Symbols::LowercaseR ( )
inlinestatic

Definition at line 660 of file symbols.h.

660 {
661 return *(symbol_handles_[kNullCharId + 'r']);
662 }

◆ LParen()

static const String & dart::Symbols::LParen ( )
inlinestatic

Definition at line 629 of file symbols.h.

629 {
630 return *(symbol_handles_[kNullCharId + '(']);
631 }

◆ Minus()

static const String & dart::Symbols::Minus ( )
inlinestatic

Definition at line 618 of file symbols.h.

618{ return *(symbol_handles_[kNullCharId + '-']); }

◆ Name()

const char * dart::Symbols::Name ( SymbolId  symbol)
static

Definition at line 66 of file symbols.cc.

66 {
67 ASSERT((symbol > kIllegal) && (symbol < kNullCharId));
68 return names[symbol];
69}

◆ New() [1/4]

static StringPtr dart::Symbols::New ( Thread thread,
const char *  cstr 
)
inlinestatic

Definition at line 723 of file symbols.h.

723 {
724 return New(thread, cstr, strlen(cstr));
725 }

◆ New() [2/4]

StringPtr dart::Symbols::New ( Thread thread,
const char *  cstr,
intptr_t  length 
)
static

Definition at line 190 of file symbols.cc.

190 {
191 ASSERT((cstr != nullptr) && (len >= 0));
192 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr);
193 return Symbols::FromUTF8(thread, utf8_array, len);
194}
static StringPtr FromUTF8(Thread *thread, const uint8_t *utf8_array, intptr_t len)
Definition: symbols.cc:196

◆ New() [3/4]

StringPtr dart::Symbols::New ( Thread thread,
const String str 
)
static

Definition at line 436 of file symbols.cc.

436 {
437 if (str.IsSymbol()) {
438 return str.ptr();
439 }
440 return New(thread, str, 0, str.Length());
441}

◆ New() [4/4]

StringPtr dart::Symbols::New ( Thread thread,
const String str,
intptr_t  begin_index,
intptr_t  length 
)
static

Definition at line 443 of file symbols.cc.

446 {
447 return NewSymbol(thread, StringSlice(str, begin_index, len));
448}

◆ NewFormatted()

StringPtr dart::Symbols::NewFormatted ( Thread thread,
const char *  format,
  ... 
)
static

Definition at line 450 of file symbols.cc.

450 {
451 va_list args;
453 StringPtr result = NewFormattedV(thread, format, args);
454 NoSafepointScope no_safepoint;
455 va_end(args);
456 return result;
457}
static StringPtr static StringPtr NewFormattedV(Thread *thread, const char *format, va_list args)
Definition: symbols.cc:459
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
GAsyncResult * result
uint32_t uint32_t * format
va_start(args, format)
va_end(args)

◆ NewFormattedV()

StringPtr dart::Symbols::NewFormattedV ( Thread thread,
const char *  format,
va_list  args 
)
static

Definition at line 459 of file symbols.cc.

461 {
462 va_list args_copy;
463 va_copy(args_copy, args);
464 intptr_t len = Utils::VSNPrint(nullptr, 0, format, args_copy);
465 va_end(args_copy);
466
467 Zone* zone = Thread::Current()->zone();
468 char* buffer = zone->Alloc<char>(len + 1);
470
471 return Symbols::New(thread, buffer);
472}
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)

◆ NewLine()

static const String & dart::Symbols::NewLine ( )
inlinestatic

Definition at line 651 of file symbols.h.

651 {
652 return *(symbol_handles_[kNullCharId + '\n']);
653 }

◆ Percent()

static const String & dart::Symbols::Percent ( )
inlinestatic

Definition at line 679 of file symbols.h.

679 {
680 return *(symbol_handles_[kNullCharId + '%']);
681 }

◆ Plus()

static const String & dart::Symbols::Plus ( )
inlinestatic

Definition at line 617 of file symbols.h.

617{ return *(symbol_handles_[kNullCharId + '+']); }

◆ PredefinedAddress()

static StringPtr * dart::Symbols::PredefinedAddress ( )
inlinestatic

Definition at line 772 of file symbols.h.

772 {
773 return reinterpret_cast<StringPtr*>(&predefined_);
774 }

◆ QuestionMark()

static const String & dart::Symbols::QuestionMark ( )
inlinestatic

Definition at line 682 of file symbols.h.

682 {
683 return *(symbol_handles_[kNullCharId + '?']);
684 }

◆ RAngleBracket()

static const String & dart::Symbols::RAngleBracket ( )
inlinestatic

Definition at line 626 of file symbols.h.

626 {
627 return *(symbol_handles_[kNullCharId + '>']);
628 }

◆ RBrace()

static const String & dart::Symbols::RBrace ( )
inlinestatic

Definition at line 644 of file symbols.h.

644 {
645 return *(symbol_handles_[kNullCharId + '}']);
646 }

◆ RBracket()

static const String & dart::Symbols::RBracket ( )
inlinestatic

Definition at line 638 of file symbols.h.

638 {
639 return *(symbol_handles_[kNullCharId + ']']);
640 }

◆ RParen()

static const String & dart::Symbols::RParen ( )
inlinestatic

Definition at line 632 of file symbols.h.

632 {
633 return *(symbol_handles_[kNullCharId + ')']);
634 }

◆ Semicolon()

static const String & dart::Symbols::Semicolon ( )
inlinestatic

Definition at line 675 of file symbols.h.

675 {
676 return *(symbol_handles_[kNullCharId + ';']);
677 }

◆ SetupSymbolTable()

void dart::Symbols::SetupSymbolTable ( IsolateGroup isolate_group)
static

Definition at line 168 of file symbols.cc.

168 {
169 ASSERT(isolate_group != nullptr);
170
171 // Setup the symbol table used within the String class.
172 const intptr_t initial_size = (isolate_group == Dart::vm_isolate_group())
173 ? kInitialVMIsolateSymtabSize
174 : kInitialSymtabSize;
175 class WeakArray& array = WeakArray::Handle(
176 HashTables::New<CanonicalStringSet>(initial_size, Heap::kOld));
177 isolate_group->object_store()->set_symbol_table(array);
178}

◆ SingleQuote()

static const String & dart::Symbols::SingleQuote ( )
inlinestatic

Definition at line 657 of file symbols.h.

657 {
658 return *(symbol_handles_[kNullCharId + '\'']);
659 }

◆ Slash()

static const String & dart::Symbols::Slash ( )
inlinestatic

Definition at line 670 of file symbols.h.

670{ return *(symbol_handles_[kNullCharId + '/']); }

◆ Star()

static const String & dart::Symbols::Star ( )
inlinestatic

Definition at line 678 of file symbols.h.

678{ return *(symbol_handles_[kNullCharId + '*']); }

◆ Super()

static const String & dart::Symbols::Super ( )
inlinestatic

Definition at line 691 of file symbols.h.

691{ return *(symbol_handles_[kSUPERId]); }

◆ Symbol()

static const String & dart::Symbols::Symbol ( intptr_t  index)
inlinestatic

Definition at line 607 of file symbols.h.

607 {
608 ASSERT((index > kIllegal) && (index < kMaxPredefinedId));
609 return *(symbol_handles_[index]);
610 }

◆ This()

static const String & dart::Symbols::This ( )
inlinestatic

Definition at line 692 of file symbols.h.

692{ return *(symbol_handles_[kTHISId]); }

◆ Tilde()

static const String & dart::Symbols::Tilde ( )
inlinestatic

Definition at line 686 of file symbols.h.

686{ return *(symbol_handles_[kNullCharId + '~']); }

◆ Token()

const String & dart::Symbols::Token ( Token::Kind  token)
static

Definition at line 71 of file symbols.cc.

71 {
72 const int tok_index = token;
73 ASSERT((0 <= tok_index) && (tok_index < Token::kNumTokens));
74 // First keyword symbol is in symbol_handles_[kTokenTableStart + 1].
75 const intptr_t token_id = Symbols::kTokenTableStart + 1 + tok_index;
76 ASSERT(symbol_handles_[token_id] != nullptr);
77 return *symbol_handles_[token_id];
78}

◆ True()

static const String & dart::Symbols::True ( )
inlinestatic

Definition at line 693 of file symbols.h.

693{ return *(symbol_handles_[kTRUEId]); }

◆ Void()

static const String & dart::Symbols::Void ( )
inlinestatic

Definition at line 694 of file symbols.h.

694{ return *(symbol_handles_[kVOIDId]); }

Friends And Related Function Documentation

◆ Dart

friend class Dart
friend

Definition at line 810 of file symbols.h.

◆ Deserializer

friend class Deserializer
friend

Definition at line 813 of file symbols.h.

◆ Serializer

friend class Serializer
friend

Definition at line 812 of file symbols.h.

◆ String

friend class String
friend

Definition at line 811 of file symbols.h.

Member Data Documentation

◆ kNullCharCodeSymbolOffset

constexpr int dart::Symbols::kNullCharCodeSymbolOffset = 0
staticconstexpr

Definition at line 605 of file symbols.h.

◆ kNumberOfOneCharCodeSymbols

constexpr int dart::Symbols::kNumberOfOneCharCodeSymbols
staticconstexpr
Initial value:
=
(kMaxPredefinedId - kNullCharId)

Definition at line 601 of file symbols.h.


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