2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.jvm;
21 import gov.nasa.jpf.util.FixedBitSet;
22 import gov.nasa.jpf.vm.MethodInfo;
23 import gov.nasa.jpf.vm.StackFrame;
24 import gov.nasa.jpf.vm.ThreadInfo;
27 * a stackframe that is used for executing Java bytecode, supporting both
28 * locals and an operand stack. This is essentially the JVm stack machine
31 public class JVMStackFrame extends StackFrame {
33 public JVMStackFrame (MethodInfo callee){
38 * creates callerSlots dummy Stackframe for testing of operand/local operations
39 * NOTE - TESTING ONLY! this does not have callerSlots MethodInfo
41 protected JVMStackFrame (int nLocals, int nOperands){
42 super( nLocals, nOperands);
46 * this sets up arguments from a bytecode caller
48 protected void setCallArguments (ThreadInfo ti){
49 StackFrame caller = ti.getTopFrame();
50 MethodInfo miCallee = mi;
51 int nArgSlots = miCallee.getArgumentsSize();
54 int[] calleeSlots = slots;
55 FixedBitSet calleeRefs = isRef;
56 int[] callerSlots = caller.getSlots();
57 FixedBitSet callerRefs = caller.getReferenceMap();
59 for (int i = 0, j = caller.getTopPos() - nArgSlots + 1; i < nArgSlots; i++, j++) {
60 calleeSlots[i] = callerSlots[j];
61 if (callerRefs.get(j)) {
64 Object a = caller.getSlotAttr(j);
70 if (!miCallee.isStatic()) {
71 thisRef = calleeSlots[0];
77 public void setExceptionReference (int exRef){
82 //--- these are for setting up arguments from a VM / listener caller
85 * to be used to initialize locals of a stackframe (only required for explicit construction without a caller,
86 * otherwise the Stackframe ctor/invoke insn will take care of copying the values from its caller)
89 public void setArgumentLocal (int idx, int v, Object attr){
90 setLocalVariable( idx, v);
92 setLocalAttr( idx, attr);
96 public void setReferenceArgumentLocal (int idx, int ref, Object attr){
97 setLocalReferenceVariable( idx, ref);
99 setLocalAttr( idx, attr);
103 public void setLongArgumentLocal (int idx, long v, Object attr){
104 setLongLocalVariable( idx, v);
106 setLocalAttr( idx, attr);