mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 12:18:31 +00:00
Optimize memory layout
Compared to b69f3d2488
, old windows specific fd, zipos and nsync memory ranges in libc/runtime/memtrack.internal.h were kept.
This commit is contained in:
parent
0740e68ea0
commit
555260d2e5
41 changed files with 381 additions and 345 deletions
|
@ -16,32 +16,62 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/winargs.internal.h"
|
||||
|
||||
#define ADDR(x) ((int64_t)((uint64_t)(x) << 32) >> 16)
|
||||
#define UNSHADOW(x) ((int64_t)(MAX(0, (x)-0x7fff8000)) << 3)
|
||||
#define FRAME(x) ((int)((x) >> 16))
|
||||
|
||||
const char *(DescribeFrame)(char buf[32], int x) {
|
||||
/* asan runtime depends on this function */
|
||||
char *p;
|
||||
if (IsShadowFrame(x)) {
|
||||
ksnprintf(buf, 32, " shadow=%.8x", FRAME(UNSHADOW(ADDR(x))));
|
||||
return buf;
|
||||
return " shadow ";
|
||||
static const char *GetFrameName(int x) {
|
||||
if (!x) {
|
||||
return "null";
|
||||
} else if (IsShadowFrame(x)) {
|
||||
return "shadow";
|
||||
} else if (IsAutoFrame(x)) {
|
||||
return " automap";
|
||||
return "automap";
|
||||
} else if (IsFixedFrame(x)) {
|
||||
return " fixed ";
|
||||
return "fixed";
|
||||
} else if (IsArenaFrame(x)) {
|
||||
return " arena ";
|
||||
return "arena";
|
||||
} else if (IsStaticStackFrame(x)) {
|
||||
return " stack ";
|
||||
return "stack";
|
||||
} else if (IsGfdsFrame(x)) {
|
||||
return "g_fds";
|
||||
} else if (IsZiposFrame(x)) {
|
||||
return "zipos";
|
||||
} else if (IsNsyncFrame(x)) {
|
||||
return "nsync";
|
||||
} else if (IsMemtrackFrame(x)) {
|
||||
return "memtrack";
|
||||
} else if (IsOldStackFrame(x)) {
|
||||
return "oldstack";
|
||||
} else if (IsWindows() &&
|
||||
(((GetStaticStackAddr(0) + GetStackSize()) >> 16) <= x &&
|
||||
x <= ((GetStaticStackAddr(0) + GetStackSize() +
|
||||
sizeof(struct WinArgs) - 1) >>
|
||||
16))) {
|
||||
return "winargs";
|
||||
} else if ((int)((intptr_t)_base >> 16) <= x &&
|
||||
x <= (int)(((intptr_t)_end - 1) >> 16)) {
|
||||
return "image";
|
||||
} else {
|
||||
return "";
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char *(DescribeFrame)(char buf[32], int x) {
|
||||
char *p;
|
||||
if (IsShadowFrame(x)) {
|
||||
ksnprintf(buf, 64, "%s %s %.8x", GetFrameName(x),
|
||||
GetFrameName(FRAME(UNSHADOW(ADDR(x)))), FRAME(UNSHADOW(ADDR(x))));
|
||||
return buf;
|
||||
} else {
|
||||
return GetFrameName(x);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue