Flutter Engine
The Flutter Engine
Macros | Functions
SkAssert.h File Reference
#include "include/private/base/SkAPI.h"
#include "include/private/base/SkAttributes.h"
#include "include/private/base/SkDebug.h"
#include <cstddef>
#include <limits>

Go to the source code of this file.

Macros

#define SK_LIKELY
 
#define SK_UNLIKELY
 
#define SK_ASSUME(cond)   ((void)0)
 
#define SK_DUMP_GOOGLE3_STACK()
 
#define SK_DUMP_LINE_FORMAT   "%s:%d"
 
#define SK_ABORT(message, ...)
 
#define SkASSERT_RELEASE(cond)    static_cast<void>( (cond) ? static_cast<void>(0) : []{ SK_ABORT("check(%s)", #cond); }() )
 
#define SkASSERTF_RELEASE(cond, fmt, ...)
 
#define SkASSERT(cond)   static_cast<void>(0)
 
#define SkASSERTF(cond, fmt, ...)   static_cast<void>(0)
 
#define SkDEBUGFAIL(message)
 
#define SkDEBUGFAILF(fmt, ...)
 
#define SkAssertResult(cond)   if (cond) {} do {} while(false)
 
#define SkUNREACHABLE   __builtin_trap()
 

Functions

SK_API void sk_abort_no_print (void)
 
SK_API void sk_print_index_out_of_bounds (size_t i, size_t size)
 
template<typename T >
SK_API T sk_collection_check_bounds (T i, T size)
 
SK_API void sk_print_length_too_big (size_t i, size_t size)
 
template<typename T >
SK_API T sk_collection_check_length (T i, T size)
 
SK_API void sk_collection_not_empty (bool empty)
 
SK_API void sk_print_size_too_big (size_t size, size_t maxSize)
 
template<typename T >
SK_ALWAYS_INLINE size_t check_size_bytes_too_big (size_t size)
 

Macro Definition Documentation

◆ SK_ABORT

#define SK_ABORT (   message,
  ... 
)
Value:
do { \
SkDebugf(SK_DUMP_LINE_FORMAT ": fatal error: \"" message "\"\n", \
__FILE__, __LINE__, ##__VA_ARGS__); \
SK_DUMP_GOOGLE3_STACK(); \
sk_abort_no_print(); \
} while (false)
#define SK_DUMP_LINE_FORMAT
Definition: SkAssert.h:68
Win32Message message

Definition at line 70 of file SkAssert.h.

◆ SK_ASSUME

#define SK_ASSUME (   cond)    ((void)0)

Definition at line 44 of file SkAssert.h.

◆ SK_DUMP_GOOGLE3_STACK

#define SK_DUMP_GOOGLE3_STACK ( )

Definition at line 60 of file SkAssert.h.

◆ SK_DUMP_LINE_FORMAT

#define SK_DUMP_LINE_FORMAT   "%s:%d"

Definition at line 68 of file SkAssert.h.

◆ SK_LIKELY

#define SK_LIKELY

Definition at line 27 of file SkAssert.h.

◆ SK_UNLIKELY

#define SK_UNLIKELY

Definition at line 28 of file SkAssert.h.

◆ SkASSERT

#define SkASSERT (   cond)    static_cast<void>(0)

Definition at line 116 of file SkAssert.h.

◆ SkASSERT_RELEASE

#define SkASSERT_RELEASE (   cond)     static_cast<void>( (cond) ? static_cast<void>(0) : []{ SK_ABORT("check(%s)", #cond); }() )

Definition at line 100 of file SkAssert.h.

◆ SkASSERTF

#define SkASSERTF (   cond,
  fmt,
  ... 
)    static_cast<void>(0)

Definition at line 117 of file SkAssert.h.

◆ SkASSERTF_RELEASE

#define SkASSERTF_RELEASE (   cond,
  fmt,
  ... 
)
Value:
static_cast<void>( (cond) \
? static_cast<void>(0) \
: [&]{ SK_ABORT("assertf(%s): " fmt, #cond, ##__VA_ARGS__); }() )
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
static SkString fmt(SkColor4f c)
Definition: p3.cpp:43

Definition at line 103 of file SkAssert.h.

◆ SkAssertResult

#define SkAssertResult (   cond)    if (cond) {} do {} while(false)

Definition at line 123 of file SkAssert.h.

◆ SkDEBUGFAIL

#define SkDEBUGFAIL (   message)

Definition at line 118 of file SkAssert.h.

◆ SkDEBUGFAILF

#define SkDEBUGFAILF (   fmt,
  ... 
)

Definition at line 119 of file SkAssert.h.

◆ SkUNREACHABLE

#define SkUNREACHABLE   __builtin_trap()

Definition at line 135 of file SkAssert.h.

Function Documentation

◆ check_size_bytes_too_big()

template<typename T >
SK_ALWAYS_INLINE size_t check_size_bytes_too_big ( size_t  size)

Definition at line 190 of file SkAssert.h.

190 {
191 const size_t kMaxSize = std::numeric_limits<size_t>::max() / sizeof(T);
192 if (size > kMaxSize) {
193 #if defined(SK_DEBUG)
194 sk_print_size_too_big(size, kMaxSize);
195 #else
197 #endif
198 }
199 return size;
200}
#define SkUNREACHABLE
Definition: SkAssert.h:135
SK_API void sk_print_size_too_big(size_t size, size_t maxSize)
Definition: SkAssert.h:185
static float max(float r, float g, float b)
Definition: hsl.cpp:49
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 T
Definition: precompiler.cc:65

◆ sk_abort_no_print()

SK_API void sk_abort_no_print ( void  )

Called internally if we hit an unrecoverable error. The platform implementation must not return, but should either throw an exception or otherwise exit.

Definition at line 56 of file SkMemory_malloc.cpp.

56 {
57#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN)
58 __fastfail(FAST_FAIL_FATAL_APP_EXIT);
59#elif defined(__clang__)
60 __builtin_trap();
61#else
62 abort();
63#endif
64}

◆ sk_collection_check_bounds()

template<typename T >
SK_API T sk_collection_check_bounds ( T  i,
T  size 
)
inline

Definition at line 143 of file SkAssert.h.

143 {
144 if (0 <= i && i < size) SK_LIKELY {
145 return i;
146 }
147
149 #if defined(SK_DEBUG)
150 sk_print_index_out_of_bounds(static_cast<size_t>(i), static_cast<size_t>(size));
151 #else
153 #endif
154 }
155}
#define SK_LIKELY
Definition: SkAssert.h:27
SK_API void sk_print_index_out_of_bounds(size_t i, size_t size)
Definition: SkAssert.h:139
#define SK_UNLIKELY
Definition: SkAssert.h:28

◆ sk_collection_check_length()

template<typename T >
SK_API T sk_collection_check_length ( T  i,
T  size 
)
inline

Definition at line 161 of file SkAssert.h.

161 {
162 if (0 <= i && i <= size) SK_LIKELY {
163 return i;
164 }
165
167 #if defined(SK_DEBUG)
168 sk_print_length_too_big(static_cast<size_t>(i), static_cast<size_t>(size));
169 #else
171 #endif
172 }
173}
SK_API void sk_print_length_too_big(size_t i, size_t size)
Definition: SkAssert.h:157

◆ sk_collection_not_empty()

SK_API void sk_collection_not_empty ( bool  empty)
inline

Definition at line 175 of file SkAssert.h.

175 {
176 if (empty) SK_UNLIKELY {
177 #if defined(SK_DEBUG)
178 SK_ABORT("Collection is empty.\n");
179 #else
181 #endif
182 }
183}
EMSCRIPTEN_KEEPALIVE void empty()

◆ sk_print_index_out_of_bounds()

SK_API void sk_print_index_out_of_bounds ( size_t  i,
size_t  size 
)
inline

Definition at line 139 of file SkAssert.h.

139 {
140 SK_ABORT("Index (%zu) out of bounds for size %zu.\n", i, size);
141}

◆ sk_print_length_too_big()

SK_API void sk_print_length_too_big ( size_t  i,
size_t  size 
)
inline

Definition at line 157 of file SkAssert.h.

157 {
158 SK_ABORT("Length (%zu) is too big for size %zu.\n", i, size);
159}

◆ sk_print_size_too_big()

SK_API void sk_print_size_too_big ( size_t  size,
size_t  maxSize 
)
inline

Definition at line 185 of file SkAssert.h.

185 {
186 SK_ABORT("Size (%zu) can't be represented in bytes. Max size is %zu.\n", size, maxSize);
187}