Branch: Tag:

2014-12-04

2014-12-04 19:26:26 by Per Hedbor <ph@opera.com>

Binary size: push_constant_text -> push_text when not time-critical.

Especially in error handling, and code that does a lot of other string
operations anyway the speed gain is not wort the 100+ bytes code size
of each instance of push_constant_text

This saves about 20K of code size (main pike binary), while not really
changing the speed much.

push_constant_text that seemed to be in at least pseudo-time-critical
code was kept as they were.

On a related note, push_constant_text(":") four times in a row creates
four different string variables, for obvious reasons.

Some of the remaining push_constant_text really should have a
module/file local string variable, even though that is more bothersome
to create.

It might be nice to have this in .cmod files automatically.

3409:    * (On some architectures longjump() might restore obj_arr's original    * value (eg if obj_arr is in a register)).    */ + #if 0    struct array **obj_arr_ = (struct array **)xalloc(sizeof(struct array *));    ONERROR tmp;   
3416:       SET_ONERROR(tmp, free_obj_arr, obj_arr_);    - #if 0 +     {    struct gc_pop_frame *p;    unsigned cycle = 0;
3431: Inside #if 0
   p = p->next;    if (p ? ((unsigned)(p->cycle != cycle)) : cycle) {    if ((*obj_arr_)->size >= 2) { -  push_constant_text("gc"); -  push_constant_text("bad_cycle"); +  push_text("gc"); +  push_text("bad_cycle");    push_array(*obj_arr_);    *obj_arr_ = 0;    SAFE_APPLY_MASTER("runtime_warning", 3);
3444: Inside #if 0
   if (!p) break;    }    } - #endif +        CALL_AND_UNSET_ONERROR(tmp); -  + #endif   }      size_t do_gc(void *UNUSED(ignored), int explicit_call)
4227:       pop_n_elems(args);    -  push_constant_text("num_objects"); +  push_text("num_objects");    push_int(num_objects);    size++;    -  push_constant_text("num_allocs"); +  push_text("num_allocs");    push_int64(num_allocs);    size++;    -  push_constant_text("alloc_threshold"); +  push_text("alloc_threshold");    push_int64(alloc_threshold);    size++;    -  push_constant_text("projected_garbage"); +  push_text("projected_garbage");    push_float(DO_NOT_WARN((FLOAT_TYPE)(objects_freed * (double) num_allocs /    (double) alloc_threshold)));    size++;    -  push_constant_text("objects_alloced"); +  push_text("objects_alloced");    push_int64(DO_NOT_WARN((INT64)objects_alloced));    size++;    -  push_constant_text("objects_freed"); +  push_text("objects_freed");    push_int64(DO_NOT_WARN((INT64)objects_freed));    size++;    -  push_constant_text("last_garbage_ratio"); +  push_text("last_garbage_ratio");    push_float(DO_NOT_WARN((FLOAT_TYPE) last_garbage_ratio));    size++;    -  push_constant_text("non_gc_time"); +  push_text("non_gc_time");    push_int64(DO_NOT_WARN((INT64) non_gc_time));    size++;    -  push_constant_text("gc_time"); +  push_text("gc_time");    push_int64(DO_NOT_WARN((INT64) gc_time));    size++;    -  push_constant_text ("last_garbage_strategy"); +  push_text ("last_garbage_strategy");    switch (last_garbage_strategy) {    case GARBAGE_RATIO_LOW: -  push_constant_text ("garbage_ratio_low"); break; +  push_text ("garbage_ratio_low"); break;    case GARBAGE_RATIO_HIGH: -  push_constant_text ("garbage_ratio_high"); break; +  push_text ("garbage_ratio_high"); break;    case GARBAGE_MAX_INTERVAL: -  push_constant_text ("garbage_max_interval"); break; +  push_text ("garbage_max_interval"); break;   #ifdef PIKE_DEBUG    default:    Pike_fatal ("Unknown last_garbage_strategy %d\n", last_garbage_strategy);
4279:    }    size++;    -  push_constant_text("last_gc"); +  push_text("last_gc");    push_int64(last_gc);    size++;    -  push_constant_text ("total_gc_cpu_time"); +  push_text ("total_gc_cpu_time");    push_int64 (auto_gc_time);   #ifndef LONG_CPU_TIME    push_int (1000000000 / CPU_TIME_TICKS);
4291:   #endif    size++;    -  push_constant_text ("total_gc_real_time"); +  push_text ("total_gc_real_time");    push_int64 (auto_gc_real_time);   #ifndef LONG_CPU_TIME    push_int (1000000000 / CPU_TIME_TICKS);
4300:    size++;      #ifdef PIKE_DEBUG -  push_constant_text ("max_rec_frames"); +  push_text ("max_rec_frames");    push_int64 (DO_NOT_WARN ((INT64) tot_max_rec_frames));    size++;    -  push_constant_text ("max_link_frames"); +  push_text ("max_link_frames");    push_int64 (DO_NOT_WARN ((INT64) tot_max_link_frames));    size++;    -  push_constant_text ("max_free_extra_frames"); +  push_text ("max_free_extra_frames");    push_int64 (DO_NOT_WARN ((INT64) tot_max_free_extra_frames));    size++;   #endif