_PAGE_READWRITE = 0x0004
_PAGE_NOACCESS = 0x0001
+
+ _ERROR_NOT_ENOUGH_MEMORY = 8
+ _ERROR_COMMITMENT_LIMIT = 1455
)
// Don't split the stack as this function may be invoked without a valid G,
mSysStatInc(sysStat, n)
p := stdcall4(_VirtualAlloc, uintptr(v), n, _MEM_COMMIT, _PAGE_READWRITE)
if p != uintptr(v) {
- print("runtime: VirtualAlloc of ", n, " bytes failed with errno=", getlasterror(), "\n")
- throw("runtime: cannot map pages in arena address space")
+ errno := getlasterror()
+ print("runtime: VirtualAlloc of ", n, " bytes failed with errno=", errno, "\n")
+ switch errno {
+ case _ERROR_NOT_ENOUGH_MEMORY, _ERROR_COMMITMENT_LIMIT:
+ throw("out of memory")
+ default:
+ throw("runtime: cannot map pages in arena address space")
+ }
}
}