heap
This commit is contained in:
parent
f8d0703983
commit
46a32fbd83
16
C/alloc.c
16
C/alloc.c
@ -42,6 +42,12 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#if HAVE_FCNTL_H
|
#if HAVE_FCNTL_H
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_SYS_TIME_H
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
#if HAVE_SYS_RESOURCE_H
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
#if HAVE_SYS_STAT_H
|
#if HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
@ -383,6 +389,16 @@ void Yap_InitHeap(void *heap_addr) {
|
|||||||
HeapMax = 0;
|
HeapMax = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get an approximation to total memory data-base size.
|
||||||
|
size_t Yap_HeapUsed(void)
|
||||||
|
{
|
||||||
|
#if HAVE_MALLINFO
|
||||||
|
struct mallinfo mi = mallinfo();
|
||||||
|
return mi.uordblks - (LOCAL_TrailTop-LOCAL_GlobalBase);
|
||||||
|
#endif
|
||||||
|
return Yap_ClauseSpace+Yap_IndexSpace_Tree+Yap_LUClauseSpace+Yap_LUIndexSpace_CP;
|
||||||
|
}
|
||||||
|
|
||||||
static void InitExStacks(int wid, int Trail, int Stack) {
|
static void InitExStacks(int wid, int Trail, int Stack) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
UInt pm, sa;
|
UInt pm, sa;
|
||||||
|
@ -112,6 +112,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
#include "YapEval.h"
|
#include "YapEval.h"
|
||||||
|
#include "alloc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ eval0(Int fi) {
|
|||||||
/// - heapused
|
/// - heapused
|
||||||
/// Heap (data-base) space used, in bytes.
|
/// Heap (data-base) space used, in bytes.
|
||||||
///
|
///
|
||||||
RINT(HeapUsed);
|
RINT(Yap_HeapUsed());
|
||||||
case op_localsp:
|
case op_localsp:
|
||||||
/// - local
|
/// - local
|
||||||
/// Local stack in use, in bytes
|
/// Local stack in use, in bytes
|
||||||
|
5
C/qlyr.c
5
C/qlyr.c
@ -836,6 +836,7 @@ static void ReadHash(FILE *stream) {
|
|||||||
UInt sz = read_UInt(stream);
|
UInt sz = read_UInt(stream);
|
||||||
UInt nrefs = read_UInt(stream);
|
UInt nrefs = read_UInt(stream);
|
||||||
LogUpdClause *ncl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(sz);
|
LogUpdClause *ncl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(sz);
|
||||||
|
Yap_LUClauseSpace += sz;
|
||||||
if (!ncl) {
|
if (!ncl) {
|
||||||
QLYR_ERROR(OUT_OF_CODE_SPACE);
|
QLYR_ERROR(OUT_OF_CODE_SPACE);
|
||||||
}
|
}
|
||||||
@ -874,6 +875,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses,
|
|||||||
nrefs = cl->ClRefCount;
|
nrefs = cl->ClRefCount;
|
||||||
} else {
|
} else {
|
||||||
cl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(size);
|
cl = (LogUpdClause *)Yap_AlwaysAllocCodeSpace(size);
|
||||||
|
Yap_LUClauseSpace += size;
|
||||||
}
|
}
|
||||||
read_bytes(stream, cl, size);
|
read_bytes(stream, cl, size);
|
||||||
cl->ClFlags &= ~InUseMask;
|
cl->ClFlags &= ~InUseMask;
|
||||||
@ -887,6 +889,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses,
|
|||||||
char *base = (void *)read_UInt(stream);
|
char *base = (void *)read_UInt(stream);
|
||||||
UInt mask = read_UInt(stream);
|
UInt mask = read_UInt(stream);
|
||||||
UInt size = read_UInt(stream);
|
UInt size = read_UInt(stream);
|
||||||
|
Yap_ClauseSpace += size;
|
||||||
MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size);
|
MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size);
|
||||||
|
|
||||||
if (nclauses) {
|
if (nclauses) {
|
||||||
@ -918,6 +921,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses,
|
|||||||
char *base = (void *)read_UInt(stream);
|
char *base = (void *)read_UInt(stream);
|
||||||
UInt size = read_UInt(stream);
|
UInt size = read_UInt(stream);
|
||||||
DynamicClause *cl = (DynamicClause *)Yap_AlwaysAllocCodeSpace(size);
|
DynamicClause *cl = (DynamicClause *)Yap_AlwaysAllocCodeSpace(size);
|
||||||
|
Yap_LUClauseSpace += size;
|
||||||
|
|
||||||
LOCAL_HDiff = (char *)cl - base;
|
LOCAL_HDiff = (char *)cl - base;
|
||||||
read_bytes(stream, cl, size);
|
read_bytes(stream, cl, size);
|
||||||
@ -948,6 +952,7 @@ static void read_clauses(FILE *stream, PredEntry *pp, UInt nclauses,
|
|||||||
char *base = (void *)read_UInt(stream);
|
char *base = (void *)read_UInt(stream);
|
||||||
UInt size = read_UInt(stream);
|
UInt size = read_UInt(stream);
|
||||||
StaticClause *cl = (StaticClause *)Yap_AlwaysAllocCodeSpace(size);
|
StaticClause *cl = (StaticClause *)Yap_AlwaysAllocCodeSpace(size);
|
||||||
|
Yap_ClauseSpace += size;
|
||||||
|
|
||||||
LOCAL_HDiff = (char *)cl - base;
|
LOCAL_HDiff = (char *)cl - base;
|
||||||
read_bytes(stream, cl, size);
|
read_bytes(stream, cl, size);
|
||||||
|
17
H/alloc.h
17
H/alloc.h
@ -96,10 +96,11 @@ typedef struct FREEB {
|
|||||||
/* Operating system and architecture dependent page size */
|
/* Operating system and architecture dependent page size */
|
||||||
extern size_t Yap_page_size;
|
extern size_t Yap_page_size;
|
||||||
|
|
||||||
void Yap_InitHeap(void *);
|
extern void Yap_InitHeap(void *);
|
||||||
UInt Yap_ExtendWorkSpaceThroughHole(UInt);
|
extern UInt Yap_ExtendWorkSpaceThroughHole(UInt);
|
||||||
void Yap_AllocHole(UInt, UInt);
|
extern void Yap_AllocHole(UInt, UInt);
|
||||||
|
extern size_t Yap_HeapUsed(void);
|
||||||
|
;
|
||||||
#if USE_SYSTEM_MMAP && ! defined(__CYGWIN__)
|
#if USE_SYSTEM_MMAP && ! defined(__CYGWIN__)
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -120,10 +121,10 @@ void *sbrk(caddr_t);
|
|||||||
|
|
||||||
typedef unsigned size_t;
|
typedef unsigned size_t;
|
||||||
|
|
||||||
MALLOC_T malloc(size_t);
|
extern MALLOC_T malloc(size_t);
|
||||||
void free(MALLOC_T);
|
extern void free(MALLOC_T);
|
||||||
MALLOC_T realloc(MALLOC_T,size_t);
|
extern MALLOC_T realloc(MALLOC_T,size_t);
|
||||||
MALLOC_T calloc(size_t,size_t);
|
extern MALLOC_T calloc(size_t,size_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -777,7 +777,7 @@ install_t install_pypreds(void) {
|
|||||||
PL_register_foreign("python_access", 3, python_access, 0);
|
PL_register_foreign("python_access", 3, python_access, 0);
|
||||||
PL_register_foreign("python_threaded", 0, p_python_threaded, 0);
|
PL_register_foreign("python_threaded", 0, p_python_threaded, 0);
|
||||||
PL_register_foreign("python_clear_errors", 0, python_clear_errors, 0);
|
PL_register_foreign("python_clear_errors", 0, python_clear_errors, 0);
|
||||||
PL_register_foreign("python_string_to", 0, python_string_to, 1);
|
PL_register_foreign("python_string_to", 1, python_string_to, 0);
|
||||||
|
|
||||||
init_python_vfs();
|
init_python_vfs();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user