Attached is a patch that moves all the instance variable methods to a new interface. In their place, IRubyObject contains a new method getInstanceVariables which returns an InstanceVariables instance. In the case of RubyObject and descendants, this just returns 'this', minimizing the impact to that concrete hierarchy. But the result of removing the methods from the interface is that other implementations of IRubyObject can provide their own custom versions of InstanceVariables, or perhaps none at all; but at the very least they don't have to immediately implement all the ivar methods.

I plan to do the same with the other variable types, but I'd like some review on this. It slows down ivar access, but only slightly (1/15 or so in my measurements, and it seems to even out on any non-trivial run). I think the benefits of a simple-to-implement IRubyObject interface outweigh a minor perf hit here.

- Charlie
Index: src/org/jruby/RubyUndef.java
===================================================================
--- src/org/jruby/RubyUndef.java        (revision 5047)
+++ src/org/jruby/RubyUndef.java        (working copy)
@@ -8,6 +8,7 @@
 import org.jruby.runtime.CallType;
 import org.jruby.runtime.ThreadContext;
 import org.jruby.runtime.builtin.IRubyObject;
+import org.jruby.runtime.builtin.InstanceVariables;
 import org.jruby.runtime.builtin.Variable;
 
 public class RubyUndef implements IRubyObject {
@@ -168,16 +169,6 @@
         return null;
     }
 
-    @Deprecated
-    public Map getInstanceVariables() {
-        return null;
-    }
-
-    @Deprecated
-    public Map getInstanceVariablesSnapshot() {
-        return null;
-    }
-
     public Class getJavaClass() {
         return null;
     }
@@ -266,27 +257,9 @@
         return false;
     }
 
-    @Deprecated
-    public Map safeGetInstanceVariables() {
-        return null;
-    }
-
-    @Deprecated
-    public boolean safeHasInstanceVariables() {
-        return false;
-    }
-
     public void setFrozen(boolean b) {
     }
 
-    public IRubyObject setInstanceVariable(String string, IRubyObject 
rubyObject) {
-        return null;
-    }
-
-    @Deprecated
-    public void setInstanceVariables(Map instanceVariables) {
-    }
-
     public void setMetaClass(RubyClass metaClass) {
     }
 
@@ -347,32 +320,8 @@
         return null;
     }
     
-    public IRubyObject fastGetInstanceVariable(String name) {
+    public InstanceVariables getInstanceVariables() {
         return null;
     }
     
-    public boolean hasInstanceVariable(String name) {
-        return false;
-    }
-    
-    public boolean fastHasInstanceVariable(String name) {
-        return false;
-    }
-    
-    public IRubyObject fastSetInstanceVariable(String name, IRubyObject value) 
{
-        return null;
-    }
-    
-    public IRubyObject removeInstanceVariable(String name) {
-        return null;
-    }
-    
-    public List<Variable<IRubyObject>> getInstanceVariableList() {
-        return null;
-    }
-
-    public List<String> getInstanceVariableNameList() {
-        return null;
-    }
-    
 }
Index: src/org/jruby/runtime/builtin/IRubyObject.java
===================================================================
--- src/org/jruby/runtime/builtin/IRubyObject.java      (revision 5047)
+++ src/org/jruby/runtime/builtin/IRubyObject.java      (working copy)
@@ -312,22 +312,9 @@
     //
     // INSTANCE VARIABLE METHODS
     //
-
-    boolean hasInstanceVariable(String name);
-    boolean fastHasInstanceVariable(String internedName);
     
-    IRubyObject getInstanceVariable(String name);
-    IRubyObject fastGetInstanceVariable(String internedName);
-    
-    IRubyObject setInstanceVariable(String name, IRubyObject value);
-    IRubyObject fastSetInstanceVariable(String internedName, IRubyObject 
value);
+    InstanceVariables getInstanceVariables();
 
-    IRubyObject removeInstanceVariable(String name);
-
-    List<Variable<IRubyObject>> getInstanceVariableList();
-
-    List<String> getInstanceVariableNameList();
-
     //
     // INTERNAL VARIABLE METHODS
     //
