allow copying a chunk of floats to a list in a single operation. Also
improve performance of sum out operation on arrays.
This commit is contained in:
@@ -441,6 +441,7 @@ X_API void *STD_PROTO(YAP_ReallocSpaceFromYap,(void*,unsigned int));
|
||||
X_API void STD_PROTO(YAP_FreeSpaceFromYap,(void *));
|
||||
X_API int STD_PROTO(YAP_StringToBuffer, (Term, char *, unsigned int));
|
||||
X_API Term STD_PROTO(YAP_ReadBuffer, (char *,Term *));
|
||||
X_API Term STD_PROTO(YAP_FloatsToList, (double *, size_t));
|
||||
X_API Term STD_PROTO(YAP_BufferToString, (char *));
|
||||
X_API Term STD_PROTO(YAP_NBufferToString, (char *, size_t));
|
||||
X_API Term STD_PROTO(YAP_WideBufferToString, (wchar_t *));
|
||||
@@ -966,7 +967,7 @@ YAP_MkPairTerm(Term t1, Term t2)
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
if (H > ASP-1024) {
|
||||
while (H > ASP-1024) {
|
||||
Int sl1 = Yap_InitSlot(t1 PASS_REGS);
|
||||
Int sl2 = Yap_InitSlot(t2 PASS_REGS);
|
||||
RECOVER_H();
|
||||
@@ -3538,6 +3539,41 @@ YAP_cwd(void)
|
||||
return buf;
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_FloatsToList(double *dblp, size_t sz)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term t;
|
||||
CELL *oldH;
|
||||
BACKUP_H();
|
||||
|
||||
if (!sz)
|
||||
return TermNil;
|
||||
while (ASP-1024 < H + sz*(2+2+SIZEOF_DOUBLE/SIZEOF_LONG_INT)) {
|
||||
if (dblp > H0 && dblp < H) {
|
||||
/* we are in trouble */
|
||||
LOCAL_OpenArray = dblp;
|
||||
}
|
||||
if (!dogc( PASS_REGS1 )) {
|
||||
RECOVER_H();
|
||||
return 0L;
|
||||
}
|
||||
dblp = LOCAL_OpenArray;
|
||||
LOCAL_OpenArray = NULL;
|
||||
}
|
||||
t = AbsPair(H);
|
||||
while (sz) {
|
||||
oldH = H;
|
||||
H +=2;
|
||||
oldH[0] = MkFloatTerm(*dblp++);
|
||||
oldH[1] = AbsPair(H);
|
||||
sz--;
|
||||
}
|
||||
oldH[1] = TermNil;
|
||||
RECOVER_H();
|
||||
return t;
|
||||
}
|
||||
|
||||
X_API Term
|
||||
YAP_OpenList(int n)
|
||||
{
|
||||
@@ -3545,7 +3581,7 @@ YAP_OpenList(int n)
|
||||
Term t;
|
||||
BACKUP_H();
|
||||
|
||||
if (H+2*n > ASP-1024) {
|
||||
while (H+2*n > ASP-1024) {
|
||||
if (!dogc( PASS_REGS1 )) {
|
||||
RECOVER_H();
|
||||
return FALSE;
|
||||
|
10
C/compiler.c
10
C/compiler.c
@@ -2759,7 +2759,7 @@ c_layout(compiler_struct *cglobs)
|
||||
{
|
||||
PInstr *savepc = cglobs->BodyStart->nextInst;
|
||||
register Ventry *v = cglobs->vtable;
|
||||
Int *up = cglobs->Uses, Arity;
|
||||
Int *up = cglobs->Uses;
|
||||
CELL *cop = cglobs->Contents;
|
||||
/* tell put_values used in bip optimisation */
|
||||
int rn_kills = 0;
|
||||
@@ -3024,11 +3024,13 @@ c_layout(compiler_struct *cglobs)
|
||||
checktemp(arg, rn, ic, cglobs);
|
||||
break;
|
||||
case safe_call_op:
|
||||
Arity = RepPredProp((Prop) arg)->ArityOfPE;
|
||||
/*
|
||||
vsc: The variables will be in use after this!!!!
|
||||
for (rn = 1; rn <= Arity; ++rn)
|
||||
--cglobs->Uses[rn];
|
||||
{
|
||||
UInt Arity = RepPredProp((Prop) arg)->ArityOfPE;
|
||||
for (rn = 1; rn <= Arity; ++rn)
|
||||
--cglobs->Uses[rn];
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case call_op:
|
||||
|
2
C/grow.c
2
C/grow.c
@@ -158,6 +158,8 @@ SetHeapRegs(int copying_threads USES_REGS)
|
||||
#endif
|
||||
if (HB)
|
||||
HB = PtoGloAdjust(HB);
|
||||
if (LOCAL_OpenArray)
|
||||
LOCAL_OpenArray = PtoGloAdjust(LOCAL_OpenArray);
|
||||
if (B)
|
||||
B = ChoicePtrAdjust(B);
|
||||
#ifdef TABLING
|
||||
|
10
C/heapgc.c
10
C/heapgc.c
@@ -3432,6 +3432,16 @@ compact_heap( USES_REGS1 )
|
||||
*dest++ = *current++;
|
||||
}
|
||||
*old_dest = *current;
|
||||
/* if we have are calling from the C-interface,
|
||||
we may have an open array when we start the gc */
|
||||
if (LOCAL_OpenArray) {
|
||||
CELL *start = current + (dest-old_dest);
|
||||
if (LOCAL_OpenArray < current &&
|
||||
LOCAL_OpenArray > start) {
|
||||
UInt off = LOCAL_OpenArray-start;
|
||||
LOCAL_OpenArray = old_dest+off;
|
||||
}
|
||||
}
|
||||
*dest++ = EndSpecials;
|
||||
#ifdef DEBUG
|
||||
found_marked += (dest-old_dest);
|
||||
|
Reference in New Issue
Block a user