Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
StackCheckerCtx Class Reference
Inheritance diagram for StackCheckerCtx:
SkRasterPipeline_CallbackCtx

Public Types

enum class  Behavior { kGrowth , kBaseline , kUnknown }
 

Public Member Functions

 StackCheckerCtx ()
 
StackCheckerCtxexpectGrowth ()
 
StackCheckerCtxexpectBaseline ()
 
void validate (skiatest::Reporter *r)
 

Static Public Member Functions

static Behavior GrowthBehavior ()
 

Detailed Description

Definition at line 3348 of file SkRasterPipelineTest.cpp.

Member Enumeration Documentation

◆ Behavior

enum class StackCheckerCtx::Behavior
strong
Enumerator
kGrowth 
kBaseline 
kUnknown 

Definition at line 3357 of file SkRasterPipelineTest.cpp.

3357 {
3358 kGrowth,
3359 kBaseline,
3360 kUnknown,
3361 };
@ kBaseline
Match the baseline of the placeholder with the baseline.

Constructor & Destructor Documentation

◆ StackCheckerCtx()

StackCheckerCtx::StackCheckerCtx ( )
inline

Definition at line 3350 of file SkRasterPipelineTest.cpp.

3350 {
3351 this->fn = [](SkRasterPipeline_CallbackCtx* self, int active_pixels) {
3352 auto ctx = (StackCheckerCtx*)self;
3353 ctx->fStackAddrs.push_back(&active_pixels);
3354 };
3355 }
void(* fn)(SkRasterPipeline_CallbackCtx *self, int active_pixels)

Member Function Documentation

◆ expectBaseline()

StackCheckerCtx * StackCheckerCtx::expectBaseline ( )
inline

Definition at line 3376 of file SkRasterPipelineTest.cpp.

3376 {
3377 fExpectedBehavior.push_back(Behavior::kBaseline);
3378 return this;
3379 }

◆ expectGrowth()

StackCheckerCtx * StackCheckerCtx::expectGrowth ( )
inline

Definition at line 3371 of file SkRasterPipelineTest.cpp.

3371 {
3372 fExpectedBehavior.push_back(GrowthBehavior());
3373 return this;
3374 }
static Behavior GrowthBehavior()

◆ GrowthBehavior()

static Behavior StackCheckerCtx::GrowthBehavior ( )
inlinestatic

Definition at line 3363 of file SkRasterPipelineTest.cpp.

3363 {
3364 // Only some stages use the musttail attribute, so we have no way of knowing what's going to
3365 // happen. In release builds, it's likely that the compiler will apply tail-call
3366 // optimization. Even in some debug builds (on Windows), we don't see stack growth.
3367 return Behavior::kUnknown;
3368 }

◆ validate()

void StackCheckerCtx::validate ( skiatest::Reporter r)
inline

Definition at line 3381 of file SkRasterPipelineTest.cpp.

3381 {
3382 REPORTER_ASSERT(r, fStackAddrs.size() == fExpectedBehavior.size());
3383
3384 // This test is storing and comparing stack pointers (to dead stack frames) as a way of
3385 // measuring stack usage. Unsurprisingly, ASAN doesn't like that. HWASAN actually inserts
3386 // tag bytes in the pointers, causing them not to match. Newer versions of vanilla ASAN
3387 // also appear to salt the stack slightly, causing repeated calls to scrape different
3388 // addresses, even though $rsp is identical on each invocation of the lambda.
3389#if !defined(SK_SANITIZE_ADDRESS)
3390 void* baseline = fStackAddrs[0];
3391 for (size_t i = 1; i < fStackAddrs.size(); i++) {
3392 if (fExpectedBehavior[i] == Behavior::kGrowth) {
3393 REPORTER_ASSERT(r, fStackAddrs[i] != baseline);
3394 } else if (fExpectedBehavior[i] == Behavior::kBaseline) {
3395 REPORTER_ASSERT(r, fStackAddrs[i] == baseline);
3396 } else {
3397 // Unknown behavior, nothing we can assert here
3398 }
3399 }
3400#endif
3401 }
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286

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