Index: src/org/jruby/runtime/builtin/InstanceVariables.java
===================================================================
--- src/org/jruby/runtime/builtin/InstanceVariables.java        (revision 0)
+++ src/org/jruby/runtime/builtin/InstanceVariables.java        (revision 0)
@@ -0,0 +1,33 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.jruby.runtime.builtin;
+
+import java.util.List;
+
+/**
+ *
+ * @author headius
+ */
+public interface InstanceVariables {
+    //
+    // INSTANCE VARIABLE METHODS
+    //
+
+    boolean hasInstanceVariable(String name);
+    boolean fastHasInstanceVariable(String internedName);
+    
+    IRubyObject getInstanceVariable(String name);
+    IRubyObject fastGetInstanceVariable(String internedName);
+    
+    IRubyObject setInstanceVariable(String name, IRubyObject value);
+    IRubyObject fastSetInstanceVariable(String internedName, IRubyObject 
value);
+
+    IRubyObject removeInstanceVariable(String name);
+
+    List<Variable<IRubyObject>> getInstanceVariableList();
+
+    List<String> getInstanceVariableNameList();
+}
Index: src/org/jruby/RubyYAML.java
===================================================================
--- src/org/jruby/RubyYAML.java (revision 5047)
+++ src/org/jruby/RubyYAML.java (working copy)
@@ -435,7 +435,7 @@
             return self.toString().indexOf('\0') != -1 ? 
self.getRuntime().getTrue() : self.getRuntime().getFalse();
         }
         private static org.jruby.yaml.JRubyRepresenter into(IRubyObject arg) {
-            IRubyObject jobj = arg.fastGetInstanceVariable("@java_object");
+            IRubyObject jobj = 
arg.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if(jobj != null) {
                 return 
(org.jruby.yaml.JRubyRepresenter)(((org.jruby.javasupport.JavaObject)jobj).getValue());
             }
Index: src/org/jruby/ext/Generator.java
===================================================================
--- src/org/jruby/ext/Generator.java    (revision 5047)
+++ src/org/jruby/ext/Generator.java    (working copy)
@@ -227,8 +227,8 @@
         // Generator#initialize
         GeneratorData d = (GeneratorData)self.dataGetStruct();
         
-        self.setInstanceVariable("@queue",self.getRuntime().newArray());
-        self.setInstanceVariable("@index",self.getRuntime().newFixnum(0));
+        
self.getInstanceVariables().setInstanceVariable("@queue",self.getRuntime().newArray());
+        
self.getInstanceVariables().setInstanceVariable("@index",self.getRuntime().newFixnum(0));
         
         if(Arity.checkArgumentCount(self.getRuntime(), args,0,1) == 1) {
             d.setEnum(args[0]);
@@ -240,7 +240,7 @@
 
     public static IRubyObject yield(IRubyObject self, IRubyObject value, Block 
block) {
         // Generator#yield
-        
self.getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"<<",value);
+        
self.getInstanceVariables().getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"<<",value);
         GeneratorData d = (GeneratorData)self.dataGetStruct();
         d.doWait();
         return self;
@@ -260,7 +260,7 @@
 
     public static IRubyObject index(IRubyObject self) {
         // Generator#index
-        return self.getInstanceVariable("@index");
+        return self.getInstanceVariables().getInstanceVariable("@index");
     }
 
     public static IRubyObject next(IRubyObject self, Block block) {
@@ -270,25 +270,25 @@
             throw self.getRuntime().newEOFError();
         }
         d.generate();
-        
self.setInstanceVariable("@index",self.getInstanceVariable("@index").callMethod(self.getRuntime().getCurrentContext(),MethodIndex.OP_PLUS,
 "+",self.getRuntime().newFixnum(1)));
-        return 
self.getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"shift");
+        
self.getInstanceVariables().setInstanceVariable("@index",self.getInstanceVariables().getInstanceVariable("@index").callMethod(self.getRuntime().getCurrentContext(),MethodIndex.OP_PLUS,
 "+",self.getRuntime().newFixnum(1)));
