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

#include <profiler_service.h>

Inheritance diagram for dart::ProfileCode:
dart::ZoneAllocated

Public Types

enum  Kind {
  kDartCode , kCollectedCode , kNativeCode , kReusedCode ,
  kTagCode
}
 

Public Member Functions

 ProfileCode (Kind kind, uword start, uword end, int64_t timestamp, const AbstractCode code)
 
Kind kind () const
 
uword start () const
 
void set_start (uword start)
 
uword end () const
 
void set_end (uword end)
 
void ExpandLower (uword start)
 
void ExpandUpper (uword end)
 
void TruncateLower (uword start)
 
void TruncateUpper (uword end)
 
bool Contains (uword pc) const
 
bool Overlaps (const ProfileCode *other) const
 
int64_t compile_timestamp () const
 
void set_compile_timestamp (int64_t timestamp)
 
intptr_t exclusive_ticks () const
 
void set_exclusive_ticks (intptr_t exclusive_ticks)
 
void IncExclusiveTicks ()
 
intptr_t inclusive_ticks () const
 
void set_inclusive_ticks (intptr_t inclusive_ticks)
 
void IncInclusiveTicks ()
 
bool IsOptimizedDart () const
 
const AbstractCode code () const
 
const char * name () const
 
void SetName (const char *name)
 
void GenerateAndSetSymbolName (const char *prefix)
 
void PrintToJSONArray (JSONArray *codes)
 
ProfileFunctionfunction () const
 
intptr_t code_table_index () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static const char * KindToCString (Kind kind)
 

Friends

class ProfileBuilder
 

Detailed Description

Definition at line 232 of file profiler_service.h.

Member Enumeration Documentation

◆ Kind

Enumerator
kDartCode 
kCollectedCode 
kNativeCode 
kReusedCode 
kTagCode 

Definition at line 234 of file profiler_service.h.

234 {
235 kDartCode, // Live Dart code.
236 kCollectedCode, // Dead Dart code.
237 kNativeCode, // Native code.
238 kReusedCode, // Dead Dart code that has been reused by new kDartCode.
239 kTagCode, // A special kind of code representing a tag.
240 };

Constructor & Destructor Documentation

◆ ProfileCode()

dart::ProfileCode::ProfileCode ( Kind  kind,
uword  start,
uword  end,
int64_t  timestamp,
const AbstractCode  code 
)

Definition at line 252 of file profiler_service.cc.

257 : kind_(kind),
258 start_(start),
259 end_(end),
260 exclusive_ticks_(0),
261 inclusive_ticks_(0),
262 inclusive_serial_(-1),
263 code_(code),
264 name_(nullptr),
265 compile_timestamp_(0),
266 function_(nullptr),
267 code_table_index_(-1),
268 address_ticks_(0) {
269 ASSERT(start_ < end_);
270}
uword start() const
const AbstractCode code() const
#define ASSERT(E)

Member Function Documentation

◆ code()

const AbstractCode dart::ProfileCode::code ( ) const
inline

Definition at line 283 of file profiler_service.h.

283{ return code_; }

◆ code_table_index()

intptr_t dart::ProfileCode::code_table_index ( ) const
inline

Definition at line 295 of file profiler_service.h.

295{ return code_table_index_; }

◆ compile_timestamp()

int64_t dart::ProfileCode::compile_timestamp ( ) const
inline

Definition at line 265 of file profiler_service.h.

265{ return compile_timestamp_; }

◆ Contains()

bool dart::ProfileCode::Contains ( uword  pc) const
inline

Definition at line 261 of file profiler_service.h.

261{ return (pc >= start_) && (pc < end_); }

◆ end()

uword dart::ProfileCode::end ( ) const
inline

Definition at line 253 of file profiler_service.h.

253{ return end_; }

◆ exclusive_ticks()

intptr_t dart::ProfileCode::exclusive_ticks ( ) const
inline

Definition at line 270 of file profiler_service.h.

270{ return exclusive_ticks_; }

◆ ExpandLower()

void dart::ProfileCode::ExpandLower ( uword  start)

Definition at line 286 of file profiler_service.cc.

286 {
287 if (start < start_) {
288 start_ = start;
289 }
290 ASSERT(start_ < end_);
291}

◆ ExpandUpper()

void dart::ProfileCode::ExpandUpper ( uword  end)

Definition at line 293 of file profiler_service.cc.

293 {
294 if (end > end_) {
295 end_ = end;
296 }
297 ASSERT(start_ < end_);
298}

◆ function()

ProfileFunction * dart::ProfileCode::function ( ) const
inline

Definition at line 293 of file profiler_service.h.

293{ return function_; }

◆ GenerateAndSetSymbolName()

void dart::ProfileCode::GenerateAndSetSymbolName ( const char *  prefix)

Definition at line 319 of file profiler_service.cc.

319 {
320 const intptr_t kBuffSize = 512;
321 char buff[kBuffSize];
322 Utils::SNPrint(&buff[0], kBuffSize - 1, "%s [%" Px ", %" Px ")", prefix,
323 start(), end());
324 SetName(buff);
325}
void SetName(const char *name)
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
#define Px
Definition: globals.h:410

◆ IncExclusiveTicks()

void dart::ProfileCode::IncExclusiveTicks ( )
inline

Definition at line 274 of file profiler_service.h.

274{ exclusive_ticks_++; }

◆ IncInclusiveTicks()

void dart::ProfileCode::IncInclusiveTicks ( )
inline

Definition at line 280 of file profiler_service.h.

280{ inclusive_ticks_++; }

◆ inclusive_ticks()

intptr_t dart::ProfileCode::inclusive_ticks ( ) const
inline

