Branch: Tag:

2014-08-07

2014-08-07 16:24:32 by Per Hedbor <ph@opera.com>

Optimized access to private/final global variables

Especially the machine code version is now significantly faster, it
will simply read the variable directly from the known byte offset
instead of calling a function that resolves it in the vtable.

Gives about a 20x speedup of trivial code along the lines of
globala = globala + globalb;

Also tried to disable some of the optimizations that causes lvalues to
be generated instead of the desired global/assign_global opcodes.

For now this is only done if the global variabeles are known to not be
arrays, multiset, strings, mapping or objects, since those
optimizations are needed to quickly append things to arrays (and
mappings/multiset, but that is less common. It is also needed for
destructive modifications of strings, something that is even less
common).

355:    });   });    + OPCODE1(F_PRIVATE_GLOBAL, "global <private>", I_UPDATE_SP, { +  struct svalue *sp; +  sp = (struct svalue *)(Pike_fp->current_object->storage + Pike_fp->context->storage_offset + arg1); +  push_svalue( sp ); +  print_return_value(); + }); +    OPCODE2_TAIL(F_MARK_AND_EXTERNAL, "mark & external", I_UPDATE_SP|I_UPDATE_M_SP, {    *(Pike_mark_sp++)=Pike_sp;   
1075:    pop_stack();   });    + OPCODE1(F_ASSIGN_PRIVATE_GLOBAL_AND_POP, "assign private global and pop", I_UPDATE_SP, { +  struct svalue *tmp; +  tmp = (struct svalue *)(Pike_fp->current_object->storage + Pike_fp->context->storage_offset + arg1); +  free_svalue(tmp); +  *tmp = *--Pike_sp; + }); +  + OPCODE1(F_ASSIGN_PRIVATE_GLOBAL, "assign private global", I_UPDATE_SP, { +  struct svalue *tmp; +  tmp = (struct svalue *)(Pike_fp->current_object->storage + Pike_fp->context->storage_offset + arg1); +  assign_svalue( tmp, Pike_sp-1 ); + }); +    OPCODE2(F_ASSIGN_GLOBAL_NUMBER_AND_POP, "assign global number and pop", 0, {    struct svalue tmp;    SET_SVAL(tmp,PIKE_T_INT,0,integer,arg2);