+        return 
self.getInstanceVariables().getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"shift");
     }
 
     public static IRubyObject current(IRubyObject self, Block block) {
             // Generator#current
-        
if(self.getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),MethodIndex.EMPTY_P,
 "empty?").isTrue()) {
+        
if(self.getInstanceVariables().getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),MethodIndex.EMPTY_P,
 "empty?").isTrue()) {
             throw self.getRuntime().newEOFError();
         }
-        return 
self.getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"first");
+        return 
self.getInstanceVariables().getInstanceVariable("@queue").callMethod(self.getRuntime().getCurrentContext(),"first");
     }
 
     public static IRubyObject rewind(IRubyObject self, Block block) {
         // Generator#rewind
-        
if(self.getInstanceVariable("@index").callMethod(self.getRuntime().getCurrentContext(),"nonzero?").isTrue())
 {
+        
if(self.getInstanceVariables().getInstanceVariable("@index").callMethod(self.getRuntime().getCurrentContext(),"nonzero?").isTrue())
 {
             GeneratorData d = (GeneratorData)self.dataGetStruct();
 
-            self.setInstanceVariable("@queue",self.getRuntime().newArray());
-            self.setInstanceVariable("@index",self.getRuntime().newFixnum(0));
+            
self.getInstanceVariables().setInstanceVariable("@queue",self.getRuntime().newArray());
+            
self.getInstanceVariables().setInstanceVariable("@index",self.getRuntime().newFixnum(0));
             
             d.start();
         }
Index: src/org/jruby/evaluator/AssignmentVisitor.java
===================================================================
--- src/org/jruby/evaluator/AssignmentVisitor.java      (revision 5047)
+++ src/org/jruby/evaluator/AssignmentVisitor.java      (working copy)
@@ -181,7 +181,7 @@
 
     private static void instAsgnNode(IRubyObject self, Node node, IRubyObject 
value) {
         InstAsgnNode iVisited = (InstAsgnNode)node;
-        self.fastSetInstanceVariable(iVisited.getName(), value);
+        
self.getInstanceVariables().fastSetInstanceVariable(iVisited.getName(), value);
     }
 
     private static void localAsgnNode(ThreadContext context, Node node, 
IRubyObject value) {
Index: src/org/jruby/evaluator/ASTInterpreter.java
===================================================================
--- src/org/jruby/evaluator/ASTInterpreter.java (revision 5047)
+++ src/org/jruby/evaluator/ASTInterpreter.java (working copy)
@@ -1229,14 +1229,14 @@
         InstAsgnNode iVisited = (InstAsgnNode) node;
    
         IRubyObject result = evalInternal(runtime,context, 
iVisited.getValueNode(), self, aBlock);
-        self.fastSetInstanceVariable(iVisited.getName(), result);
+        
self.getInstanceVariables().fastSetInstanceVariable(iVisited.getName(), result);
    
         return result;
     }
 
     private static IRubyObject instVarNode(Ruby runtime, Node node, 
IRubyObject self) {
         InstVarNode iVisited = (InstVarNode) node;
-        IRubyObject variable = 
self.fastGetInstanceVariable(iVisited.getName());
+        IRubyObject variable = 
self.getInstanceVariables().fastGetInstanceVariable(iVisited.getName());
    
         if (variable != null) return variable;
         
@@ -2060,7 +2060,7 @@
             }
             return null;
         case INSTVARNODE:
-            if (self.fastHasInstanceVariable(((InstVarNode) node).getName())) {
+            if 
(self.getInstanceVariables().fastHasInstanceVariable(((InstVarNode) 
node).getName())) {
                 return "instance-variable";
             }
             return null;
Index: src/org/jruby/RubyJRuby.java
===================================================================
--- src/org/jruby/RubyJRuby.java        (revision 5047)
+++ src/org/jruby/RubyJRuby.java        (working copy)
@@ -29,6 +29,8 @@
 package org.jruby;
 
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import org.jruby.anno.JRubyMethod;
 
 import org.jruby.javasupport.Java;
@@ -46,6 +48,7 @@
 import org.jruby.compiler.impl.StandardASMCompiler;
 import org.jruby.runtime.InterpretedBlock;
 import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.util.TraceClassVisitor;
 
 /**
  * Module which defines JRuby-specific methods for use. 
@@ -174,19 +177,19 @@
     public static class JRubyCompiledScript {
         @JRubyMethod(name = "to_s")
         public static IRubyObject compiled_script_to_s(IRubyObject recv) {
-            return recv.fastGetInstanceVariable("@original_script");
+            return 
recv.getInstanceVariables().fastGetInstanceVariable("@original_script");
         }
 
         @JRubyMethod(name = "inspect")
         public static IRubyObject compiled_script_inspect(IRubyObject recv) {
-            return recv.getRuntime().newString("#<JRuby::CompiledScript " + 
recv.fastGetInstanceVariable("@name") + ">");
+            return recv.getRuntime().newString("#<JRuby::CompiledScript " + 
recv.getInstanceVariables().fastGetInstanceVariable("@name") + ">");
         }
 
         @JRubyMethod(name = "inspect_bytecode")
         public static IRubyObject compiled_script_inspect_bytecode(IRubyObject 
recv) {
-            java.io.StringWriter sw = new java.io.StringWriter();
-            org.objectweb.asm.ClassReader cr = new 
org.objectweb.asm.ClassReader((byte[])org.jruby.javasupport.JavaUtil.convertRubyToJava(recv.fastGetInstanceVariable("@code"),byte[].class));
-            org.objectweb.asm.util.TraceClassVisitor cv = new 
org.objectweb.asm.util.TraceClassVisitor(new java.io.PrintWriter(sw));
+            StringWriter sw = new StringWriter();
+            ClassReader cr = new 
ClassReader((byte[])org.jruby.javasupport.JavaUtil.convertRubyToJava(recv.getInstanceVariables().fastGetInstanceVariable("@code"),byte[].class));
+            TraceClassVisitor cv = new TraceClassVisitor(new PrintWriter(sw));
             cr.accept(cv, ClassReader.SKIP_DEBUG);
             return recv.getRuntime().newString(sw.toString());
         }
Index: src/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java
===================================================================
--- src/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java      
(revision 5047)
+++ src/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java      
(working copy)
@@ -83,7 +83,7 @@
 
     public IRubyObject op_equal(IRubyObject other) {
         if (!(other instanceof JavaProxyReflectionObject)) {
-            other = other.fastGetInstanceVariable("@java_object");
+            other = 
other.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if (!(other instanceof JavaObject)) {
                 return getRuntime().getFalse();
             }
@@ -107,7 +107,7 @@
     
     public IRubyObject same(IRubyObject other) {
         if (!(other instanceof JavaObject)) {
-            other = other.fastGetInstanceVariable("@java_object");
+            other = 
other.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if (!(other instanceof JavaObject)) {
                 return getRuntime().getFalse();
             }
Index: src/org/jruby/javasupport/proxy/JavaProxyClass.java
===================================================================
--- src/org/jruby/javasupport/proxy/JavaProxyClass.java (revision 5047)
+++ src/org/jruby/javasupport/proxy/JavaProxyClass.java (working copy)
@@ -547,14 +547,14 @@
                 if (skipRemainingClasses) continue;
                 // we only collect methods and interfaces for 
                 // user-defined proxy classes.
-                if (!ancestor.fastHasInstanceVariable("@java_proxy_class")) {
+                if 
(!ancestor.getInstanceVariables().fastHasInstanceVariable("@java_proxy_class")) 
{
                     skipRemainingClasses = true;
                     continue;
                 }
 
                 // get JavaClass if this is the new proxy class; verify it
                 // matches if this is a superclass proxy.
-                IRubyObject var = 
ancestor.fastGetInstanceVariable("@java_class");
+                IRubyObject var = 
ancestor.getInstanceVariables().fastGetInstanceVariable("@java_class");
                 if (var == null) {
                     throw runtime.newTypeError(
                             "no java_class defined for proxy (or ancestor): " 
+ ancestor);
@@ -572,7 +572,7 @@
                             " (" + var + ")");
                 }
                 // get any included interfaces
-                var = ancestor.fastGetInstanceVariable("@java_interfaces");
+                var = 
ancestor.getInstanceVariables().fastGetInstanceVariable("@java_interfaces");
                 if (var != null && !(var instanceof RubyNil)) {
                     if (!(var instanceof RubyArray)) {
                         throw runtime.newTypeError(
@@ -605,7 +605,7 @@
                 
                 // FIXME: shouldn't need @__java_ovrd_methods, just query 
locally defined methods.
                 
-                var = ancestor.fastGetInstanceVariable("@__java_ovrd_methods");
+                var = 
ancestor.getInstanceVariables().fastGetInstanceVariable("@__java_ovrd_methods");
                 if (var == null) {
                     // lock in the overridden methods for the new class, and 
any as-yet
                     // uninstantiated ancestor class.
Index: src/org/jruby/javasupport/JavaClass.java
===================================================================
--- src/org/jruby/javasupport/JavaClass.java    (revision 5047)
+++ src/org/jruby/javasupport/JavaClass.java    (working copy)
@@ -234,7 +234,7 @@
                 javaField = new JavaField(getRuntime(),field);
             }
             return Java.java_to_ruby(self,
-                    
javaField.value(self.fastGetInstanceVariable("@java_object")),
+                    
javaField.value(self.getInstanceVariables().fastGetInstanceVariable("@java_object")),
                     Block.NULL_BLOCK);
         }
         public Arity getArity() {
@@ -256,7 +256,7 @@
                 javaField = new JavaField(getRuntime(),field);
             }
             return Java.java_to_ruby(self,
-                    
javaField.set_value(self.fastGetInstanceVariable("@java_object"),
+                    
javaField.set_value(self.getInstanceVariables().fastGetInstanceVariable("@java_object"),
                             Java.ruby_to_java(self,args[0],Block.NULL_BLOCK)),
                     Block.NULL_BLOCK);
         }
@@ -416,7 +416,7 @@
                 args = newArgs;
             }
             IRubyObject[] convertedArgs = new IRubyObject[len+1];
-            convertedArgs[0] = self.fastGetInstanceVariable("@java_object");
+            convertedArgs[0] = 
self.getInstanceVariables().fastGetInstanceVariable("@java_object");
             int i = len;
             if (block.isGiven()) {
                 convertedArgs[len] = args[len - 1];
Index: src/org/jruby/javasupport/JavaObject.java
===================================================================
--- src/org/jruby/javasupport/JavaObject.java   (revision 5047)
+++ src/org/jruby/javasupport/JavaObject.java   (working copy)
@@ -136,7 +136,7 @@
 
     public IRubyObject op_equal(IRubyObject other) {
         if (!(other instanceof JavaObject)) {
-            other = other.fastGetInstanceVariable("@java_object");
+            other = 
other.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if (!(other instanceof JavaObject)) {
                 return getRuntime().getFalse();
             }
@@ -152,7 +152,7 @@
     
     public IRubyObject same(IRubyObject other) {
         if (!(other instanceof JavaObject)) {
-            other = other.fastGetInstanceVariable("@java_object");
+            other = 
other.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if (!(other instanceof JavaObject)) {
               return getRuntime().getFalse();
             }
Index: src/org/jruby/javasupport/JavaArrayUtilities.java
===================================================================
--- src/org/jruby/javasupport/JavaArrayUtilities.java   (revision 5047)
+++ src/org/jruby/javasupport/JavaArrayUtilities.java   (working copy)
@@ -51,7 +51,7 @@
     
     public static IRubyObject bytes_to_ruby_string(IRubyObject recv, 
IRubyObject wrappedObject) {
         Ruby runtime = recv.getRuntime();
-        IRubyObject byteArray = 
wrappedObject.fastGetInstanceVariable("@java_object");
+        IRubyObject byteArray = 
wrappedObject.getInstanceVariables().fastGetInstanceVariable("@java_object");
         if (!(byteArray instanceof JavaArray &&
                 ((JavaArray)byteArray).getValue() instanceof byte[])) {
             throw runtime.newTypeError("wrong argument type " + 
wrappedObject.getMetaClass() +
Index: src/org/jruby/javasupport/Java.java
===================================================================
--- src/org/jruby/javasupport/Java.java (revision 5047)
+++ src/org/jruby/javasupport/Java.java (working copy)
@@ -125,7 +125,7 @@
             }
             final IRubyObject packageName;
             // again, shouldn't happen. TODO: might want to throw exception 
instead.
-            if ((packageName = pkg.fastGetInstanceVariable("@package_name")) 
== null) return null;
+            if ((packageName = 
pkg.getInstanceVariables().fastGetInstanceVariable("@package_name")) == null) 
return null;
 
             final Ruby runtime = pkg.getRuntime();
             return (RubyClass)get_proxy_class(
@@ -136,7 +136,7 @@
         public RubyModule defineModuleUnder(final RubyModule pkg, final String 
name) {
             final IRubyObject packageName;
             // again, shouldn't happen. TODO: might want to throw exception 
instead.
-            if ((packageName = pkg.fastGetInstanceVariable("@package_name")) 
== null) return null;
+            if ((packageName = 
pkg.getInstanceVariables().fastGetInstanceVariable("@package_name")) == null) 
return null;
 
             final Ruby runtime = pkg.getRuntime();
             return (RubyModule)get_interface_module(
@@ -148,13 +148,13 @@
     // JavaProxy
     public static IRubyObject new_instance_for(IRubyObject recv, IRubyObject 
java_object) {
         IRubyObject new_instance = ((RubyClass)recv).allocate();
-        new_instance.fastSetInstanceVariable("@java_object",java_object);
+        
new_instance.getInstanceVariables().fastSetInstanceVariable("@java_object",java_object);
         return new_instance;
     }
 
     // If the proxy class itself is passed as a parameter this will be called 
by Java#ruby_to_java    
     public static IRubyObject to_java_object(IRubyObject recv) {
-        return recv.fastGetInstanceVariable("@java_class");
+        return 
recv.getInstanceVariables().fastGetInstanceVariable("@java_class");
     }
 
     // JavaUtilities
@@ -168,7 +168,7 @@
         // hacky workaround in case any users call this directly.
         // most will have called JavaUtilities.extend_proxy instead.
         recv.getRuntime().getWarnings().warn("JavaUtilities.add_proxy_extender 
is deprecated - use JavaUtilities.extend_proxy instead");
-        final IRubyObject javaClassVar = 
extender.fastGetInstanceVariable("@java_class");
+        final IRubyObject javaClassVar = 
extender.getInstanceVariables().fastGetInstanceVariable("@java_class");
         if (!(javaClassVar instanceof JavaClass)) {
             throw recv.getRuntime().newArgumentError("extender does not have a 
valid @java_class");
         }
@@ -738,7 +738,7 @@
      */
     public static IRubyObject ruby_to_java(final IRubyObject recv, IRubyObject 
object, Block unusedBlock) {
        if(object.respondsTo("to_java_object")) {
-            IRubyObject result = 
object.fastGetInstanceVariable("@java_object");
+            IRubyObject result = 
object.getInstanceVariables().fastGetInstanceVariable("@java_object");
             if(result == null) {
                 result = 
object.callMethod(recv.getRuntime().getCurrentContext(), "to_java_object");
             }
Index: src/org/jruby/javasupport/util/RuntimeHelpers.java
===================================================================
--- src/org/jruby/javasupport/util/RuntimeHelpers.java  (revision 5047)
+++ src/org/jruby/javasupport/util/RuntimeHelpers.java  (working copy)
@@ -788,7 +788,7 @@
     }
     
     public static IRubyObject getInstanceVariable(Ruby runtime, IRubyObject 
self, String name) {
-        IRubyObject result = self.getInstanceVariable(name);
+        IRubyObject result = 
self.getInstanceVariables().getInstanceVariable(name);
         
         if (result != null) return result;
         
@@ -799,7 +799,7 @@
     
     public static IRubyObject fastGetInstanceVariable(Ruby runtime, 
IRubyObject self, String internedName) {
         IRubyObject result;
-        if ((result = self.fastGetInstanceVariable(internedName)) != null) 
return result;
+        if ((result = 
self.getInstanceVariables().fastGetInstanceVariable(internedName)) != null) 
return result;
         
         runtime.getWarnings().warning("instance variable " + internedName + " 
not initialized");
         
Index: src/org/jruby/RubyObject.java
===================================================================
--- src/org/jruby/RubyObject.java       (revision 5047)
+++ src/org/jruby/RubyObject.java       (working copy)
@@ -68,6 +68,7 @@
 import org.jruby.javasupport.util.RuntimeHelpers;
 import org.jruby.runtime.ClassIndex;
 import org.jruby.runtime.MethodIndex;
+import org.jruby.runtime.builtin.InstanceVariables;
 import org.jruby.runtime.marshal.CoreObjectType;
 import org.jruby.util.TypeConverter;
 
@@ -75,7 +76,7 @@
  *
  * @author  jpetersen
  */
-public class RubyObject implements Cloneable, IRubyObject, Serializable, 
CoreObjectType {
+public class RubyObject implements Cloneable, IRubyObject, Serializable, 
CoreObjectType, InstanceVariables {
     
     private RubyObject(){};
     // An instance that never equals any other instance
@@ -1260,6 +1261,10 @@
     // INSTANCE VARIABLE API METHODS
     //
     
+    public InstanceVariables getInstanceVariables() {
+        return this;
+    }
+    
     public boolean hasInstanceVariable(String name) {
         assert IdUtil.isInstanceVariable(name);
         return variableTableContains(name);
@@ -1782,7 +1787,7 @@
         out.writeInt(names.size());
         for (String name : names) {
             out.writeObject(name);
-            out.writeObject(getInstanceVariable(name));
+            out.writeObject(getInstanceVariables().getInstanceVariable(name));
         }
     }
 
Index: src/org/jruby/RubyModule.java
===================================================================
--- src/org/jruby/RubyModule.java       (revision 5047)
+++ src/org/jruby/RubyModule.java       (working copy)
@@ -946,7 +946,7 @@
                 public IRubyObject call(ThreadContext context, IRubyObject 
self, RubyModule clazz, String name, IRubyObject[] args, Block block) {
                     if (args.length != 0) Arity.raiseArgumentError(runtime, 
args.length, 0, 0);
 
-                    IRubyObject variable = 
self.fastGetInstanceVariable(variableName);
+                    IRubyObject variable = 
self.getInstanceVariables().fastGetInstanceVariable(variableName);
 
                     return variable == null ? runtime.getNil() : variable;
                 }
@@ -965,7 +965,7 @@
                     // ENEBO: Can anyone get args to be anything but length 1?
                     if (args.length != 1) Arity.raiseArgumentError(runtime, 
args.length, 1, 1);
 
-                    return self.fastSetInstanceVariable(variableName, args[0]);
+                    return 
self.getInstanceVariables().fastSetInstanceVariable(variableName, args[0]);
                 }
 
                 public Arity getArity() {
Index: src/org/jruby/compiler/impl/StandardASMCompiler.java
===================================================================
--- src/org/jruby/compiler/impl/StandardASMCompiler.java        (revision 5047)
+++ src/org/jruby/compiler/impl/StandardASMCompiler.java        (working copy)
@@ -84,15 +84,14 @@
 import org.jruby.runtime.CallSite;
 import org.jruby.runtime.CallType;
 import org.jruby.runtime.CallbackFactory;
-import org.jruby.runtime.CompiledBlock;
 import org.jruby.runtime.CompiledBlockCallback;
-import org.jruby.runtime.CompiledSharedScopeBlock;
 import org.jruby.runtime.DynamicScope;
 import org.jruby.runtime.Frame;
 import org.jruby.runtime.MethodIndex;
 import org.jruby.runtime.ThreadContext;
 import org.jruby.runtime.Visibility;
 import org.jruby.runtime.builtin.IRubyObject;
+import org.jruby.runtime.builtin.InstanceVariables;
 import org.jruby.util.ByteList;
 import org.jruby.util.CodegenUtils;
 import org.jruby.util.JRubyClassLoader;
@@ -1185,7 +1184,8 @@
             method.ldc(name);
             method.swap();
 
-            invokeIRubyObject("fastSetInstanceVariable", 
cg.sig(IRubyObject.class, cg.params(String.class, IRubyObject.class)));
+            invokeIRubyObject("getInstanceVariables", 
cg.sig(InstanceVariables.class));
+            method.invokeinterface(cg.p(InstanceVariables.class), 
"fastSetInstanceVariable", cg.sig(IRubyObject.class, cg.params(String.class, 
IRubyObject.class)));
         }
 
         public void retrieveGlobalVariable(String name) {
@@ -1791,9 +1791,10 @@
         
         public void isInstanceVariableDefined(String name, BranchCallback 
trueBranch, BranchCallback falseBranch) {
             loadSelf();
+            invokeIRubyObject("getInstanceVariables", 
cg.sig(InstanceVariables.class));
             method.ldc(name);
             //method.invokeinterface(cg.p(IRubyObject.class), 
"getInstanceVariable", cg.sig(IRubyObject.class, cg.params(String.class)));
-            method.invokeinterface(cg.p(IRubyObject.class), 
"fastHasInstanceVariable", cg.sig(boolean.class, cg.params(String.class)));
+            method.invokeinterface(cg.p(InstanceVariables.class), 
"fastHasInstanceVariable", cg.sig(boolean.class, cg.params(String.class)));
             Label trueLabel = new Label();
             Label exitLabel = new Label();
             //method.ifnonnull(trueLabel);
@@ -1972,7 +1973,8 @@
         
         public void getInstanceVariable(String name) {
             method.ldc(name);
-            method.invokeinterface(cg.p(IRubyObject.class), 
"fastGetInstanceVariable", cg.sig(IRubyObject.class, cg.params(String.class)));
+            invokeIRubyObject("getInstanceVariables", 
cg.sig(InstanceVariables.class));
+            method.invokeinterface(cg.p(InstanceVariables.class), 
"fastGetInstanceVariable", cg.sig(IRubyObject.class, cg.params(String.class)));
         }
         
         public void getFrameName() {
Index: src/org/jruby/ast/executable/YARVMachine.java
===================================================================
--- src/org/jruby/ast/executable/YARVMachine.java       (revision 5047)
+++ src/org/jruby/ast/executable/YARVMachine.java       (working copy)
@@ -285,10 +285,10 @@
                 context.getCurrentScope().setValue((int) bytecodes[ip].l_op0, 
pop(), 0);
                 break;
             case YARVInstructions.GETINSTANCEVARIABLE:
-                push(self.fastGetInstanceVariable(bytecodes[ip].s_op0));
+                
push(self.getInstanceVariables().fastGetInstanceVariable(bytecodes[ip].s_op0));
                 break;
             case YARVInstructions.SETINSTANCEVARIABLE:
-                self.fastSetInstanceVariable(bytecodes[ip].s_op0, pop());
+                
self.getInstanceVariables().fastSetInstanceVariable(bytecodes[ip].s_op0, pop());
                 break;
             case YARVInstructions.GETCLASSVARIABLE: {
                 RubyModule rubyClass = context.getRubyClass();

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to