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

#include <dart_entry.h>

Inheritance diagram for dart::ArgumentsDescriptor:
dart::ValueObject

Public Types

enum  { kCachedDescriptorCount = 32 }
 

Public Member Functions

 ArgumentsDescriptor (const Array &array)
 
intptr_t TypeArgsLen () const
 
intptr_t FirstArgIndex () const
 
intptr_t CountWithTypeArgs () const
 
intptr_t Count () const
 
intptr_t Size () const
 
intptr_t SizeWithTypeArgs () const
 
intptr_t PositionalCount () const
 
intptr_t NamedCount () const
 
StringPtr NameAt (intptr_t i) const
 
intptr_t PositionAt (intptr_t i) const
 
bool MatchesNameAt (intptr_t i, const String &other) const
 
ArrayPtr GetArgumentNames () const
 
void PrintTo (BaseTextBuffer *buffer, bool show_named_positions=false) const
 
const char * ToCString () const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Static Public Member Functions

static intptr_t type_args_len_offset ()
 
static intptr_t count_offset ()
 
static intptr_t size_offset ()
 
static intptr_t positional_count_offset ()
 
static intptr_t first_named_entry_offset ()
 
static intptr_t name_offset ()
 
static intptr_t position_offset ()
 
static intptr_t named_entry_size ()
 
