mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 970643 - Valgrind does not understand OdinMonkey's guard page mechanism. r=luke.
This commit is contained in:
parent
e88569a5ca
commit
880659951c
@ -15,6 +15,10 @@
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_VALGRIND
|
||||
# include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
#include "jscntxt.h"
|
||||
@ -428,10 +432,16 @@ ArrayBufferObject::prepareForAsmJS(JSContext *cx, Handle<ArrayBufferObject*> buf
|
||||
return false;
|
||||
}
|
||||
# else
|
||||
if (mprotect(data, buffer->byteLength(), PROT_READ | PROT_WRITE)) {
|
||||
size_t validLength = buffer->byteLength();
|
||||
if (mprotect(data, validLength, PROT_READ | PROT_WRITE)) {
|
||||
munmap(data, AsmJSMappedSize);
|
||||
return false;
|
||||
}
|
||||
# if defined(MOZ_VALGRIND) && defined(VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE)
|
||||
// Tell Valgrind/Memcheck to not report accesses in the inaccessible region.
|
||||
VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE((unsigned char*)data + validLength,
|
||||
AsmJSMappedSize-validLength);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
// Copy over the current contents of the typed array.
|
||||
@ -458,6 +468,13 @@ ArrayBufferObject::releaseAsmJSArray(FreeOp *fop)
|
||||
VirtualFree(data, 0, MEM_RELEASE);
|
||||
# else
|
||||
munmap(data, AsmJSMappedSize);
|
||||
# if defined(MOZ_VALGRIND) && defined(VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE)
|
||||
// Tell Valgrind/Memcheck to recommence reporting accesses in the
|
||||
// previously-inaccessible region.
|
||||
if (AsmJSMappedSize > 0) {
|
||||
VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(data, AsmJSMappedSize);
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#else /* defined(JS_ION) && defined(JS_CPU_X64) */
|
||||
|
@ -15,6 +15,10 @@
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_VALGRIND
|
||||
# include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "jit/AsmJS.h"
|
||||
|
||||
@ -79,10 +83,16 @@ SharedArrayRawBuffer::New(uint32_t length)
|
||||
if (!p)
|
||||
return nullptr;
|
||||
|
||||
if (!MarkValidRegion(p, AsmJSPageSize + length)) {
|
||||
size_t validLength = AsmJSPageSize + length;
|
||||
if (!MarkValidRegion(p, validLength)) {
|
||||
UnmapMemory(p, AsmJSMappedSize);
|
||||
return nullptr;
|
||||
}
|
||||
# if defined(MOZ_VALGRIND) && defined(VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE)
|
||||
// Tell Valgrind/Memcheck to not report accesses in the inaccessible region.
|
||||
VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE((unsigned char*)p + validLength,
|
||||
AsmJSMappedSize-validLength);
|
||||
# endif
|
||||
#else
|
||||
uint32_t allocSize = length + AsmJSPageSize;
|
||||
if (allocSize <= length)
|
||||
@ -116,6 +126,14 @@ SharedArrayRawBuffer::dropReference()
|
||||
JS_ASSERT(uintptr_t(p) % AsmJSPageSize == 0);
|
||||
#ifdef JS_CPU_X64
|
||||
UnmapMemory(p, AsmJSMappedSize);
|
||||
# if defined(MOZ_VALGRIND) \
|
||||
&& defined(VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE)
|
||||
// Tell Valgrind/Memcheck to recommence reporting accesses in the
|
||||
// previously-inaccessible region.
|
||||
if (AsmJSMappedSize > 0) {
|
||||
VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(p, AsmJSMappedSize);
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
UnmapMemory(p, this->length + AsmJSPageSize);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user