db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: Code generation into multiple methods to avoid 64k code limit
Date Thu, 16 Feb 2006 18:04:11 GMT
Daniel John Debrunner wrote:

> <long post on improvements in Derby's code generation snipped>

An update on this topic, I'll do next step in another e-mail.

I committed changes that splits a large generated method into
sub-methods to avoid the 64k jvm code limit. The only split alogirthm is
the "zero stack" one, which corresponds in Java language terms to a
splitting a number of statements into a sub method.

This change showed the generalized approach is working as it bumped the
limit of one of the queries in largeCodeGen.java test from 3,400
parameters to 98,000 parameters, yes ninety eight thousand!

The quick summary is (see CodeChunk.java for more details) the byte code
compiler walks the generated byte code from a starting program counter
(pc) (initially zero) and tracks pc's where the stack drops back to
zero. If the size of the code block from the starting pc to the current
pc is suitable for spliting it moves the block of code into a sub-method
and sets up the original method to call it. This process repeats until
no more splits are possible or the original method has dropped below
64k. The starting pc is moved after each split to avoid pushing the
calls to the sub-methods into sub-methods themselves. This stops deep
stack nesting.

For example, this is the kind of split that occurs, written as a Java
language.

   public void bigMethod()
   {
      a();
      b(3);
      c(d());
      f = e();
      ...
   }

to

   public void bigMethod()
   {
      bigMethod_s1();
      f = e();
      ...
   }

   private void bigMethod_s1()
   {
      a();
      b(3);
      c(d());
   }

I testing the change running derbyall with the split point set to 2,000
rather than the 64k limit. This exercised the code, though only about 9
tests hit splits, in some cases splitting a 50k method into around 25
sub-methods.

Dan.


Mime
View raw message