mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-14 23:09:16 +00:00
Fix minor suboptimalities in memory manager
This commit is contained in:
parent
76cea6c687
commit
23dfb79d33
3 changed files with 49 additions and 60 deletions
|
@ -1,14 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_MAPS_H_
|
||||
#define COSMOPOLITAN_MAPS_H_
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/dll.h"
|
||||
#include "libc/intrin/tree.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/thread/tls2.internal.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define MAP_TREE_CONTAINER(e) TREE_CONTAINER(struct Map, tree, e)
|
||||
#define MAP_FREE_CONTAINER(e) DLL_CONTAINER(struct Map, free, e)
|
||||
|
||||
struct Map {
|
||||
char *addr; /* granule aligned */
|
||||
|
@ -22,14 +20,14 @@ struct Map {
|
|||
intptr_t hand; /* windows nt only */
|
||||
union {
|
||||
struct Tree tree;
|
||||
struct Dll free;
|
||||
struct Map *free;
|
||||
};
|
||||
};
|
||||
|
||||
struct Maps {
|
||||
atomic_int lock;
|
||||
struct Tree *maps;
|
||||
struct Dll *free;
|
||||
_Atomic(struct Map *) free;
|
||||
size_t count;
|
||||
size_t pages;
|
||||
atomic_size_t rollo;
|
||||
|
@ -64,14 +62,14 @@ forceinline optimizespeed int __maps_search(const void *key,
|
|||
return (addr > map->addr) - (addr < map->addr);
|
||||
}
|
||||
|
||||
static struct Map *__maps_next(struct Map *map) {
|
||||
static inline struct Map *__maps_next(struct Map *map) {
|
||||
struct Tree *node;
|
||||
if ((node = tree_next(&map->tree)))
|
||||
return MAP_TREE_CONTAINER(node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct Map *__maps_first(void) {
|
||||
static inline struct Map *__maps_first(void) {
|
||||
struct Tree *node;
|
||||
if ((node = tree_first(__maps.maps)))
|
||||
return MAP_TREE_CONTAINER(node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue