Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::BacktrackStack Class Reference

Public Member Functions

 BacktrackStack ()
 
 ~BacktrackStack ()
 
bool out_of_memory () const
 
int32_t * data () const
 
intptr_t max_size () const
 

Detailed Description

Definition at line 140 of file regexp_interpreter.cc.

Constructor & Destructor Documentation

◆ BacktrackStack()

dart::BacktrackStack::BacktrackStack ( )
inline

Definition at line 142 of file regexp_interpreter.cc.

142 {
144 // Note: using malloc here has a potential of triggering jemalloc/tcmalloc
145 // bugs which cause application to leak memory and eventually OOM.
146 // See https://github.com/dart-lang/sdk/issues/38820 and
147 // https://github.com/flutter/flutter/issues/29007 for examples.
148 // So instead we directly ask OS to provide us memory.
149 if (memory_ == nullptr) {
150 const bool executable = false;
151 const bool compressed = false;
152 const intptr_t size_in_bytes = Utils::RoundUp(
153 FLAG_regexp_backtrack_stack_size_kb * KB, VirtualMemory::PageSize());
154 memory_ = std::unique_ptr<VirtualMemory>(VirtualMemory::Allocate(
155 size_in_bytes, executable, compressed, "regexp-backtrack-stack"));
156 }
157 }
static Isolate * Current()
Definition isolate.h:939
std::unique_ptr< VirtualMemory > TakeRegexpBacktrackStack()
Definition isolate.h:1420
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:105
static intptr_t PageSize()
static VirtualMemory * Allocate(intptr_t size, bool is_executable, bool is_compressed, const char *name)
constexpr intptr_t KB
Definition globals.h:528

◆ ~BacktrackStack()

dart::BacktrackStack::~BacktrackStack ( )
inline

Definition at line 159 of file regexp_interpreter.cc.

159 {
160 if (memory_ != nullptr) {
161 Isolate::Current()->CacheRegexpBacktrackStack(std::move(memory_));
162 }
163 }
void CacheRegexpBacktrackStack(std::unique_ptr< VirtualMemory > stack)
Definition isolate.h:1424

Member Function Documentation

◆ data()

int32_t * dart::BacktrackStack::data ( ) const
inline

Definition at line 167 of file regexp_interpreter.cc.

167 {
168 return reinterpret_cast<int32_t*>(memory_->address());
169 }

◆ max_size()

intptr_t dart::BacktrackStack::max_size ( ) const
inline

Definition at line 171 of file regexp_interpreter.cc.

171{ return memory_->size() / sizeof(int32_t); }

◆ out_of_memory()

bool dart::BacktrackStack::out_of_memory ( ) const
inline

Definition at line 165 of file regexp_interpreter.cc.

165{ return memory_ == nullptr; }

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