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.vm;
22 * this is our implementation independent model of the heap
24 public interface Heap extends Iterable<ElementInfo> {
26 //--- this is the common heap client API
28 ElementInfo get (int objref);
29 ElementInfo getModifiable (int objref);
33 boolean isOutOfMemory();
35 void setOutOfMemory(boolean isOutOfMemory);
37 //--- the allocator primitives
38 ElementInfo newArray (String elementType, int nElements, ThreadInfo ti);
39 ElementInfo newObject (ClassInfo ci, ThreadInfo ti);
41 ElementInfo newSystemArray (String elementType, int nElements, ThreadInfo ti, int anchor);
42 ElementInfo newSystemObject (ClassInfo ci, ThreadInfo ti, int anchor);
44 //--- convenience allocators that avoid constructor calls
45 // (those are mostly used for their reference values since they already have initialized fields,
46 // but to keep it consistent we use ElementInfo return types)
47 ElementInfo newString (String str, ThreadInfo ti);
48 ElementInfo newSystemString (String str, ThreadInfo ti, int anchor);
50 ElementInfo newInternString (String str, ThreadInfo ti);
52 ElementInfo newSystemThrowable (ClassInfo ci, String details, int[] stackSnapshot, int causeRef,
53 ThreadInfo ti, int anchor);
55 Iterable<ElementInfo> liveObjects();
59 //--- system internal interface
62 //void updateReachability( boolean isSharedOwner, int oldRef, int newRef);
64 void markThreadRoot (int objref, int tid);
66 void markStaticRoot (int objRef);
68 // these update per-object counters - object will be gc'ed if it goes to zero
69 void registerPinDown (int objRef);
70 void releasePinDown (int objRef);
74 void cleanUpDanglingReferences();
76 boolean isAlive (ElementInfo ei);
78 void registerWeakReference (ElementInfo ei);
80 // to be called from ElementInfo.markRecursive(), to avoid exposure of
81 // mark implementation
82 void queueMark (int objref);
87 // <2do> this will go away
88 void markChanged(int objref);
90 void resetVolatiles();
92 void restoreVolatiles();
94 void checkConsistency (boolean isStateStore);
97 Memento<Heap> getMemento(MementoFactory factory);
98 Memento<Heap> getMemento();