Cut thread switching time down.

Based on profiling release Windows.

Took these funcs from taking 1.6% to 0.5% time.
This commit is contained in:
Unknown W. Brackets 2013-01-26 11:27:06 -08:00
parent a6094e25ff
commit 7f4e322266
2 changed files with 19 additions and 32 deletions

View File

@ -887,48 +887,34 @@ u32 sceKernelGetThreadmanIdList(u32 type, u32 readBufPtr, u32 readBufSize, u32 i
// Saves the current CPU context
void __KernelSaveContext(ThreadContext *ctx)
{
for (int i = 0; i < 32; i++)
{
ctx->r[i] = currentMIPS->r[i];
ctx->f[i] = currentMIPS->f[i];
}
for (int i=0; i<128; i++)
{
ctx->v[i] = currentMIPS->v[i];
}
for (int i=0; i<16; i++)
{
ctx->vfpuCtrl[i] = currentMIPS->vfpuCtrl[i];
}
memcpy(ctx->r, currentMIPS->r, sizeof(ctx->r));
memcpy(ctx->f, currentMIPS->f, sizeof(ctx->f));
// TODO: Make VFPU saving optional/delayed, only necessary between VFPU-attr-marked threads
memcpy(ctx->v, currentMIPS->v, sizeof(ctx->v));
memcpy(ctx->vfpuCtrl, currentMIPS->vfpuCtrl, sizeof(ctx->vfpuCtrl));
ctx->pc = currentMIPS->pc;
ctx->hi = currentMIPS->hi;
ctx->lo = currentMIPS->lo;
ctx->pc = currentMIPS->pc;
ctx->fcr0 = currentMIPS->fcr0;
ctx->fcr31 = currentMIPS->fcr31;
ctx->fpcond = currentMIPS->fpcond;
// TODO: Make VFPU saving optional/delayed, only necessary between VFPU-attr-marked threads
}
// Loads a CPU context
void __KernelLoadContext(ThreadContext *ctx)
{
for (int i=0; i<32; i++)
{
currentMIPS->r[i] = ctx->r[i];
currentMIPS->f[i] = ctx->f[i];
}
for (int i=0; i<128; i++)
{
currentMIPS->v[i] = ctx->v[i];
}
for (int i=0; i<15; i++)
{
currentMIPS->vfpuCtrl[i] = ctx->vfpuCtrl[i];
}
memcpy(currentMIPS->r, ctx->r, sizeof(ctx->r));
memcpy(currentMIPS->f, ctx->f, sizeof(ctx->f));
// TODO: Make VFPU saving optional/delayed, only necessary between VFPU-attr-marked threads
memcpy(currentMIPS->v, ctx->v, sizeof(ctx->v));
memcpy(currentMIPS->vfpuCtrl, ctx->vfpuCtrl, sizeof(ctx->vfpuCtrl));
currentMIPS->pc = ctx->pc;
currentMIPS->hi = ctx->hi;
currentMIPS->lo = ctx->lo;
currentMIPS->pc = ctx->pc;
currentMIPS->fcr0 = ctx->fcr0;
currentMIPS->fcr31 = ctx->fcr31;
currentMIPS->fpcond = ctx->fpcond;

View File

@ -93,13 +93,14 @@ struct ThreadContext
float v[128];
u32 vfpuCtrl[16];
u32 pc;
u32 hi;
u32 lo;
u32 pc;
u32 fpcond;
u32 fcr0;
u32 fcr31;
u32 fpcond;
};
// Internal API, used by implementations of kernel functions