/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariable(RubyBasicObject self, RubyClass realClass, int index, Object value) { while (true) { int currentStamp = self.varTableStamp; // spin-wait if odd if((currentStamp & 0x01) != 0) continue; Object[] currentTable = (Object[]) UnsafeHolder.U.getObjectVolatile(self, RubyBasicObject.VAR_TABLE_OFFSET); if (currentTable == null || index >= currentTable.length) { if (!createTableUnsafe(self, currentStamp, realClass, currentTable, index, value)) continue; } else { if (!updateTableUnsafe(self, currentStamp, currentTable, index, value)) continue; } break; } }
/** * Set this variable into the given object using Unsafe to ensure * safe updating of the variable table. * * @param object the object into which to set this variable * @param value the variable's value */ public void set(Object object, Object value) { ((RubyBasicObject)object).ensureInstanceVariablesSettable(); setVariable((RubyBasicObject)object, realClass, index, value); }
/** * Allocate a new VariableAccessor for the named variable. * * @param name the name of the variable * @return the new VariableAccessor */ synchronized final VariableAccessor allocateVariableAccessor(String name) { int id = realClass.id; String[] myVariableNames = variableNames; int newIndex = myVariableNames.length; String[] newVariableNames = new String[newIndex + 1]; VariableAccessor newVariableAccessor; if (UnsafeHolder.U == null) { newVariableAccessor = new SynchronizedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id); } System.arraycopy(myVariableNames, 0, newVariableNames, 0, newIndex); newVariableNames[newIndex] = name; variableNames = newVariableNames; return newVariableAccessor; }
/** * Allocate a new VariableAccessor for the named variable. * * @param name the name of the variable * @return the new VariableAccessor */ synchronized final VariableAccessor allocateVariableAccessor(String name) { int id = realClass.id; String[] myVariableNames = variableNames; int newIndex = myVariableNames.length; String[] newVariableNames = new String[newIndex + 1]; VariableAccessor newVariableAccessor; if (UnsafeHolder.U == null) { newVariableAccessor = new SynchronizedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id); } System.arraycopy(myVariableNames, 0, newVariableNames, 0, newIndex); newVariableNames[newIndex] = name; variableNames = newVariableNames; return newVariableAccessor; }
/** * Set this variable into the given object using Unsafe to ensure * safe updating of the variable table. * * @param object the object into which to set this variable * @param value the variable's value */ public void set(Object object, Object value) { ((RubyBasicObject)object).ensureInstanceVariablesSettable(); setVariable((RubyBasicObject)object, realClass, index, value); }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariable(RubyBasicObject self, RubyClass realClass, int index, Object value) { while (true) { int currentStamp = self.varTableStamp; // spin-wait if odd if((currentStamp & 0x01) != 0) continue; Object[] currentTable = (Object[]) UnsafeHolder.U.getObjectVolatile(self, RubyBasicObject.VAR_TABLE_OFFSET); if (currentTable == null || index >= currentTable.length) { if (!createTableUnsafe(self, currentStamp, realClass, currentTable, index, value)) continue; } else { if (!updateTableUnsafe(self, currentStamp, currentTable, index, value)) continue; } break; } }
newVariableAccessor = new SynchronizedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id);
/** * Set this variable into the given object using Unsafe to ensure * safe updating of the variable table. * * @param object the object into which to set this variable * @param value the variable's value */ public void set(Object object, Object value) { ((RubyBasicObject)object).ensureInstanceVariablesSettable(); setVariable((RubyBasicObject)object, realClass, index, value); }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariable(RubyBasicObject self, RubyClass realClass, int index, Object value) { while (true) { int currentStamp = self.varTableStamp; // spin-wait if odd if((currentStamp & 0x01) != 0) continue; Object[] currentTable = (Object[]) UnsafeHolder.U.getObjectVolatile(self, RubyBasicObject.VAR_TABLE_OFFSET); if (currentTable == null || index >= currentTable.length) { if (!createTableUnsafe(self, currentStamp, realClass, currentTable, index, value)) continue; } else { if (!updateTableUnsafe(self, currentStamp, currentTable, index, value)) continue; } break; } }
newVariableAccessor = new SynchronizedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id); } else { newVariableAccessor = new StampedVariableAccessor(realClass, name, newIndex, id);
/** * Static entry point for setting a variable in an object. * * @param realClass the "real" class of the object * @param self the object into which to set the variable * @param index the index allocated for the variable * @param value the value of the variable */ public static void setVariableInternal(RubyClass realClass, RubyBasicObject self, int index, Object value) { if(UnsafeHolder.U == null) { SynchronizedVariableAccessor.setVariable(self,realClass,index,value); } else { StampedVariableAccessor.setVariable(self,realClass,index,value); } }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariable(RubyBasicObject self, RubyClass realClass, int index, Object value) { while (true) { int currentStamp = self.varTableStamp; // spin-wait if odd if((currentStamp & 0x01) != 0) continue; Object[] currentTable = (Object[]) UnsafeHolder.U.getObjectVolatile(self, RubyBasicObject.VAR_TABLE_OFFSET); if (currentTable == null || index >= currentTable.length) { if (!createTableUnsafe(self, currentStamp, realClass, currentTable, index, value)) continue; } else { if (!updateTableUnsafe(self, currentStamp, currentTable, index, value)) continue; } break; } }
/** * Set this variable into the given object using Unsafe to ensure * safe updating of the variable table. * * @param object the object into which to set this variable * @param value the variable's value */ public void set(Object object, Object value) { ((RubyBasicObject)object).ensureInstanceVariablesSettable(); setVariable((RubyBasicObject)object, realClass, index, value); }
/** * Virtual entry point for setting a variable into an object. * * @param self the object into which to set the value * @param index the index allocated for the value * @param value the value */ public void setVariableInternal(RubyBasicObject self, int index, Object value) { if(UnsafeHolder.U == null) { SynchronizedVariableAccessor.setVariable(self,realClass,index,value); } else { StampedVariableAccessor.setVariable(self,realClass,index,value); } }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. This version checks * if self has been frozen before proceeding to set the variable. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariableChecked(RubyBasicObject self, RubyClass realClass, int index, Object value) { self.ensureInstanceVariablesSettable(); setVariable(self, realClass, index, value); }
/** * Virtual entry point for setting a variable into an object. * * @param self the object into which to set the value * @param index the index allocated for the value * @param value the value */ public void setVariableInternal(RubyBasicObject self, int index, Object value) { if(UnsafeHolder.U == null) { SynchronizedVariableAccessor.setVariable(self,realClass,index,value); } else { StampedVariableAccessor.setVariable(self,realClass,index,value); } }
/** * Virtual entry point for setting a variable into an object. * * @param self the object into which to set the value * @param index the index allocated for the value * @param value the value */ public void setVariableInternal(RubyBasicObject self, int index, Object value) { if(UnsafeHolder.U == null) { SynchronizedVariableAccessor.setVariable(self,realClass,index,value); } else { StampedVariableAccessor.setVariable(self,realClass,index,value); } }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. This version checks * if self has been frozen before proceeding to set the variable. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariableChecked(RubyBasicObject self, RubyClass realClass, int index, Object value) { self.ensureInstanceVariablesSettable(); setVariable(self, realClass, index, value); }
/** * Set the given variable index into the specified object. The "real" class * and index are pass in to provide functional access. This version checks * if self has been frozen before proceeding to set the variable. * * @param self the object into which to set the variable * @param realClass the "real" class for the object * @param index the index of the variable * @param value the variable's value */ public static void setVariableChecked(RubyBasicObject self, RubyClass realClass, int index, Object value) { self.ensureInstanceVariablesSettable(); setVariable(self, realClass, index, value); }
/** * Virtual entry point for setting a variable into an object. * * @param self the object into which to set the value * @param index the index allocated for the value * @param value the value */ public void setVariableInternal(RubyBasicObject self, int index, Object value) { if(UnsafeHolder.U == null) { SynchronizedVariableAccessor.setVariable(self,realClass,index,value); } else { StampedVariableAccessor.setVariable(self,realClass,index,value); } }