Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Memory/Manager/GCMapIteratorGroup.java


1   // GCMapIteratorGroup.java, created Tue Dec 10 14:02:30 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package Memory.Manager;
5   
6   import Clazz.jq_CompiledCode;
7   import Memory.Address;
8   import Scheduler.jq_RegisterState;
9   import Scheduler.jq_Thread;
10  
11  /**
12   * @author John Whaley <jwhaley@alum.mit.edu>
13   * @version $Id: GCMapIteratorGroup.java,v 1.2 2003/05/12 10:05:19 joewhaley Exp $
14   */
15  public class GCMapIteratorGroup {
16  
17      /** current location (memory address) of each gpr register */
18      private Address[] registerLocations;
19  
20      /** iterator for VM_BootImageCompiler stackframes */
21      private GCMapIterator bootImageCompilerIterator;
22  
23      /** iterator for VM_RuntimeCompiler stackframes */
24      private GCMapIterator runtimeCompilerIterator;
25  
26      /** iterator for VM_HardwareTrap stackframes */
27      private GCMapIterator hardwareTrapIterator;
28  
29      /** iterator for fallback compiler (baseline) stackframes */
30      private GCMapIterator fallbackCompilerIterator;
31  
32      /** iterator for test compiler (opt) stackframes */
33      private GCMapIterator testOptCompilerIterator;
34  
35      /** iterator for JNI Java -> C  stackframes */
36      private GCMapIterator jniIterator;
37  
38      GCMapIteratorGroup() {
39          /*
40          registerLocations = new int[VM_Constants.NUM_GPRS];
41          bootImageCompilerIterator =
42              VM_BootImageCompiler.createGCMapIterator(registerLocations);
43          runtimeCompilerIterator =
44              VM_RuntimeCompiler.createGCMapIterator(registerLocations);
45          hardwareTrapIterator =
46              new VM_HardwareTrapGCMapIterator(registerLocations);
47          fallbackCompilerIterator =
48              new VM_BaselineGCMapIterator(registerLocations);
49          jniIterator = new VM_JNIGCMapIterator(registerLocations);
50          */
51      }
52  
53      /**
54       * Prepare to scan a thread's stack for object references.
55       * Called by collector threads when beginning to scan a threads stack.
56       * Calls newStackWalk for each of the contained GCMapIterators.
57       * <p>
58       * Assumption:  the thread is currently suspended, ie. its saved gprs[]
59       * contain the thread's full register state.
60       * <p>
61       * Side effect: registerLocations[] initialized with pointers to the
62       * thread's saved gprs[] (in thread.contextRegisters.gprs)
63       * <p>
64       * @param thread  VM_Thread whose registers and stack are to be scanned
65       */
66      void newStackWalk(jq_Thread thread) {
67          jq_RegisterState rs = thread.getRegisterState();
68          /*
69          Address registerLocation = 
70              VM_Magic.objectAsAddress(thread.contextRegisters.gprs);
71          for (int i = 0; i < VM_Constants.NUM_GPRS; ++i) {
72              registerLocations[i] = registerLocation.toInt();
73              registerLocation = registerLocation.offset(4);
74          }
75          bootImageCompilerIterator.newStackWalk(thread);
76          runtimeCompilerIterator.newStackWalk(thread);
77          hardwareTrapIterator.newStackWalk(thread);
78          fallbackCompilerIterator.newStackWalk(thread);
79          if (testOptCompilerIterator != null)
80              testOptCompilerIterator.newStackWalk(thread);
81          if (jniIterator != null)
82              jniIterator.newStackWalk(thread);
83              */
84      }
85  
86      /**
87       * Select iterator for scanning for object references in a stackframe.
88       * Called by collector threads while scanning a threads stack.
89       *
90       * @param compiledMethod  VM_CompiledMethod for the method executing
91       *                        in the stack frame
92       *
93       * @return GCMapIterator to use
94       */
95      GCMapIterator selectIterator(jq_CompiledCode compiledMethod) {
96          
97          /*
98          int type = compiledMethod.getCompilerType();
99  
100         if (type == bootImageCompilerIterator.getType())
101             return bootImageCompilerIterator;
102 
103         if (type == runtimeCompilerIterator.getType())
104             return runtimeCompilerIterator;
105 
106         if (type == hardwareTrapIterator.getType())
107             return hardwareTrapIterator;
108 
109         if (type == fallbackCompilerIterator.getType())
110             return fallbackCompilerIterator;
111 
112         if (jniIterator != null && type == jniIterator.getType())
113             return jniIterator;
114 
115         if (testOptCompilerIterator != null
116             && type == testOptCompilerIterator.getType())
117             return testOptCompilerIterator;
118 
119         if (VM.VerifyAssertions)
120             VM._assert(VM.NOT_REACHED);
121             */
122         return null;
123         
124     }
125 
126     /**
127      * get the GCMapIterator used for scanning JNI native stack frames.
128      *
129      * @return jniIterator
130      */
131     GCMapIterator getJniIterator() {
132         return jniIterator;
133     }
134 
135 }