Branch: Tag:

2017-06-25

2017-06-25 01:38:13 by Martin Nilsson <nilsson@fastmail.com>

Line numbers start a 1, so we can let 0 stead of -1 mean unknown in backtrace_frame objects. This allows us to initialize the object with a zeroed storage. Skipping the C init code makes for 2% faster backtraces.

2599:    CVAR PIKE_OPCODE_T *pc;       /* These two are considered to be uninitialized from prog, pc and -  * fun as long as lineno == -1. */ +  * fun as long as lineno == 0. */    CVAR struct pike_string *filename;    CVAR INT_TYPE lineno;    -  + #ifdef PIKE_NULL_IS_SPECIAL    INIT    {    THIS->pc = NULL; -  THIS->lineno = -1; +  THIS->lineno = 0;    THIS->filename = NULL;    } -  + #endif       EXIT    gc_trivial;
2618:    THIS->filename = NULL;    }    THIS->pc = NULL; -  THIS->lineno = -1; +  THIS->lineno = 0;    }       /* NOTE: Use old-style getter/setter syntax for compatibility with
2655:    static void fill_in_file_and_line()    {    struct pike_string *file = NULL; -  assert (THIS->lineno == -1); +  assert (THIS->lineno == 0);       if (THIS->pc && THIS->prog) {    file = low_get_line(THIS->pc, THIS->prog, &THIS->lineno);
2702:       push_static_text("backtrace_frame(");    -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();       if (THIS->filename) {    ref_push_string(THIS->filename);
2803:    for (i = index; i <= end; i++) {    switch(i) {    case 0: /* Filename */ -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();    if (THIS->filename)    ref_push_string(THIS->filename);    else    push_int(0);    break;    case 1: /* Linenumber */ -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();    push_int(THIS->lineno);    break;    case 2: /* Function */
2858:       switch(index) {    case 0: /* Filename */ -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();    if (TYPEOF(*value) != PIKE_T_STRING) {    if ((TYPEOF(*value) != PIKE_T_INT) ||    (value->u.integer)) {
2878:    break;       case 1: /* Linenumber */ -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();    if (TYPEOF(*value) != PIKE_T_INT)    SIMPLE_ARG_TYPE_ERROR("`[]=", 2, "int(1..)");    THIS->lineno = value->u.integer;    break;       case 2: /* Function */ -  if (THIS->lineno == -1) fill_in_file_and_line(); +  if (THIS->lineno == 0) fill_in_file_and_line();    assign_svalue(&THIS->_fun, value);    break;    default: /* Arguments */