Definition at line 276 of file profiler_service.h.

276{ return inclusive_ticks_; }

◆ IsOptimizedDart()

bool dart::ProfileCode::IsOptimizedDart ( ) const

Definition at line 306 of file profiler_service.cc.

306 {
307 return !code_.IsNull() && code_.is_optimized();
308}
bool IsNull() const
Definition: profiler.h:482
bool is_optimized() const
Definition: profiler.h:485

◆ kind()

Kind dart::ProfileCode::kind ( ) const
inline

Definition at line 248 of file profiler_service.h.

248{ return kind_; }

◆ KindToCString()

const char * dart::ProfileCode::KindToCString ( Kind  kind)
static

Definition at line 441 of file profiler_service.cc.

441 {
442 switch (kind) {
443 case kDartCode:
444 return "Dart";
445 case kCollectedCode:
446 return "Collected";
447 case kNativeCode:
448 return "Native";
449 case kReusedCode:
450 return "Overwritten";
451 case kTagCode:
452 return "Tag";
453 }
454 UNREACHABLE();
455 return nullptr;
456}
#define UNREACHABLE()
Definition: assert.h:248

◆ name()

const char * dart::ProfileCode::name ( ) const
inline

Definition at line 285 of file profiler_service.h.

285{ return name_; }

◆ Overlaps()

bool dart::ProfileCode::Overlaps ( const ProfileCode other) const

Definition at line 300 of file profiler_service.cc.

300 {
301 ASSERT(other != nullptr);
302 return other->Contains(start_) || other->Contains(end_ - 1) ||
303 Contains(other->start()) || Contains(other->end() - 1);
304}
bool Contains(uword pc) const

◆ PrintToJSONArray()

void dart::ProfileCode::PrintToJSONArray ( JSONArray codes)

Definition at line 458 of file profiler_service.cc.

458 {
459 JSONObject obj(codes);
460 obj.AddProperty("kind", ProfileCode::KindToCString(kind()));
461 obj.AddProperty("inclusiveTicks", inclusive_ticks());
462 obj.AddProperty("exclusiveTicks", exclusive_ticks());
463 if (kind() == kDartCode) {
464 ASSERT(!code_.IsNull());
465 obj.AddProperty("code", *code_.handle());
466 } else if (kind() == kCollectedCode) {
467 PrintCollectedCode(&obj);
468 } else if (kind() == kReusedCode) {
469 PrintOverwrittenCode(&obj);
470 } else if (kind() == kTagCode) {
471 PrintTagCode(&obj);
472 } else {
473 ASSERT(kind() == kNativeCode);
474 PrintNativeCode(&obj);
475 }
476 {
477 JSONArray ticks(&obj, "ticks");
478 for (intptr_t i = 0; i < address_ticks_.length(); i++) {
479 const ProfileCodeAddress& entry = address_ticks_[i];
480 ticks.AddValueF("%" Px "", entry.pc());
481 ticks.AddValue(entry.exclusive_ticks());
482 ticks.AddValue(entry.inclusive_ticks());
483 }
484 }
485}
const Object * handle() const
Definition: profiler.h:413
intptr_t inclusive_ticks() const
static const char * KindToCString(Kind kind)
intptr_t exclusive_ticks() const

◆ set_compile_timestamp()

void dart::ProfileCode::set_compile_timestamp ( int64_t  timestamp)
inline

Definition at line 266 of file profiler_service.h.

266 {
267 compile_timestamp_ = timestamp;
268 }

◆ set_end()

void dart::ProfileCode::set_end ( uword  end)
inline

Definition at line 254 of file profiler_service.h.

254{ end_ = end; }

◆ set_exclusive_ticks()

void dart::ProfileCode::set_exclusive_ticks ( intptr_t  exclusive_ticks)
inline

Definition at line 271 of file profiler_service.h.

271 {
272 exclusive_ticks_ = exclusive_ticks;
273 }

◆ set_inclusive_ticks()

void dart::ProfileCode::set_inclusive_ticks ( intptr_t  inclusive_ticks)
inline

Definition at line 277 of file profiler_service.h.

277 {
278 inclusive_ticks_ = inclusive_ticks;
279 }

◆ set_start()

void dart::ProfileCode::set_start ( uword  start)
inline

Definition at line 251 of file profiler_service.h.

251{ start_ = start; }

◆ SetName()

void dart::ProfileCode::SetName ( const char *  name)

Definition at line 310 of file profiler_service.cc.

310 {
311 if (name == nullptr) {
312 name_ = nullptr;
313 }
314 intptr_t len = strlen(name) + 1;
315 name_ = Thread::Current()->zone()->Alloc<char>(len);
316 strncpy(name_, name, len);
317}
const char * name() const
Zone * zone() const
Definition: thread_state.h:37
static Thread * Current()
Definition: thread.h:362
ElementType * Alloc(intptr_t length)

◆ start()

uword dart::ProfileCode::start ( ) const
inline

Definition at line 250 of file profiler_service.h.

250{ return start_; }

◆ TruncateLower()

void dart::ProfileCode::TruncateLower ( uword  start)

Definition at line 272 of file profiler_service.cc.

272 {
273 if (start > start_) {
274 start_ = start;
275 }
276 ASSERT(start_ < end_);
277}

◆ TruncateUpper()

void dart::ProfileCode::TruncateUpper ( uword  end)

Definition at line 279 of file profiler_service.cc.

279 {
280 if (end < end_) {
281 end_ = end;
282 }
283 ASSERT(start_ < end_);
284}

Friends And Related Function Documentation

◆ ProfileBuilder

friend class ProfileBuilder
friend

Definition at line 324 of file profiler_service.h.


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