Fixes default method resolution (#159)
[jpf-core.git] / src / main / gov / nasa / jpf / vm / Heap.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
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
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
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.
17  */
18
19 package gov.nasa.jpf.vm;
20
21 /**
22  * this is our implementation independent model of the heap
23  */
24 public interface Heap extends Iterable<ElementInfo> {
25
26   //--- this is the common heap client API
27
28   ElementInfo get (int objref);
29   ElementInfo getModifiable (int objref);
30
31   void gc();
32
33   boolean isOutOfMemory();
34
35   void setOutOfMemory(boolean isOutOfMemory);
36
37   //--- the allocator primitives
38   ElementInfo newArray (String elementType, int nElements, ThreadInfo ti);
39   ElementInfo newObject (ClassInfo ci, ThreadInfo ti);
40   
41   ElementInfo newSystemArray (String elementType, int nElements, ThreadInfo ti, int anchor);
42   ElementInfo newSystemObject (ClassInfo ci, ThreadInfo ti, int anchor);
43
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);
49   
50   ElementInfo newInternString (String str, ThreadInfo ti);
51   
52   ElementInfo newSystemThrowable (ClassInfo ci, String details, int[] stackSnapshot, int causeRef,
53                           ThreadInfo ti, int anchor);
54   
55   Iterable<ElementInfo> liveObjects();
56
57   int size();
58
59   //--- system internal interface
60
61
62   //void updateReachability( boolean isSharedOwner, int oldRef, int newRef);
63
64   void markThreadRoot (int objref, int tid);
65
66   void markStaticRoot (int objRef);
67
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);
71
72   void unmarkAll();
73
74   void cleanUpDanglingReferences();
75
76   boolean isAlive (ElementInfo ei);
77
78   void registerWeakReference (ElementInfo ei);
79
80   // to be called from ElementInfo.markRecursive(), to avoid exposure of
81   // mark implementation
82   void queueMark (int objref);
83
84   boolean hasChanged();
85
86
87   // <2do> this will go away
88   void markChanged(int objref);
89
90   void resetVolatiles();
91
92   void restoreVolatiles();
93
94   void checkConsistency (boolean isStateStore);
95
96
97   Memento<Heap> getMemento(MementoFactory factory);
98   Memento<Heap> getMemento();
99 }