static ArrayPtr NewBoxed (intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
 
static ArrayPtr New (intptr_t type_args_len, intptr_t num_arguments, intptr_t size_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
 
static ArrayPtr NewBoxed (intptr_t type_args_len, intptr_t num_arguments, Heap::Space space=Heap::kOld)
 
static ArrayPtr New (intptr_t type_args_len, intptr_t num_arguments, intptr_t size_arguments, Heap::Space space=Heap::kOld)
 
static void Init ()
 
static void Cleanup ()
 
static constexpr bool ContainsCompressedPointers ()
 

Friends

class VMSerializationRoots
 
class VMDeserializationRoots
 

Detailed Description

Definition at line 31 of file dart_entry.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kCachedDescriptorCount 

Definition at line 127 of file dart_entry.h.

Constructor & Destructor Documentation

◆ ArgumentsDescriptor()

dart::ArgumentsDescriptor::ArgumentsDescriptor ( const Array array)
explicit

Definition at line 357 of file dart_entry.cc.

357: array_(array) {}

Member Function Documentation

◆ Cleanup()

void dart::ArgumentsDescriptor::Cleanup ( )
static

Definition at line 576 of file dart_entry.cc.

576 {
577 for (int i = 0; i < kCachedDescriptorCount; i++) {
578 // Don't free pointers to RawArray objects managed by the VM.
579 cached_args_descriptors_[i] = nullptr;
580 }
581}

◆ ContainsCompressedPointers()

static constexpr bool dart::ArgumentsDescriptor::ContainsCompressedPointers ( )
inlinestaticconstexpr

Definition at line 130 of file dart_entry.h.

130 {
131 // Use the same state as the backing store.
133 }
static constexpr bool ContainsCompressedPointers()
Definition: object.h:329

◆ Count()

intptr_t dart::ArgumentsDescriptor::Count ( ) const

Definition at line 363 of file dart_entry.cc.

363 {
364 return Smi::Value(Smi::RawCast(array_.At(kCountIndex)));
365}
ObjectPtr At(intptr_t index) const
Definition: object.h:10875
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
intptr_t Value() const
Definition: object.h:9990

◆ count_offset()

static intptr_t dart::ArgumentsDescriptor::count_offset ( )
inlinestatic

Definition at line 57 of file dart_entry.h.

57{ return Array::element_offset(kCountIndex); }
static intptr_t element_offset(intptr_t index)
Definition: object.h:10838

◆ CountWithTypeArgs()

intptr_t dart::ArgumentsDescriptor::CountWithTypeArgs ( ) const
inline

Definition at line 38 of file dart_entry.h.

38{ return FirstArgIndex() + Count(); }
intptr_t Count() const
Definition: dart_entry.cc:363
intptr_t FirstArgIndex() const
Definition: dart_entry.h:37

◆ first_named_entry_offset()

static intptr_t dart::ArgumentsDescriptor::first_named_entry_offset ( )
inlinestatic

Definition at line 65 of file dart_entry.h.

65 {
66 return Array::element_offset(kFirstNamedEntryIndex);
67 }

◆ FirstArgIndex()

intptr_t dart::ArgumentsDescriptor::FirstArgIndex ( ) const
inline

Definition at line 37 of file dart_entry.h.

37{ return TypeArgsLen() > 0 ? 1 : 0; }
intptr_t TypeArgsLen() const
Definition: dart_entry.cc:359

◆ GetArgumentNames()

ArrayPtr dart::ArgumentsDescriptor::GetArgumentNames ( ) const

Definition at line 394 of file dart_entry.cc.

394 {
395 const intptr_t num_named_args = NamedCount();
396 if (num_named_args == 0) {
397 return Array::null();
398 }
399
400 Zone* zone = Thread::Current()->zone();
401 const Array& names =
402 Array::Handle(zone, Array::New(num_named_args, Heap::kOld));
403 String& name = String::Handle(zone);
404 const intptr_t num_pos_args = PositionalCount();
405 for (intptr_t i = 0; i < num_named_args; ++i) {
406 const intptr_t index = PositionAt(i) - num_pos_args;
407 name = NameAt(i);
408 ASSERT(names.At(index) == Object::null());
409 names.SetAt(index, name);
410 }
411 return names.ptr();
412}
intptr_t PositionalCount() const
Definition: dart_entry.cc:371
intptr_t NamedCount() const
Definition: dart_entry.h:43
intptr_t PositionAt(intptr_t i) const
Definition: dart_entry.cc:383
StringPtr NameAt(intptr_t i) const
Definition: dart_entry.cc:375
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
@ kOld
Definition: heap.h:39
static ObjectPtr null()
Definition: object.h:433
static Object & Handle()
Definition: object.h:407
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)
static const char *const names[]
Definition: symbols.cc:24
const char *const name

◆ Init()

void dart::ArgumentsDescriptor::Init ( )
static

Definition at line 569 of file dart_entry.cc.

569 {
570 for (int i = 0; i < kCachedDescriptorCount; i++) {
571 cached_args_descriptors_[i] =
572 NewNonCached(/*type_args_len=*/0, i, i, false, Heap::kOld);
573 }
574}

◆ MatchesNameAt()

bool dart::ArgumentsDescriptor::MatchesNameAt ( intptr_t  i,
const String other 
) const

Definition at line 389 of file dart_entry.cc.

390 {
391 return NameAt(index) == other.ptr();
392}

◆ name_offset()

static intptr_t dart::ArgumentsDescriptor::name_offset ( )
inlinestatic

Definition at line 69 of file dart_entry.h.

69{ return kNameOffset * kCompressedWordSize; }
static constexpr intptr_t kCompressedWordSize
Definition: globals.h:42

◆ NameAt()

StringPtr dart::ArgumentsDescriptor::NameAt ( intptr_t  i) const

Definition at line 375 of file dart_entry.cc.

375 {
376 const intptr_t offset =
377 kFirstNamedEntryIndex + (index * kNamedEntrySize) + kNameOffset;
378 String& result = String::Handle();
379 result ^= array_.At(offset);
380 return result.ptr();
381}
GAsyncResult * result
SeparatedVector2 offset

◆ named_entry_size()

static intptr_t dart::ArgumentsDescriptor::named_entry_size ( )
inlinestatic

Definition at line 73 of file dart_entry.h.

73 {
74 return kNamedEntrySize * kCompressedWordSize;
75 }

◆ NamedCount()

intptr_t dart::ArgumentsDescriptor::NamedCount ( ) const
inline

Definition at line 43 of file dart_entry.h.

43{ return Count() - PositionalCount(); }

◆ New() [1/2]

ArrayPtr dart::ArgumentsDescriptor::New ( intptr_t  type_args_len,
intptr_t  num_arguments,
intptr_t  size_arguments,
const Array optional_arguments_names,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 444 of file dart_entry.cc.

448 {
449 const intptr_t num_named_args =
450 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
451 if (num_named_args == 0) {
452 return ArgumentsDescriptor::New(type_args_len, num_arguments,
453 size_arguments, space);
454 }
455 ASSERT(type_args_len >= 0);
456 ASSERT(num_arguments >= 0);
457 const intptr_t num_pos_args = num_arguments - num_named_args;
458
459 // Build the arguments descriptor array, which consists of the type
460 // argument vector length (0 if none); total argument count; the positional
461 // argument count; a sequence of (name, position) pairs, sorted by name, for
462 // each named optional argument; and a terminating null to simplify iterating
463 // in generated code.
464 Thread* thread = Thread::Current();
465 Zone* zone = thread->zone();
466 const intptr_t descriptor_len = LengthFor(num_named_args);
467 Array& descriptor = Array::Handle(zone, Array::New(descriptor_len, space));
468
469 // Set length of type argument vector.
470 descriptor.SetAt(kTypeArgsLenIndex, Smi::Handle(Smi::New(type_args_len)));
471 // Set total number of passed arguments.
472 descriptor.SetAt(kCountIndex, Smi::Handle(Smi::New(num_arguments)));
473 // Set total number of passed arguments.
474 descriptor.SetAt(kSizeIndex, Smi::Handle(Smi::New(size_arguments)));
475
476 // Set number of positional arguments.
477 descriptor.SetAt(kPositionalCountIndex, Smi::Handle(Smi::New(num_pos_args)));
478
479 // Set alphabetically sorted entries for named arguments.
480 String& name = String::Handle(zone);
481 Smi& pos = Smi::Handle(zone);
482 String& previous_name = String::Handle(zone);
483 Smi& previous_pos = Smi::Handle(zone);
484 for (intptr_t i = 0; i < num_named_args; i++) {
485 name ^= optional_arguments_names.At(i);
486 pos = Smi::New(num_pos_args + i);
487 intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize * i);
488 // Shift already inserted pairs with "larger" names.
489 while (insert_index > kFirstNamedEntryIndex) {
490 intptr_t previous_index = insert_index - kNamedEntrySize;
491 previous_name ^= descriptor.At(previous_index + kNameOffset);
492 intptr_t result = name.CompareTo(previous_name);
493 ASSERT(result != 0); // Duplicate argument names checked in parser.
494 if (result > 0) break;
495 previous_pos ^= descriptor.At(previous_index + kPositionOffset);
496 descriptor.SetAt(insert_index + kNameOffset, previous_name);
497 descriptor.SetAt(insert_index + kPositionOffset, previous_pos);
498 insert_index = previous_index;
499 }
500 // Insert pair in descriptor array.
501 descriptor.SetAt(insert_index + kNameOffset, name);
502 descriptor.SetAt(insert_index + kPositionOffset, pos);
503 }
504 // Set terminating null.
505 descriptor.SetAt(descriptor_len - 1, Object::null_object());
506
507 // Share the immutable descriptor when possible by canonicalizing it.
508 descriptor.MakeImmutable();
509 descriptor ^= descriptor.Canonicalize(thread);
510 ASSERT(!descriptor.IsNull());
511 return descriptor.ptr();
512}
SkPoint pos
static ArrayPtr New(intptr_t type_args_len, intptr_t num_arguments, intptr_t size_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
Definition: dart_entry.cc:444
static SmiPtr New(intptr_t value)
Definition: object.h:10006

◆ New() [2/2]

ArrayPtr dart::ArgumentsDescriptor::New ( intptr_t  type_args_len,
intptr_t  num_arguments,
intptr_t  size_arguments,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 514 of file dart_entry.cc.

517 {
518 ASSERT(type_args_len >= 0);
519 ASSERT(num_arguments >= 0);
520
521 if ((type_args_len == 0) && (num_arguments < kCachedDescriptorCount) &&
522 (num_arguments == size_arguments)) {
523 return cached_args_descriptors_[num_arguments];
524 }
525 return NewNonCached(type_args_len, num_arguments, size_arguments, true,
526 space);
527}

◆ NewBoxed() [1/2]

static ArrayPtr dart::ArgumentsDescriptor::NewBoxed ( intptr_t  type_args_len,
intptr_t  num_arguments,
const Array optional_arguments_names,
Heap::Space  space = Heap::kOld 
)
inlinestatic

Definition at line 83 of file dart_entry.h.

86 {
87 return New(type_args_len, num_arguments, num_arguments,
88 optional_arguments_names, space);
89 }

◆ NewBoxed() [2/2]

static ArrayPtr dart::ArgumentsDescriptor::NewBoxed ( intptr_t  type_args_len,
intptr_t  num_arguments,
Heap::Space  space = Heap::kOld 
)
inlinestatic

Definition at line 106 of file dart_entry.h.

108 {
109 return New(type_args_len, num_arguments, num_arguments, space);
110 }

◆ position_offset()

static intptr_t dart::ArgumentsDescriptor::position_offset ( )
inlinestatic

Definition at line 70 of file dart_entry.h.

70 {
71 return kPositionOffset * kCompressedWordSize;
72 }

◆ positional_count_offset()

static intptr_t dart::ArgumentsDescriptor::positional_count_offset ( )
inlinestatic

Definition at line 61 of file dart_entry.h.

61 {
62 return Array::element_offset(kPositionalCountIndex);
63 }

◆ PositionalCount()

intptr_t dart::ArgumentsDescriptor::PositionalCount ( ) const

Definition at line 371 of file dart_entry.cc.

371 {
372 return Smi::Value(Smi::RawCast(array_.At(kPositionalCountIndex)));
373}

◆ PositionAt()

intptr_t dart::ArgumentsDescriptor::PositionAt ( intptr_t  i) const

Definition at line 383 of file dart_entry.cc.

383 {
384 const intptr_t offset =
385 kFirstNamedEntryIndex + (index * kNamedEntrySize) + kPositionOffset;
386 return Smi::Value(Smi::RawCast(array_.At(offset)));
387}

◆ PrintTo()

void dart::ArgumentsDescriptor::PrintTo ( BaseTextBuffer buffer,
bool  show_named_positions = false 
) const

Definition at line 414 of file dart_entry.cc.

415 {
416 if (TypeArgsLen() > 0) {
417 buffer->Printf("<%" Pd ">", TypeArgsLen());
418 }
419 buffer->Printf("(%" Pd "", Count());
420 if (NamedCount() > 0) {
421 buffer->AddString(" {");
422 auto& str = String::Handle();
423 for (intptr_t i = 0; i < NamedCount(); i++) {
424 if (i != 0) {
425 buffer->AddString(", ");
426 }
427 str = NameAt(i);
428 buffer->Printf("%s", str.ToCString());
429 if (show_named_positions) {
430 buffer->Printf(" (%" Pd ")", PositionAt(i));
431 }
432 }
433 buffer->Printf("}");
434 }
435 buffer->Printf(")");
436}
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
#define Pd
Definition: globals.h:408

◆ Size()

intptr_t dart::ArgumentsDescriptor::Size ( ) const

Definition at line 367 of file dart_entry.cc.

367 {
368 return Smi::Value(Smi::RawCast(array_.At(kSizeIndex)));
369}

◆ size_offset()

static intptr_t dart::ArgumentsDescriptor::size_offset ( )
inlinestatic

Definition at line 59 of file dart_entry.h.

59{ return Array::element_offset(kSizeIndex); }

◆ SizeWithTypeArgs()

intptr_t dart::ArgumentsDescriptor::SizeWithTypeArgs ( ) const
inline

Definition at line 41 of file dart_entry.h.

41{ return FirstArgIndex() + Size(); }
intptr_t Size() const
Definition: dart_entry.cc:367

◆ ToCString()

const char * dart::ArgumentsDescriptor::ToCString ( ) const

Definition at line 438 of file dart_entry.cc.

438 {
439 ZoneTextBuffer buf(Thread::Current()->zone());
440 PrintTo(&buf);
441 return buf.buffer();
442}
void PrintTo(BaseTextBuffer *buffer, bool show_named_positions=false) const
Definition: dart_entry.cc:414

◆ type_args_len_offset()

static intptr_t dart::ArgumentsDescriptor::type_args_len_offset ( )
inlinestatic

Definition at line 53 of file dart_entry.h.

53 {
54 return Array::element_offset(kTypeArgsLenIndex);
55 }

◆ TypeArgsLen()

intptr_t dart::ArgumentsDescriptor::TypeArgsLen ( ) const

Definition at line 359 of file dart_entry.cc.

359 {
360 return Smi::Value(Smi::RawCast(array_.At(kTypeArgsLenIndex)));
361}

Friends And Related Function Documentation

◆ VMDeserializationRoots

friend class VMDeserializationRoots
friend

Definition at line 183 of file dart_entry.h.

◆ VMSerializationRoots

friend class VMSerializationRoots
friend

Definition at line 182 of file dart_entry.h.


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