summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-23 10:24:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-23 10:24:06 +0200
commit007efb5f05e33dee024da658077fe3e4977993bc (patch)
tree3fcd8183bf6023254a09d8691c0feba2da8f4838
parent209a7506c336391e000f2b93c19fc1b2e1b317d9 (diff)
eo: fix call stack shrink_frame
- do never shrink under EO_CALL_STACK_DEPTH_MIN size - set shrink_frame at (current_size/2) - EO_CALL_STACK_SHRINK_OFFSET
-rw-r--r--src/lib/eo/eo.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 5713f4e..3ab323f 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -259,7 +259,8 @@ EAPI Eo_Hook_Call eo_hook_call_post = NULL;
259#define EO_INVALID_DATA (void *) -1 259#define EO_INVALID_DATA (void *) -1
260// 1024 entries == 8k or 16k (32 or 64bit) for eo call stack. that's 1024 260// 1024 entries == 8k or 16k (32 or 64bit) for eo call stack. that's 1024
261// recursion entires it can handle before barfing. i'd say that's ok 261// recursion entires it can handle before barfing. i'd say that's ok
262#define EO_CALL_STACK_DEPTH 16 262#define EO_CALL_STACK_DEPTH_MIN 16
263#define EO_CALL_STACK_SHRINK_DROP 8
263 264
264typedef struct _Eo_Stack_Frame 265typedef struct _Eo_Stack_Frame
265{ 266{
@@ -355,7 +356,7 @@ _eo_call_stack_create()
355 return NULL; 356 return NULL;
356 357
357// XXX: leave in for noew in case this breaks, but remove later when ok 358// XXX: leave in for noew in case this breaks, but remove later when ok
358// stack->frames = calloc(EO_CALL_STACK_DEPTH, sizeof(Eo_Stack_Frame)); 359// stack->frames = calloc(EO_CALL_STACK_DEPTH_MIN, sizeof(Eo_Stack_Frame));
359 stack->max_size = 8192 * sizeof(Eo_Stack_Frame); 360 stack->max_size = 8192 * sizeof(Eo_Stack_Frame);
360 stack->frames = _eo_call_stack_mem_alloc(stack->max_size); 361 stack->frames = _eo_call_stack_mem_alloc(stack->max_size);
361 if (!stack->frames) 362 if (!stack->frames)
@@ -366,7 +367,7 @@ _eo_call_stack_create()
366 367
367 // first frame is never used 368 // first frame is never used
368 stack->frame_ptr = stack->frames; 369 stack->frame_ptr = stack->frames;
369 stack->last_frame = &stack->frames[EO_CALL_STACK_DEPTH - 1]; 370 stack->last_frame = &stack->frames[EO_CALL_STACK_DEPTH_MIN - 1];
370 stack->shrink_frame = stack->frames; 371 stack->shrink_frame = stack->frames;
371 372
372 return stack; 373 return stack;
@@ -461,12 +462,15 @@ _eo_call_stack_resize(Eo_Call_Stack *stack, Eina_Bool grow)
461 stack->frame_ptr = &stack->frames[frame_offset]; 462 stack->frame_ptr = &stack->frames[frame_offset];
462 stack->last_frame = &stack->frames[next_sz - 1]; 463 stack->last_frame = &stack->frames[next_sz - 1];
463 464
464 if (grow) 465 if (next_sz == EO_CALL_STACK_DEPTH_MIN)
465 frame_offset = (sz >> 1);
466 if (next_sz == EO_CALL_STACK_DEPTH)
467 frame_offset = 0; 466 frame_offset = 0;
468 else 467 else
469 frame_offset = (next_sz >> 1); 468 {
469 if (grow)
470 frame_offset = sz - EO_CALL_STACK_SHRINK_DROP;
471 else
472 frame_offset = (next_sz / 2) - EO_CALL_STACK_SHRINK_DROP;
473 }
470 stack->shrink_frame = &stack->frames[frame_offset]; 474 stack->shrink_frame = &stack->frames[frame_offset];
471} 475}
472 476