Branch: Tag:

2014-08-16

2014-08-16 21:45:10 by Per Hedbor <ph@opera.com>

Added a few more global variable opcodes.

Gotta catch em all!

This time:

PRIVATE_IF_DIRECT_GLOBAL and ASSIGN_PRIVATE_IF_DIRECT_GLOBAL

These will fetch or assign a global variable if the currently
executing program is the program the object is cloned from.

These are only slightly slower than the F_PRIVATE_GLOBAL family of
opcodes, and the overhead if the global is not actually private is
minimal.

Missing: [ASSIGN_]PRIVATE_IF_DIRECT_TYPED_GLOBAL[_AND_POP] and
ASSIGN_PRIVATE_IF_DIRECT_GLOBAL_AND_POP.

365:    print_return_value();   });    + OPCODE2(F_PRIVATE_IF_DIRECT_GLOBAL, "global <private if direct>", +  I_UPDATE_SP, { +  struct object *co = Pike_fp->current_object; +  struct inherit *cx = Pike_fp->context; +  if(!co->prog) /* note: generate an error. */ +  object_low_set_index(co,0,0); +  if( co->prog != cx->prog ) +  { +  low_index_current_object_no_free(Pike_sp, arg2); +  Pike_sp++; +  print_return_value(); +  } +  else +  { +  struct svalue *sp; +  sp = (struct svalue *)(co->storage + cx->storage_offset + arg1); +  push_svalue( sp ); +  print_return_value(); +  } + }); +  + OPCODE2(F_ASSIGN_PRIVATE_IF_DIRECT_GLOBAL, +  "assign global <private if direct>", 0, +  { +  struct object *co = Pike_fp->current_object; +  struct inherit *cx = Pike_fp->context; +  +  if( co->prog != cx->prog ) +  { +  object_low_set_index(co, arg2 + cx->identifier_level, Pike_sp-1); +  } +  else +  { +  struct svalue *tmp; +  tmp = (struct svalue *)(co->storage + cx->storage_offset + arg1); +  assign_svalue(tmp,Pike_sp-1); +  } +  }); +    OPCODE2(F_ASSIGN_PRIVATE_TYPED_GLOBAL_AND_POP, "assign global <private,typed> and pop", I_UPDATE_SP, {    /* lazy mode. */    LOCAL_VAR(union anything *tmp);
1111:    pop_stack(); /* leaves arr on stack. */   });    - OPCODE2(F_APPLY_ASSIGN_LOCAL_AND_POP, "apply, assign local and pop", I_UPDATE_SP|I_UPDATE_M_SP, { + OPCODE2(F_APPLY_ASSIGN_LOCAL_AND_POP, +  "apply, assign local and pop", I_UPDATE_SP|I_UPDATE_M_SP, {    apply_svalue(&((Pike_fp->context->prog->constants + arg1)->sval),    DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)));    free_svalue(Pike_fp->locals+arg2);
1154:    pop_stack();   });    - OPCODE1(F_ASSIGN_PRIVATE_GLOBAL_AND_POP, "assign private global and pop", I_UPDATE_SP, { + OPCODE1(F_ASSIGN_PRIVATE_GLOBAL_AND_POP, +  "assign private global and pop", I_UPDATE_SP, {    LOCAL_VAR(struct svalue *tmp);    LOCAL_VAR(struct object *co);    co = Pike_fp->current_object;
1171:    co = Pike_fp->current_object;    if(!co->prog) /* note: generate an error. */    object_low_set_index(co,0,0); -  tmp = (struct svalue *)(Pike_fp->current_object->storage + Pike_fp->context->storage_offset + arg1); +  tmp = (struct svalue *)(co->storage +Pike_fp->context->storage_offset +arg1);    assign_svalue( tmp, Pike_sp-1 );   });