|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ bytecode overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.services.bytecode
Class BCMethod

java.lang.Objectorg.apache.derby.impl.services.bytecode.BCMethod
- All Implemented Interfaces:
- org.apache.derby.iapi.services.compiler.MethodBuilder
- public class BCMethod
- extends java.lang.Object
- implements org.apache.derby.iapi.services.compiler.MethodBuilder
- extends java.lang.Object
MethodBuilder is used to piece together a method when building a java class definition.
When a method is first created, it has:
- a return type
- modifiers
- a name
- an empty parameter list
- an empty throws list
- an empty statement block
MethodBuilder implementations are required to supply a way for Statements and Expressions to give them code. Most typically, they may have a stream to which their contents writes the code that is of the type to satisfy what the contents represent. MethodBuilder implementations also have to have a way to supply ClassBuilders with their code, that satisfies the type of class builder they are implemented with. This is implementation-dependent, so ClassBuilders, MethodBuilders, Statements, and Expressions all have to be of the same implementation in order to interact to generate a class.
Method Builder implementation for generating bytecode.
| Field Summary | |
(package private) BCClass |
cb
|
private Conditional |
condition
|
private int |
currentVarNum
|
private boolean |
handlingOverflow
True if we are currently switching control over to a sub method to avoid hitting the code generation limit of 65535 bytes per method. |
private int |
maxStack
|
protected org.apache.derby.iapi.services.classfile.ClassHolder |
modClass
|
(package private) CodeChunk |
myCode
|
protected org.apache.derby.iapi.services.classfile.ClassMember |
myEntry
|
private java.lang.String |
myName
The original name of the method, this represents how any user would call this method. |
private java.lang.String |
myReturnType
|
private static byte[] |
newArrayElementTypeMap
this array maps the BCExpr vm_* constants 0..6 to the expected VM type constants for the newarray instruction. |
protected BCLocalField[] |
parameters
|
private int |
stackDepth
|
private int |
stackTypeOffset
|
private Type[] |
stackTypes
|
private int |
statementNum
|
private int |
subMethodCount
How many sub-methods we have overflowed to. |
(package private) static byte |
T_BOOLEAN
|
protected java.util.Vector |
thrownExceptions
|
| Constructor Summary | |
(package private) |
BCMethod(org.apache.derby.iapi.services.compiler.ClassBuilder cb,
java.lang.String returnType,
java.lang.String methodName,
int modifiers,
java.lang.String[] parms,
BCJava factory)
|
| Method Summary | |
void |
addThrownException(java.lang.String exceptionClass)
a throwable can be added to the end of the list of thrownExceptions. |
int |
callMethod(java.lang.Object methodDescriptor)
Call a method previously described by describeMethod(). |
int |
callMethod(short opcode,
java.lang.String declaringClass,
java.lang.String methodName,
java.lang.String returnType,
int numArgs)
Call a method. |
void |
callSuper()
Call super(). |
void |
cast(java.lang.String className)
Cast the top stack value. |
void |
complete()
when the method has had all of its parameters and thrown exceptions defined, and its statement block has been completed, it can be completed and its class file information generated. |
void |
completeConditional()
Complete the a ?: operator which completes the false code path. |
void |
conditionalIf()
Initiate a sequence that corresponds to the Java language ' value ? ... |
private void |
conditionalIf(short opcode)
|
void |
conditionalIfNull()
Initiate a sequence that corresponds to the Java language 'ref == null ? ... |
(package private) org.apache.derby.iapi.services.classfile.ClassHolder |
constantPool()
In their giveCode methods, the parts of the method body will want to get to the constant pool to add their constants. |
java.lang.Object |
describeMethod(short opcode,
java.lang.String declaringClass,
java.lang.String methodName,
java.lang.String returnType)
Return an object that efficiently (to the implementation) describes a zero-argument method and can be used with the single argument callMethod(). |
void |
dup()
Duplicate the top value on the stack. |
void |
endStatement()
End a statement. |
void |
getArrayElement(int element)
Pop an array refrence off the stack and push an element from that array. |
void |
getField(org.apache.derby.iapi.services.compiler.LocalField field)
Push the contents of the local field onto the stack. |
private void |
getField(short opcode,
java.lang.String declaringClass,
java.lang.String fieldName,
java.lang.String fieldType)
|
void |
getField(java.lang.String declaringClass,
java.lang.String fieldName,
java.lang.String fieldType)
Push the contents of the described field onto the stack. |
java.lang.String |
getName()
Return the logical name of the method. |
void |
getParameter(int id)
Push a parameter value. |
void |
getStaticField(java.lang.String declaringClass,
java.lang.String fieldName,
java.lang.String fieldType)
Push the contents of the described static field onto the stack. |
private void |
growStack(int size,
Type type)
|
private void |
growStack(Type type)
|
void |
isInstanceOf(java.lang.String className)
Pop the top stack value and push a boolean that is the result of an instanceof check on the popped reference. |
void |
methodReturn()
Return from a method, optionally with a value. |
private void |
overflowMethodCheck()
Check to see if the current method byte code is nearing the limit of 65535. |
void |
pop()
Pop the top value off the stack |
private Type |
popStack()
|
void |
push(boolean value)
Push a boolean constant onto the stack |
void |
push(byte value)
Push a byte constant onto the stack |
void |
push(double value)
Push a double constant onto the stack |
void |
push(float value)
Push a float constant onto the stack |
void |
push(int value)
Push a int constant onto the stack |
private void |
push(int value,
Type type)
|
void |
push(long value)
Push a long constant onto the stack |
void |
push(short value)
Push a short constant onto the stack |
void |
push(java.lang.String value)
Push a String constant onto the stack |
void |
pushNewArray(java.lang.String className,
int size)
Create an array instance Stack ... |
void |
pushNewComplete(int numArgs)
Complete the sequence that was started with pushNewStart(). |
void |
pushNewStart(java.lang.String className)
Initiate a sequence that calls a constructor, equivalent to the new operator in Java. |
void |
pushNull(java.lang.String type)
Push a typed null onto the stack |
void |
pushThis()
Push this onto the stack. |
void |
putField(org.apache.derby.iapi.services.compiler.LocalField field)
Upon entry the top word(s) on the stack is the value to be put into the field. |
void |
putField(java.lang.String fieldName,
java.lang.String fieldType)
Pop the top stack value and store it in the instance field of this class. |
void |
putField(java.lang.String declaringClass,
java.lang.String fieldName,
java.lang.String fieldType)
Pop the top stack value and store it in the field. |
private void |
putField(Type fieldType,
int cpi,
boolean dup)
|
void |
setArrayElement(int element)
Pop an array reference off the stack, store a value in the array at the passed in offset. |
void |
setField(org.apache.derby.iapi.services.compiler.LocalField field)
Set the field but don't duplicate its value so nothing is left on the stack after this call. |
void |
startElseCode()
Complete the true code path of a ?: operator. |
boolean |
statementNumHitLimit(int noStatementsAdded)
Tell if statement number in this method builder hits limit. |
void |
swap()
Swap the top two values on the stack. |
void |
upCast(java.lang.String className)
Upcast the top stack value. |
private Type |
vmNameDeclaringClass(java.lang.String declaringClass)
|
protected void |
writeExceptions()
sets exceptionBytes to the attribute_info needed for a method's Exceptions attribute. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
cb
final BCClass cb
modClass
protected final org.apache.derby.iapi.services.classfile.ClassHolder modClass
myReturnType
private final java.lang.String myReturnType
myName
private final java.lang.String myName
- The original name of the method, this
represents how any user would call this method.
parameters
protected BCLocalField[] parameters
thrownExceptions
protected java.util.Vector thrownExceptions
myCode
CodeChunk myCode
myEntry
protected org.apache.derby.iapi.services.classfile.ClassMember myEntry
currentVarNum
private int currentVarNum
statementNum
private int statementNum
handlingOverflow
private boolean handlingOverflow
- True if we are currently switching control
over to a sub method to avoid hitting the code generation
limit of 65535 bytes per method.
subMethodCount
private int subMethodCount
- How many sub-methods we have overflowed to.
stackTypes
private Type[] stackTypes
stackTypeOffset
private int stackTypeOffset
maxStack
private int maxStack
stackDepth
private int stackDepth
condition
private Conditional condition
newArrayElementTypeMap
private static final byte[] newArrayElementTypeMap
- this array maps the BCExpr vm_* constants 0..6 to
the expected VM type constants for the newarray instruction.
Because boolean was mapped to integer for general instructions, it will have to be specially matched and mapped to its value directly (4).
T_BOOLEAN
static final byte T_BOOLEAN
- See Also:
- Constant Field Values
| Constructor Detail |
BCMethod
BCMethod(org.apache.derby.iapi.services.compiler.ClassBuilder cb, java.lang.String returnType, java.lang.String methodName, int modifiers, java.lang.String[] parms, BCJava factory)
| Method Detail |
getName
public java.lang.String getName()
- Return the logical name of the method. The current
myEntry refers to the sub method we are currently
overflowing to. Those sub-methods are hidden from any caller.
- Specified by:
getNamein interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getParameter
public void getParameter(int id)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a parameter value.
Stack ... => ...,param_value- Specified by:
getParameterin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
addThrownException
public void addThrownException(java.lang.String exceptionClass)
- a throwable can be added to the end of
the list of thrownExceptions.
- Specified by:
addThrownExceptionin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
complete
public void complete()
- when the method has had all of its parameters
and thrown exceptions defined, and its statement
block has been completed, it can be completed and
its class file information generated.
further alterations of the method will not be reflected in the code generated for it.
- Specified by:
completein interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
constantPool
org.apache.derby.iapi.services.classfile.ClassHolder constantPool()
- In their giveCode methods, the parts of the method body
will want to get to the constant pool to add their constants.
We really only want them treating it like a constant pool
inclusion mechanism, we could write a wrapper to limit it to that.
writeExceptions
protected void writeExceptions()
- sets exceptionBytes to the attribute_info needed
for a method's Exceptions attribute.
The ClassUtilities take care of the header 6 bytes for us,
so they are not included here.
See The Java Virtual Machine Specification Section 4.7.5,
Exceptions attribute.
growStack
private void growStack(int size,
Type type)
growStack
private void growStack(Type type)
popStack
private Type popStack()
pushThis
public void pushThis()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push this onto the stack.
Stack ... => ...,this_ref- Specified by:
pushThisin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(byte value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a byte constant onto the stack
Stack ... => ...,byte_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(boolean value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a boolean constant onto the stack
Stack ... => ...,boolean_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(short value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a short constant onto the stack
Stack ... => ...,short_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(int value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a int constant onto the stack
Stack ... => ...,int_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
dup
public void dup()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Duplicate the top value on the stack.
Stack ...,value => ...,value,value- Specified by:
dupin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
swap
public void swap()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Swap the top two values on the stack.
Stack ...,valueA,valueB => ...,valueB,valueA- Specified by:
swapin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
private void push(int value,
Type type)
push
public void push(long value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a long constant onto the stack
Stack ... => ...,long_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(float value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a float constant onto the stack
Stack ... => ...,float_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(double value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a double constant onto the stack
Stack ... => ...,double_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
push
public void push(java.lang.String value)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a String constant onto the stack
Stack ... => ...,String_value- Specified by:
pushin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
methodReturn
public void methodReturn()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Return from a method, optionally with a value.
Must only be called if zero or one item exists
on the stack. If the stack contains a single
value then that is popped and used as the returned value.
Stack value => :empty: or Stack :empty: => :empty:.- Specified by:
methodReturnin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
describeMethod
public java.lang.Object describeMethod(short opcode, java.lang.String declaringClass, java.lang.String methodName, java.lang.String returnType)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Return an object that efficiently (to the implementation) describes a zero-argument method and
can be used with the single argument callMethod(). Descriptions for the parameters to this
method are the same as the five argument callMethod(). This allows the caller to cache frequently
used methods. The returned object is only valid for use by this MethodBuilder.
This call does not affect the Stack.- Specified by:
describeMethodin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
callMethod
public int callMethod(java.lang.Object methodDescriptor)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Call a method previously described by describeMethod().
static methods Stack ...,value* => [numArgs number of values will be popped] ...,return_value [void methods will not push a value] non-static methods Stack ...,ref,value* => [numArgs number of values will be popped] ...,return_value [void methods will not push a value]- Specified by:
callMethodin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
callMethod
public int callMethod(short opcode,
java.lang.String declaringClass,
java.lang.String methodName,
java.lang.String returnType,
int numArgs)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Call a method. The instance (receiver or reference) for non-static methods
must be pushed by the caller. The instance (for non-static) and the arguments
are popped of the stack, and the return value (if any) is pushed onto the stack.
The type needs to be one of:- VMOpcode.INVOKESTATIC - call a static method
- VMOpcode.INVOKEVIRTUAL - call method declared in the class or super-class.
- VMOpcode.INVOKEINTERFACE - call a method declared in an interface
static methods Stack ...,value* => [numArgs number of values will be popped] ...,return_value [void methods will not push a value] non-static methods Stack ...,ref,value* => [numArgs number of values will be popped] ...,return_value [void methods will not push a value]
The type of the arguments to the methods must exactly match the declared types of the parameters to the methods. If a argument is of the incorrect type the caller must up cast it or down cast it.- Specified by:
callMethodin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
vmNameDeclaringClass
private Type vmNameDeclaringClass(java.lang.String declaringClass)
callSuper
public void callSuper()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Call super(). Caller must only add this to a constructor.
Stack ... => ...- Specified by:
callSuperin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
pushNewStart
public void pushNewStart(java.lang.String className)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Initiate a sequence that calls a constructor, equivalent to the new operator in Java.
After this call, the caller must push any arguments and then complete the
construction with a call to pushNewComplete(). Only arguments to the constructor
can be pushed onto the stack between the pushNewStart() and pushNewComplete() method
calls.
Stack ... => [unchanged] ...- Specified by:
pushNewStartin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
pushNewComplete
public void pushNewComplete(int numArgs)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Complete the sequence that was started with pushNewStart().
Pop the arguments to the constructor and push the reference
to the newly created object.
Stack ...,value* => [numArgs number of values will be popped] ...,new_ref- Specified by:
pushNewCompletein interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
upCast
public void upCast(java.lang.String className)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Upcast the top stack value. This is used for correct method resolution
by upcasting method parameters. It does not put any casting code into the
byte code stream. Can only be used for refrences.
Stack ...,ref => ...,ref- Specified by:
upCastin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
cast
public void cast(java.lang.String className)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Cast the top stack value. Correctly down-casts a reference or casts
a primitive type (e.g. int to short).
Stack ...,value => ...,cast_value- Specified by:
castin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
isInstanceOf
public void isInstanceOf(java.lang.String className)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Pop the top stack value and push a boolean that is the result of
an instanceof check on the popped reference.
Stack ...,ref => ...,boolean_value.- Specified by:
isInstanceOfin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
pushNull
public void pushNull(java.lang.String type)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push a typed null onto the stack
Stack ... => ...,null- Specified by:
pushNullin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getField
public void getField(org.apache.derby.iapi.services.compiler.LocalField field)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push the contents of the local field onto the stack.
This call pushes the this instance required to access the field itself.
Stack ... => ...,field_value- Specified by:
getFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getField
public void getField(java.lang.String declaringClass, java.lang.String fieldName, java.lang.String fieldType)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Push the contents of the described field onto the stack.
This call requires the instance (reference) to be pushed by the caller.
Stack ...,field_ref => ...,field_value- Specified by:
getFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getStaticField
public void getStaticField(java.lang.String declaringClass, java.lang.String fieldName, java.lang.String fieldType)
- Push the contents of the described static field onto the stack.
- Specified by:
getStaticFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getField
private void getField(short opcode,
java.lang.String declaringClass,
java.lang.String fieldName,
java.lang.String fieldType)
setField
public void setField(org.apache.derby.iapi.services.compiler.LocalField field)
- Set the field but don't duplicate its value so
nothing is left on the stack after this call.
- Specified by:
setFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
putField
public void putField(org.apache.derby.iapi.services.compiler.LocalField field)
- Upon entry the top word(s) on the stack is
the value to be put into the field. Ie.
we have
wordBefore the call we needword this wordword2,word1 -> word2, word1, word2 So that we are left with word after the put.- Specified by:
putFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
putField
public void putField(java.lang.String fieldName, java.lang.String fieldType)
- Pop the top stack value and store it in the instance field of this class.
- Specified by:
putFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
putField
private void putField(Type fieldType, int cpi, boolean dup)
putField
public void putField(java.lang.String declaringClass, java.lang.String fieldName, java.lang.String fieldType)
- Pop the top stack value and store it in the field.
This call requires the instance to be pushed by the caller.
- Specified by:
putFieldin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
conditionalIfNull
public void conditionalIfNull()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Initiate a sequence that corresponds to the Java language 'ref == null ? ... : ...'.
The top value on the stack (a reference) is popped and compared to 'null'.
If the value is null then the code following this call until the startElseCode()
will be executed at runtime, otherwise the code following startElseCode() until
the completeConditional() is called.
E.g.mb.callMethod(...); // pushes an object onto the stack mb.conditionalIfNull(); mb.push(3); mb.startElseCode(); mb.push(5); mb.completeConditional(); // at this point 3 or 5 will be on the stackEach path through the ?: statement must leave the stack at the same depth as the other.Stack ...,ref => ....- Specified by:
conditionalIfNullin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
conditionalIf
public void conditionalIf()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Initiate a sequence that corresponds to the Java language ' value ? ... : ...'.
The top value on the stack must be a boolean and will be popped. If it
is true then the code following this call until the startElseCode()
will be executed at runtime, otherwise the code following startElseCode() until
the completeConditional() is called. See conditionalIfNull() for example.
Stack ...,boolean_value => ....- Specified by:
conditionalIfin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
conditionalIf
private void conditionalIf(short opcode)
startElseCode
public void startElseCode()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Complete the true code path of a ?: operator.
- Specified by:
startElseCodein interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
completeConditional
public void completeConditional()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Complete the a ?: operator which completes the false code path.
- Specified by:
completeConditionalin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
pop
public void pop()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Pop the top value off the stack
Stack ..., value => ....- Specified by:
popin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
endStatement
public void endStatement()
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - End a statement.
Pops the top-word of the stack, if any.
Must only be called if zero or one item exists
on the stack.
Stack value => :empty: or Stack :empty: => :empty:.- Specified by:
endStatementin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
getArrayElement
public void getArrayElement(int element)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Pop an array refrence off the stack and push an element from that array.
Stack ...,array_ref => ...,value- Specified by:
getArrayElementin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
setArrayElement
public void setArrayElement(int element)
- Description copied from interface:
org.apache.derby.iapi.services.compiler.MethodBuilder - Pop an array reference off the stack, store a value in the array at the passed in offset.
Stack ...,array_ref, value => ...- Specified by:
setArrayElementin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
pushNewArray
public void pushNewArray(java.lang.String className, int size)
- Create an array instance
Stack ... =>
...,arrayref
- Specified by:
pushNewArrayin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
statementNumHitLimit
public boolean statementNumHitLimit(int noStatementsAdded)
- Tell if statement number in this method builder hits limit. This
method builder keeps a counter of how many statements are added to it.
Caller should call this function every time it tries to add a statement
to this method builder (counter is increased by 1), then the function
returns whether the accumulated statement number hits a limit.
The reason of doing this is that Java compiler has a limit of 64K code
size for each method. We might hit this limit if an extremely long
insert statement is issued, for example (see beetle 4293). Counting
statement number is an approximation without too much overhead.
- Specified by:
statementNumHitLimitin interfaceorg.apache.derby.iapi.services.compiler.MethodBuilder
overflowMethodCheck
private void overflowMethodCheck()
- Check to see if the current method byte code is nearing the
limit of 65535. If it is start overflowing to a new method.
Overflow is handled for a method named e23 as:
public Object e23() { ... existing code // split point return e23_0(); } private Object e23_0() { ... first set overflowed code // split point return e23_1(); } private Object e23_1() { ... second set overflowed code // method complete return result; }These overflow methods are hidden from the code using this MethodBuilder, it continues to think that it is building a single method with the original name.
Restrictions:- Only handles methods with no arguments
- Stack depth must be zero
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ bytecode overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.impl.services.bytecode.BCMethod