Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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:10854
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969

◆ 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:10817

◆ 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
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

◆ 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
intptr_t NamedCount() const
Definition dart_entry.h:43
intptr_t PositionAt(intptr_t i) const
StringPtr NameAt(intptr_t i) const
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
@ kOld
Definition heap.h:39
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
Zone * zone() const
static Thread * Current()
Definition thread.h:361
#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
Point 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)
static SmiPtr New(intptr_t value)
Definition object.h:9985

◆ 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}
static const uint8_t buffer[]
#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

◆ 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

◆ 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 Symbol 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: