MCPcopy Create free account
hub / github.com/apitrace/apitrace / onAddressWrite

Method onAddressWrite

wrappers/glmemshadow.cpp:294–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void GLMemoryShadow::onAddressWrite(uintptr_t addr, size_t page)
295{
296 const size_t relativePage = (addr - reinterpret_cast<uintptr_t>(shadowMemory)) / sPageSize;
297 if (isPageDirty(relativePage)) {
298 // It is possible if writing to the same buffer from two threads
299 return;
300 }
301
302 if ((relativePage == lastDirtiedRelativePage + 1) && isPageDirty(relativePage - 1)) {
303 /* Ensure that we would have log(n) page exceptions if traced application writes
304 * to n consecutive pages.
305 */
306 pagesToDirtyOnConsecutiveWrites *= 2;
307 } else {
308 pagesToDirtyOnConsecutiveWrites = 1;
309 }
310
311 const size_t endPageToDirty = std::min(relativePage + pagesToDirtyOnConsecutiveWrites, nPages);
312 for (size_t pageToDirty = relativePage; pageToDirty < endPageToDirty; pageToDirty++) {
313 setPageDirty(pageToDirty);
314 }
315
316 lastDirtiedRelativePage = endPageToDirty - 1;
317
318 memProtect(reinterpret_cast<void*>(page * sPageSize),
319 (endPageToDirty - relativePage) * sPageSize, MemProtection::READ_WRITE);
320}
321
322GLbitfield GLMemoryShadow::getMapFlags() const
323{

Callers 2

VectoredHandlerFunction · 0.80

Calls 1

memProtectFunction · 0.85

Tested by

no test coverage detected