Permalink
Browse files

Make RubyClass.allocate be a fast method since it does not ever pass …

…a around a block or do a calMethod

git-svn-id: http://svn.codehaus.org/jruby/branches/enebo_block@2844 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
enebo committed Jan 26, 2007
1 parent bc682bc commit 667e851eb2e81a05f3f78e403e1ba027cfdd8fd6
@@ -148,7 +148,7 @@ public RubyBigDecimal(IRuby runtime, BigDecimal value) {
public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
RubyClass klass = (RubyClass)recv;
- RubyBigDecimal result = (RubyBigDecimal)klass.allocate(null);
+ RubyBigDecimal result = (RubyBigDecimal) klass.allocate();
result.callInit(args, unusedBlock);
@@ -81,8 +81,7 @@ protected RubyClass(IRuby runtime, RubyClass metaClass, RubyClass superClass, Ob
this.runtime = runtime;
}
- // ENEBO: We only have block in cases like this because we set up other stuff in TC
- public final IRubyObject allocate(Block unusedBlock) {
+ public final IRubyObject allocate() {
return getAllocator().allocate(getRuntime(), this);
}
@@ -123,7 +122,7 @@ public boolean isClass() {
public static void createClassClass(RubyClass classClass) {
CallbackFactory callbackFactory = classClass.getRuntime().callbackFactory(RubyClass.class);
classClass.defineSingletonMethod("new", callbackFactory.getOptSingletonMethod("newClass"));
- classClass.defineMethod("allocate", callbackFactory.getMethod("allocate"));
+ classClass.defineFastMethod("allocate", callbackFactory.getFastMethod("allocate"));
classClass.defineMethod("new", callbackFactory.getOptMethod("newInstance"));
classClass.defineMethod("superclass", callbackFactory.getMethod("superclass"));
classClass.defineSingletonMethod("inherited", callbackFactory.getSingletonMethod("inherited", IRubyObject.class));
@@ -203,7 +202,7 @@ protected RubyClass subclass() {
*
*/
public IRubyObject newInstance(IRubyObject[] args, Block block) {
- IRubyObject obj = (IRubyObject) allocate(null);
+ IRubyObject obj = (IRubyObject) allocate();
obj.callInit(args, block);
return obj;
}
@@ -119,7 +119,7 @@ public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args) {
RubyClass klass = (RubyClass)recv;
- Base result = (Base)klass.allocate(null);
+ Base result = (Base) klass.allocate();
try {
result.setAlgorithm(((RubyClass)recv).getClassVar("metadata"));
} catch(NoSuchAlgorithmException e) {
@@ -242,8 +242,7 @@ private RubyEnumeratorStub0(RubyClass enumeratorClass,
public IRubyObject method0(ThreadContext tc, IRubyObject self, IRubyObject[] args, Block block) {
RubyClass klass = (RubyClass)self;
- // ENEBO: Enumerator new not block capable?
- RubyEnumerator result = (RubyEnumerator) klass.allocate(null);
+ RubyEnumerator result = (RubyEnumerator) klass.allocate();
result.callInit(args, block);
@@ -76,7 +76,7 @@ public RubyNameError(IRuby runtime, RubyClass exceptionClass, String message, St
public static RubyNameError newRubyNameError(IRubyObject recv, IRubyObject[] args) {
RubyClass klass = (RubyClass)recv;
- RubyNameError newError = (RubyNameError)klass.allocate(null);
+ RubyNameError newError = (RubyNameError) klass.allocate();
newError.callInit(args, null);
@@ -176,7 +176,7 @@ public static RubyRegexp newRegexp(IRuby runtime, String str, int options, Strin
public static RubyRegexp newInstance(IRubyObject recv, IRubyObject[] args) {
RubyClass klass = (RubyClass)recv;
- RubyRegexp re = (RubyRegexp)klass.allocate(null);
+ RubyRegexp re = (RubyRegexp) klass.allocate();
re.callInit(args, null);
@@ -627,7 +627,7 @@ public IRubyObject allocate(IRuby runtime, RubyClass klass) {
public static RubyGzipFile newInstance(IRubyObject recv, Block block) {
RubyClass klass = (RubyClass)recv;
- RubyGzipFile result = (RubyGzipFile)klass.allocate(null);
+ RubyGzipFile result = (RubyGzipFile) klass.allocate();
result.callInit(new IRubyObject[0], block);
@@ -715,7 +715,7 @@ public IRubyObject allocate(IRuby runtime, RubyClass klass) {
private static RubyGzipReader newInstance(IRubyObject recv, IRubyObject[] args, Block block) {
RubyClass klass = (RubyClass)recv;
- RubyGzipReader result = (RubyGzipReader)klass.allocate(null);
+ RubyGzipReader result = (RubyGzipReader)klass.allocate();
result.callInit(args, block);
return result;
}
@@ -936,7 +936,7 @@ public IRubyObject allocate(IRuby runtime, RubyClass klass) {
private static RubyGzipWriter newGzipWriter(IRubyObject recv, IRubyObject[] args, Block block) {
RubyClass klass = (RubyClass)recv;
- RubyGzipWriter result = (RubyGzipWriter)klass.allocate(null);
+ RubyGzipWriter result = (RubyGzipWriter)klass.allocate();
result.callInit(args, block);
return result;
}
@@ -90,7 +90,7 @@ private static String transformDigest(String inp) {
}
public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Block block) {
- Digest result = (Digest)((RubyClass)recv).allocate(null);
+ Digest result = (Digest) ((RubyClass) recv).allocate();
if(!(recv.toString().equals("OpenSSL::Digest::Digest"))) {
try {
result.name = recv.toString();
@@ -147,8 +147,7 @@ public IRubyObject allocate(IRuby runtime, RubyClass klass) {
};
public static IRubyObject create(IRubyObject klass, IRubyObject[] args, Block block) {
- // FIXME: Why is this calling newArray directly instead of the normal newInstance process? Performance?
- RubyArray array = (RubyArray)((RubyClass)klass).allocate(null);
+ RubyArray array = (RubyArray) ((RubyClass) klass).allocate();
array.callInit(IRubyObject.NULL_ARRAY, block);
if (args.length >= 1) {
@@ -106,7 +106,7 @@ public IRubyObject allocate(IRuby runtime, RubyClass klass) {
};
public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Block block) {
- RubyHash hash = (RubyHash)((RubyClass)recv).allocate(null);
+ RubyHash hash = (RubyHash) ((RubyClass) recv).allocate();
hash.callInit(args, block);
@@ -115,8 +115,8 @@ public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Bloc
public static IRubyObject create(IRubyObject recv, IRubyObject[] args, Block block) {
IRuby runtime = recv.getRuntime();
- RubyClass klass = (RubyClass)recv;
- RubyHash hash = (RubyHash)klass.allocate(null);
+ RubyClass klass = (RubyClass) recv;
+ RubyHash hash = (RubyHash) klass.allocate();
if (args.length == 1) {
hash.setValueMap(new HashMap(((RubyHash) args[0]).getValueMap()));
@@ -68,7 +68,7 @@ protected Meta getMeta() {
* this case, we need to check previous frame for a block to consume.
*/
public IRubyObject newInstance(IRubyObject[] args, Block block) {
- IRubyObject obj = (IRubyObject) allocate(null);
+ IRubyObject obj = (IRubyObject) allocate();
// No passed in block, lets check next outer frame for one ('Proc.new')
if (block == null) {
@@ -28,7 +28,6 @@
package org.jruby.runtime.callback;
import org.jruby.IRuby;
-import org.jruby.util.JRubyClassLoader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

0 comments on commit 667e851

Please sign in to comment.